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:
parent
7e99f97958
commit
b16ab5205c
3 changed files with 14 additions and 4 deletions
|
|
@ -1,4 +1,3 @@
|
||||||
[defaults]
|
[defaults]
|
||||||
|
|
||||||
inventory = ./inventory
|
inventory = ./staging
|
||||||
group = testing
|
|
||||||
|
|
|
||||||
3
group_vars/testing.yml
Normal file
3
group_vars/testing.yml
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
docker_swarm_advertise_addr: eth1
|
||||||
|
|
@ -3,11 +3,19 @@
|
||||||
# needs community docker module installed:
|
# needs community docker module installed:
|
||||||
# run $`ansible-galaxy collection install community.docker`
|
# 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:
|
community.docker.docker_swarm:
|
||||||
state: present
|
state: present
|
||||||
# advertise_addr: eth1 # necessary for testing setup on vagrant
|
|
||||||
become: true
|
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
|
- name: Ensure public network exists
|
||||||
community.docker.docker_network:
|
community.docker.docker_network:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue