Skip to content

Commit

Permalink
Workaround for CentOS7 reporting ansible_facts['service_mgr'] == 'sys…
Browse files Browse the repository at this point in the history
…vinit' in containers

Signed-off-by: Jakub Jelen <[email protected]>
  • Loading branch information
Jakuje committed Feb 15, 2024
1 parent e119c3f commit 237e8b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 4 additions & 1 deletion tasks/install_service.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
---
- 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:
- name: Install service unit file
ansible.builtin.template:
Expand Down
7 changes: 4 additions & 3 deletions tests/tests_systemd_services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
- name: Read the service files and verify they are reasonable
tags: tests::verify
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:
- name: Read the distribution service file
ansible.builtin.slurp:
Expand Down Expand Up @@ -114,7 +115,8 @@
- name: Read the instantiated service file and verify they are reasonable
tags: tests::verify
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
block:
- name: Read the distribution instantiated service file
Expand Down Expand Up @@ -154,6 +156,5 @@
that:
- "' -f /etc/ssh/' in service_inst.content | b64decode"


- name: "Restore configuration files"
ansible.builtin.include_tasks: tasks/restore.yml

0 comments on commit 237e8b4

Please sign in to comment.