Skip to content

Commit

Permalink
enhancement: add service debug role to catch and display service errors
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Krause <[email protected]>
  • Loading branch information
wookietreiber committed Dec 18, 2023
1 parent 214f7ed commit 1204992
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
6 changes: 6 additions & 0 deletions roles/blackbox_exporter/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,9 @@
enabled: true
tags:
- blackbox_exporter_run

- name: Display service errors
ansible.builtin.include_role:
name: service_debug
vars:
__service_name: blackbox_exporter
27 changes: 27 additions & 0 deletions roles/service_debug/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---

- name: 'Run `systemctl status {{ __service_name }}`'
ansible.builtin.command: 'systemctl status {{ __service_name }}.service'
changed_when: false
failed_when: false
register: __service_status

- name: 'Show `systemctl status` output for {{ __service_name }}'
ansible.builtin.debug:
var: __service_status.stdout_lines
changed_when: false
failed_when: false

- name: 'Run `journalctl -x -u {{ __service_name }}`'
ansible.builtin.command: 'journalctl -x -u {{ __service_name }}.service'
changed_when: false
failed_when: false
register: __service_journal

- name: 'Show `journalctl -x` output for {{ __service_name }}'
ansible.builtin.debug:
var: __service_journal.stdout_lines
changed_when: false
failed_when: false

...
6 changes: 6 additions & 0 deletions roles/smokeping_prober/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,9 @@
- not ansible_check_mode
tags:
- smokeping_prober_run

- name: Display service errors
ansible.builtin.include_role:
name: service_debug
vars:
__service_name: smokeping_prober

0 comments on commit 1204992

Please sign in to comment.