Hello Ansiblers!
I was trying to think of a way to expose multiple ports in a row by using the docker module (http://docs.ansible.com/ansible/docker_module.html) but I can’t think of anything except looping through the values I would need by means of the usual with_items way, which is not what I want because it would result in an overwrite of the previous iteration.
My scenario is as follows:
             
            
              
              
              
            
            
           
          
            
            
              I found a solution for now. I quickly wrote a filter plugin to obtain what I wanted - https://gist.github.com/walterdolce/93a89018d69392de7c94bf690b761455
The final product for now is:
tasks:
   - name: Install Nginx container
     docker:
       name: webserver_nginx
       image: nginx
       state: reloaded
       expose: "{{ ansible_all_ipv4_addresses | map_ipv4_port_exports(container_port='80', host_port='80') }}"
       ports: "{{ ansible_all_ipv4_addresses | map_ipv4_port_exports(container_port='80', host_port='80') }}"
I could probably change the name of the filter to make it more docker specific.
Any feedback is more than welcome!