This file contains hidden or 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
# /etc/ansible/roles/tmp/tasks/main.yml | |
--- | |
- name: do something with passed var | |
debug: var=myothervar | |
- name: do something with set_fact var | |
debug: var=myvar |
This file contains hidden or 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 [all] ******************************************************************** | |
TASK: [register a fact] ******************************************************* | |
ok: [localhost] | |
PLAY [all] ******************************************************************** | |
TASK: [tmp | do something with passed var] ************************************ | |
ok: [localhost] => { | |
"item": "", |
This file contains hidden or 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 [all] ******************************************************************** | |
GATHERING FACTS *************************************************************** | |
ok: [localhost] | |
TASK: [role1 | set_fact foo=bar] ********************************************** | |
ok: [localhost] | |
TASK: [role2 | debug var=foo] ************************************************* | |
ok: [localhost] => { |
This file contains hidden or 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: install.yml | |
when: 'etcd' in groups | |
- include: cleanup.yml | |
when: 'etcd' not in groups |
This file contains hidden or 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
# head -n3 roles/hosts-canonical/vars/main.yml | |
--- | |
ipaddr_to_hostname: | |
10.0.0.2: ['c0w2', 'l2'] | |
10.0.0.3: ['alt-gateway'] |
This file contains hidden or 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
... | |
TASK: [debug var=mydate] ****************************************************** | |
ok: [localhost] => { | |
"mydate": "20140605101824" | |
} | |
... |
This file contains hidden or 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
# the file doesn't exist | |
TASK: [debug var=foo] ********************************************************* | |
ok: [localhost] => { | |
"foo": { | |
"changed": false, | |
"invocation": { | |
"module_args": "path=/tmp/file", | |
"module_name": "stat" | |
}, |
This file contains hidden or 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
# roles/do_something/tasks/main.yml | |
--- | |
- name: do something | |
command: grep foo /tmp/bar | |
register: result | |
- name: add host to new group based on result | |
add_host: hostname=inventory_hostname group_name=mynewgroup | |
when: result.stdout == 'whatever' |
This file contains hidden or 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: all | |
vars: | |
mypath: ~/.zprezto/runcoms | |
tasks: | |
- name: Find runcom Prezto files | |
shell: find {{ mypath }} -type f -name 'z*' | |
register: file_list | |
# verify what's returned first |
This file contains hidden or 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
TASK: [debug var=source_ip] *************************************************** | |
ok: [localhost] => { | |
"source_ip": "127.0.0.1" | |
} |