redhat-cop/casl-ansible

Not all variables in group_vars supported

Closed this issue · 3 comments

Given the following in .../inventory/group_vars/masters.yml:

---
openshift_node_group_name: 'node-config-master'
[SNIP]
...

And omitting the same from .../inventory/hosts, the following error (paraphrased) is given upon running ansible-playbook -i $INVENTORY playbooks/openshift/byo-infra.yml:

error: $MASTER_HOSTNAME 'openshift_node_group_name is undefined'

This happens in the OSEv3 play during fact setting.

The expected behavior is that setting a variable for the masters group in group_vars/masters.yml populates the variable and "matches" it to the hosts in the group.

NOTE: I've worked around this issue by setting:

#.../inventory/hosts
...SNIP...
[masters:vars]
openshift_node_group_name='node-config-master'
...SNIP...
[>] ansible --version
ansible 2.6.5
  config file = /root/advanced-openshift-deployment-homework/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /bin/ansible
  python version = 2.7.5 (default, Feb 20 2018, 09:19:12) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]

Repo and commit containing code to reproduce: darthlukan/advanced-openshift-deployment-homework@8a92a11

oybed commented

@darthlukan please use yaml format in the .yml files - i.e.: : instead of =:
openshift_node_group_name: 'node-config-master'

Please see sample inventories for further examples:
https://github.com/redhat-cop/casl-ansible/blob/master/inventory/sample.osp.example.com.d/inventory/group_vars/masters.yml

Apologies, I have a typo in my yaml (didn't copy/paste into the issue). In the file, it's formatted correctly. Issue still stands.

Closing as "user error".
My run command is incorrect, it should be:
ansible-playbook -i path/to/inventory/dir playbooks/openshift/byo-infra.yml and should not use the hosts file directly. Using the correct command referencing just the directory causes all inventory files to be parsed, whereas my original is only parsing the hosts file itself.