sr2c.podman.podman_networks role – Create Podman network quadlets
Note
This role is part of the sr2c.podman collection (version 0.0.1).
It is not included in ansible-core.
To check whether it is installed, run ansible-galaxy collection list.
To install it use: ansible-galaxy collection install sr2c.podman.
To use it in a playbook, specify: sr2c.podman.podman_networks.
Entry point main – Create Podman network quadlets
Synopsis
Creates the network quadlets for a rootless Podman user from
podman_networks_config, and corrects any configuration or runtime drift.Podman only reads a network’s options when it creates the network. Quadlet runs
podman network create --ignore, so changingSubnet=,Internal=orIPRange=in a quadlet does nothing to a network that already exists. This role inspects each live network, and when one differs from its definition it stopspodman_networks_stop_units, removes the network and restarts<name>-network.serviceto create it again.The role fails before changing anything if an entry has an unknown option or the wrong type. The role is not aware of networks defined by previous calls for the same user, so keep all of one user’s subnets in one call.
In order to avoid issues with inheritance or priority, the role will fail if anywhere under
~/.config/containers/systemdthere is a network drop-in directory (<name>.network.d, a truncated one such asfoo-.network.d, ornetwork.d), a.networkquadlet below the top level, or a directory named*.network.podman_networks_configshould contain every network the user should have. Whenpodman_networks_pruneistrue, the default, the role also removes any other.networkquadlet in~/.config/containers/systemd, and any other loaded<name>-network.servicethat quadlet generated, along with its Podman network, so deleting an entry retires the network without the need for additional guard tasks.Enforces that the quadlet’s name
<name>.networkmatches theNetworkName=<name>entry.Requires the
jsonschemaandnetaddrPython libraries on the controller.
Parameters
Parameter |
Comments |
|---|---|
The networks, keyed by name. The name is the quadlet file name (
Default: |
|
The rootless Podman user that owns the networks. The calling role passes its own |
|
Remove every other network quadlet in Set to Choices:
|
|
User units to stop before a network is removed or recreated, usually the stack’s target and anything else on the network, for example They are only stopped when a network is actually removed or recreated, because Default: |
Entry point verify – Check the runtime networks match their definitions, once the stack has started
Synopsis
Fails if a network in
podman_networks_configis missing, or its subnet, internal flag or IP range differs from its definition.Also fails on network drop-in directories and nested
.networkquadlets, as the main entry point does.Run it once the calling role has started its stack, with the same variables as the main entry point.
Parameters
Parameter |
Comments |
|---|---|
The same networks passed to the main entry point; see Default: |
|
The rootless Podman user that owns the networks. |
Authors
Iain Learmonth (https://guardianproject.dev/irl)