Skip to content

Commit 92fe146

Browse files
authored
fix for tls_verify being ignored (#815)
Signed-off-by: kubealex <[email protected]>
1 parent 93c1532 commit 92fe146

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

plugins/module_utils/podman/podman_container_lib.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,10 +1529,14 @@ def ensure_image_exists(module, image, module_params):
15291529
return image_actions
15301530
if not image:
15311531
return image_actions
1532-
rc, out, err = module.run_command([module_exec, 'image', 'exists', image])
1532+
image_exists_cmd = [module_exec, 'image', 'exists', image]
1533+
rc, out, err = module.run_command(image_exists_cmd)
15331534
if rc == 0:
15341535
return image_actions
1535-
rc, out, err = module.run_command([module_exec, 'image', 'pull', image])
1536+
image_pull_cmd = [module_exec, 'image', 'pull', image]
1537+
if module_params['tls_verify'] is False:
1538+
image_pull_cmd.append('--tls-verify=false')
1539+
rc, out, err = module.run_command(image_pull_cmd)
15361540
if rc != 0:
15371541
module.fail_json(msg="Can't pull image %s" % image, stdout=out,
15381542
stderr=err)

tests/integration/targets/podman_container/tasks/main.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,53 @@
108108
fail_msg: Pulling image test failed!
109109
success_msg: Pulling image test passed!
110110

111+
- name: Ensure image doesn't exist - TLS verify OFF
112+
containers.podman.podman_image:
113+
executable: "{{ test_executable | default('podman') }}"
114+
name: alpine:3.20
115+
state: absent
116+
117+
- name: Check pulling image - TLS verify OFF
118+
containers.podman.podman_container:
119+
executable: "{{ test_executable | default('podman') }}"
120+
name: container_tls
121+
image: alpine:3.20
122+
state: started
123+
command: sleep 1d
124+
tls_verify: false
125+
register: image_tls
126+
127+
- name: Check output is correct - TLS verify OFF
128+
assert:
129+
that:
130+
- image_tls.podman_actions | select('search', '--tls-verify=False') | list | length > 0
131+
132+
- name: Check using already pulled image - TLS verify OFF
133+
containers.podman.podman_container:
134+
executable: "{{ test_executable | default('podman') }}"
135+
name: container2_tls
136+
image: alpine:3.20
137+
state: started
138+
command: sleep 1d
139+
tls_verify: false
140+
register: image2_tls
141+
142+
- name: Check output is correct - TLS verify OFF
143+
assert:
144+
that:
145+
- image_tls is changed
146+
- image_tls.container is defined
147+
- image_tls.container['State']['Running']
148+
- "'pulled image alpine:3.20' in image_tls.actions"
149+
- "'started container_tls' in image_tls.actions"
150+
- image2_tls is changed
151+
- image2_tls.container is defined
152+
- image2_tls.container['State']['Running']
153+
- "'pulled image alpine:3.20' not in image2_tls.actions"
154+
- "'started container2_tls' in image2_tls.actions"
155+
fail_msg: Pulling image test failed!
156+
success_msg: Pulling image test passed!
157+
111158
- name: Check failed image pull
112159
containers.podman.podman_container:
113160
executable: "{{ test_executable | default('podman') }}"
@@ -1368,6 +1415,7 @@
13681415
- "container2"
13691416
- "container3"
13701417
- "testidem-pod"
1418+
- "container_tls"
13711419

13721420
- name: Remove pod
13731421
shell: podman pod rm -f testidempod

0 commit comments

Comments
 (0)