This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Patch files from command line | |
$ cd ~/ansible-playbooks/playbooks/ | |
$ ansible-playbook -i ~/temp_patches patch_things.yml -e 'target_hosts=all' | |
# Load ad-hoc inventory patches into Ansible Tower | |
$ tower-manage inventory_import --source patch_hosts --inventory-name Patches --overwrite --overwrite-vars | |
=========== | |
# Playbook | |
- name: Patch all the things |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import (absolute_import, division, print_function) | |
__metaclass__ = type | |
from random import choice | |
from ansible.plugins.lookup import LookupBase | |
class LookupModule(LookupBase): | |
def run(self, terms, **kwargs): | |
count = terms.pop(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sdoran@sdoran-OSX ~/P/A/P/playbooks (master) [1]> ansible --version | |
ansible 2.2.0.0 | |
config file = /Users/sdoran/.ansible.cfg | |
configured module search path = Default w/o overrides | |
----------------------- | |
sdoran@sdoran-OSX ~/P/A/P/playbooks (master) [2]> ansible-playbook -i inventory/home vyos.yml -vvv | |
Using /Users/sdoran/.ansible.cfg as config file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# vim: set fileencoding=utf-8 : | |
# | |
# Copyright (C) 2016 Guido Günther <agx@sigxcpu.org> | |
# | |
# This script 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 | |
# (at your option) any later version. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[lab] | |
lab-1 ansible_host=10.77.1.11 | |
lab-2 ansible_host=10.77.2.11 | |
lab-3 ansible_host=10.77.3.11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function docktest --description "Test an Ansible role inside a container" | |
while set -q argv[1] | |
switch $argv[1] | |
case '-h' '--help' | |
echo "-h --help Print out help" | |
echo "-n --nuke Stop and destroy test container" | |
echo "-r --rolepath Path to role. Defaults to current directory." | |
echo "-i --image Docker image OS to run. Defaults to centos7." | |
set -e argv[1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- hosts: somehosts | |
become: yes | |
tasks: | |
- name: Get list of task files | |
find: | |
paths: /opt/ansible/tasks | |
patterns: '*.yml' | |
register: _task_files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- include: "{{ lookup('pipe', 'find /path/to/search -type f -name cluster.yml') }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"instances": [ | |
{ | |
"kernel": null, | |
"root_device_type": "ebs", | |
"private_dns_name": "ip-172-31-23-35.us-east-2.compute.internal", | |
"public_ip": "18.220.201.254", | |
"private_ip": "172.31.23.35", | |
"id": "i-02d9de367d3e62929", | |
"ebs_optimized": false, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Get Ansible Vault password from macOS Keychain | |
# | |
# You will need to create a new password item in the login keychain | |
SECURITY_BIN=$(which security) | |
set_vault_account() { |