I’m trying to figure out how to do ‘subelements’ with the query plugin. The thing below doesn’t work, it complains that “could not find ‘ssh_key’ key in iterated item”. So the skip_missing is not working. While when I use ‘with_subelements’ it does work. Can someone see what I’m doing wrong?
Hi,
I'm trying to figure out how to do 'subelements' with the query
plugin. The thing below doesn't work, it complains that "could not
find 'ssh_key' key in iterated item". So the skip_missing is not
working. While when I use 'with_subelements' it does work. Can
someone see what I'm doing wrong?> - name: debug user struct
> debug:
> msg: "{{ item.1 }}"
> loop: "{{ query('subelements', user, 'ssh_key', skip_missing=yes) }}"
> tags: test29
According to the documentation (see last example here:
https://docs.ansible.com/ansible/2.5/plugins/lookup/subelements.html#examples)
you need to quote skip_missing=yes:
- name: debug user struct
debug:
msg: "{{ item.1 }}"
loop: "{{ query('subelements', user, 'ssh_key', 'skip_missing=yes') }}"
tags: test29
(Haven't tried it, though.)
Cheers,
Felix