Moved ansible stuff to own folder

This commit is contained in:
Jef Roosens 2021-12-18 10:30:44 +01:00
parent 868acbc08f
commit fb5bb177ca
Signed by: Jef Roosens
GPG key ID: 955C0660072F691F
33 changed files with 1 additions and 22 deletions

View file

@ -0,0 +1,17 @@
---
- name: Check node state.
register: node_state
shell: "docker info --format '{{ '{{' }}.Swarm.LocalNodeState{{ '}}' }}'"
ignore_errors: true
changed_when: false
- name: Add worker to swarm.
register: join_cmd
shell: >
docker swarm join
--token {{ hostvars.admin.worker_token }}
{{ hostvars.admin.ansible_host }}:2377
# 0 means it was successfully added, 1 means it's already in the swarm.
failed_when: join_cmd.rc != 0
changed_when: join_cmd.rc == 0
when: node_state.stdout not in [ 'active', 'locked', 'error' ]