diff --git a/plugins/module_utils/podman/common.py b/plugins/module_utils/podman/common.py index acdc649..ec06af2 100644 --- a/plugins/module_utils/podman/common.py +++ b/plugins/module_utils/podman/common.py @@ -357,6 +357,10 @@ def createcommand(argument, info_config, boolean_type=False): cr_com = info_config["createcommand"] argument_values = ARGUMENTS_OPTS_DICT.get(argument, [argument]) all_values = [] + # Remove command args from the list + container_cmd = info_config.get("cmd") + if container_cmd and container_cmd == cr_com[-len(container_cmd):]: + cr_com = cr_com[:-len(container_cmd)] for arg in argument_values: for ind, cr_opt in enumerate(cr_com): if arg == cr_opt: diff --git a/plugins/module_utils/podman/podman_container_lib.py b/plugins/module_utils/podman/podman_container_lib.py index 76458f1..f9d46f3 100644 --- a/plugins/module_utils/podman/podman_container_lib.py +++ b/plugins/module_utils/podman/podman_container_lib.py @@ -459,7 +459,7 @@ class PodmanModuleParams: return c + ['--dns-search', self.params['dns_search']] def addparam_entrypoint(self, c): - return c + ['--entrypoint', self.params['entrypoint']] + return c + ['--entrypoint=%s' % self.params['entrypoint']] def addparam_env(self, c): for env_value in self.params['env'].items(): @@ -1010,6 +1010,8 @@ class PodmanContainerDiff: if self.module_params['command'] is not None: before = self.info['config']['cmd'] after = self.params['command'] + if isinstance(after, list): + after = [str(i) for i in after] if isinstance(after, str): after = shlex.split(after) return self._diff_update_and_compare('command', before, after) diff --git a/tests/integration/targets/podman_container_idempotency/tasks/idem_all.yml b/tests/integration/targets/podman_container_idempotency/tasks/idem_all.yml index 11dbf59..91eec8a 100644 --- a/tests/integration/targets/podman_container_idempotency/tasks/idem_all.yml +++ b/tests/integration/targets/podman_container_idempotency/tasks/idem_all.yml @@ -420,6 +420,69 @@ assert: that: test29 is changed +- name: Run container with complex command + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: idempotency2 + image: alpine + command: + - sh + - -c + - read + - -p + - 8012 + interactive: true + tty: true + device: + - /dev/fuse + register: test30 + +- name: Run container with complex command again + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: idempotency2 + image: alpine + command: + - sh + - -c + - read + - -p + - 8012 + interactive: true + tty: true + device: + - /dev/fuse + register: test31 + +- name: Run container with different complex command + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: idempotency2 + image: alpine + command: + - sh + - -c + - read + - -p + - 8015 + interactive: true + tty: true + device: + - /dev/fuse + register: test32 + +- name: Check info of container with complex command + assert: + that: test30 is changed + +- name: Check info of container with complex command again + assert: + that: test31 is not changed + +- name: Check info of container with complex command + assert: + that: test32 is changed + - name: Remove dependent test container containers.podman.podman_container: executable: "{{ test_executable | default('podman') }}"