Workaround for CentOS7 reporting ansible_facts['service_mgr'] == 'sysvinit' in containers

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
Jakub Jelen 2024-02-06 09:43:37 +01:00 committed by Jakub Jelen
parent e119c3fd28
commit 237e8b4255
2 changed files with 8 additions and 4 deletions

View file

@ -1,6 +1,9 @@
--- ---
- name: Install systemd service files - name: Install systemd service files
when: sshd_install_service | bool and ansible_facts['service_mgr'] == 'systemd' when:
- sshd_install_service | bool
- ansible_facts['service_mgr'] == 'systemd' or
(ansible_facts['os_family'] == 'RedHat' and ansible_facts['distribution_major_version'] == '7')
block: block:
- name: Install service unit file - name: Install service unit file
ansible.builtin.template: ansible.builtin.template:

View file

@ -34,7 +34,8 @@
- name: Read the service files and verify they are reasonable - name: Read the service files and verify they are reasonable
tags: tests::verify tags: tests::verify
when: when:
- ansible_facts['service_mgr'] == 'systemd' - ansible_facts['service_mgr'] == 'systemd' or
(ansible_facts['os_family'] == 'RedHat' and ansible_facts['distribution_major_version'] == '7')
block: block:
- name: Read the distribution service file - name: Read the distribution service file
ansible.builtin.slurp: ansible.builtin.slurp:
@ -114,7 +115,8 @@
- name: Read the instantiated service file and verify they are reasonable - name: Read the instantiated service file and verify they are reasonable
tags: tests::verify tags: tests::verify
when: when:
- ansible_facts['service_mgr'] == 'systemd' - ansible_facts['service_mgr'] == 'systemd' or
(ansible_facts['os_family'] == 'RedHat' and ansible_facts['distribution_major_version'] == '7')
- ansible_facts['distribution'] != "Debian" or ansible_facts['distribution_major_version'] | int < 12 - ansible_facts['distribution'] != "Debian" or ansible_facts['distribution_major_version'] | int < 12
block: block:
- name: Read the distribution instantiated service file - name: Read the distribution instantiated service file
@ -154,6 +156,5 @@
that: that:
- "' -f /etc/ssh/' in service_inst.content | b64decode" - "' -f /etc/ssh/' in service_inst.content | b64decode"
- name: "Restore configuration files" - name: "Restore configuration files"
ansible.builtin.include_tasks: tasks/restore.yml ansible.builtin.include_tasks: tasks/restore.yml