summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--playbooks/byo/openshift-preflight/check.yml4
-rw-r--r--roles/openshift_health_checker/action_plugins/openshift_health_check.py23
-rw-r--r--roles/openshift_health_checker/openshift_checks/__init__.py9
-rw-r--r--roles/openshift_health_checker/openshift_checks/package_availability.py1
-rw-r--r--roles/openshift_health_checker/openshift_checks/package_update.py1
-rw-r--r--roles/openshift_health_checker/openshift_checks/package_version.py1
6 files changed, 35 insertions, 4 deletions
diff --git a/playbooks/byo/openshift-preflight/check.yml b/playbooks/byo/openshift-preflight/check.yml
index 935531e02..c5f05d0f0 100644
--- a/playbooks/byo/openshift-preflight/check.yml
+++ b/playbooks/byo/openshift-preflight/check.yml
@@ -9,6 +9,4 @@
- action: openshift_health_check
args:
checks:
- - package_availability
- - package_update
- - package_version
+ - '@preflight'
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 36defde0a..0411797b1 100644
--- a/roles/openshift_health_checker/action_plugins/openshift_health_check.py
+++ b/roles/openshift_health_checker/action_plugins/openshift_health_check.py
@@ -41,7 +41,7 @@ class ActionModule(ActionBase):
return result
args = self._task.args
- requested_checks = set(args.get("checks", []))
+ requested_checks = resolve_checks(args.get("checks", []), known_checks.values())
unknown_checks = requested_checks - set(known_checks)
if unknown_checks:
@@ -93,3 +93,24 @@ class ActionModule(ActionBase):
known_checks[check_name] = cls(module_executor=self._execute_module)
return known_checks
+
+
+def resolve_checks(names, all_checks):
+ """Returns a set of resolved check names.
+
+ Resolving a check name involves expanding tag references (e.g., '@tag') with
+ all the checks that contain the given tag.
+
+ names should be a sequence of strings.
+
+ all_checks should be a sequence of check classes/instances.
+ """
+ resolved = set()
+ for name in names:
+ if name.startswith("@"):
+ for check in all_checks:
+ if name[1:] in check.tags:
+ resolved.add(check.name)
+ else:
+ resolved.add(name)
+ return resolved
diff --git a/roles/openshift_health_checker/openshift_checks/__init__.py b/roles/openshift_health_checker/openshift_checks/__init__.py
index d893ba591..ff99e7b4c 100644
--- a/roles/openshift_health_checker/openshift_checks/__init__.py
+++ b/roles/openshift_health_checker/openshift_checks/__init__.py
@@ -26,6 +26,15 @@ class OpenShiftCheck(object):
"""The name of this check, usually derived from the class name."""
return "openshift_check"
+ @property
+ def tags(self):
+ """A list of tags that this check satisfy.
+
+ Tags are used to reference multiple checks with a single '@tagname'
+ special check name.
+ """
+ return []
+
@classmethod
def is_active(cls, task_vars): # pylint: disable=unused-argument
"""Returns true if this check applies to the ansible-playbook run."""
diff --git a/roles/openshift_health_checker/openshift_checks/package_availability.py b/roles/openshift_health_checker/openshift_checks/package_availability.py
index 4260cbf7c..31277a3b9 100644
--- a/roles/openshift_health_checker/openshift_checks/package_availability.py
+++ b/roles/openshift_health_checker/openshift_checks/package_availability.py
@@ -7,6 +7,7 @@ class PackageAvailability(NotContainerized, OpenShiftCheck):
"""Check that required RPM packages are available."""
name = "package_availability"
+ tags = ["preflight"]
def run(self, tmp, task_vars):
try:
diff --git a/roles/openshift_health_checker/openshift_checks/package_update.py b/roles/openshift_health_checker/openshift_checks/package_update.py
index 316a776f5..86b7b6245 100644
--- a/roles/openshift_health_checker/openshift_checks/package_update.py
+++ b/roles/openshift_health_checker/openshift_checks/package_update.py
@@ -7,6 +7,7 @@ class PackageUpdate(NotContainerized, OpenShiftCheck):
"""Check that there are no conflicts in RPM packages."""
name = "package_update"
+ tags = ["preflight"]
def run(self, tmp, task_vars):
args = {"packages": []}
diff --git a/roles/openshift_health_checker/openshift_checks/package_version.py b/roles/openshift_health_checker/openshift_checks/package_version.py
index a473119f3..9394466f2 100644
--- a/roles/openshift_health_checker/openshift_checks/package_version.py
+++ b/roles/openshift_health_checker/openshift_checks/package_version.py
@@ -7,6 +7,7 @@ class PackageVersion(NotContainerized, OpenShiftCheck):
"""Check that available RPM packages match the required versions."""
name = "package_version"
+ tags = ["preflight"]
@classmethod
def is_active(cls, task_vars):