diff --git a/tests/collection-requirements.yml b/tests/collection-requirements.yml index 8264ef1..a9c13c4 100644 --- a/tests/collection-requirements.yml +++ b/tests/collection-requirements.yml @@ -1,4 +1,3 @@ --- collections: - - name: containers.podman - name: fedora.linux_system_roles diff --git a/tests/tasks/setup_candlepin.yml b/tests/tasks/setup_candlepin.yml index 17e0915..132cd45 100644 --- a/tests/tasks/setup_candlepin.yml +++ b/tests/tasks/setup_candlepin.yml @@ -22,6 +22,31 @@ 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 | reject('match', '^$') | list }}" + - name: Add candlepin hostname to /etc/hosts lineinfile: path: /etc/hosts @@ -37,23 +62,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: