Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ansible map dictionary items to a list [duplicate]

You have a list of ansible dictionaries:

domains:
  - { domain: example.com, cert: cert1.pem }
  - { domain: example.in, cert: cert2.pem }

how do you produce joined array list in a jinja2 template from domains only?

domains=example.com,example.in
like image 823
Julius Žaromskis Avatar asked Jan 28 '23 15:01

Julius Žaromskis


1 Answers

domains={{ domains | map(attribute='domain') | list | join(",") }}

Ansible: filter a list by its attributes

https://github.com/ansible/ansible/issues/24338

like image 153
Julius Žaromskis Avatar answered Jan 31 '23 23:01

Julius Žaromskis