From 68ff609d2948734303c5a845a53402cd8399e619 Mon Sep 17 00:00:00 2001 From: Rodolfo Carvalho Date: Thu, 11 May 2017 15:26:01 +0200 Subject: Allow disabling checks via Ansible variable Example usage: $ ansible-playbook -i hosts playbooks/byo/config.yml -e openshift_disable_check=memory_availability,disk_availability Or add the variable to the inventory / hosts file. --- .../action_plugins/openshift_health_check.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'roles') diff --git a/roles/openshift_health_checker/action_plugins/openshift_health_check.py b/roles/openshift_health_checker/action_plugins/openshift_health_check.py index 03c40b78b..e8a4c6474 100644 --- a/roles/openshift_health_checker/action_plugins/openshift_health_check.py +++ b/roles/openshift_health_checker/action_plugins/openshift_health_check.py @@ -46,11 +46,16 @@ class ActionModule(ActionBase): result["checks"] = check_results = {} + user_disabled_checks = [ + check.strip() + for check in task_vars.get("openshift_disable_check", "").split(",") + ] + for check_name in resolved_checks: display.banner("CHECK [{} : {}]".format(check_name, task_vars["ansible_host"])) check = known_checks[check_name] - if check.is_active(task_vars): + if check_name not in user_disabled_checks and check.is_active(task_vars): try: r = check.run(tmp, task_vars) except OpenShiftCheckException as e: @@ -58,6 +63,8 @@ class ActionModule(ActionBase): r["failed"] = True r["msg"] = str(e) else: + # TODO(rhcarvalho): we may want to provide some distinctive + # complementary message to know why a check was skipped. r = {"skipped": True} check_results[check_name] = r -- cgit v1.2.1