forked from ISTI-ansible-roles/ansible-roles
44 lines
1.3 KiB
YAML
44 lines
1.3 KiB
YAML
---
|
|
- block:
|
|
- debug:
|
|
msg: "Tasks that setup the Swarm worker nodes"
|
|
|
|
when: docker_swarm_node | bool
|
|
tags: [ 'docker', 'docker_swarm' ]
|
|
|
|
- block:
|
|
- name: Get swarm status information
|
|
docker_swarm:
|
|
state: inspect
|
|
register: swarm_info_data
|
|
|
|
- name: Get the swarm worker node token
|
|
set_fact:
|
|
docker_swarm_worker_token: '{{ swarm_info_data.swarm_facts.JoinTokens.Worker }}'
|
|
cacheable: True
|
|
|
|
when: docker_swarm_node | bool
|
|
delegate_to: '{{ docker_swarm_manager_main_node_hostname }}'
|
|
tags: [ 'docker', 'docker_swarm' ]
|
|
|
|
- block:
|
|
- name: Add worker nodes to the docker swarm cluster
|
|
docker_swarm:
|
|
state: join
|
|
advertise_addr: '{{ ansible_default_ipv4.address }}'
|
|
join_token: '{{ docker_swarm_worker_token }}'
|
|
remote_addrs: [ '{{ docker_swarm_manager_main_node_hostname }}:2377' ]
|
|
|
|
when: docker_swarm_node | bool
|
|
tags: [ 'docker', 'docker_swarm', 'docker_swarm_worker_nodes' ]
|
|
|
|
- block:
|
|
- name: Set the swarm nodes availability. Default 'active'
|
|
docker_node:
|
|
hostname: '{{ ansible_hostname }}'
|
|
availability: '{{ docker_swarm_node_availability }}'
|
|
|
|
when: docker_swarm_node | bool
|
|
delegate_to: '{{ docker_swarm_manager_main_node_hostname }}'
|
|
tags: [ 'docker', 'docker_swarm', 'docker_swarm_worker_nodes', 'docker_swarm_worker_nodes_availability' ]
|