Skip to content

Instantly share code, notes, and snippets.

Avatar
😏

Matt Martz sivel

😏
View GitHub Profile
@sivel
sivel / yescrypt_ctypes.py
Last active September 28, 2021 13:24
Ansible filter plugin to encrypt a string with yescrypt
View yescrypt_ctypes.py
# Copyright (c) 2021 Matt Martz <matt@sivel.net>
# 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
View 00-README.md

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
View make_manifest.py
#!/usr/bin/env python
# Copyright (c) 2020 Matt Martz <matt@sivel.net>
# 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
View 00-split_changelog.py
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# (c) 2020 Matt Martz <matt@sivel.net>
# GNU General Public License v3.0+
# (see https://www.gnu.org/licenses/gpl-3.0.txt)
import argparse
import json
import re
import sys
View print_wcwidth.py
# -*- 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 October 24, 2021 21:49
Ansible Include Until
View 00-include_until.yml
---
- hosts: localhost
gather_facts: false
tasks:
- include_tasks: include_me.yml
vars:
include_max: 10
View ansible-conv.md

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

View vmware-deploy-ovf-inject.diff
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:
View selective-restores-on-macos.md

Selective Restores on macOS

Note: This post is not yet finished

I have owned a Mac continuously for the last 8 years as part of my job and used it full time both professionally and personally. Over that time I have carried a lot of crap from machine to machine, and a lot of that was very work specific. Certs, credentials, applications, and other various configurations and files. I've always just performed a full Time Machine restore each time I upgraded.

I recently switched employers, and wanted to start mostly fresh, but with the ability to keep some of the more generic configurations on my Mac like VIM configurations, and the ability to bring over personal files. I wasn't sure how I was going to approach this at first. I imagined, that I would just take a Time Machine backup, perform a fresh install, and then use the Migration Assistant to uncheck some things I don't want.

Using the Time Machine backup and Migration Assistant, seemed like a great idea, although Migration Assistant doesn't give y

@sivel
sivel / cprofile-callback.txt
Last active December 1, 2021 18:50
Ansible callback plugin to profile code execution via cProfile
View cprofile-callback.txt
$ ANSIBLE_CALLBACK_WHITELIST=cprofile CPROFILE_FILTERS=ansible.plugins.connection,ansible.executor.task_executor ansible-playbook -i localhosts whoami.yml
PLAY [My Cool Play] **************************************************************************************************************************************************************************************************************************
TASK [Check who I am 1] **********************************************************************************************************************************************************************************************************************
changed: [localhost0]
changed: [localhost1]
TASK [Check who I am 2] **********************************************************************************************************************************************************************************************************************
changed: [localhost0]