Skip to content

Instantly share code, notes, and snippets.

Avatar
😏

Matt Martz sivel

😏
View GitHub Profile
@sivel
sivel / 00-README.md
Last active Jul 29, 2020
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 Mar 18, 2020
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 Mar 10, 2020
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 Jun 23, 2020
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]
@sivel
sivel / ansible-performance-brain-dump.md
Last active Sep 12, 2019
This is a brain dump of all of the Ansible performance related things that sivel knows
View ansible-performance-brain-dump.md

Perf things that I know

As you will note while reading this, I haven't provided numbers to back up these statements. We'll get there eventually, so while I have experience with some of these, others are more "theoretical" based on my knowledge.

Additionally, this probably isn't everything. I'll add more as I think of it.

Fact gathering

  • the default of gather_subset: [all] can consume a lot of RAM, and with a higher fork count causes CPU contention processing results in the main process. The CPU penalty is lessened with deepdish in 2.7
  • [min] is largely what people need and less impactful. This can be set via ansible.cfg as a default
You can’t perform that action at this time.