I'm trying to work out how to loop over a list of dicts and extract the name of each entry to merge with another variable.
jinja2 pseudo code which should give the desired result:
---
docker_applications:
- name: foo
zfs_opts:
quota: 4G
compression: false
- name: bar
zfs_filesystems:
- name: rust/ftp
- name: ssd/one
quota: 1T
- name: ssd/two
{% for i in docker_applications %}
- name: "docker/{{ i.name }}"
{% for k, v in i.zfs_opts %}
{{ k }}: {{ v }}
{% endfor %}
{% endfor %}
Which would give:
---
zfs_filesystems:
- name: rust/ftp
- name: ssd/one
quota: 1T
- name: ssd/two
- name: docker/foo
quota: 4G
compression: false
- name: docker/bar
I know you can't use jinja2 templates in a variable files, so I am trying to do the merge in the inventory file but I'm at a loss on how I could achieve this.
- name: nas
hosts: nas
become: true
become_user: root
roles:
- docker
- zfs
vars:
zfs_filesystems: zfs_filesystems|do_something