Created
June 27, 2013 17:21
-
-
Save cbrinker/5878410 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
$ cat group_vars/all | |
foo: bar | |
$ cat test.yml | |
--- | |
# file: test.yml | |
- hosts: localhost | |
tasks: | |
- name: Create foo | |
template: src=foo.j2 dest=/tmp/foo | |
$ cat foo.j2 | |
Hopefully this says bar = ${foo} | |
$ ansible-playbook -i /etc/ansible/hosts test.yml -CD | |
PLAY [localhost] ************************************************************** | |
GATHERING FACTS *************************************************************** | |
ok: [localhost] | |
TASK: [Create foo] ************************************************************ | |
--- before: /tmp/foo | |
+++ after: /Users/chris/work/configurator/ansible/foo.j2 | |
@@ -1,0 +1,1 @@ | |
+Hopefully this says bar = ${foo} | |
changed: [localhost] | |
PLAY RECAP ******************************************************************** | |
localhost : ok=2 changed=1 unreachable=0 failed=0 | |
========================================================================================= | |
===================== NOW adding a vars_files directive to playbook ===================== | |
========================================================================================= | |
$ cat test.yml | |
--- | |
# file: test.yml | |
- hosts: localhost | |
tasks: | |
- name: Create foo | |
template: src=foo.j2 dest=/tmp/foo | |
vars_files: # Not certain if this is required, but it doesn't seem to hurt¬ | |
- "group_vars/all" | |
$ ansible-playbook -i /etc/ansible/hosts test.yml -CD | |
PLAY [localhost] ************************************************************** | |
GATHERING FACTS *************************************************************** | |
ok: [localhost] | |
TASK: [Create foo] ************************************************************ | |
--- before: /tmp/foo | |
+++ after: /Users/chris/work/configurator/ansible/foo.j2 | |
@@ -1,0 +1,1 @@ | |
+Hopefully this says bar = bar | |
changed: [localhost] | |
PLAY RECAP ******************************************************************** | |
localhost : ok=2 changed=1 unreachable=0 failed=0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For those seeing similar issues, There were 2 discoveries here.
1: the {{}} variable syntax > ${}
2: The group_vars/all file is searched for relative to the specified inventory location (/etc/ansible/group_vars/all by default apparently)