From 25276bda8c002f4279e5c1748f64a9fd1ee999a4 Mon Sep 17 00:00:00 2001 From: Rodolfo Carvalho Date: Fri, 23 Jun 2017 15:31:12 +0200 Subject: List existing health checks when none is requested This is a simple mechanism to learn what health checks are available. Note that we defer task_vars verification, so that we can compute requested_checks and resolved_checks earlier, allowing us to list checks even if openshift_facts has not run. --- playbooks/byo/openshift-checks/README.md | 10 +++++++++- playbooks/byo/openshift-checks/adhoc.yml | 21 +++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) (limited to 'playbooks') diff --git a/playbooks/byo/openshift-checks/README.md b/playbooks/byo/openshift-checks/README.md index c17f5b6b7..b26e7d7ed 100644 --- a/playbooks/byo/openshift-checks/README.md +++ b/playbooks/byo/openshift-checks/README.md @@ -26,7 +26,8 @@ callback plugin summarizes execution errors at the end of a playbook run. 3. Certificate expiry playbooks ([certificate_expiry](certificate_expiry)) - check that certificates in use are valid and not expiring soon. -4. Adhoc playbook ([adhoc.yml](adhoc.yml)) - use it to run adhoc checks. +4. Adhoc playbook ([adhoc.yml](adhoc.yml)) - use it to run adhoc checks or to + list existing checks. See the [next section](#the-adhoc-playbook) for a usage example. ## Running @@ -89,6 +90,13 @@ $ ansible-playbook -i playbooks/byo/openshift-checks/adhoc.yml It is valid to specify multiple check tags and individual check names together in a comma-separated list. +To list all of the available checks and tags, run the adhoc playbook without +setting the `openshift_checks` variable: + +```console +$ ansible-playbook -i playbooks/byo/openshift-checks/adhoc.yml +``` + ## Running in a container This repository is built into a Docker image including Ansible so that it can diff --git a/playbooks/byo/openshift-checks/adhoc.yml b/playbooks/byo/openshift-checks/adhoc.yml index 2ece40e96..226bed732 100644 --- a/playbooks/byo/openshift-checks/adhoc.yml +++ b/playbooks/byo/openshift-checks/adhoc.yml @@ -1,4 +1,25 @@ --- +# NOTE: ideally this would be just part of a single play in +# common/openshift-checks/adhoc.yml that lists the existing checks when +# openshift_checks is not set or run the requested checks. However, to actually +# run the checks we need to have the included dependencies to run first and that +# takes time. To speed up listing checks, we use this separate play that runs +# before the include of dependencies to save time and improve the UX. +- name: OpenShift health checks + # NOTE: though the openshift_checks variable could be potentially defined on + # individual hosts while not defined for localhost, we do not support that + # usage. Running this play only in localhost speeds up execution. + hosts: localhost + connection: local + roles: + - openshift_health_checker + vars: + - r_openshift_health_checker_playbook_context: adhoc + pre_tasks: + - name: List known health checks + action: openshift_health_check + when: openshift_checks is undefined or not openshift_checks + - include: ../openshift-cluster/initialize_groups.yml - include: ../../common/openshift-cluster/std_include.yml -- cgit v1.2.3