Created
December 3, 2013 03:15
-
-
Save joshuaconner/7763339 to your computer and use it in GitHub Desktop.
env-or-else with Ansible... possible?
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: test jinja2 default filter | |
hosts: localhost | |
gather_facts: False | |
tasks: | |
- name: debug | |
debug: msg="{{ lookup('env', 'UNDEFINED_THING')|default('foo') }}" |
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
$ ansible-playbook -i hosts playbook1.yml | |
PLAY [test jinja2 default filter] ********************************************* | |
TASK: [debug] ***************************************************************** | |
ok: [localhost] => { | |
"msg": "" | |
} | |
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
--- | |
- name: test jinja2 default filter | |
hosts: localhost | |
gather_facts: False | |
tasks: | |
- name: debug | |
debug: msg="{{ undefined_variable|default('foo') }}" |
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
$ ansible-playbook -i hosts playbook2.yml | |
PLAY [test jinja2 default filter] ********************************************* | |
TASK: [debug] ***************************************************************** | |
ok: [localhost] => { | |
"msg": "foo" | |
} | |
PLAY RECAP ******************************************************************** | |
localhost : ok=1 changed=0 unreachable=0 failed=0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The solution, FYI:
Thanks to Zart in #ansible for the help!