Last active
December 25, 2020 08:40
-
-
Save zeitounator/066c5a64fad630d8e2ed3d155b731e6b to your computer and use it in GitHub Desktop.
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
[test_group] | |
localhost test_var=88 | |
# This is the group definition used for the second run (remove previous) | |
# [test_group] | |
# localhost | |
[test_group:vars] | |
test_var=99 |
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
--- | |
test_var: 77 |
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
--- | |
- name: Debug value of test_var | |
debug: | |
var: test_var |
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: test_group | |
gather_facts: false | |
roles: | |
- role: test_role |
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
$ # Please note that gists do not accept subdirs in file names, so I replaced / with - above for the paths. | |
$ # I also prepended each file with a number that is not part of the path to keep a coherent order | |
$ # Commands below are using the resulting file tree and are run from the playbook root. | |
$ # Run playbook with initial inventory | |
$ ansible-playbook -i inventories/test_inventory/hosts.ini playbook.yml | |
PLAY [test_group] ********************************************************************************************************************************************************************************************************************** | |
TASK [test_role : Debug value of test_var] ********************************************************************************************************************************************************************************************* | |
ok: [localhost] => { | |
"test_var": 88 | |
} | |
PLAY RECAP ***************************************************************************************************************************************************************************************************************************** | |
localhost : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 | |
$ # Now edit the inventory file and change for the group def that is commented out in my example | |
$ ansible-playbook -i inventories/test_inventory/hosts.ini playbook.yml | |
PLAY [test_group] ********************************************************************************************************************************************************************************************************************** | |
TASK [test_role : Debug value of test_var] ********************************************************************************************************************************************************************************************* | |
ok: [localhost] => { | |
"test_var": 99 | |
} | |
PLAY RECAP ***************************************************************************************************************************************************************************************************************************** | |
localhost : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment