Skip to content

Commit

Permalink
Env in container exec are wrongly double quoted
Browse files Browse the repository at this point in the history
Signed-off-by: Michée Lengronne <[email protected]>
  • Loading branch information
micheelengronne committed Feb 17, 2024
1 parent efbfba7 commit ad08980
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions plugins/modules/podman_container_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
description:
- Set environment variables.
type: dict
env_quoted:
description: Double-quote the environment variables.
type: bool
default: true
privileged:
description:
- Give extended privileges to the container.
Expand Down Expand Up @@ -137,6 +141,7 @@ def run_container_exec(module: AnsibleModule) -> dict:
command = module.params['command']
detach = module.params['detach']
env = module.params['env']
env_quoted = module.params['env_quoted']
privileged = module.params['privileged']
tty = module.params['tty']
user = module.params['user']
Expand All @@ -155,8 +160,13 @@ def run_container_exec(module: AnsibleModule) -> dict:
msg="Specify string value %s on the env field" % (value))

to_text(value, errors='surrogate_or_strict')
exec_options += ['--env',
'%s="%s"' % (key, value)]

if env_quoted is not None and env_quoted == false:
exec_options += ['--env',
'%s=%s' % (key, value)]
else:
exec_options += ['--env',
'%s="%s"' % (key, value)]

if privileged:
exec_options.append('--privileged')
Expand Down

0 comments on commit ad08980

Please sign in to comment.