Skip to content

Commit

Permalink
DONOTMERGE
Browse files Browse the repository at this point in the history
  • Loading branch information
rpelisse committed Oct 9, 2023
1 parent 4f52147 commit 8e81840
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions roles/amq_streams_common/tasks/validation/service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@
- name: Populate service facts
ansible.builtin.service_facts:

- name: Check if service is started
ansible.builtin.assert:
that:
- ansible_facts is defined
- ansible_facts.services is defined
- ansible_facts.services["{{ service_name }}.service"] is defined
- ansible_facts.services["{{ service_name }}.service"]['state'] is defined
- ansible_facts.services["{{ service_name }}.service"]['state'] == 'running'
- ansible_facts.services["{{ service_name }}.service"]['status'] == 'enabled'
quiet: true
fail_msg: "Service is not started."
- name: "Check service status"
block:
- name: Check if service is started
ansible.builtin.assert:
that:
- ansible_facts is defined
- ansible_facts.services is defined
- ansible_facts.services["{{ service_name }}.service"] is defined
- ansible_facts.services["{{ service_name }}.service"]['state'] is defined
- ansible_facts.services["{{ service_name }}.service"]['state'] == 'running'
- ansible_facts.services["{{ service_name }}.service"]['status'] == 'enabled'
quiet: true
fail_msg: "Service is not started."
rescue:
- name: "Display service status"
ansible.builtin.command: systemctl status "{{ service_name }}"

0 comments on commit 8e81840

Please sign in to comment.