Merge "Add new healthcheck-service-status validation"

This commit is contained in:
Zuul 2019-10-02 17:24:52 +00:00 committed by Gerrit Code Review
commit 4208691bc4
5 changed files with 69 additions and 0 deletions

View File

@ -0,0 +1,6 @@
==========================
healthcheck-service-status
==========================
.. ansibleautoplugin::
:role: roles/healthcheck-service-status

View File

@ -0,0 +1,14 @@
---
- hosts: undercloud, overcloud
vars:
metadata:
name: Healthcheck systemd services Check
description: >
Check for failed healthcheck systemd services.
groups:
- post-deployment
retries_number: 1
delay_number: 1
inflight_healthcheck_services: []
roles:
- healthcheck-service-status

View File

@ -0,0 +1,8 @@
---
# The default values for the two following variables are set up to wait up to
# 300s for the first healthcheck to run.
retries_number: 10
delay_number: 30
# Please use inflight_healtcheck_services when using this role through the
# inflight validations.
inflight_healthcheck_services: []

View File

@ -0,0 +1,34 @@
---
- name: Get the healthcheck services list enabled on node
shell: >
systemctl list-unit-files | grep "^tripleo.*healthcheck.*enabled" | awk -F'.' '{print $1}'
changed_when: False
register: healthcheck_services_list
when: inflight_healthcheck_services | length < 1
- name: Set hc_services
set_fact:
hc_services: >
{%- if inflight_healthcheck_services | length > 0 -%}
{{ inflight_healthcheck_services }}
{%- else -%}
{{ healthcheck_services_list.stdout_lines }}
{%- endif -%}
- name: Get systemd healthcheck service status
systemd:
name: "{{ item }}"
retries: "{{ retries_number|int }}"
delay: "{{ delay_number|int }}"
until:
- systemd_healthcheck_state.status.ExecMainPID != '0'
- systemd_healthcheck_state.status.ActiveState in ['inactive', 'failed']
ignore_errors: True
register: systemd_healthcheck_state
with_items: "{{ hc_services }}"
- name: Fail if systemd healthcheck services are in failed status
fail:
msg: "Failed systemd healthcheck service detected: {{ item.item }}"
when: item.status.ExecMainStatus != '0'
loop: "{{ systemd_healthcheck_state.results }}"

View File

@ -0,0 +1,7 @@
---
metadata:
name: Healthcheck systemd services Check
description: >
Check for failed healthcheck systemd services.
groups:
- post-deployment