Variable `docker_stack_files_dir` can be used if other stack deployments need to copy over configuration files or other extra files. Defaults to `/stacks` but can be set to anything and other roles should take care to respect this and put their files relative to it. Variable `docker_swarm_public_network_name` can be used to set the name of the network to be created that faces outwards (ingress network) and to which all stacks will be connecting.
32 lines
960 B
YAML
32 lines
960 B
YAML
---
|
|
# Bring up a docker swarm
|
|
# needs community docker module installed:
|
|
# run $`ansible-galaxy collection install community.docker`
|
|
|
|
- name: Ensure swarm is initialized with default advertise address
|
|
community.docker.docker_swarm:
|
|
state: present
|
|
become: true
|
|
when: docker_swarm_advertise_addr is undefined
|
|
|
|
# ensure setups with multiple ip addresses can be initialized
|
|
- name: Ensure swarm is initialized with specified advertise address
|
|
community.docker.docker_swarm:
|
|
state: present
|
|
advertise_addr: "{{ docker_swarm_advertise_addr }}"
|
|
become: true
|
|
when: docker_swarm_advertise_addr is defined
|
|
|
|
- name: Ensure public network exists
|
|
community.docker.docker_network:
|
|
name: "{{ docker_swarm_public_network_name }}"
|
|
driver: overlay
|
|
state: present
|
|
become: true
|
|
|
|
- name: Ensure stack files directory exists
|
|
ansible.builtin.file:
|
|
path: "{{ docker_stack_files_dir }}"
|
|
state: directory
|
|
mode: '0755'
|
|
become: true
|