I am having problem while joining a worker node with manager node. But i am having issue in the system while join the worker in the cluster.
docker_worker_token set to another host.
host1:
- name: Get the worker join-token.
shell: docker swarm join-token -q worker
with_items:
- "{{ groups['manager'] }}"
register: docker_worker_token
host2:
- name: join node to the cluster
shell: docker swarm join --token {{ hostvars[item]['docker_worker_token'] }} {{ managerip }}:2377
with_items:
- "{{ groups['manager'] }}"
The error i am getting below like this.
failed: [188.166.30.64] (item=188.166.17.148) => {"changed": true, "cmd": "docker swarm join --token {'msg': u'All items completed', 'changed': True, 'results': [{u'changed': True, u'end': u'2016-09-10 13:42:11.439043', '_ansible_no_log': False, u'stdout': u'SWMTKN-1-34rdkhgb6ij6njvzdnutvbt8ee3crelm5as7dm7c7y7s03nvr3-9m0c8vp9hjb84ne90etapxec5', '_ansible_item_result': True, 'item': u'188.166.17.148', u'delta': u'0:00:00.016042', u'cmd': u'docker swarm join-token -q worker', u'stderr': u'', u'rc': 0, 'invocation': {'module_name': u'command', u'module_args': {u'warn': True, u'executable': None, u'_uses_shell': True, u'_raw_params': u'docker swarm join-token -q worker', u'removes': None, u'creates': None, u'chdir': None}}, 'stdout_lines': [u'SWMTKN-1-34rdkhgb6ij6njvzdnutvbt8ee3crelm5as7dm7c7y7s03nvr3-9m0c8vp9hjb84ne90etapxec5'], u'start': u'2016-09-10 13:42:11.423001', u'warnings': []}]} 188.166.17.148:2377", "delta": "0:00:00.060083", "end": "2016-09-10 13:42:24.251326", "failed": true, "item": "188.166.17.148", "rc": 1, "start": "2016-09-10 13:42:24.191243", "stderr": "\"docker swarm join\" requires exactly 1 argument(s).\nSee 'docker swarm join --help'.\n\nUsage: docker swarm join [OPTIONS] HOST:PORT\n\nJoin a swarm as a node and/or manager", "stdout": "", "stdout_lines": [], "warnings": []}
Now how i write the {{ hostvars[item]['docker_worker_token'] }} so i can get the token information from the hostvars.