--- - name: Create the networks that haproxy will attach to and that are not created by the services block: - name: Create the overlay networks that are not created by the services docker_network: name: '{{ item }}' driver: overlay scope: swarm with_items: '{{ docker_swarm_haproxy_additional_networks }}' - name: Connect haproxy to the overlay networks docker_compose: project_name: haproxy_haproxy definition: version: 3 services: haproxy_haproxy: networks: '{{ docker_swarm_haproxy_networks }}' ignore_errors: True - name: Connect haproxy to the overlay networks docker_compose: project_name: haproxy_haproxy definition: version: 3 services: haproxy_haproxy: networks: '{{ docker_swarm_haproxy_additional_networks }}' ignore_errors: True when: docker_swarm_manager_main_node | bool tags: [ 'haproxy', 'docker_haproxy', 'docker_swarm', 'docker', 'docker_network' ]