Ansible and Sops files

Hi,

I’m using some Sops files inside one ansible project.
Version is 8.3.0 - core 2.15.3

When launch one playbook shows warnings like:

[WARNING]: Skipping key (aaa) in group (bbb) as it is not a mapping, it is a <class ‘ansible.parsing.yaml.objects.AnsibleUnicode’>


How do I prevent those warnings from appearing?
I need extra configuration?

Regards,
Cesar Jorge

You do not give enough details, the message seems to indicate
malformed YAML, could you show the files involved?

Hi,

Yes (I have secrets here, then I cut):
One file example is: inventory/dev/ssh.yml

Then the sops encrypted file has this text in clear (sops -d file):

This file is…

data:
sshpriv1: |
TEXT1
sshpub.pub: |
TEXT2

The warnings show like:
[WARNING]: Skipping key (MYKEY1) in group (data) as it is not a mapping, it is a <class ‘ansible.parsing.yaml.objects.AnsibleUnicode’>
[WARNING]: Skipping key (MYKEY2) in group (data) as it is not a mapping, it is a <class ‘ansible.parsing.yaml.objects.AnsibleUnicode’>
[WARNING]: Skipping key (MYKEY3 ) in group (data) as it is not a mapping, it is a <class ‘ansible.parsing.yaml.objects.AnsibleUnicode’>
[WARNING]: Skipping key (MYKEY4) in group (data) as it is not a mapping, it is a <class ‘ansible.parsing.yaml.objects.AnsibleUnicode’>
[WARNING]: Skipping key (kms) in group (sops) as it is not a mapping, it is a <class ‘ansible.parsing.yaml.objects.AnsibleSequence’>
[WARNING]: Skipping key (gcp_kms) in group (sops) as it is not a mapping, it is a <class ‘ansible.parsing.yaml.objects.AnsibleSequence’>
[WARNING]: Skipping key (azure_kv) in group (sops) as it is not a mapping, it is a <class ‘ansible.parsing.yaml.objects.AnsibleSequence’>
[WARNING]: Skipping key (hc_vault) in group (sops) as it is not a mapping, it is a <class ‘ansible.parsing.yaml.objects.AnsibleSequence’>
[WARNING]: Skipping key (age) in group (sops) as it is not a mapping, it is a <class ‘ansible.parsing.yaml.objects.AnsibleSequence’>
[WARNING]: Skipping key (lastmodified) in group (sops) as it is not a mapping, it is a <class ‘ansible.parsing.yaml.objects.AnsibleUnicode’>
[WARNING]: Skipping key (mac) in group (sops) as it is not a mapping, it is a <class ‘ansible.parsing.yaml.objects.AnsibleUnicode’>
[WARNING]: Skipping key (pgp) in group (sops) as it is not a mapping, it is a <class ‘ansible.parsing.yaml.objects.AnsibleSequence’>
[WARNING]: Skipping key (unencrypted_suffix) in group (sops) as it is not a mapping, it is a <class ‘ansible.parsing.yaml.objects.AnsibleUnicode’>
[WARNING]: Skipping key (version) in group (sops) as it is not a mapping, it is a <class ‘ansible.parsing.yaml.objects.AnsibleUnicode’>

The playbook works, but show these warns.
ansible-playbook -v -i inventory/dev …

Also I’m using in Ansible configuration file:
callback_result_format=yaml

The sops version is 3.7.3.

Ah, at the moment that I write this, the inventory file is:
inventory/dev/hosts.yml

When I change the launch as:
ansible-playbook -v -i inventory/dev/hosts.yml …

The warns dissapear. Hum, howto exclude with Ansible any encrypted files to use “inventory/dev”?
Or howto reorder this structure?

Regards,
Cesar Jorge

You are trying to use a vars file as an inventory also, that is why
you are getting those warnings. move it into a host_vars or group_vars
directory instead

Hum, but I would no longer have my inventory (machine location, ips, and their secrets…) centralized in one place