YAML inventory with group name "DEV" causes error

19 views
Skip to first unread message

Tdev Feeds

unread,
Apr 30, 2020, 12:57:23 PM4/30/20
to Ansible Development
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.





Matt Martz

unread,
Apr 30, 2020, 1:06:18 PM4/30/20
to Tdev Feeds, Ansible Development
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
--
You received this message because you are subscribed to the Google Groups "Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-deve...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-devel/c5af9291-9998-4073-9ca4-53508270031a%40googlegroups.com.


--
Matt Martz
@sivel
sivel.net

Tdev Feeds

unread,
Apr 30, 2020, 1:23:48 PM4/30/20
to Ansible Development
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]




On Thursday, April 30, 2020 at 12:06:18 PM UTC-5, Matt Martz wrote:
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


On Thu, Apr 30, 2020 at 11:57 AM Tdev Feeds <tdev...@gmail.com> wrote:
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.





--
You received this message because you are subscribed to the Google Groups "Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansibl...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages