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 6021f1d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
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 }}.service`'

Check failure on line 3 in roles/__service_debug/tasks/main.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

fqcn[action-core]

Use FQCN for builtin module actions (command).

Check failure on line 3 in roles/__service_debug/tasks/main.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

name[template]

Jinja templates should only be at the end of 'name'
command: 'systemctl status {{ __service_name }}.service'
changed_when: no

Check failure on line 5 in roles/__service_debug/tasks/main.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

yaml[truthy]

Truthy value should be one of \[false, true]
failed_when: no

Check failure on line 6 in roles/__service_debug/tasks/main.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

yaml[truthy]

Truthy value should be one of \[false, true]
register: __service_status

- name: 'Show `systemctl status` output for {{ __service_name }}.service'

Check failure on line 9 in roles/__service_debug/tasks/main.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

fqcn[action-core]

Use FQCN for builtin module actions (debug).

Check failure on line 9 in roles/__service_debug/tasks/main.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

name[template]

Jinja templates should only be at the end of 'name'
debug:
var: __service_status.stdout_lines
changed_when: no

Check failure on line 12 in roles/__service_debug/tasks/main.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

yaml[truthy]

Truthy value should be one of \[false, true]
failed_when: no

Check failure on line 13 in roles/__service_debug/tasks/main.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

yaml[truthy]

Truthy value should be one of \[false, true]

- name: 'Run `journalctl -x -u {{ __service_name }}.service`'

Check failure on line 15 in roles/__service_debug/tasks/main.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

fqcn[action-core]

Use FQCN for builtin module actions (command).
command: 'journalctl -x -u {{ __service_name }}.service'
changed_when: no
failed_when: no
register: __service_journal

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

...
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
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 6021f1d

Please sign in to comment.