Use module command to run podman
with support of additional parameters for run_command of ansible. Add expand_user_and_var=False to not expand users and vars Change-Id: I07a8e5ed7d58c6e3e90c27f6cbf706489c6d558e
This commit is contained in:
parent
de0d5bca20
commit
db6723e62d
@ -24,7 +24,6 @@ import json
|
|||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule, env_fallback
|
from ansible.module_utils.basic import AnsibleModule, env_fallback
|
||||||
from ansible.module_utils.podman.common import run_podman_command
|
|
||||||
from ansible.module_utils._text import to_bytes, to_native
|
from ansible.module_utils._text import to_bytes, to_native
|
||||||
|
|
||||||
ANSIBLE_METADATA = {
|
ANSIBLE_METADATA = {
|
||||||
@ -1176,14 +1175,10 @@ def ensure_image_exists(module, image):
|
|||||||
module_exec = module.params['executable']
|
module_exec = module.params['executable']
|
||||||
if not image:
|
if not image:
|
||||||
return image_actions
|
return image_actions
|
||||||
rc, out, err = run_podman_command(module, executable=module_exec,
|
rc, out, err = module.run_command([module_exec, 'image', 'exists', image])
|
||||||
args=['image', 'exists', image],
|
|
||||||
ignore_errors=True)
|
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
return image_actions
|
return image_actions
|
||||||
rc, out, err = run_podman_command(module, executable=module_exec,
|
rc, out, err = module.run_command([module_exec, 'image', 'pull', image])
|
||||||
args=['image', 'pull', image],
|
|
||||||
ignore_errors=True)
|
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
module.fail_json(msg="Can't pull image %s" % image, stdout=out,
|
module.fail_json(msg="Can't pull image %s" % image, stdout=out,
|
||||||
stderr=err)
|
stderr=err)
|
||||||
@ -1235,10 +1230,8 @@ class PodmanContainer:
|
|||||||
|
|
||||||
def get_info(self):
|
def get_info(self):
|
||||||
"""Inspect container and gather info about it."""
|
"""Inspect container and gather info about it."""
|
||||||
rc, out, err = run_podman_command(
|
rc, out, err = self.module.run_command(
|
||||||
module=self.module,
|
[self.module.params['executable'], b'container', b'inspect', self.name])
|
||||||
executable=self.module.params['executable'],
|
|
||||||
args=['container', 'inspect', self.name], ignore_errors=True)
|
|
||||||
return json.loads(out)[0] if rc == 0 else {}
|
return json.loads(out)[0] if rc == 0 else {}
|
||||||
|
|
||||||
def _perform_action(self, action):
|
def _perform_action(self, action):
|
||||||
@ -1252,10 +1245,9 @@ class PodmanContainer:
|
|||||||
).construct_command_from_params()
|
).construct_command_from_params()
|
||||||
self.module.log("PODMAN-CONTAINER-DEBUG: " +
|
self.module.log("PODMAN-CONTAINER-DEBUG: " +
|
||||||
"%s" % " ".join([to_native(i) for i in b_command]))
|
"%s" % " ".join([to_native(i) for i in b_command]))
|
||||||
rc, out, err = run_podman_command(
|
rc, out, err = self.module.run_command(
|
||||||
module=self.module,
|
[self.module.params['executable'], b'container'] + b_command,
|
||||||
args=[b'container'] + b_command,
|
expand_user_and_vars=False)
|
||||||
ignore_errors=True)
|
|
||||||
self.stdout = out
|
self.stdout = out
|
||||||
self.stderr = err
|
self.stderr = err
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user