-
-
Save halberom/9ff6a085210fed45b75b to your computer and use it in GitHub Desktop.
passing var to role arg
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
# /tmp/foo | |
bar |
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] ******************************************************* | |
changed: [localhost] | |
PLAY [all] ******************************************************************** | |
TASK: [tmp | do something] **************************************************** | |
ok: [localhost] => { | |
"item": "", | |
"myvar": "bar" | |
} | |
PLAY RECAP ******************************************************************** | |
localhost : ok=2 changed=1 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/roles/tmp/tasks/main.yml | |
--- | |
- name: do something | |
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
# /etc/ansible/tmp.yml | |
--- | |
- hosts: all | |
gather_facts: no | |
tasks: | |
- name: register a fact | |
command: cat /tmp/foo | |
register: output | |
- hosts: all | |
gather_facts: no | |
roles: | |
- { role: tmp, myvar: "{{ output.stdout }}" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment