mirror of
https://github.com/containers/ansible-podman-collections.git
synced 2026-02-04 07:11:49 +00:00
Fix idempotency with complex commands
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
This commit is contained in:
parent
6399080356
commit
0d10745853
3 changed files with 70 additions and 1 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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') }}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue