From e61819d89f52beddfa244e825931e068872f44f2 Mon Sep 17 00:00:00 2001
From: Rodolfo Carvalho <rhcarvalho@gmail.com>
Date: Tue, 25 Jul 2017 09:51:19 +0200
Subject: Clean up openshift-checks playbooks

- The referenced issue was closed, seems like a wontfix. Just use the
old syntax and make no noise about it.
- Remove inconsistent use of tags: if tags are passed in the command
line, there is no point in evaluating groups if the checks won't be run
anyway.
- Remove temporal comment, easy to get out of sync.
---
 playbooks/common/openshift-checks/health.yml      | 5 +----
 playbooks/common/openshift-checks/pre-install.yml | 5 +----
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/playbooks/common/openshift-checks/health.yml b/playbooks/common/openshift-checks/health.yml
index c7766ff04..713d85eeb 100644
--- a/playbooks/common/openshift-checks/health.yml
+++ b/playbooks/common/openshift-checks/health.yml
@@ -1,8 +1,5 @@
 ---
-# openshift_health_checker depends on openshift_version which now requires group eval.
 - include: ../openshift-cluster/evaluate_groups.yml
-  tags:
-  - always
 
 - name: Run OpenShift health checks
   hosts: OSEv3
@@ -11,6 +8,6 @@
   vars:
   - r_openshift_health_checker_playbook_context: "health"
   post_tasks:
-  - action: openshift_health_check  # https://github.com/ansible/ansible/issues/20513
+  - action: openshift_health_check
     args:
       checks: ['@health']
diff --git a/playbooks/common/openshift-checks/pre-install.yml b/playbooks/common/openshift-checks/pre-install.yml
index 7ca9f7e8b..edc0162b9 100644
--- a/playbooks/common/openshift-checks/pre-install.yml
+++ b/playbooks/common/openshift-checks/pre-install.yml
@@ -1,8 +1,5 @@
 ---
-# openshift_health_checker depends on openshift_version which now requires group eval.
 - include: ../openshift-cluster/evaluate_groups.yml
-  tags:
-  - always
 
 - hosts: OSEv3
   name: run OpenShift pre-install checks
@@ -11,6 +8,6 @@
   vars:
   - r_openshift_health_checker_playbook_context: "pre-install"
   post_tasks:
-  - action: openshift_health_check  # https://github.com/ansible/ansible/issues/20513
+  - action: openshift_health_check
     args:
       checks: ['@preflight']
-- 
cgit v1.2.3


From 85bb52d586297233728d331e37ef238e902bfeac Mon Sep 17 00:00:00 2001
From: Rodolfo Carvalho <rhcarvalho@gmail.com>
Date: Fri, 21 Jul 2017 14:53:33 +0200
Subject: Make LoggingCheck.run return the correct type

The run method is expected to return a dict. Even though we should not
run LoggingCheck by itself, it is still possible to do it and without
this change we get an unhandled exception.
---
 roles/openshift_health_checker/openshift_checks/logging/logging.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/roles/openshift_health_checker/openshift_checks/logging/logging.py b/roles/openshift_health_checker/openshift_checks/logging/logging.py
index a48e1c728..43ba6c406 100644
--- a/roles/openshift_health_checker/openshift_checks/logging/logging.py
+++ b/roles/openshift_health_checker/openshift_checks/logging/logging.py
@@ -11,6 +11,9 @@ from openshift_checks import OpenShiftCheck, OpenShiftCheckException
 class LoggingCheck(OpenShiftCheck):
     """Base class for OpenShift aggregated logging component checks"""
 
+    # FIXME: this should not be listed as a check, since it is not meant to be
+    # run by itself.
+
     name = "logging"
     logging_namespace = "logging"
 
@@ -27,7 +30,7 @@ class LoggingCheck(OpenShiftCheck):
         return masters[0] == hostname
 
     def run(self):
-        pass
+        return {}
 
     def get_pods_for_component(self, namespace, logging_component):
         """Get all pods for a given component. Returns: list of pods for component, error string"""
-- 
cgit v1.2.3


From 72b2e842f1ebd5e703fa3fe2778e45ea1bb1a9d1 Mon Sep 17 00:00:00 2001
From: Rodolfo Carvalho <rhcarvalho@gmail.com>
Date: Fri, 9 Jun 2017 17:03:37 +0200
Subject: Clean up unnecessary quotes

---
 playbooks/common/openshift-checks/health.yml      | 2 +-
 playbooks/common/openshift-checks/pre-install.yml | 2 +-
 playbooks/common/openshift-cluster/config.yml     | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/playbooks/common/openshift-checks/health.yml b/playbooks/common/openshift-checks/health.yml
index 713d85eeb..7e83b4aa6 100644
--- a/playbooks/common/openshift-checks/health.yml
+++ b/playbooks/common/openshift-checks/health.yml
@@ -6,7 +6,7 @@
   roles:
   - openshift_health_checker
   vars:
-  - r_openshift_health_checker_playbook_context: "health"
+  - r_openshift_health_checker_playbook_context: health
   post_tasks:
   - action: openshift_health_check
     args:
diff --git a/playbooks/common/openshift-checks/pre-install.yml b/playbooks/common/openshift-checks/pre-install.yml
index edc0162b9..afd4f95e0 100644
--- a/playbooks/common/openshift-checks/pre-install.yml
+++ b/playbooks/common/openshift-checks/pre-install.yml
@@ -6,7 +6,7 @@
   roles:
   - openshift_health_checker
   vars:
-  - r_openshift_health_checker_playbook_context: "pre-install"
+  - r_openshift_health_checker_playbook_context: pre-install
   post_tasks:
   - action: openshift_health_check
     args:
diff --git a/playbooks/common/openshift-cluster/config.yml b/playbooks/common/openshift-cluster/config.yml
index 7224ae712..31c4b04af 100644
--- a/playbooks/common/openshift-cluster/config.yml
+++ b/playbooks/common/openshift-cluster/config.yml
@@ -6,7 +6,7 @@
   roles:
   - openshift_health_checker
   vars:
-  - r_openshift_health_checker_playbook_context: "install"
+  - r_openshift_health_checker_playbook_context: install
   post_tasks:
   - action: openshift_health_check
     args:
-- 
cgit v1.2.3


From d6d5fe2954942a6706f5ae0255d94435ceade50b Mon Sep 17 00:00:00 2001
From: Rodolfo Carvalho <rhcarvalho@gmail.com>
Date: Fri, 23 Jun 2017 15:30:08 +0200
Subject: Normalize list of checks passed to action plugin

This allows users to pass either a string with comma-separated check
names or a proper list of strings, whatever is more convenient in the
context.

For consistency, the same normalization is applied to the
'openshift_disable_check' variable.
---
 .../action_plugins/openshift_health_check.py         | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

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 581dd7d15..23da53940 100644
--- a/roles/openshift_health_checker/action_plugins/openshift_health_check.py
+++ b/roles/openshift_health_checker/action_plugins/openshift_health_check.py
@@ -13,6 +13,7 @@ except ImportError:
     display = Display()
 
 from ansible.plugins.action import ActionBase
+from ansible.module_utils.six import string_types
 
 # Augment sys.path so that we can import checks from a directory relative to
 # this callback plugin.
@@ -39,7 +40,8 @@ class ActionModule(ActionBase):
         try:
             known_checks = self.load_known_checks(tmp, task_vars)
             args = self._task.args
-            resolved_checks = resolve_checks(args.get("checks", []), known_checks.values())
+            requested_checks = normalize(args.get('checks', []))
+            resolved_checks = resolve_checks(requested_checks, known_checks.values())
         except OpenShiftCheckException as e:
             result["failed"] = True
             result["msg"] = str(e)
@@ -47,10 +49,7 @@ class ActionModule(ActionBase):
 
         result["checks"] = check_results = {}
 
-        user_disabled_checks = [
-            check.strip()
-            for check in task_vars.get("openshift_disable_check", "").split(",")
-        ]
+        user_disabled_checks = normalize(task_vars.get('openshift_disable_check', []))
 
         for check_name in resolved_checks:
             display.banner("CHECK [{} : {}]".format(check_name, task_vars["ansible_host"]))
@@ -134,3 +133,14 @@ def resolve_checks(names, all_checks):
         resolved.update(tag_to_checks[tag])
 
     return resolved
+
+
+def normalize(checks):
+    """Return a clean list of check names.
+
+    The input may be a comma-separated string or a sequence. Leading and
+    trailing whitespace characters are removed. Empty items are discarded.
+    """
+    if isinstance(checks, string_types):
+        checks = checks.split(',')
+    return [name.strip() for name in checks if name.strip()]
-- 
cgit v1.2.3