Skip to content

Instantly share code, notes, and snippets.

View sivel's full-sized avatar
🥴

Matt Martz sivel

🥴
View GitHub Profile

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 16, 2023 07:26
Ansible callback plugin to profile code execution via cProfile
$ 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]
vars_secret_funky_json: !vault |
$ANSIBLE_VAULT;1.2;AES256;alan_host
35356666616633303337313766346562613961313262333530663432393965303736653334306433
6239666265343936343462653836386162343234353961330a306665396665353364613863316362
66646663313737393763383565333237316663666339623063646666646261643338616261633330
3634313634666264620a383632386661653330326435633861333031643334643237366430313733
3733
{
"vars_secret_funky_json": {
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
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
@sivel
sivel / with2loop.yml
Last active February 4, 2020 22:12
Ansible playbook showcasing conversion from with_X loops to loop using filters instead of lookup
---
- name: Playbook showcasing conversion from with_X loops to loop+filters
hosts: localhost
gather_facts: false
vars:
items:
-
- foo
-
- bar
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):
@sivel
sivel / memrecap.py
Last active March 26, 2018 17:26
This is an ansible callback plugin that profiles maximum memory usage of ansible per task, and displays a recap at the end
# (c) 2018 Matt Martz <[email protected]>
# 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'}
@sivel
sivel / cherry-pick-pr.md
Last active August 14, 2018 06:26
Basic workflow for creating a cherry-pick pull request for ansible

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

@sivel
sivel / changelog.py
Last active February 20, 2018 21:24
Simple script that looks for issue/pr references in commit messages, and generates something like a changelog
#!/usr/bin/env python
import os
import re
import mistune # mistune
from github import Github # PyGithub
from argparse import ArgumentParser