Skip to content

Instantly share code, notes, and snippets.

View sivel's full-sized avatar
🥴

Matt Martz sivel

🥴
View GitHub Profile
@sivel
sivel / dt.yml
Created May 29, 2025 16:47
2025 Red Hat Summit ansible-core demo
- hosts: localhost
gather_facts: false
vars:
test:
slow: '{{ lookup("pipe", "sleep 10") }}'
fast: 'fast'
tasks:
- tags:
- never
- fast

Multiple registers per task and data manipulation

.. versionadded:: fallible

Note

This feature has not been included in a released version of ansible-core yet, and is a tech preview as part of fallible.

This feature allows a playbook author to register multiple variables on a task, manipulate the data before registered to that variable, and provides implicit register names scoped to a single task. Individual loop results cannot be manipulated, this feature only applies to the final task result.

@sivel
sivel / yescrypt_ctypes.py
Last active September 28, 2021 13:24
Ansible filter plugin to encrypt a string with yescrypt
# Copyright (c) 2021 Matt Martz <[email protected]>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import ctypes
from ansible.errors import AnsibleFilterError
from ansible.module_utils.common.text.converters import to_bytes, to_text
@sivel
sivel / 00-README.md
Last active July 29, 2020 17:19
Ansible Callback to aid in replicating set_stats workflow behavior in Tower

dump_stats Ansible callback plugin

This callback plugin can aid in replicating the set_stats workflow behavior in Tower

It allows you to dump the stats set with set_stats to a file, and then use that file with --extra-vars in subsequent ansible-playbook calls.

Usage

  1. Download dump_stats.py file to a callback_plugins directory relative to your playbook
  2. Run ansible-playbook with ANSIBLE_CALLBACK_WHITELIST=dump_stats
@sivel
sivel / make_manifest.py
Last active May 25, 2022 06:49
Script to create a MANIFEST.json and FILES.json for an Ansible collection from galaxy.yml
#!/usr/bin/env python
# Copyright (c) 2020 Matt Martz <[email protected]>
# GNU General Public License v3.0+
# (see https://www.gnu.org/licenses/gpl-3.0.txt)
import json
import os
from ansible.galaxy.collection import _build_files_manifest
from ansible.galaxy.collection import _build_manifest
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# (c) 2020 Matt Martz <[email protected]>
# GNU General Public License v3.0+
# (see https://www.gnu.org/licenses/gpl-3.0.txt)
import argparse
import json
import re
import sys
# -*- coding: utf-8 -*-
# Copyright (c) 2019 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import ctypes.util
import locale
@sivel
sivel / 00-include_until.yml
Last active March 15, 2024 08:17
Ansible Include Until
---
- hosts: localhost
gather_facts: false
tasks:
- include_tasks: include_me.yml
vars:
include_max: 10

Draft

Using to_bytes/to_native/to_text

errors

The default value for errors, although specified as None in the function signature is surrogate_then_replace

The most common and recommended values for compatibility between python2

diff --git a/lib/ansible/modules/cloud/vmware/vmware_deploy_ovf.py b/lib/ansible/modules/cloud/vmware/vmware_deploy_ovf.py
index 6eb690baed..0fe301a301 100644
--- a/lib/ansible/modules/cloud/vmware/vmware_deploy_ovf.py
+++ b/lib/ansible/modules/cloud/vmware/vmware_deploy_ovf.py
@@ -56,6 +56,12 @@ options:
default: thin
description:
- Disk provisioning type.
+ enable_hidden_properties:
+ description: