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 }}"
 

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/ff4b848f-1277-4152-82a7-cadd79f3fba3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to