Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Env in container exec are wrongly double quoted #715

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading