Skip to content

Commit

Permalink
fix for tls_verify being ignored (#815)
Browse files Browse the repository at this point in the history
Signed-off-by: kubealex <[email protected]>
  • Loading branch information
kubealex authored Aug 15, 2024
1 parent 93c1532 commit 92fe146
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 2 deletions.
8 changes: 6 additions & 2 deletions plugins/module_utils/podman/podman_container_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1529,10 +1529,14 @@ def ensure_image_exists(module, image, module_params):
return image_actions
if not image:
return image_actions
rc, out, err = module.run_command([module_exec, 'image', 'exists', image])
image_exists_cmd = [module_exec, 'image', 'exists', image]
rc, out, err = module.run_command(image_exists_cmd)
if rc == 0:
return image_actions
rc, out, err = module.run_command([module_exec, 'image', 'pull', image])
image_pull_cmd = [module_exec, 'image', 'pull', image]
if module_params['tls_verify'] is False:
image_pull_cmd.append('--tls-verify=false')
rc, out, err = module.run_command(image_pull_cmd)
if rc != 0:
module.fail_json(msg="Can't pull image %s" % image, stdout=out,
stderr=err)
Expand Down
48 changes: 48 additions & 0 deletions tests/integration/targets/podman_container/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,53 @@
fail_msg: Pulling image test failed!
success_msg: Pulling image test passed!

- name: Ensure image doesn't exist - TLS verify OFF
containers.podman.podman_image:
executable: "{{ test_executable | default('podman') }}"
name: alpine:3.20
state: absent

- name: Check pulling image - TLS verify OFF
containers.podman.podman_container:
executable: "{{ test_executable | default('podman') }}"
name: container_tls
image: alpine:3.20
state: started
command: sleep 1d
tls_verify: false
register: image_tls

- name: Check output is correct - TLS verify OFF
assert:
that:
- image_tls.podman_actions | select('search', '--tls-verify=False') | list | length > 0

- name: Check using already pulled image - TLS verify OFF
containers.podman.podman_container:
executable: "{{ test_executable | default('podman') }}"
name: container2_tls
image: alpine:3.20
state: started
command: sleep 1d
tls_verify: false
register: image2_tls

- name: Check output is correct - TLS verify OFF
assert:
that:
- image_tls is changed
- image_tls.container is defined
- image_tls.container['State']['Running']
- "'pulled image alpine:3.20' in image_tls.actions"
- "'started container_tls' in image_tls.actions"
- image2_tls is changed
- image2_tls.container is defined
- image2_tls.container['State']['Running']
- "'pulled image alpine:3.20' not in image2_tls.actions"
- "'started container2_tls' in image2_tls.actions"
fail_msg: Pulling image test failed!
success_msg: Pulling image test passed!

- name: Check failed image pull
containers.podman.podman_container:
executable: "{{ test_executable | default('podman') }}"
Expand Down Expand Up @@ -1368,6 +1415,7 @@
- "container2"
- "container3"
- "testidem-pod"
- "container_tls"

- name: Remove pod
shell: podman pod rm -f testidempod
Expand Down

0 comments on commit 92fe146

Please sign in to comment.