fix: cluster init
This commit is contained in:
parent
0cd13ec31c
commit
e1e0c79428
4 changed files with 7 additions and 3 deletions
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
swarm_manager: false
|
swarm_manager: false
|
||||||
|
swarm_init: false
|
||||||
swarm_advertise_addr: 127.0.0.1
|
swarm_advertise_addr: 127.0.0.1
|
||||||
swarm_services: {}
|
swarm_services: {}
|
||||||
swarm_networks: {}
|
swarm_networks: {}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
- swarm
|
- swarm
|
||||||
vars:
|
vars:
|
||||||
swarm_manager: true
|
swarm_manager: true
|
||||||
|
swarm_init: true
|
||||||
swarm_networks:
|
swarm_networks:
|
||||||
proxy:
|
proxy:
|
||||||
swarm_services:
|
swarm_services:
|
||||||
|
|
|
@ -3,14 +3,15 @@
|
||||||
community.docker.docker_swarm:
|
community.docker.docker_swarm:
|
||||||
advertise_addr: '{{ swarm_advertise_addr }}'
|
advertise_addr: '{{ swarm_advertise_addr }}'
|
||||||
state: present
|
state: present
|
||||||
when: swarm_manager
|
when: swarm_manager and swarm_init
|
||||||
|
register: result
|
||||||
tags: swarm
|
tags: swarm
|
||||||
|
|
||||||
- name: join swarm cluster
|
- name: join swarm cluster
|
||||||
community.docker.docker_swarm:
|
community.docker.docker_swarm:
|
||||||
advertise_addr: '{{ swarm_advertise_addr }}'
|
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 }}'
|
remote_addrs: '{{ swarm_remote_addrs }}'
|
||||||
state: join
|
state: join
|
||||||
when: not swarm_manager
|
when: not result.changed
|
||||||
tags: swarm
|
tags: swarm
|
||||||
|
|
|
@ -27,4 +27,5 @@
|
||||||
loop: '{{ swarm_services|dict2items }}'
|
loop: '{{ swarm_services|dict2items }}'
|
||||||
loop_control:
|
loop_control:
|
||||||
label: '{{ item.key }}'
|
label: '{{ item.key }}'
|
||||||
|
run_once: true
|
||||||
tags: swarm
|
tags: swarm
|
||||||
|
|
Loading…
Reference in a new issue