I am having trouble getting my jinja2 template from ansible to be able to read a global variable set in group_vars/all.yml
.
** My Question is **: How can I get my j2 template to be able to see global variables set within group_vars/all.yml
? from my understanding, group_vars/all
should apply to all groups.
My ansible project is as follows:
group_vars/
all.yml
playbooks/
roles/
some-role/
tasks/
main.yml
templates/
template.conf.j2
my-playbook.yml
tasks/main.yml
---
- name: do it
template:
src: template.conf.j2
dest: ...
templates/template.conf.j2
The global variable is: {{ GlobalVariable }}
group_vars/all.yml
GlobalVariable: something
When I run the playbook, I get an error when trying to write that template.
AnsibleUndefinedVariable: One or more undefined variables: 'GlobalVariable' is undefined