Created
May 28, 2014 10:34
-
-
Save halberom/4dce510435f9757daf22 to your computer and use it in GitHub Desktop.
call role with arg, set_fact
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": "", | |
"myothervar": [ | |
"one", | |
2, | |
"three" | |
] | |
} | |
TASK: [tmp | do something with set_fact var] ********************************** | |
ok: [localhost] => { | |
"item": "", | |
"myvar": [ | |
"one", | |
2, | |
"three" | |
] | |
} | |
PLAY RECAP ******************************************************************** | |
localhost : ok=3 changed=0 unreachable=0 failed=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
# /etc/ansible/tmp.yml | |
--- | |
- hosts: all | |
gather_facts: no | |
tasks: | |
- name: register a fact | |
set_fact: myvar="['one',2,'three']" | |
- hosts: all | |
gather_facts: no | |
roles: | |
- { role: tmp, myothervar: "{{ myvar }}" } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment