The deploy failed on hngmohali with 'all predefined address pools have been fully subnetted': every 172.17-172.30/16 is in use, 172.31/16 is the host's own VPC so Docker will not allocate from it, and all sixteen 192.168.0-240/20 blocks are taken. Docker therefore refuses a network created without a subnet. Each Site now names a free network_subnet (10.210.0.0/16, one /24 each), the role looks the network up first and only creates it when it is absent and with that subnet, and it fails with an explanation when a Site declares none. Existing networks are left alone, because Docker cannot change a subnet in place and the Sites already running have theirs. The test checks every Site declares one, and the deployment readme says a new Site needs a free subnet. deploy.sh now deploys every Site by default, with SITE=<name> to narrow it, which is what the local edit was reaching for.
33 lines
1.0 KiB
YAML
33 lines
1.0 KiB
YAML
---
|
|
- name: Look for the app network
|
|
docker_network_info:
|
|
name: '{{ docker_network }}'
|
|
register: menu_network
|
|
|
|
- name: Fail when this Site declares no subnet
|
|
fail:
|
|
msg: >-
|
|
{{ inventory_hostname }} needs a network_subnet in its vars file. This host's
|
|
default address pools are exhausted (every 172.17-172.30/16 and every
|
|
192.168.0-240/20 is taken), so Docker refuses to allocate one and a network
|
|
has to be created with an explicit subnet.
|
|
when: network_subnet | default('') == ''
|
|
|
|
# An existing network is left exactly as it is: Docker cannot change a network's
|
|
# subnet in place, and the Sites already running have theirs.
|
|
- name: Create the app network with this Site's subnet
|
|
docker_network:
|
|
name: '{{ docker_network }}'
|
|
ipam_config:
|
|
- subnet: '{{ network_subnet }}'
|
|
state: present
|
|
when: not menu_network.exists
|
|
|
|
- name: Put Caddy on the app network
|
|
docker_network:
|
|
name: '{{ docker_network }}'
|
|
state: present
|
|
connected:
|
|
- '{{ caddy_container }}'
|
|
appends: yes
|