Created
September 16, 2015 10:07
-
-
Save halberom/62a3abb110f32960370c to your computer and use it in GitHub Desktop.
ansible - example of asserting that vars are defined with_items
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
PLAY [localhost] ************************************************************** | |
GATHERING FACTS *************************************************************** | |
$ ansible-playbook --version | |
ansible-playbook 1.9.3 | |
configured module search path = ~/git/ansible-modules-core:~/git/ansible-modules-extra:./library | |
$ ansible-playbook play.yml | |
ok: [localhost] | |
TASK: [assert ] *************************************************************** | |
ok: [localhost] => (item=foo) | |
failed: [localhost] => (item=bar) => {"assertion": "bar is defined", "evaluated_to": false, "failed": true, "item": "bar"} | |
failed: [localhost] => (item=abc) => {"assertion": "abc is defined", "evaluated_to": false, "failed": true, "item": "abc"} | |
failed: [localhost] => (item=def) => {"assertion": "def is defined", "evaluated_to": false, "failed": true, "item": "def"} | |
FATAL: all hosts have already failed -- aborting | |
PLAY RECAP ******************************************************************** | |
to retry, use: --limit @/Users/glynch/assert_vars_defined.retry | |
localhost : ok=1 changed=0 unreachable=0 failed=1 |
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: localhost | |
vars: | |
foo: bar | |
tasks: | |
- assert: { that: "{{ item }} is defined" } | |
with_items: | |
- foo | |
- bar | |
- abc | |
- def |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment