Create the networks used by haproxy and attach it to them

This commit is contained in:
Andrea Dell'Amico 2020-10-01 17:38:36 +02:00
parent 7f79381d55
commit 65856cbbc4
5 changed files with 24 additions and 3 deletions

View File

@ -8,5 +8,5 @@
template: src=haproxy.cfg.j2 dest=/etc/haproxy/haproxy.cfg owner=root group=root mode='0444'
notify: Reload the HAPROXY configuration
when: docker_swarm_manager_main_node
when: docker_swarm_manager_main_node | bool
tags: [ 'haproxy', 'docker_haproxy', 'docker_swarm', 'docker', 'haproxy_conf' ]

View File

@ -0,0 +1,18 @@
---
- name: Create the networks that haproxy will attach to
block:
- name: Create the overlay networks
docker_network:
name: '{{ item }}'
driver: overlay
with_items: '{{ docker_swarm_haproxy_networks }}'
- name: Connect haproxy to the overlay networks
docker_network:
name: '{{ item }}'
connected:
- 'haproxy_haproxy'
append: yes
when: docker_swarm_manager_main_node | bool
tags: [ 'haproxy', 'docker_haproxy', 'docker_swarm', 'docker', 'docker_network' ]

View File

@ -1,4 +1,6 @@
---
- import_tasks: haproxy_networks.yml
when: docker_swarm_cluster_haproxy_install
- import_tasks: haproxy_conf.yml
when: docker_swarm_cluster_haproxy_install
- import_tasks: portainer.yml

View File

@ -12,5 +12,5 @@
- /srv/portainer-agent-stack.yml
run_once: True
when: docker_swarm_manager_main_node
when: docker_swarm_manager_main_node | bool
tags: [ 'portainer', 'docker_portainer', 'docker_swarm', 'docker' ]

View File

@ -45,7 +45,8 @@ services:
- '{{ constraint }}'
{% endfor %}
{% if docker_log_to_journal %}
log_driver: 'journald'
logging:
driver: 'journald'
{% endif %}
networks: