2023-12-25 18:22:22 +00:00
|
|
|
---
|
|
|
|
|
2024-02-08 22:44:36 +00:00
|
|
|
- name: Setup Docker Swarm manager
|
|
|
|
hosts: manager
|
2023-12-25 18:22:22 +00:00
|
|
|
tasks:
|
|
|
|
- name: Create Docker Swarm
|
|
|
|
docker_swarm:
|
|
|
|
|
2024-02-08 22:44:36 +00:00
|
|
|
- name: Get Docker Swarm manager info
|
2023-12-25 18:22:22 +00:00
|
|
|
docker_swarm_info:
|
|
|
|
nodes: yes
|
|
|
|
nodes_filters:
|
2024-02-08 22:44:36 +00:00
|
|
|
name: manager
|
2023-12-25 18:22:22 +00:00
|
|
|
register: swarm_info
|
|
|
|
|
2024-02-08 22:44:36 +00:00
|
|
|
- hosts: workers
|
2023-12-25 18:22:22 +00:00
|
|
|
tasks:
|
|
|
|
- name: Join Docker Swarm
|
|
|
|
docker_swarm:
|
|
|
|
state: join
|
2024-02-08 22:44:36 +00:00
|
|
|
join_token: "{{ hostvars.manager.swarm_info.swarm_facts.JoinTokens.Worker }}"
|
2023-12-25 18:22:22 +00:00
|
|
|
remote_addrs:
|
2024-02-08 22:44:36 +00:00
|
|
|
- "{{ hostvars.manager.ansible_default_ipv4.address }}"
|