Skip to content

Commit 9ea20cc

Browse files
committed
Fixes #353 - Add health check command
Add a new foremanctl health command that verifies the state of all Foreman services after installation or during troubleshooting. Checks performed: - Core services running (foreman, httpd, redis, postgresql) - Dynflow workers running (orchestrator, worker, worker-hosts-queue) - Pulp services running (pulp-api, pulp-content) - Candlepin service running - Foreman API responding (GET /api/v2/ping) - Foreman tasks status (via Katello ping response) Reports a summary of all failures and exits non-zero if any check fails, making it suitable for scripting and CI use.
1 parent 5efa47a commit 9ea20cc

File tree

4 files changed

+90
-0
lines changed

4 files changed

+90
-0
lines changed

src/playbooks/health/health.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
- name: Run Foreman health checks
3+
hosts: quadlet
4+
become: true
5+
gather_facts: true
6+
vars_files:
7+
- "../../vars/defaults.yml"
8+
- "../../vars/base.yaml"
9+
tasks:
10+
- name: Execute health checks
11+
ansible.builtin.include_tasks: ../../roles/checks/tasks/execute_check.yml
12+
loop:
13+
- check_services
14+
- check_foreman_api
15+
16+
- name: Report status of health checks
17+
ansible.builtin.fail:
18+
msg: "{{ checks_results }}"
19+
when:
20+
- checks_results|default([])|length > 0
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
help: |
3+
Run health checks on Foreman services
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
- name: Check Foreman API responds
3+
ansible.builtin.uri:
4+
url: "{{ foreman_url }}/api/v2/ping"
5+
validate_certs: false
6+
status_code: 200
7+
timeout: 10
8+
register: foreman_ping
9+
10+
- name: Check Foreman tasks status
11+
ansible.builtin.assert:
12+
that:
13+
- foreman_ping.json.results.katello.services.foreman_tasks.status == 'ok'
14+
fail_msg: "Foreman tasks status: {{ foreman_ping.json.results.katello.services.foreman_tasks.status | default('unknown') }}"
15+
success_msg: "Foreman tasks status: ok"
16+
when:
17+
- enabled_features | select('contains', 'content/') | list | length > 0
18+
- foreman_ping.json.results.katello is defined
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
- name: Gather service facts
3+
ansible.builtin.service_facts:
4+
5+
- name: Check core services are running
6+
ansible.builtin.assert:
7+
that:
8+
- "ansible_facts.services[item + '.service'] is defined"
9+
- "ansible_facts.services[item + '.service']['state'] == 'running'"
10+
fail_msg: "Service {{ item }} is not running"
11+
success_msg: "Service {{ item }} is running"
12+
loop:
13+
- foreman
14+
- httpd
15+
- redis
16+
- postgresql
17+
18+
- name: Check dynflow services are running
19+
ansible.builtin.assert:
20+
that:
21+
- "ansible_facts.services[item + '.service'] is defined"
22+
- "ansible_facts.services[item + '.service']['state'] == 'running'"
23+
fail_msg: "Service {{ item }} is not running"
24+
success_msg: "Service {{ item }} is running"
25+
loop:
26+
- dynflow-sidekiq@orchestrator
27+
- dynflow-sidekiq@worker
28+
- dynflow-sidekiq@worker-hosts-queue
29+
30+
- name: Check Pulp services are running
31+
ansible.builtin.assert:
32+
that:
33+
- "ansible_facts.services[item + '.service'] is defined"
34+
- "ansible_facts.services[item + '.service']['state'] == 'running'"
35+
fail_msg: "Service {{ item }} is not running"
36+
success_msg: "Service {{ item }} is running"
37+
loop:
38+
- pulp-api
39+
- pulp-content
40+
when: enabled_features | select('contains', 'content/') | list | length > 0
41+
42+
- name: Check Candlepin service is running
43+
ansible.builtin.assert:
44+
that:
45+
- "ansible_facts.services['candlepin.service'] is defined"
46+
- "ansible_facts.services['candlepin.service']['state'] == 'running'"
47+
fail_msg: "Service candlepin is not running"
48+
success_msg: "Service candlepin is running"
49+
when: enabled_features | select('contains', 'content/') | list | length > 0

0 commit comments

Comments
 (0)