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: localhost | |
connection: local | |
gather_facts: false | |
vars: | |
things: | |
- "{{ foo }}" | |
- "{{ foob }}" | |
foo: "Hello" | |
tasks: | |
- name: debug 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
[WARNING]: It is unnecessary to use '{{' in loops, leave variables in loop | |
expressions bare. | |
PLAY [localhost] ************************************************************** | |
TASK: [debug things] ********************************************************** | |
ok: [localhost] => { | |
"things": [ | |
"Hello", |
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
[WARNING]: It is unnecessary to use '{{' in loops, leave variables in loop | |
expressions bare. | |
PLAY [localhost] ************************************************************** | |
TASK: [debug things] ********************************************************** | |
ok: [localhost] => { | |
"things": [ | |
"Hello", |
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 | |
import sys | |
from yaml import load | |
try: | |
from simplejson import dump | |
except ImportError: | |
from json import dump |
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
- name: Collect public key | |
slurp: src="/var/lib/postgresql/.ssh/id_rsa.pub" | |
register: mykey | |
- | |
- name: Setup ssh keys | |
authorized_key: key="{{mykey.content.decode('base64')}}" user="backup" | |
delegate_to: "{{item}}" | |
with_items: groups['backup'] |
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
ansible -m getent -a 'database=passwd key=bcoca' -i 'localhost,' all -c local | |
localhost | success >> { | |
"ansible_facts": { | |
"getent_passwd": { | |
"bcoca": [ | |
"x", | |
"1000", | |
"1000", | |
"", | |
"/home/bcoca", |
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: legacy_servers | |
gather_facts: false | |
tags: | |
- legacy | |
tasks: | |
- name: get metadata on legacy servers | |
shell: > | |
hostname; len=`hostname | wc -c` ; export len; perl -E 'say "=" x ($ENV{"len"} - 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
#play.yml | |
--- | |
- hosts: localhost | |
connection: local | |
gather_facts: false | |
roles: | |
- test | |
tasks: | |
- debug: msg="ran untagged" |
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
Github workflow | |
=============== | |
Fork a repo using github GUI, now there are 2 repos you are going to deal with, 1 the repo under your user bcoca/ansible and the main project ansible/ansible | |
* Clone the ansible repo (this is now 'origin'), the following assumes youre ssh keys are setup. | |
There are several ways of doing this and organizing your workflow, this is just 'my way' and it can be used with several variations. | |
Those with direct commit access might want to reverse this, you cannot count on direct pushes being rejected. | |
#>git clone git@github.com:ansible/ansible |
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
ansible -m stat -a 'path=/home/bcoca/work/ansible/tmp' localhost | |
localhost | SUCCESS => { | |
"changed": false, | |
"stat": { | |
"atime": 1460579289.7836845, | |
"ctime": 1460579289.7836845, | |
"dev": 2083, | |
"exists": true, | |
"gid": 1000, | |
"gr_name": "bcoca", |