fix: cluster init

This commit is contained in:
Adrien Waksberg 2021-11-22 14:38:49 +01:00
parent 0cd13ec31c
commit e1e0c79428
4 changed files with 7 additions and 3 deletions

View file

@ -1,5 +1,6 @@
---
swarm_manager: false
swarm_init: false
swarm_advertise_addr: 127.0.0.1
swarm_services: {}
swarm_networks: {}

View file

@ -5,6 +5,7 @@
- swarm
vars:
swarm_manager: true
swarm_init: true
swarm_networks:
proxy:
swarm_services:

View file

@ -3,14 +3,15 @@
community.docker.docker_swarm:
advertise_addr: '{{ swarm_advertise_addr }}'
state: present
when: swarm_manager
when: swarm_manager and swarm_init
register: result
tags: swarm
- name: join swarm cluster
community.docker.docker_swarm:
advertise_addr: '{{ swarm_advertise_addr }}'
join_token: '{{ swarm_join_token }}'
join_token: '{{ swarm_manager|ternary(swarm_join_token_manager, swarm_join_token_worker) }}'
remote_addrs: '{{ swarm_remote_addrs }}'
state: join
when: not swarm_manager
when: not result.changed
tags: swarm

View file

@ -27,4 +27,5 @@
loop: '{{ swarm_services|dict2items }}'
loop_control:
label: '{{ item.key }}'
run_once: true
tags: swarm