Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use the right systemd service for remediations in EL 10+ #209

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tasks/insights-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,13 @@
systemd:
enabled: true
state: started
name: rhcd
name: "{{ __rhc_yggdrasil_systemd_service }}"

- name: Disable remediation
systemd:
enabled: false
state: stopped
name: rhcd
name: "{{ __rhc_yggdrasil_systemd_service }}"
when:
- rhc_insights.remediation | d("present") == "absent"
- '"rhc" in ansible_facts.packages'
13 changes: 9 additions & 4 deletions tests/tests_insights_remediation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- name: Register insights and enable remediation
include_role:
name: linux-system-roles.rhc
public: true
vars:
rhc_auth:
login:
Expand All @@ -41,14 +42,18 @@
insecure: "{{ lsr_rhc_test_data.candlepin_insecure }}"
rhc_baseurl: "{{ lsr_rhc_test_data.baseurl | d(omit) }}"

- name: Set the fact for the systemd service
set_fact:
yggdrasil_systemd_service: "{{ __rhc_yggdrasil_systemd_service + '.service' }}"

- name: Get service_facts
service_facts:

- name: Check remediation is enabled
assert:
that:
- "'rhcd.service' in ansible_facts.services"
- ansible_facts.services['rhcd.service'].status == 'enabled'
- yggdrasil_systemd_service in ansible_facts.services
- ansible_facts.services[yggdrasil_systemd_service].status == 'enabled'

- name: Disable remediation
include_role:
Expand All @@ -63,8 +68,8 @@
- name: Check remediation is disabled
assert:
that:
- "'rhcd.service' in ansible_facts.services"
- ansible_facts.services['rhcd.service'].status == 'disabled'
- yggdrasil_systemd_service in ansible_facts.services
- ansible_facts.services[yggdrasil_systemd_service].status == 'disabled'

- name: Disable remediation (noop)
include_role:
Expand Down
7 changes: 7 additions & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ __rhc_insights_conf: "/etc/insights-client/insights-client.conf"

__rhc_insights_tags: "/etc/insights-client/tags.yaml"

# name of the rhcd/yggdrasil systemd service that maintains the mqtt connection
# to Insights, used for remediations; starting from EL 10 the service is the
# upstream one, and no more the downstream-branded one
__rhc_yggdrasil_systemd_service: "{{ 'yggdrasil'
if (ansible_distribution_major_version | int >= 10)
else 'rhcd' }}"

# BEGIN - DO NOT EDIT THIS BLOCK - rh distros variables
# Ansible distribution identifiers that the role treats like RHEL
__rhc_rh_distros:
Expand Down
Loading