Created
September 25, 2014 03:41
-
-
Save rektide/164b80c9b120361759b2 to your computer and use it in GitHub Desktop.
ansible with uninitialized vars
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: all | |
gather_facts: False | |
vars: | |
foo: "one" | |
bar: "{{tbd}}" | |
tasks: | |
# this first line will fail, saying: fatal: [127.0.0.1] => One or more undefined variables: 'tbd' is undefined | |
- debug: msg="{{vars['foo']|default('nope')}}" | |
# but these would have been fine | |
- set_fact: tbd="two" | |
- debug: msg="{{vars['foo']|default('nope')}}" | |
- debug: msg="{{vars['doesnotexist']|default('nope')}}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment