1
0
Fork 0
mirror of https://github.com/containers/ansible-podman-collections.git synced 2026-02-04 07:11:49 +00:00

Alias generate systemd options stop_timeout and time (#685)

* Alias generate systemd options `stop_timeout` and `time`

Closes #683

Option `time` was used before Podman v4, then it was renamed
`stop_timeout`.
Accept both names (the newer takes prirority) and set the correct
CLI argument name based on the detected Podman version.

Signed-off-by: Alessandro Fulgini <fuljo97@gmail.com>

* Fix typo in parameter name `--stop-timeout`

Signed-off-by: Alessandro Fulgini <fuljo97@gmail.com>

* Don't delete temporary variables at the end of block

Co-authored-by: Sergey <6213510+sshnaidm@users.noreply.github.com>

---------

Signed-off-by: Alessandro Fulgini <fuljo97@gmail.com>
Co-authored-by: Sergey <6213510+sshnaidm@users.noreply.github.com>
This commit is contained in:
Alessandro Fulgini 2023-12-07 10:24:28 +01:00 committed by GitHub
parent e245e332f0
commit 4d233a4146
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 15 deletions

View file

@ -52,12 +52,13 @@ def run_generate_systemd_command(module, module_params, name, version):
sysconf['restart_policy']])
if sysconf.get('restart_sec') is not None:
command.extend(['--restart-sec=%s' % sysconf['restart_sec']])
if sysconf.get('stop_timeout') is not None:
command.extend(['--stop-timeout=%s' % sysconf['stop_timeout']])
if (sysconf.get('stop_timeout') is not None) or (sysconf.get('time') is not None):
# Select correct parameter name based on version
arg_name = 'stop-timeout' if gt4ver else 'time'
arg_value = sysconf.get('stop_timeout') if sysconf.get('stop_timeout') is not None else sysconf.get('time')
command.extend(['--%s=%s' % (arg_name, arg_value)])
if sysconf.get('start_timeout') is not None:
command.extend(['--start-timeout=%s' % sysconf['start_timeout']])
if sysconf.get('time'):
command.extend(['--time', str(sysconf['time'])])
if sysconf.get('no_header'):
command.extend(['--no-header'])
if sysconf.get('names', True):