From c3b0000a61c478fb16156604a4b1cd3d9f961fba Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Mon, 5 Oct 2020 18:54:59 +0200 Subject: [PATCH] Use a shell command to update the haproxy networks. --- tasks/haproxy_networks.yml | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/tasks/haproxy_networks.yml b/tasks/haproxy_networks.yml index 6486bb8..60c1679 100644 --- a/tasks/haproxy_networks.yml +++ b/tasks/haproxy_networks.yml @@ -9,23 +9,17 @@ 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 }}' + shell: docker service update --network-add {{ item }} {{ docker_haproxy_service_name }} --update-delay 30s --update-parallelism 1 && touch {{ haproxy_docker_compose_dir }}/.network_{{ item }} + with_items: '{{ docker_swarm_haproxy_networks }}' + args: + creates: '{{ haproxy_docker_compose_dir }}/.network_{{ item }}' 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 }}' + - name: Connect haproxy to some additional overlay networks + shell: docker service update --network-add {{ item }} {{ docker_haproxy_service_name }} --update-delay 30s --update-parallelism 1 && touch {{ haproxy_docker_compose_dir }}/.additional_network_{{ item }} + with_items: '{{ docker_swarm_haproxy_additional_networks }}' + args: + creates: '{{ haproxy_docker_compose_dir }}/.additional_network_{{ item }}' ignore_errors: True when: docker_swarm_manager_main_node | bool