Skip to content

Commit

Permalink
tests: run podman directly instead of using containers.podman
Browse files Browse the repository at this point in the history
Using the containers.podman collection to handle podman is a nice idea,
however what that collection supports now is becoming more strict than
what this role supports. Case in point: containers.podman now requires
Python 3.6+ for the managed nodes, which breaks the testing of EL 7.

This means that sadly the setup of a self-deployed Candlepin needs to
run podman commands manually. Since there are parameters of "podman run"
that depend on the OS, store them in an helper fact, filtering it to
avoid empty items.

The gymnastics of checking the return code & stderr of "podman stop"
are needed because the "--ignore" option (which would be ideal) was
introduced in podman 1.7.0, and EL 7 has podman 1.6.4.

There is no behaviour change.

Signed-off-by: Pino Toscano <[email protected]>
  • Loading branch information
ptoscano committed Aug 6, 2024
1 parent 449e1bf commit 81d6117
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 16 deletions.
1 change: 0 additions & 1 deletion tests/collection-requirements.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
collections:
- name: containers.podman
- name: fedora.linux_system_roles
55 changes: 40 additions & 15 deletions tests/tasks/setup_candlepin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,32 @@
set_fact:
_cp_url_owner: "{{ _cp_url }}/owners/{{ lsr_rhc_test_data.reg_organization }}" # yamllint disable-line

- name: Set helper fact with start of podman run invocation
set_fact:
podman_run_cli:
- podman
- run
- --rm
- --detach
- --hostname
- "{{ lsr_rhc_test_data.candlepin_host }}"
- --name
- candlepin
- --publish
- 8443:8443
- --publish
- 8080:8080
- "{{ '--privileged'
if (ansible_distribution in ['CentOS', 'RedHat']
and ansible_distribution_major_version | int < 8)
else '' }}"
- ghcr.io/ptoscano/candlepin-unofficial

- name: Filter empty items from podman run invocation
set_fact:
podman_run_cli:
"{{ podman_run_cli | select() }}"

- name: Add candlepin hostname to /etc/hosts
lineinfile:
path: /etc/hosts
Expand All @@ -37,23 +63,22 @@
ternary('ansible.posix.rhel_rpm_ostree', omit) }}"

- name: Stop and remove Candlepin container
containers.podman.podman_container:
name: candlepin
state: absent
command:
argv:
- podman
- stop
- candlepin
register: podman_stop_status
failed_when:
- podman_stop_status.rc != 0
- '"no such container" not in podman_stop_status.stderr'
changed_when: false

- name: Start Candlepin container
containers.podman.podman_container:
detach: true
hostname: "{{ lsr_rhc_test_data.candlepin_host }}"
image: ghcr.io/ptoscano/candlepin-unofficial
name: candlepin
privileged: "{{ ansible_distribution in ['CentOS', 'RedHat']
and ansible_distribution_major_version | int < 8 }}"
publish:
- 8443:8443
- 8080:8080
rm: true
state: started
command:
argv:
"{{ podman_run_cli }}"
changed_when: false

- name: Ensure directories exist
file:
Expand Down

0 comments on commit 81d6117

Please sign in to comment.