diff --git a/tasks/haproxy-docker-service.yml b/tasks/haproxy-docker-service.yml index b8a923b..f92bab8 100644 --- a/tasks/haproxy-docker-service.yml +++ b/tasks/haproxy-docker-service.yml @@ -17,6 +17,12 @@ - name: Install the docker compose file template: src=haproxy-docker-stack.yml.j2 dest={{ haproxy_docker_compose_dir }}/docker-haproxy-stack.yml mode='0644' + - name: Create the overlay network that will be joined by the proxied services + docker_network: + name: '{{ haproxy_docker_overlay_network }}' + driver: overlay + scope: swarm + - name: Run the docker compose file to start the service docker_stack: name: haproxy diff --git a/templates/haproxy-docker-stack.yml.j2 b/templates/haproxy-docker-stack.yml.j2 index 76ed599..ded0d38 100644 --- a/templates/haproxy-docker-stack.yml.j2 +++ b/templates/haproxy-docker-stack.yml.j2 @@ -7,6 +7,8 @@ services: - {{ haproxy_cert_dir }}:{{ haproxy_cert_dir }}:ro - /etc/haproxy:/usr/local/etc/haproxy:ro - /var/run/docker.sock:/var/run/docker.sock + networks: + - {{ haproxy_docker_overlay_network }} ports: - target: {{ haproxy_default_port }} published: {{ haproxy_default_port }} @@ -75,3 +77,7 @@ services: logging: driver: 'journald' {% endif %} + +networks: + {{ haproxy_docker_overlay_network }}: + esternal: True diff --git a/vars/main.yml b/vars/main.yml index 3808477..e5d8a25 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,2 +1,2 @@ --- -# vars file for ansible-role-template \ No newline at end of file +haproxy_docker_overlay_network: 'haproxy-public' \ No newline at end of file