Instantly share code, notes, and snippets.

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

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]
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.

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
  • Not gathering facts when they aren't needed is a boost
View 00-output.txt
vars_secret_funky_json: !vault |
$ANSIBLE_VAULT;1.2;AES256;alan_host
35356666616633303337313766346562613961313262333530663432393965303736653334306433
6239666265343936343462653836386162343234353961330a306665396665353364613863316362
66646663313737393763383565333237316663666339623063646666646261643338616261633330
3634313634666264620a383632386661653330326435633861333031643334643237366430313733
3733
{
"vars_secret_funky_json": {
View AnsibleJSONDecoder-object_hook.diff
diff --git a/lib/ansible/parsing/ajson.py b/lib/ansible/parsing/ajson.py
index 7444a9f403..36c693dead 100644
--- a/lib/ansible/parsing/ajson.py
+++ b/lib/ansible/parsing/ajson.py
@@ -20,33 +20,27 @@ class AnsibleJSONDecoder(json.JSONDecoder):
_vaults = {}
+ def __init__(self, *args, **kwargs):
+ kwargs['object_hook'] = self.object_hook
View github-hashicorp-packer-6379.log
2018/06/13 10:10:05 [INFO] Packer version: 1.2.4
2018/06/13 10:10:05 Packer Target OS/Arch: darwin amd64
2018/06/13 10:10:05 Built with Go Version: go1.10.1
2018/06/13 10:10:05 Detected home directory from env var: /Users/matt
2018/06/13 10:10:05 Using internal plugin for parallels-iso
2018/06/13 10:10:05 Using internal plugin for amazon-chroot
2018/06/13 10:10:05 Using internal plugin for amazon-instance
2018/06/13 10:10:05 Using internal plugin for lxd
2018/06/13 10:10:05 Using internal plugin for null
2018/06/13 10:10:05 Using internal plugin for virtualbox-ovf
View with2loop.yml
---
- name: Playbook showcasing conversion from with_X loops to loop+filters
hosts: localhost
gather_facts: false
vars:
items:
-
- foo
-
- bar
View import_playbook_vars.diff
diff --git a/lib/ansible/playbook/__init__.py b/lib/ansible/playbook/__init__.py
index 7391414949..0ec3e10e22 100644
--- a/lib/ansible/playbook/__init__.py
+++ b/lib/ansible/playbook/__init__.py
@@ -54,7 +54,7 @@ class Playbook:
pb._load_playbook_data(file_name=file_name, variable_manager=variable_manager)
return pb
- def _load_playbook_data(self, file_name, variable_manager):
+ def _load_playbook_data(self, file_name, variable_manager, vars=None):
View memrecap.py
# (c) 2018 Matt Martz <matt@sivel.net>
# 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
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'community'}
View cherry-pick-pr.md

After submitting a PR to Ansible for the devel branch, and having it merged, the following instructions will help you create a pull request to backport the change to a previous stable branch

These instructions assume that stable-2.5 is the previous release branch.

  1. Update devel, to ensure you have the commit to cherry pick:

    git checkout devel
    git --fetch upstream
    git merge upstream/devel