Skip to content

Instantly share code, notes, and snippets.

@technovangelist
Last active December 9, 2016 18:18
Show Gist options
  • Select an option

  • Save technovangelist/6e2f504818d33235bee2311845df586a to your computer and use it in GitHub Desktop.

Select an option

Save technovangelist/6e2f504818d33235bee2311845df586a to your computer and use it in GitHub Desktop.
- hosts: manager
become: yes
tasks:
- name: Initialize Docker Swarm
shell: docker swarm init --advertise-addr {{ ansible_eth1.ipv4.address}}
- hosts: manager
become: no
tasks:
- name: Capture Docker Swarm Join Command
shell: docker swarm join-token worker -q
register: swarmtoken
- local_action: copy content="{{ swarmtoken.stdout }}" dest=./swarmtoken force=yes
- hosts: group-workers
become: yes
tasks:
- name: Start Swarm Nodes
shell: docker swarm join --token={{ lookup('file', './swarmtoken') }} {{ hostvars['manager'].ansible_eth1.ipv4.address }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment