1
0
Fork 0
mirror of https://github.com/containers/ansible-podman-collections.git synced 2026-04-25 10:32:41 +00:00

Add new options for pod module (#361)

This commit is contained in:
Sergey 2022-01-13 15:10:05 +02:00 committed by GitHub
parent d185616a72
commit 4f3a84f4e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 152 additions and 3 deletions

View file

@ -26,10 +26,15 @@ ARGUMENTS_SPEC_POD = dict(
recreate=dict(type='bool', default=False),
add_host=dict(type='list', required=False, elements='str'),
cgroup_parent=dict(type='str', required=False),
cpus=dict(type='str', required=False),
cpuset_cpus=dict(type='str', required=False),
device=dict(type='list', elements='str', required=False),
device_read_bps=dict(type='list', elements='str', required=False),
dns=dict(type='list', elements='str', required=False),
dns_opt=dict(type='list', elements='str', required=False),
dns_search=dict(type='list', elements='str', required=False),
generate_systemd=dict(type='dict', default={}),
gidmap=dict(type='list', elements='str', required=False),
hostname=dict(type='str', required=False),
infra=dict(type='bool', required=False),
infra_conmon_pidfile=dict(type='str', required=False),
@ -42,11 +47,20 @@ ARGUMENTS_SPEC_POD = dict(
mac_address=dict(type='str', required=False),
name=dict(type='str', required=True),
network=dict(type='str', required=False),
network_alias=dict(type='list', elements='str', required=False,
aliases=['network_aliases']),
no_hosts=dict(type='bool', required=False),
pid=dict(type='str', required=False),
pod_id_file=dict(type='str', required=False),
publish=dict(type='list', required=False,
elements='str', aliases=['ports']),
share=dict(type='str', required=False),
subgidname=dict(type='str', required=False),
subuidname=dict(type='str', required=False),
uidmap=dict(type='list', elements='str', required=False),
userns=dict(type='str', required=False),
volume=dict(type='list', elements='str', aliases=['volumes'],
required=False),
executable=dict(type='str', required=False, default='podman'),
debug=dict(type='bool', default=False),
)
@ -123,6 +137,22 @@ class PodmanPodModuleParams:
def addparam_cgroup_parent(self, c):
return c + ['--cgroup-parent', self.params['cgroup_parent']]
def addparam_cpus(self, c):
return c + ['--cpus', self.params['cpus']]
def addparam_cpuset_cpus(self, c):
return c + ['--cpuset-cpus', self.params['cpuset_cpus']]
def addparam_device(self, c):
for dev in self.params['device']:
c += ['--device', dev]
return c
def addparam_device_read_bps(self, c):
for dev in self.params['device_read_bps']:
c += ['--device-read-bps', dev]
return c
def addparam_dns(self, c):
for g in self.params['dns']:
c += ['--dns', g]
@ -138,6 +168,11 @@ class PodmanPodModuleParams:
c += ['--dns-search', g]
return c
def addparam_gidmap(self, c):
for gidmap in self.params['gidmap']:
c += ['--gidmap', gidmap]
return c
def addparam_hostname(self, c):
return c + ['--hostname', self.params['hostname']]
@ -179,9 +214,17 @@ class PodmanPodModuleParams:
def addparam_network(self, c):
return c + ['--network', self.params['network']]
def addparam_network_aliases(self, c):
for alias in self.params['network_aliases']:
c += ['--network-alias', alias]
return c
def addparam_no_hosts(self, c):
return c + ["=".join('--no-hosts', self.params['no_hosts'])]
def addparam_pid(self, c):
return c + ['--pid', self.params['pid']]
def addparam_pod_id_file(self, c):
return c + ['--pod-id-file', self.params['pod_id_file']]
@ -193,6 +236,26 @@ class PodmanPodModuleParams:
def addparam_share(self, c):
return c + ['--share', self.params['share']]
def addparam_subgidname(self, c):
return c + ['--subgidname', self.params['subgidname']]
def addparam_subuidname(self, c):
return c + ['--subuidname', self.params['subuidname']]
def addparam_uidmap(self, c):
for uidmap in self.params['uidmap']:
c += ['--uidmap', uidmap]
return c
def addparam_userns(self, c):
return c + ['--userns', self.params['userns']]
def addparam_volume(self, c):
for vol in self.params['volume']:
if vol:
c += ['--volume', vol]
return c
class PodmanPodDefaults:
def __init__(self, module, podman_version):

View file

@ -49,6 +49,31 @@ options:
init process. Cgroups will be created if they do not already exist.
type: str
required: false
cpus:
description:
- Set the total number of CPUs delegated to the pod.
Default is 0.000 which indicates that there is no limit on computation power.
required: false
type: str
cpuset_cpus:
description:
- Limit the CPUs to support execution. First CPU is numbered 0.
Unlike `cpus` this is of type string and parsed as a list of numbers. Format is 0-3,0,1
required: false
type: str
device:
description:
- Add a host device to the pod. Optional permissions parameter can be used to specify
device permissions. It is a combination of r for read, w for write, and m for mknod(2)
elements: str
required: false
type: list
device_read_bps:
description:
- Limit read rate (bytes per second) from a device (e.g. device-read-bps=/dev/sda:1mb)
elements: str
required: false
type: list
dns:
description:
- Set custom DNS servers in the /etc/resolv.conf file that will be shared between
@ -138,6 +163,13 @@ options:
Refer to podman-generate-systemd(1) for more information.
type: bool
default: false
gidmap:
description:
- GID map for the user namespace. Using this flag will run the container with
user namespace enabled. It conflicts with the `userns` and `subgidname` flags.
elements: str
required: false
type: list
hostname:
description:
- Set a hostname to the pod
@ -205,11 +237,28 @@ options:
join.
type: str
required: false
network_alias:
description:
- Add a network-scoped alias for the pod, setting the alias for all networks that the pod joins.
To set a name only for a specific network, use the alias option as described under the -`network` option.
Network aliases work only with the bridge networking mode.
This option can be specified multiple times.
elements: str
required: false
type: list
aliases:
- network_aliases
no_hosts:
description:
- Disable creation of /etc/hosts for the pod.
type: bool
required: false
pid:
description:
- Set the PID mode for the pod. The default is to create a private PID namespace
for the pod. Requires the PID namespace to be shared via `share` option.
required: false
type: str
pod_id_file:
description:
- Write the pod ID to the file.
@ -230,15 +279,52 @@ options:
user, uts.
type: str
required: false
subgidname:
description:
- Name for GID map from the /etc/subgid file. Using this flag will run the container
with user namespace enabled. This flag conflicts with `userns` and `gidmap`.
required: false
type: str
subuidname:
description:
- Name for UID map from the /etc/subuid file.
Using this flag will run the container with user namespace enabled.
This flag conflicts with `userns` and `uidmap`.
required: false
type: str
uidmap:
description:
- Run the container in a new user namespace using the supplied mapping.
This option conflicts with the `userns` and `subuidname` options.
This option provides a way to map host UIDs to container UIDs.
It can be passed several times to map different ranges.
elements: str
required: false
type: list
userns:
description:
- Set the user namespace mode for all the containers in a pod.
It defaults to the PODMAN_USERNS environment variable.
An empty value ("") means user namespaces are disabled.
required: false
type: str
volume:
description:
- Create a bind mount.
aliases:
- volumes
elements: str
required: false
type: list
executable:
description:
- Path to C(podman) executable if it is not in the C($PATH) on the
machine running C(podman)
- Path to C(podman) executable if it is not in the C($PATH) on the
machine running C(podman)
default: 'podman'
type: str
debug:
description:
- Return additional information which can be helpful for investigations.
- Return additional information which can be helpful for investigations.
type: bool
default: False