This is an automated email from the ASF dual-hosted git repository.
ctubbsii pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/fluo-muchos.git
The following commit(s) were added to refs/heads/master by this push:
new aac2459 Fixes #268: Setup fails when swarmmanager enabled (#278)
aac2459 is described below
commit aac2459503196a708adea723c62c542b154c98f5
Author: Nikhil Manchanda <[email protected]>
AuthorDate: Wed Sep 4 15:27:00 2019 -0700
Fixes #268: Setup fails when swarmmanager enabled (#278)
* Rename 'swarm_token' task var to 'swarm_token_stdout' to avoid
clobbering
* Do not run 'join worker to swarm' task on swarmmanager node
* Make the 'join worker to swarm' task idempotent
Signed-off-by: Nikhil Manchanda <[email protected]>
---
ansible/docker.yml | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/ansible/docker.yml b/ansible/docker.yml
index 83870be..4ef4e8a 100644
--- a/ansible/docker.yml
+++ b/ansible/docker.yml
@@ -35,10 +35,10 @@
shell: docker swarm join-token -q worker
register: swarm_token
changed_when: "'active' not in swarm_status.stdout_lines"
-- hosts: workers
+- hosts: workers:!swarmmanager
become: yes
vars:
- swarm_token: "{{
hostvars[groups['swarmmanager'][0]]['swarm_token']['stdout'] }}"
+ swarm_token_stdout: "{{
hostvars[groups['swarmmanager'][0]]['swarm_token']['stdout'] }}"
manager_ip: "{{
hostvars[groups['swarmmanager'][0]]['ansible_default_ipv4']['address'] }}"
tasks:
- name: get swarm status
@@ -47,6 +47,7 @@
register: swarm_status
changed_when: "'active' not in swarm_status.stdout_lines"
- name: join worker to swarm
- shell: >
- docker swarm join --token={{ swarm_token }} {{ manager_ip }}:2377
+ shell: |
+ docker swarm leave || echo "Not part of a swarm."
+ docker swarm join --token={{ swarm_token_stdout }} {{ manager_ip
}}:2377
when: "'active' not in swarm_status.stdout_lines"