Skip to content

Commit ba66b2a

Browse files
committed
feat(container): Allow control of Docker Swarm default-add-pool
The polaris.docker_swarm_default_addr_pool variable allows control of the default-add-pool option to docker swarm init.
1 parent e950083 commit ba66b2a

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

playbooks/container/docker_swarm.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
state: present
1313
advertise_addr: "{{ polaris.docker_swarm_advertise_address | default(omit) }}"
1414
listen_addr: "{{ polaris.docker_swarm_advertise_address | default(omit) }}"
15+
default_addr_pool:
16+
- "{{ polaris.docker_swarm_default_addr_pool | default('10.135.0.0/16') }}"
1517
register: swarm_initialisation_info
1618
- name: Peek at swarm_initialisation_info
1719
debug:
@@ -45,6 +47,8 @@
4547
join_token: "{{ target_swarm_facts.swarm_initialisation_info.swarm_facts.JoinTokens.Manager }}"
4648
advertise_addr: "{{ private_ip_address | default(omit) }}"
4749
listen_addr: "{{ private_ip_address | default(omit) }}"
50+
default_addr_pool:
51+
- "{{ polaris.docker_swarm_default_addr_pool | default('10.135.0.0/16') }}"
4852
remote_addrs:
4953
- "{{ polaris.docker_swarm_advertise_address | default(target_swarm_facts.default_ipv4.address) | default(target_swarm_facts.all_ipv4_addresses[0]) }}"
5054

@@ -71,5 +75,7 @@
7175
join_token: "{{ target_swarm_facts.swarm_initialisation_info.swarm_facts.JoinTokens.Worker }}"
7276
advertise_addr: "{{ private_ip_address | default(omit) }}"
7377
listen_addr: "{{ private_ip_address | default(omit) }}"
78+
default_addr_pool:
79+
- "{{ polaris.docker_swarm_default_addr_pool | default('10.135.0.0/16') }}"
7480
remote_addrs:
7581
- "{{ polaris.docker_swarm_advertise_address | default(target_swarm_facts.default_ipv4.address) | default(target_swarm_facts.all_ipv4_addresses[0]) }}"

variables.schema.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ properties:
4747
Externally reachable address advertised to other swarm nodes.
4848
See https://docs.ansible.com/ansible/latest/collections/community/docker/docker_swarm_module.html#parameter-advertise_addr
4949
50+
docker_swarm_default_addr_pool:
51+
type: array
52+
default: [ 10.135.0.0/16 ]
53+
description: >
54+
List of strings, each of which is a CIDR range of IP addresses which Docker will assign to containers using overlay networks.
55+
This is useful to ensure reachability of swarm services by external clients that have addresses in the 10/8 usually allocated to overlay networks.
56+
See https://docs.ansible.com/ansible/latest/collections/community/docker/docker_swarm_module.html#parameter-default_addr_pool
57+
and https://docs.docker.com/reference/cli/docker/swarm/init/#default-addr-pool
58+
5059
docker_registry_username:
5160
type: string
5261

0 commit comments

Comments
 (0)