Created
July 19, 2013 02:25
-
-
Save base10/6034641 to your computer and use it in GitHub Desktop.
Need help with testing definedness using 'when_unset' The key question. Why does when_unset not catch a variable as defined if it begins with a '$'?
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: webserver plays | |
hosts: all | |
user: nathan | |
sudo: no | |
gather_facts: false | |
vars: | |
foo: onetwothree | |
bar: fourfivesix | |
err_variable_not_present: | | |
Required variables not present. Make sure you have ~/.wa-dev-ansible-vars defined | |
Use playbooks/group_vars/default as a starting point | |
pre_tasks: | |
- name: "ensure variables" | |
fail: > | |
msg="{{ err_variable_not_present }}" | |
when_unset: $item | |
with_items: | |
- $foo | |
- $bar | |
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: webserver plays | |
hosts: all | |
user: nathan | |
sudo: no | |
gather_facts: false | |
vars: | |
foo: $onetwothree | |
bar: fourfivesix | |
err_variable_not_present: | | |
Required variables not present. Make sure you have ~/.wa-dev-ansible-vars defined | |
Use playbooks/group_vars/default as a starting point | |
pre_tasks: | |
- name: "ensure variables" | |
fail: > | |
msg="{{ err_variable_not_present }}" | |
when_unset: $item | |
with_items: | |
- $foo | |
- $bar | |
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
[auto-1115][~/code/infrastructure/wa-dev-vagrants] ansible-playbook -i fake-inventory playbooks/tmp.yml | |
PLAY [webserver plays] ******************************************************** | |
TASK: [ensure variables] ****************************************************** | |
skipping: [localhost] => (item=onetwothree) | |
skipping: [localhost] => (item=fourfivesix) | |
PLAY RECAP ******************************************************************** | |
localhost : ok=1 changed=0 unreachable=0 failed=0 |
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
[auto-1115][~/code/infrastructure/wa-dev-vagrants] ansible-playbook -i fake-inventory playbooks/tmp.yml | |
PLAY [webserver plays] ******************************************************** | |
TASK: [ensure variables] ****************************************************** | |
failed: [localhost] => (item=$onetwothree) => {"failed": true, "item": "$onetwothree"} | |
msg: Required variables not present. Make sure you have ~/.wa-dev-ansible-vars defined | |
Use playbooks/group_vars/default as a starting point | |
skipping: [localhost] => (item=fourfivesix) | |
FATAL: all hosts have already failed -- aborting | |
PLAY RECAP ******************************************************************** | |
to retry, use: --limit @/var/tmp/ansible/tmp.retry | |
localhost : ok=0 changed=0 unreachable=0 failed=1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment