Greetings,
Below is an example of a playbook to manager some docker containers. I’ve built a data structure that my tasks can loop over. The trouble is that one task attribute, published_ports requires a whole list, but when I pass is a list it only gets one element. How can I fix this?
vars:
list of images and attributes
images:
- src: …/dns
dest: /usr/src/
path: /usr/src/dns
name: my_dns
state: present
list of containers and attributes
containers:
- name: my_dns
state: started
published_ports: # <<< need to pass this list whole - 53
- 53:53/udp
tasks:
-
block:
-
name: upload dockerfile and data
copy:
src: “{{ item.src }}”
dest: “{{ item.dest }}”
with_items: “{{ images }}” -
name: build dns docker image
docker_image:
path: “{{ item.path }}”
name: “{{ item.name }}”
state: “{{ item.state }}”
with_items: “{{ images }}” -
name: deploy container
docker_container:
name: “{{ item.name }}”
image: “{{ item.name }}”
published_ports: “{{ item.published_ports }}” # <<< How pass whole list?
state: “{{ item.state }}”
with_items: “{{ containers }}”