Turns out published_ports can take  a string too, so use:

published_ports: 53:53,53:53/udp

instead of 

published_ports:
  - 53:53
  - 53:53/udp

On Friday, October 28, 2016 at 9:40:04 AM UTC-4, Neil Watson wrote:
>
> 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/d704781e-cd18-4a46-8952-250a25b481a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to