Pure 1:1 rename (69 insertions / 69 deletions across 66 files) to finish the ``docker_*`` → ``compose_*`` alignment started in 8373468e9. The flag configures whether the compose include flushes handlers right after run; the ``docker_`` prefix was misleading (handlers are Ansible-side, not docker-side) and the variable is part of the same ``sys-svc-compose`` SPOT cluster as ``compose_repository_*``. Touches the role default, the implementation (``sys-svc-compose/tasks/utils/up.yml``), all 60+ consumer roles, the network-utility wrapper + its README, and the ``test_network_create_via_util.py`` lint (both the docstring guidance and the asserted diff). Breaking change for any external override that still sets the old name — no alias is provided. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2.1 KiB
Network utils 🕸️
Reusable task files for creating Docker networks in a uniform way.
Both helpers derive the docker-side network name from role_id | get_entity_name and the subnet from meta/server.yml.networks.local.subnet, so the name and the subnet pinning live in exactly one place.
Ad-hoc community.docker.docker_network calls or docker network create / container network create shell-outs in role tasks are forbidden by test_network_create_via_util.py.
When to use which 🧭
create.yml: network only, no compose-up
Use when the role still has work to do between the network creation and the compose-up.
Examples: copy entrypoint.sh / healthcheck.sh into the instance directory before the container starts, render additional configs, pre-attach other resources.
Also the right choice when pre-creating several foreign networks in a loop (e.g. prometheus's native_metrics_apps pre-create), where firing the compose handler per iteration would be wrong.
Required var:
network_role_id: the role whose network to create. Name and subnet are derived from it.
- include_tasks: "{{ [playbook_dir, 'roles/sys-svc-compose/tasks/utils/network/create.yml'] | path_join }}"
vars:
network_role_id: "{{ application_id }}"
routine.yml: wrapper with immediate compose-up
Use when the role is a self-contained single-container service whose only pre-condition for compose-up is its own network (e.g. svc-db-mariadb, svc-db-postgres, svc-ai-ollama).
The wrapper loads the docker-python deps, calls create.yml for the role's own network (via application_id), and then re-includes sys-svc-compose with compose_handlers_flush: true so the compose-up fires right after.
- include_tasks: "{{ [playbook_dir, 'roles/sys-svc-compose/tasks/utils/network/routine.yml'] | path_join }}"
vars:
compose_handlers_flush: true
Decision rule 📌
Pick routine.yml when "create network → compose-up immediately" is the entire pre-condition chain.
Pick create.yml in every other case.