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
# /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 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 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 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 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 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 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 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" | |
} |
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
# when 'is not defined' | |
PLAY [foo] ******************************************************************** | |
GATHERING FACTS *************************************************************** | |
ok: [localhost] | |
TASK: [role1 | debug msg="doing something in foo.yml"] ************************ | |
skipping: [localhost] |
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 [foo] ******************************************************************** | |
GATHERING FACTS *************************************************************** | |
ok: [localhost] | |
TASK: [service name="ntpd" state=restarted] *********************************** | |
changed: [localhost] | |
PLAY RECAP ******************************************************************** | |
localhost : ok=2 changed=1 unreachable=0 failed=0 |