Skip to content

Instantly share code, notes, and snippets.

View sivel's full-sized avatar
😏

Matt Martz sivel

😏
View GitHub Profile
@sivel
sivel / dump.j2
Created February 9, 2016 21:25
Create Ansible host vars dump for all hosts
{
{% for host in groups.all %}
"{{ host }}": {{ hostvars[host]|to_json }}{{ ',' if not loop.last else '' }}
{% endfor %}
}
@sivel
sivel / gist:a641a7d121c3cc7c8fbf
Created February 23, 2016 21:50
copy recursive force=false
diff --git a/test/integration/roles/test_copy/tasks/main.yml b/test/integration/roles/test_copy/tasks/main.yml
index edae89f..f15559d 100644
--- a/test/integration/roles/test_copy/tasks/main.yml
+++ b/test/integration/roles/test_copy/tasks/main.yml
@@ -174,6 +174,24 @@
that:
- "not copy_result5|changed"
+- name: test recursive copy to directory sub2
+ copy: src=subdir dest={{output_dir}}/sub2 directory_mode=0700 force=false
@sivel
sivel / diff.diff
Created February 24, 2016 20:27
diff of changes made to inspect module arguments
diff --git a/hacking/test-module b/hacking/test-module
index d9f19b7..511be8b 100755
--- a/hacking/test-module
+++ b/hacking/test-module
@@ -138,8 +138,6 @@ def boilerplate_module(modfile, args, interpreter, check, destfile):
)
modfile2_path = os.path.expanduser(destfile)
- print("* including generated source, if any, saving to: %s" % modfile2_path)
- print("* this may offset any line numbers in tracebacks/debuggers!")
@sivel
sivel / ansible-git.md
Last active October 16, 2023 16:44
Ansible Contributors Guide for working with git/GitHub

Ansible Contributors Guide for working with git/GitHub

First Note

Never, ever, modify or commit things to devel, always do work in a feature branch

Setting up the ansible and modules repos from forks

export GITHUB_USER=sivel
@sivel
sivel / inventory2json.py
Last active December 19, 2023 01:54
Ansible inventory to dynamic inventory JSON output, accepts all inventory input formats
import sys
import json
from ansible.parsing.dataloader import DataLoader
try:
from ansible.inventory.manager import InventoryManager
A24 = True
except ImportError:
from ansible.vars import VariableManager
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# (c) 2016, Matt Martz <matt@sivel.net>
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
#!/bin/bash
set -x
TARGET=${1:-"ubuntu1404"}
if [[ "$TARGET" =~ centos7|fedora ]]
then
TARGET_OPTIONS="--volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
fi
@sivel
sivel / migrate_patch.py
Created December 6, 2016 21:44
Migrate mailbox patch for ansible repo merge
import re
import sys
import requests
DIFF_GIT_RE = re.compile(r'^(diff --git a/)([^ ]+ b/)([^ ]+)$', re.M)
STAT_RE = re.compile(r'^(\s+)([^ ]+\s+\|\s+\d+\s+[+-]+)$', re.M)
MINUS_PLUS_RE = re.compile(r'^((?:-|\+){3} [ab]/)(.+)$', re.M)
E123 closing bracket does not match indentation of opening bracket's line
E124 closing bracket does not match visual indentation
E127 continuation line over-indented for visual indent
E128 continuation line under-indented for visual indent
E201 whitespace after '('
E202 whitespace before '}'
E203 whitespace before ','
E211 whitespace before '('
E221 multiple spaces before operator
E222 multiple spaces after operator
@sivel
sivel / output.txt
Last active January 26, 2017 18:48
Ansible callback plugin to print the number of remaining hosts in a task
changed: [localhost3]
4 hosts remaining: localhost0, localhost1, localhost2, localhost4
changed: [localhost2]
3 hosts remaining: localhost0, localhost1, localhost4
changed: [localhost1]
2 hosts remaining: localhost0, localhost4
changed: [localhost0]
1 hosts remaining: localhost4
changed: [localhost4]
All hosts complete