Configuring networks
An application role defines all of its networks in one call to sr2c.podman.podman_networks, restarts its stack when they change, and checks them once the stack is running. The examples following are how sr2c.apps.podman_link would use it.
Install the networks before the container quadlets and the stack start:
- name: Podman Link Helpdesk | PATCH | Install networks
ansible.builtin.include_role:
name: sr2c.podman.podman_networks
vars:
podman_networks_podman_rootless_user: "{{ podman_link_podman_rootless_user }}"
podman_networks_stop_units: [link.target, nginx.service]
podman_networks_config: "{{ podman_link_networks }}"
Define the networks to use in the role’s vars, so the check at the end uses the same definitions:
podman_link_networks:
frontend:
comment: Connect's podman_nginx's nginx to zammad-nginx
subnet: 10.89.240.0/24
search:
comment: Allows Zammad and Opensearch to communicate.
subnet: 10.89.244.0/24
ip_range: 10.89.244.128-10.89.244.254
internal: true
link:
state: absent
Restart the stack when the role reports a change. The role sets
podman_networks_changed rather than notifying a handler, so it doesn’t need
to know the calling role’s handler names:
- name: Podman Link Helpdesk | PATCH | Restart Link when its networks changed
ansible.builtin.debug:
msg: Networks changed; restarting Link.
changed_when: podman_networks_changed
when: podman_networks_changed
notify:
- Restart Link
Once the stack is running, check the live networks match their definitions:
- name: Podman Link Helpdesk | AUDIT | Check the networks match their definitions
ansible.builtin.include_role:
name: sr2c.podman.podman_networks
tasks_from: verify
vars:
podman_networks_podman_rootless_user: "{{ podman_link_podman_rootless_user }}"
podman_networks_config: "{{ podman_link_networks }}"