Fix docker-swarm for multi-ip machines

Added variable docker_swarm_advertise_addr which can be set to the
advertise address swarm should use.

Mostly introduced for vagrant-based test setups for now, which contain
multiple IP addresses and fail otherwise.
This commit is contained in:
Marty Oehme 2021-07-27 13:21:08 +02:00
parent 7e99f97958
commit b16ab5205c
Signed by: Marty
GPG key ID: B7538B8F50A1C800
3 changed files with 14 additions and 4 deletions

View file

@ -3,11 +3,19 @@
# needs community docker module installed:
# run $`ansible-galaxy collection install community.docker`
- name: Ensure swarm is initialized
- name: Ensure swarm is initialized with default advertise address
community.docker.docker_swarm:
state: present
# advertise_addr: eth1 # necessary for testing setup on vagrant
become: true
when: docker_swarm_advertise_addr is undefined
# ensure setups with multiple ip addresses can be initialized
- name: Ensure swarm is initialized with specified advertise address
community.docker.docker_swarm:
state: present
advertise_addr: "{{ docker_swarm_advertise_addr }}"
become: true
when: docker_swarm_advertise_addr is defined
- name: Ensure public network exists
community.docker.docker_network: