I have an ansible structure that contains some roles.
/usr/local/ansible
playbooks
roles
role1
role2
tasks
handlers
files
templates
my_template.yml
vars
main.yml
group_vars
role2.yml
Usually, when running this from the ansible server, the template: module finds group_vars/role2.yml and applies it to my_template just fine.
When I use ansible-pull the template module cannot find the group vars and the first template line that references a variable causes an error - can't find the variable. Only by putting my variables in vars/main.yml can we find them.
ansible-pull -C dockervm -d /usr/local/ansible -U [email protected]:MRI-Software/HappySoftware-config-usr_local_ansible.git -i localhost, -e 'small=yes vagrant=True ServerNamePrefix=docker' --accept-host-key /usr/local/ansible/playbooks/docker.yml
Since the ansible-pull operation leaves behind the entire /usr/local/ansible directory tree (as pulled from the git server) I tried running ansible-playbook manually and got the same failure as ansible-pull.
ansible-playbook -i localhost -e 'small=yes vagrant=True ServerNamePrefix=docker' ./docker.yml
The main difference between this provisioning and the normal web server provisioning is that this is running against localhost.
So I made sure that /usr/local/ansible/group_vars and /usr/local/ansible/playbooks/group_vars both contained a localhost collection of variables, but the playbook still fails on the first variable reference in the template:
TASK [docker : template] *******************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: 'SSH_WEB_USER' is undefined"}
Yes, I checked that the variable definition was there.
So I transplanted the entire collection of variables to the roles/docker/vars directory inside main.yml and that works, but it's now an exception compared to the rest of the provisioning roles.
Any idea how to get the ansible-pull to reference the group_vars directory (in playbooks)?