Last active
September 21, 2017 11:35
-
-
Save halberom/2c9aa046f63b096f78b26401a11e78d4 to your computer and use it in GitHub Desktop.
ansible - broken role vars?
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
# This one works with the include_/import_ interestingly | |
--- | |
- hosts: localhost | |
gather_facts: False | |
connection: local | |
vars: | |
rolename: test2 | |
roles: | |
- test1 |
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/test1/tasks/main.yml | |
--- | |
- debug: | |
msg: "in {{ role_path }}" | |
- debug: | |
msg: "{{ rolename }}" | |
# If either of these are uncommented, no tasks run, and you get an immediate | |
# ERROR! 'rolename' is undefined | |
# | |
#- import_role: | |
# name: "{{ rolename }}" | |
#- include_role: | |
# name: "{{ rolename }}" |
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 [localhost] ********************************************************************************************************************* | |
TASK [test1 : debug] ***************************************************************************************************************** | |
ok: [localhost] => { | |
"msg": "in /private/tmp/ansible/roles/test1" | |
} | |
TASK [test1 : debug] ***************************************************************************************************************** | |
ok: [localhost] => { | |
"msg": "test2" | |
} | |
PLAY RECAP *************************************************************************************************************************** | |
localhost : ok=2 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
# This one does not work | |
--- | |
- hosts: localhost | |
gather_facts: False | |
connection: local | |
roles: | |
- { role: test1, rolename: test2 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment