Skip to content

Commit

Permalink
Fixed systemd checks for non existent services
Browse files Browse the repository at this point in the history
Signed-off-by: Roberto Alfieri <ralfieri@redhat.com>
  • Loading branch information
rebtoor committed Oct 16, 2023
1 parent b3c1ada commit 58c7344
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions roles/edpm_bootstrap/tasks/bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
delay: 5
when:
- not ansible_check_mode
- ansible_facts.services["cloud-init.service"] is defined
- ansible_facts.services["cloud-init.service"].state == "running"
- ansible_facts.services["cloud-init.service"].status == "enabled"
- ansible_facts.services["cloud-init.service"]["status"] != "not-found"
- ansible_facts.services["cloud-init.service"]["state"] == "running"
- ansible_facts.services["cloud-init.service"]["status"] == "enabled"
- cloud_init_vendor_disabled is changed
become: true

Expand Down
6 changes: 3 additions & 3 deletions roles/edpm_chrony/tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@

- name: Disable NTP before configuring Chrony
ansible.builtin.service:
name: ansible_facts.services['ntpd.service']['name']
name: ansible_facts.services["ntpd.service"]["name"]
state: stopped
enabled: false
when:
- not ansible_check_mode
- ansible_facts.services['ntpd.service'] is defined
- ansible_facts.services['ntpd.service']['state'] == 'running' or ansible_facts.services['ntpd.service']['status'] == 'enabled'
- ansible_facts.services["ntpd.service"]["status"] != "not-found"
- ansible_facts.services["ntpd.service"]["state"] == 'running' or ansible_facts.services['ntpd.service']['status'] == 'enabled'

- name: Install chronyd package
ansible.builtin.dnf:
Expand Down
4 changes: 2 additions & 2 deletions roles/edpm_multipathd/tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
state: stopped
enabled: false
when:
- ansible_facts.services["multipathd"] is defined
- ansible_facts.services["multipathd"].status == "enabled"
- ansible_facts.services["multipathd"]["status"] != "not-found"
- ansible_facts.services["multipathd"]["status"] == "enabled"
failed_when: false
loop:
- multipathd.service
Expand Down
4 changes: 2 additions & 2 deletions roles/edpm_nftables/tasks/service-bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
- name: Switch firewall engine
become: true
when:
- ansible_facts.services["nftables.service"] is defined
- ansible_facts.services["nftables.service"]["status"] != "not-found"
- ansible_facts.services["nftables.service"].status == "disabled"
block:
- name: Ensure legacy iptables services are off
Expand All @@ -32,7 +32,7 @@
- iptables.service
- ip6tables.service
when:
- ansible_facts.services["{{ item }}"] is defined
- ansible_facts["services"][item]["status"] != "not-found"

- name: Ensure nftables service is enabled and running
ansible.builtin.systemd:
Expand Down

0 comments on commit 58c7344

Please sign in to comment.