From ea51855a4cbdc436d75bd1f9f85a1f3a02ef860a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20M=C3=A9ndez=20Hern=C3=A1ndez?= Date: Wed, 29 Nov 2023 16:31:49 +0100 Subject: [PATCH] Add support for setting underlying interface in podman_network (#677) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It may be desirable to set a different interface than the default one (for example, a different bridge). In the case of a macvlan interface, it can be used instead of setting `opt.parent`. Signed-off-by: Pablo Méndez Hernández --- plugins/modules/podman_network.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/modules/podman_network.py b/plugins/modules/podman_network.py index 35c2cb2a..e702fea1 100644 --- a/plugins/modules/podman_network.py +++ b/plugins/modules/podman_network.py @@ -47,6 +47,12 @@ description: - IPv4 or IPv6 gateway for the subnet type: str + interface_name: + description: + - For bridge, it uses the bridge interface name. + For macvlan, it is the parent device on the host (it is the same + as 'opt.parent') + type: str internal: description: - Restrict external access from this network (default "false") @@ -98,7 +104,8 @@ required: false parent: description: - - The host device which should be used for the macvlan interface. + - The host device which should be used for the macvlan interface + (it is the same as 'interface' in that case). Defaults to the default route interface. type: str required: false @@ -277,6 +284,9 @@ def addparam_ipv6(self, c): def addparam_macvlan(self, c): return c + ['--macvlan', self.params['macvlan']] + def addparam_interface_name(self, c): + return c + ['--interface-name', self.params['interface_name']] + def addparam_internal(self, c): return c + ['--internal=%s' % self.params['internal']] @@ -657,6 +667,7 @@ def main(): driver=dict(type='str', required=False), force=dict(type='bool', default=False), gateway=dict(type='str', required=False), + interface_name=dict(type='str', required=False), internal=dict(type='bool', required=False), ip_range=dict(type='str', required=False), ipv6=dict(type='bool', required=False),