Simple terraform+ansible configuration to quickly spin up a development Docker swarm on my homeserver
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

9 lines
492 B

---
- name: get node status
command: "docker info -f '{{ '{{' }}.Swarm.LocalNodeState{{ '}}' }}'"
register: local_node_state
changed_when: false
- name: join swarm as worker
when: local_node_state.stdout == "inactive"
command: "docker swarm join --advertise-addr {{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }} --token {{ hostvars[groups['managers'][0]]['swarm_token_workers'] }} {{ hostvars[groups['managers'][0]]['ansible_default_ipv4']['address'] }}:2377"