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
494 B

1 year ago
  1. ---
  2. - name: get node status
  3. command: "docker info -f '{{ '{{' }}.Swarm.LocalNodeState{{ '}}' }}'"
  4. register: local_node_state
  5. changed_when: false
  6. - name: join swarm as manager
  7. when: local_node_state.stdout == "inactive"
  8. command: "docker swarm join --advertise-addr {{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }} --token {{ hostvars[groups['managers'][0]]['swarm_token_managers'] }} {{ hostvars[groups['managers'][0]]['ansible_default_ipv4']['address'] }}:2377"