mirror of
https://gitlab.com/rusty-bever/deployment.git
synced 2026-04-08 09:35:47 +02:00
first part of config
This commit is contained in:
commit
8ee7c76f64
30 changed files with 729 additions and 0 deletions
16
roles/docker-swarm-add-worker/tasks/main.yml
Normal file
16
roles/docker-swarm-add-worker/tasks/main.yml
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
---
|
||||
- name: Check node state.
|
||||
register: node_state
|
||||
shell: "docker info --format '{{ '{{' }}.Swarm.LocalNodeState{{ '}}' }}'"
|
||||
ignore_errors: true
|
||||
|
||||
- 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' ]
|
||||
Loading…
Add table
Add a link
Reference in a new issue