From bcdaa9f8257213b8da895fb94adbd183fe184a04 Mon Sep 17 00:00:00 2001 From: Sergey Date: Mon, 24 May 2021 11:39:08 +0300 Subject: [PATCH] Add support for timezones in containers (#262) * Remove choices for cgroups * Add timezone parameter to container module --- plugins/module_utils/podman/podman_container_lib.py | 11 ++++++++++- plugins/modules/podman_container.py | 11 ++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/plugins/module_utils/podman/podman_container_lib.py b/plugins/module_utils/podman/podman_container_lib.py index 73347ba..a0f6af2 100644 --- a/plugins/module_utils/podman/podman_container_lib.py +++ b/plugins/module_utils/podman/podman_container_lib.py @@ -22,7 +22,7 @@ ARGUMENTS_SPEC_CONTAINER = dict( cap_drop=dict(type='list', elements='str'), cgroup_parent=dict(type='path'), cgroupns=dict(type='str'), - cgroups=dict(type='str', choices=['default', 'disabled']), + cgroups=dict(type='str'), cidfile=dict(type='path'), cmd_args=dict(type='list', elements='str'), conmon_pidfile=dict(type='path'), @@ -115,6 +115,7 @@ ARGUMENTS_SPEC_CONTAINER = dict( subuidname=dict(type='str'), sysctl=dict(type='dict'), systemd=dict(type='str'), + timezone=dict(type='str'), tmpfs=dict(type='dict'), tty=dict(type='bool'), uidmap=dict(type='list', elements='str'), @@ -555,6 +556,9 @@ class PodmanModuleParams: c += ['--tmpfs', ':'.join(tmpfs)] return c + def addparam_timezone(self, c): + return c + ['--tz=%s' % self.params['timezone']] + def addparam_tty(self, c): return c + ['--tty=%s' % self.params['tty']] @@ -1171,6 +1175,11 @@ class PodmanContainerDiff: after = signals[after.lower()] return self._diff_update_and_compare('stop_signal', before, after) + def diffparam_timezone(self): + before = self.info['config'].get('timezone') + after = self.params['timezone'] + return self._diff_update_and_compare('timezone', before, after) + def diffparam_tty(self): before = self.info['config']['tty'] after = self.params['tty'] diff --git a/plugins/modules/podman_container.py b/plugins/modules/podman_container.py index 6aa1cf8..1e8dbe8 100644 --- a/plugins/modules/podman_container.py +++ b/plugins/modules/podman_container.py @@ -125,9 +125,6 @@ options: The disabled option will force the container to not create CGroups, and thus conflicts with CGroup options cgroupns and cgroup-parent. type: str - choices: - - default - - disabled cidfile: description: - Write the container ID to the file @@ -643,6 +640,14 @@ options: description: - Run container in systemd mode. The default is true. type: str + timezone: + description: + - Set timezone in container. This flag takes area-based timezones, + GMT time, as well as local, which sets the timezone in the container to + match the host machine. + See /usr/share/zoneinfo/ for valid timezones. + Remote connections use local containers.conf for defaults. + type: str tmpfs: description: - Create a tmpfs mount. For example tmpfs