kayobe/ansible/action_plugins/kayobe_container_image.py
Will Szumski 988a822259 Add podman support
Adds support for Podman as an alternative container engine. This builds
on the support added in kolla-ansible in the 2023.2 cycle.

Change-Id: I2c6befbdda7e684228065103feea7250a0ea3826
2025-01-27 16:42:33 +00:00

29 lines
1.1 KiB
Python

from ansible.errors import AnsibleError
from ansible.plugins.action import ActionBase
_engine_to_module = {
'docker': 'community.docker.docker_image',
'podman': 'containers.podman.podman_image'
}
class ActionModule(ActionBase):
def run(self, tmp=None, task_vars=None):
super(ActionModule, self).run(tmp, task_vars)
module_args = self._task.args.copy()
engine = task_vars.get("container_engine", "docker")
if engine == "podman":
# Translate from docker args
source = module_args["source"]
if source == "build":
module_args["state"] = "build"
elif source == "pull":
module_args["pull"] = True
else:
raise AnsibleError(f'Unsupported source parameter: {source}')
del module_args["source"]
module = _engine_to_module.get(engine)
module_return = self._execute_module(module_name=module,
module_args=module_args,
task_vars=task_vars, tmp=tmp)
return module_return