Ansible Jinja2 join dict nected values

For a certain configuration file I needed all my SSH users to be listed as p.puk,j.snot,s.sjors  etc from the following dict.

But whenever I ran the following task:

With the following template:

it would give me:

AnsibleUndefinedVariable: ‘list object’ has no attribute ‘account’

But having found:

I put the following in my template:

It gave me the following in /tmp/file.

The StackOverflow article covered something else so I wasn’t able to thank Crypto for his/her contribution but hopefully by creating this small post I can reach out to this person to say that this little fix saved my evening!

Guess I’d overlooked as I was of the assumption that my dict was YAML structured and therefor such a thing as json-query-filter wouldn’t work.

But then again:



One Reply to “Ansible Jinja2 join dict nected values”

  1. Great article. You saved my day!
    I have been searching for this solution for a couple of hours.
    Apparently, the Ansible documentation seems to be too abstract or difficult.

Leave a Reply

Your email address will not be published. Required fields are marked *