YAML inventory with group name "DEV" causes error

I’m converting our existing INI inventory to YAML. The reason is that I cannot seem to get variables like “{{ myvar }}” working within an INI inventory and have found no documentation that says INI format supports variables.

Now, we have a group defined as “DEV”. This worked in the INI format. HOWEVER, it causes errors in YAML format.

all: hosts: localhost: children: foo_group: children: my_group_name: my_group_name: hosts: myhost: vars: my_var: foo

In the example above, if I change “my_group_name” to “DEV” or “dev”, I get the following error.

ERROR! Attempting to decrypt but no vault secrets found

I’m verifying the inventory using the following command.

$ ansible-inventory -i inventory.yml --list

Is this a bug or a reserved word? Why would it work in INI and not YAML?

Thanks in advance.

Try converting it to YAML using ansible-inventory itself:

ansible-inventory -i inventory.ini --list --yaml --export

I think you probably want something like this:

all:
hosts:
localhost: {}
children:
foo_group:
children:
my_group_name:
hosts:
myhost: {}
vars:
my_var: foo

Thank you for your quick response. I was playing with the YAML indentation to see if that was a factor. It isn’t. So your example format causes the same issue. Export fails as well.

After playing around more, I can get vars to work in INI. I was simply missing quotes. <face_palm/> I think the issue is with the “ansible-inventory” command. If I run a playbook using “ansible-playbook” and the group named “DEV”, the vars work in INI and YAML. o_O?

Forgot to note the version I’m using.

$ ansible --version ansible 2.9.7 config file = /etc/ansible/ansible.cfg configured module search path = [u'/home/myuser/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python2.7/dist-packages/ansible executable location = /usr/bin/ansible python version = 2.7.17 (default, Nov 7 2019, 10:07:09) [GCC 7.4.0]