# Ansible and Sops files

**URL:** <https://forum.ansible.com/t/ansible-and-sops-files/38426>\
**Category:** Ansible Project\
**Created:** [September 12, 2023, 9:56am UTC](https://forum.ansible.com/t/ansible-and-sops-files/38426 "2023-09-12T09:56:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cesarjorgemartinez](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/cesarjorgemartinez/32/163_2.png) [@cesarjorgemartinez](https://forum.ansible.com/u/cesarjorgemartinez)\
**Post date:** [September 12, 2023, 9:56am UTC](https://forum.ansible.com/t/ansible-and-sops-files/38426/1 "2023-09-12T09:56:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [September 12, 2023, 2:11pm UTC](https://forum.ansible.com/t/ansible-and-sops-files/38426/2 "2023-09-12T14:11:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cesarjorgemartinez](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/cesarjorgemartinez/32/163_2.png) [@cesarjorgemartinez](https://forum.ansible.com/u/cesarjorgemartinez)\
**Post date:** [September 12, 2023, 4:22pm UTC](https://forum.ansible.com/t/ansible-and-sops-files/38426/3 "2023-09-12T16:22:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [September 12, 2023, 4:34pm UTC](https://forum.ansible.com/t/ansible-and-sops-files/38426/4 "2023-09-12T16:34:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cesarjorgemartinez](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/cesarjorgemartinez/32/163_2.png) [@cesarjorgemartinez](https://forum.ansible.com/u/cesarjorgemartinez)\
**Post date:** [September 12, 2023, 4:38pm UTC](https://forum.ansible.com/t/ansible-and-sops-files/38426/5 "2023-09-12T16:38:31Z")

</div>

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