--- - name: Create configuration dir for {{ namespace }} file: name: "/opt/haproxy/conf.d" state: directory - name: Copy haproxy configuration files for {{ namespace }} copy: content: "{{ item.data }}" dest: "/opt/haproxy/conf.d/{{ item.name }}" loop: "{{ haproxy['conf.d'] }}" when: haproxy['conf.d'] is defined notify: restart docker haproxy - name: Start haproxy in docker for {{ namespace }} docker_container: name: "haproxy" image: "{{ docker_registry }}/haproxy:{{ haproxy_image_tag }}" state: started ports: - "443:443" container_default_behavior: no_defaults detach: true restart_policy: unless-stopped volumes: - "/opt/haproxy/conf.d:/usr/local/etc/haproxy/conf.d"