diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d57c315 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/0.9.tar.gz diff --git a/.ipa-healthcheck.metadata b/.ipa-healthcheck.metadata new file mode 100644 index 0000000..18e4f2f --- /dev/null +++ b/.ipa-healthcheck.metadata @@ -0,0 +1 @@ +01a26143be6b2d3d4500bcd43a282c51d4f50ce8 SOURCES/0.9.tar.gz diff --git a/SOURCES/0001-Remove-ipaclustercheck.patch b/SOURCES/0001-Remove-ipaclustercheck.patch new file mode 100644 index 0000000..fb6b2ee --- /dev/null +++ b/SOURCES/0001-Remove-ipaclustercheck.patch @@ -0,0 +1,640 @@ +From 3c82636f3b1333333314bbc012d30a7faed00261 Mon Sep 17 00:00:00 2001 +From: Rob Crittenden +Date: Tue, 8 Jun 2021 13:51:28 -0400 +Subject: [PATCH] Remove ipaclustercheck + +Not shipping it from upstream into Fedora just yet +--- + setup.py | 12 +- + src/ipaclustercheck/__init__.py | 5 - + src/ipaclustercheck/core/__init__.py | 0 + src/ipaclustercheck/core/main.py | 32 ------ + src/ipaclustercheck/core/output.py | 68 ----------- + src/ipaclustercheck/ipa/__init__.py | 0 + src/ipaclustercheck/ipa/crlmanager.py | 36 ------ + src/ipaclustercheck/ipa/plugin.py | 117 ------------------- + src/ipaclustercheck/ipa/ruv.py | 155 -------------------------- + tests/test_cluster_ruv.py | 106 ------------------ + 10 files changed, 1 insertion(+), 530 deletions(-) + delete mode 100644 src/ipaclustercheck/__init__.py + delete mode 100644 src/ipaclustercheck/core/__init__.py + delete mode 100644 src/ipaclustercheck/core/main.py + delete mode 100644 src/ipaclustercheck/core/output.py + delete mode 100644 src/ipaclustercheck/ipa/__init__.py + delete mode 100644 src/ipaclustercheck/ipa/crlmanager.py + delete mode 100644 src/ipaclustercheck/ipa/plugin.py + delete mode 100644 src/ipaclustercheck/ipa/ruv.py + delete mode 100644 tests/test_cluster_ruv.py + +diff --git a/setup.py b/setup.py +index f2bdb7b..2abcf7f 100644 +--- a/setup.py ++++ b/setup.py +@@ -4,7 +4,7 @@ from setuptools import find_packages, setup + setup( + name='ipahealthcheck', + version='0.9', +- namespace_packages=['ipahealthcheck', 'ipaclustercheck'], ++ namespace_packages=['ipahealthcheck'], + package_dir={'': 'src'}, + # packages=find_packages(where='src'), + packages=[ +@@ -14,14 +14,11 @@ setup( + 'ipahealthcheck.ipa', + 'ipahealthcheck.meta', + 'ipahealthcheck.system', +- 'ipaclustercheck.core', +- 'ipaclustercheck.ipa', + ], + entry_points={ + # creates bin/ipahealthcheck + 'console_scripts': [ + 'ipa-healthcheck = ipahealthcheck.core.main:main', +- 'ipa-clustercheck = ipaclustercheck.core.main:main', + ], + # subsystem registries + 'ipahealthcheck.registry': [ +@@ -69,13 +66,6 @@ setup( + 'ipahealthcheck.system': [ + 'filesystemspace = ipahealthcheck.system.filesystemspace', + ], +- 'ipaclustercheck.registry': [ +- 'ipaclustercheck.ipa = ipaclustercheck.ipa.plugin:registry', +- ], +- 'ipaclustercheck.ipa': [ +- 'crl = ipaclustercheck.ipa.crlmanager', +- 'ruv = ipaclustercheck.ipa.ruv', +- ], + }, + classifiers=[ + 'Programming Language :: Python :: 3.6', +diff --git a/src/ipaclustercheck/__init__.py b/src/ipaclustercheck/__init__.py +deleted file mode 100644 +index 6c91ef7..0000000 +--- a/src/ipaclustercheck/__init__.py ++++ /dev/null +@@ -1,5 +0,0 @@ +-# +-# Copyright (C) 2019 FreeIPA Contributors see COPYING for license +-# +- +-__import__('pkg_resources').declare_namespace(__name__) +diff --git a/src/ipaclustercheck/core/__init__.py b/src/ipaclustercheck/core/__init__.py +deleted file mode 100644 +index e69de29..0000000 +diff --git a/src/ipaclustercheck/core/main.py b/src/ipaclustercheck/core/main.py +deleted file mode 100644 +index f475832..0000000 +--- a/src/ipaclustercheck/core/main.py ++++ /dev/null +@@ -1,32 +0,0 @@ +-# +-# Copyright (C) 2020 FreeIPA Contributors see COPYING for license +-# +- +-import sys +- +-from ipaclustercheck.core.output import output_registry +-from ipahealthcheck.core.core import RunChecks +- +- +-class ClusterChecks(RunChecks): +- +- def add_options(self): +- parser = self.parser +- parser.add_argument('--directory', dest='dir', +- help='Directory holding healthcheck logs') +- +- def validate_options(self): +- super().validate_options() +- +- if self.options.dir is None: +- print("--directory containing logs to check is required") +- return 1 +- +- return None +- +- +-def main(): +- clusterchecks = ClusterChecks(['ipaclustercheck.registry'], +- '/etc/ipa/clustercheck.conf', +- output_registry, 'ansible') +- sys.exit(clusterchecks.run_healthcheck()) +diff --git a/src/ipaclustercheck/core/output.py b/src/ipaclustercheck/core/output.py +deleted file mode 100644 +index 6a1963d..0000000 +--- a/src/ipaclustercheck/core/output.py ++++ /dev/null +@@ -1,68 +0,0 @@ +-# +-# Copyright (C) 2019 FreeIPA Contributors see COPYING for license +-# +- +-import json +-from ipahealthcheck.core.output import OutputRegistry, Output +- +- +-output_registry = OutputRegistry() +- +-class ClusterOutput(Output): +- """Base class for writing/display output of cluster results +- +- severity doesn't apply in this case so exclude those. +- """ +- def __init__(self, options): +- self.filename = options.outfile +- +- def strip_output(self, results): +- """Nothing to strip out""" +- return list(results.output()) +- +- def generate(self, data): +- raise NotImplementedError +- +- +-@output_registry +-class Ansible(ClusterOutput): +- """Output information JSON format for consumption by Ansible +- +- Required keywords in a Result: +- name - unique identifier for the return value +- +- One of these is required: +- value - the return value. Type? I dunno yet +- error - if an error was returned +- """ +- +- options = ( +- ('--indent', dict(dest='indent', type=int, default=2, +- help='Indention level of JSON output')), +- ) +- +- def __init__(self, options): +- super().__init__(options) +- self.indent = options.indent +- +- def generate(self, data): +- output = [] +- for line in data: +- kw = line.get('kw') +- name = kw.get('name') +- value = kw.get('value') +- error = kw.get('error') +- +- if value and error: +- value = '%s: %s' % (error, value) +- elif error: +- value = error +- +- rval = {'%s' % name: value} +- output.append(rval) +- +- output = json.dumps(output, indent=self.indent) +- if self.filename is None: +- output += '\n' +- +- return output +diff --git a/src/ipaclustercheck/ipa/__init__.py b/src/ipaclustercheck/ipa/__init__.py +deleted file mode 100644 +index e69de29..0000000 +diff --git a/src/ipaclustercheck/ipa/crlmanager.py b/src/ipaclustercheck/ipa/crlmanager.py +deleted file mode 100644 +index 6806d74..0000000 +--- a/src/ipaclustercheck/ipa/crlmanager.py ++++ /dev/null +@@ -1,36 +0,0 @@ +-# +-# Copyright (C) 2019 FreeIPA Contributors see COPYING for license +-# +- +-from ipaclustercheck.ipa.plugin import ClusterPlugin, registry, find_checks +-from ipahealthcheck.core.plugin import Result, duration +-from ipahealthcheck.core import constants +- +- +-@registry +-class ClusterCRLManagerCheck(ClusterPlugin): +- +- @duration +- def check(self): +- data = self.registry.json +- crlmanagers = [] +- +- for fqdn in data.keys(): +- output = find_checks(data[fqdn], 'ipahealthcheck.ipa.roles', +- 'IPACRLManagerCheck') +- enabled = output[0].get('kw').get('crlgen_enabled') +- if enabled: +- crlmanagers.append(fqdn) +- if len(crlmanagers) == 0: +- yield Result(self, constants.ERROR, +- name='crlmanager', +- error='No CRL Manager defined') +- elif len(crlmanagers) == 1: +- yield Result(self, constants.SUCCESS, +- name='crlmanager', +- value=crlmanagers[0]) +- else: +- yield Result(self, constants.ERROR, +- name='crlmanager', +- value=','.join(crlmanagers), +- error='Multiple CRL Managers defined') +diff --git a/src/ipaclustercheck/ipa/plugin.py b/src/ipaclustercheck/ipa/plugin.py +deleted file mode 100644 +index b6ad9ec..0000000 +--- a/src/ipaclustercheck/ipa/plugin.py ++++ /dev/null +@@ -1,117 +0,0 @@ +-# +-# Copyright (C) 2020 FreeIPA Contributors see COPYING for license +-# +- +-from copy import deepcopy +-import json +-import logging +-from os import listdir +-from os.path import isfile, join +- +-from ipahealthcheck.core.plugin import Plugin, Registry +-from ipalib import api +- +- +-logger = logging.getLogger() +- +-def find_checks(data, source, check): +- """Look through the dict for a matching source and check. +- +- data: dict of source and check output +- source: name of source to find +- check: name of check to find +- +- Returns list of contents of source + check or empty list +- """ +- rval = [] +- for d in data: +- if d.get('source') == source and d.get('check') == check: +- rval.append(d) +- +- return rval +- +- +-def get_masters(data): +- """ +- Return the list of known masters +- +- This is determined from the list of loaded healthcheck logs. It +- is possible that mixed versions are used so some may not be +- reporting the full list of masters, so check them all, and raise +- an exception if the list cannot be determined. +- """ +- test_masters = list(data) +- masters = None +- for master in test_masters: +- output = find_checks(data[master], 'ipahealthcheck.ipa.meta', +- 'IPAMetaCheck') +- if len(output) == 0: +- raise ValueError('Unable to determine full list of masters. ' +- 'ipahealthcheck.ipa.meta:IPAMetaCheck not ' +- 'found.') +- +- masters = output[0].get('kw').get('masters') +- if masters: +- return masters +- +- raise ValueError('Unable to determine full list of masters. ' +- 'None of ipahealthcheck.ipa.meta:IPAMetaCheck ' +- 'contain masters.') +- +- +-class ClusterPlugin(Plugin): +- pass +- +- +-class ClusterRegistry(Registry): +- def __init__(self): +- super().__init__() +- self.json = None +- +- def initialize(self, framework, config, options=None): +- super().initialize(framework, config, options) +- +- self.json = {} +- +- self.load_files(options.dir) +- +- if not api.isdone('finalize'): +- if not api.isdone('bootstrap'): +- api.bootstrap(in_server=True, +- context='ipahealthcheck', +- log=None) +- if not api.isdone('finalize'): +- api.finalize() +- +- def load_files(self, dir): +- if self.json: +- return +- +- files = [f for f in listdir(dir) if isfile(join(dir, f))] +- for file in files: +- fname = join(dir, file) +- logger.debug("Reading %s", fname) +- try: +- with open(fname, 'r') as fd: +- data = fd.read() +- except Exception as e: +- logger.error("Unable to read %s: %s", fname, e) +- continue +- +- try: +- data = json.loads(data) +- except Exception as e: +- logger.error("Unable to parse JSON in %s: %s", fname, e) +- continue +- +- meta = find_checks(data, 'ipahealthcheck.meta.core', +- 'MetaCheck') +- if meta: +- fqdn = meta[0].get('kw').get('fqdn') +- self.json[fqdn] = deepcopy(data) +- else: +- logger.error("No fqdn defined in JSON in %s", fname) +- continue +- +- +-registry = ClusterRegistry() +diff --git a/src/ipaclustercheck/ipa/ruv.py b/src/ipaclustercheck/ipa/ruv.py +deleted file mode 100644 +index 2a9540c..0000000 +--- a/src/ipaclustercheck/ipa/ruv.py ++++ /dev/null +@@ -1,155 +0,0 @@ +-# +-# Copyright (C) 2019 FreeIPA Contributors see COPYING for license +-# +- +-import logging +- +-from ipaclustercheck.ipa.plugin import ( +- ClusterPlugin, +- registry, +- find_checks, +- get_masters +-) +-from ipahealthcheck.core.plugin import Result, duration +-from ipahealthcheck.core import constants +-from ipalib import api +-from ipapython.dn import DN +- +- +-logger = logging.getLogger() +- +- +-@registry +-class ClusterRUVCheck(ClusterPlugin): +- +- # TODO: confirm that all masters are represented, otherwise the +- # trustworthiness of dangling RUV is mixed. +- # +- # gah, need to provide full list of all masters in a check. +- +- @duration +- def check(self): +- data = self.registry.json +- +- # Start with the list of masters from the file(s) collected +- # and find a MetaCheck with a full list of masters. For +- # backwards compatibility. +- try: +- masters = get_masters(data) +- except ValueError as e: +- yield Result(self, constants.ERROR, +- name='dangling_ruv', +- error=str(e)) +- return +- +- if len(data.keys()) < len(masters): +- yield Result(self, constants.ERROR, +- name='dangling_ruv', +- error='Unable to determine list of RUVs, missing ' +- 'some masters: %s' % +- ''.join(set(masters) - set(data.keys()))) +- return +- +- # collect the full set of known RUVs for each master +- info = {} +- for master in masters: +- info[master] = { +- 'ca': False, # does the host have ca configured? +- 'ruvs': set(), # ruvs on the host +- 'csruvs': set(), # csruvs on the host +- 'clean_ruv': set(), # ruvs to be cleaned from the host +- 'clean_csruv': set() # csruvs to be cleaned from the host +- } +- +- for fqdn in data.keys(): +- outputs = find_checks(data[fqdn], 'ipahealthcheck.ds.ruv', +- 'KnownRUVCheck') +- for output in outputs: +- if not 'suffix' in output.get('kw'): +- continue +- basedn = DN(output.get('kw').get('suffix')) +- +- ruvset = set() +- ruvtmp = output.get('kw').get('ruvs') +- for ruv in ruvtmp: +- ruvset.add(tuple(ruv)) +- +- if basedn == DN('o=ipaca'): +- info[fqdn]['ca'] = True +- info[fqdn]['csruvs'] = ruvset +- elif basedn == api.env.basedn: +- info[fqdn]['ruvs'] = ruvset +- else: +- yield Result(self, constants.WARNING, +- name='dangling_ruv', +- error='Unknown suffix found %s expected %s' +- % (basedn, api.env.basedn)) +- +- # Collect the nsDS5ReplicaID for each master +- ruvs = set() +- csruvs = set() +- for fqdn in data.keys(): +- outputs = find_checks(data[fqdn], 'ipahealthcheck.ds.ruv', +- 'RUVCheck') +- for output in outputs: +- if not 'key' in output.get('kw'): +- continue +- basedn = DN(output.get('kw').get('key')) +- ruv = (fqdn, (output.get('kw').get('ruv'))) +- if basedn == DN('o=ipaca'): +- csruvs.add(ruv) +- elif basedn == api.env.basedn: +- ruvs.add(ruv) +- else: +- yield Result(self, constants.WARNING, +- name='dangling_ruv', +- error='Unknown suffix found %s expected %s' +- % (basedn, api.env.basedn)) +- +- dangles = False +- # get the dangling RUVs +- for master_info in info.values(): +- for ruv in master_info['ruvs']: +- if ruv not in ruvs: +- master_info['clean_ruv'].add(ruv) +- dangles = True +- +- # if ca is not configured, there will be no csruvs in master_info +- for csruv in master_info['csruvs']: +- if csruv not in csruvs: +- master_info['clean_csruv'].add(csruv) +- dangles = True +- +- clean_csruvs = set() +- clean_ruvs = set() +- if dangles: +- for _, master_info in info.items(): +- for ruv in master_info['clean_ruv']: +- logger.debug( +- "Dangling RUV id: %s, hostname: %s", ruv[1], ruv[0] +- ) +- clean_ruvs.add(ruv[1]) +- for csruv in master_info['clean_csruv']: +- logger.debug( +- "Dangling CS RUV id: %s, hostname: %s", +- csruv[1], +- csruv[0] +- ) +- clean_csruvs.add(csruv[1]) +- +- if clean_ruvs: +- yield Result(self, constants.ERROR, +- name='dangling_ruv', +- value=', '.join(clean_ruvs)) +- else: +- yield Result(self, constants.SUCCESS, +- name='dangling_ruv', +- value='No dangling RUVs found') +- if clean_csruvs: +- yield Result(self, constants.ERROR, +- name='dangling_csruv', +- value=', '.join(clean_csruvs)) +- else: +- yield Result(self, constants.SUCCESS, +- name='dangling_csruv', +- value='No dangling CS RUVs found') +diff --git a/tests/test_cluster_ruv.py b/tests/test_cluster_ruv.py +deleted file mode 100644 +index 7583c84..0000000 +--- a/tests/test_cluster_ruv.py ++++ /dev/null +@@ -1,106 +0,0 @@ +-# +-# Copyright (C) 2019 FreeIPA Contributors see COPYING for license +-# +- +-from base import BaseTest +-from util import capture_results +- +-from ipahealthcheck.core import config +-from ipaclustercheck.ipa.plugin import ClusterRegistry +-from ipaclustercheck.ipa.ruv import ClusterRUVCheck +- +-import clusterdata +- +- +-class RUVRegistry(ClusterRegistry): +- def load_files(self, dir): +- self.json = dir +- +- +-class Options: +- def __init__(self, data): +- self.data = data +- +- @property +- def dir(self): +- return self.data +- +- +-registry = RUVRegistry() +- +- +-class TestClusterRUV(BaseTest): +- +- def test_no_ruvs(self): +- """Single master test that has never created a replica +- +- This type of master will have no RUVs created at all. +- """ +- framework = object() +- registry.initialize(framework, config.Config, +- Options(clusterdata.ONE_MASTER)) +- f = ClusterRUVCheck(registry) +- +- self.results = capture_results(f) +- +- assert len(self.results) == 2 +- result = self.results.results[0] +- assert result.kw.get('name') == 'dangling_ruv' +- assert result.kw.get('value') == 'No dangling RUVs found' +- result = self.results.results[1] +- assert result.kw.get('name') == 'dangling_csruv' +- assert result.kw.get('value') == 'No dangling CS RUVs found' +- +- def test_six_ruvs_ok(self): +- """Three master test with each having a CA, no dangling +- """ +- framework = object() +- registry.initialize(framework, config.Config, +- Options(clusterdata.THREE_MASTERS_OK)) +- f = ClusterRUVCheck(registry) +- +- self.results = capture_results(f) +- +- assert len(self.results) == 2 +- result = self.results.results[0] +- assert result.kw.get('name') == 'dangling_ruv' +- assert result.kw.get('value') == 'No dangling RUVs found' +- result = self.results.results[1] +- assert result.kw.get('name') == 'dangling_csruv' +- assert result.kw.get('value') == 'No dangling CS RUVs found' +- +- def test_six_ruvs_ipa_bad(self): +- """Three master test with each having a CA, dangling IPA RUV +- """ +- framework = object() +- registry.initialize(framework, config.Config, +- Options(clusterdata.THREE_MASTERS_BAD_IPA_RUV)) +- f = ClusterRUVCheck(registry) +- +- self.results = capture_results(f) +- +- assert len(self.results) == 2 +- result = self.results.results[0] +- assert result.kw.get('name') == 'dangling_ruv' +- assert result.kw.get('value') == '9' +- result = self.results.results[1] +- assert result.kw.get('name') == 'dangling_csruv' +- assert result.kw.get('value') == 'No dangling CS RUVs found' +- +- def test_six_ruvs_cs_bad(self): +- """Three master test with each having a CA, dangling CA RUV +- """ +- framework = object() +- registry.initialize(framework, config.Config, +- Options(clusterdata.THREE_MASTERS_BAD_CS_RUV)) +- f = ClusterRUVCheck(registry) +- +- self.results = capture_results(f) +- +- assert len(self.results) == 2 +- result = self.results.results[0] +- assert result.kw.get('name') == 'dangling_ruv' +- assert result.kw.get('value') == 'No dangling RUVs found' +- result = self.results.results[1] +- assert result.kw.get('name') == 'dangling_csruv' +- assert result.kw.get('value') == '9' +-- +2.26.3 + diff --git a/SOURCES/0002-Handle-files-that-don-t-exist-in-FileCheck.patch b/SOURCES/0002-Handle-files-that-don-t-exist-in-FileCheck.patch new file mode 100644 index 0000000..e9e04e1 --- /dev/null +++ b/SOURCES/0002-Handle-files-that-don-t-exist-in-FileCheck.patch @@ -0,0 +1,63 @@ +From 7db48931c9b3045406e465abb4d2a21beaadfcc4 Mon Sep 17 00:00:00 2001 +From: Rob Crittenden +Date: Mon, 14 Jun 2021 08:44:39 -0400 +Subject: [PATCH] Handle files that don't exist in FileCheck + +A raw os.stat() was called which could raise an exception if the file +doesn't exist. Instead call os.path.exists() and if the result is False +then raise a SUCCESS with a message that the file doesn't exist. + +https://github.com/freeipa/freeipa-healthcheck/issues/213 + +Signed-off-by: Rob Crittenden +--- + src/ipahealthcheck/core/files.py | 7 +++++++ + tests/test_core_files.py | 17 +++++++++++++++++ + 2 files changed, 24 insertions(+) + +diff --git a/src/ipahealthcheck/core/files.py b/src/ipahealthcheck/core/files.py +index a63c06b..0a7641e 100644 +--- a/src/ipahealthcheck/core/files.py ++++ b/src/ipahealthcheck/core/files.py +@@ -33,6 +33,13 @@ class FileCheck: + owner = tuple((owner,)) + if not isinstance(group, tuple): + group = tuple((group,)) ++ if not os.path.exists(path): ++ for type in ('mode', 'owner', 'group'): ++ key = '%s_%s' % (path.replace('/', '_'), type) ++ yield Result(self, constants.SUCCESS, key=key, ++ type=type, path=path, ++ msg='File does not exist') ++ continue + stat = os.stat(path) + fmode = str(oct(stat.st_mode)[-4:]) + key = '%s_mode' % path.replace('/', '_') +diff --git a/tests/test_core_files.py b/tests/test_core_files.py +index 3b71469..10824ab 100644 +--- a/tests/test_core_files.py ++++ b/tests/test_core_files.py +@@ -144,3 +144,20 @@ def test_files_mode(mock_stat): + my_results = get_results(results, 'mode') + assert my_results.results[0].result == constants.WARNING + assert my_results.results[1].result == constants.WARNING ++ ++ ++@patch('os.path.exists') ++def test_files_not_found(mock_exists): ++ mock_exists.return_value = False ++ ++ f = FileCheck() ++ f.files = files ++ ++ results = capture_results(f) ++ ++ for type in ('mode', 'group', 'owner'): ++ my_results = get_results(results, type) ++ assert len(my_results.results) == 4 ++ for result in my_results.results: ++ assert result.result == constants.SUCCESS ++ assert result.kw.get('msg') == 'File does not exist' +-- +2.26.3 + diff --git a/SOURCES/ipahealthcheck.conf b/SOURCES/ipahealthcheck.conf new file mode 100644 index 0000000..ab109a1 --- /dev/null +++ b/SOURCES/ipahealthcheck.conf @@ -0,0 +1 @@ +[default] diff --git a/SPECS/freeipa-healthcheck.spec b/SPECS/freeipa-healthcheck.spec new file mode 100644 index 0000000..4b45132 --- /dev/null +++ b/SPECS/freeipa-healthcheck.spec @@ -0,0 +1,286 @@ +%if 0%{?rhel} +%global prefix ipa +%global productname IPA +%global alt_prefix freeipa +%else +# Fedora +%global prefix freeipa +%global productname FreeIPA +%global alt_prefix ipa +%endif +%global debug_package %{nil} +%global python3dir %{_builddir}/python3-%{name}-%{version}-%{release} +%{!?python3_sitelib: %global python3_sitelib %(%{__python3} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")} +%global alt_name %{alt_prefix}-healthcheck + +%bcond_without tests + +Name: %{prefix}-healthcheck +Version: 0.9 +Release: 2%{?dist} +Summary: Health check tool for %{productname} +BuildArch: noarch +License: GPLv3 +URL: https://github.com/freeipa/freeipa-healthcheck +Source0: https://github.com/freeipa/freeipa-healthcheck/archive/%{version}.tar.gz +Source1: ipahealthcheck.conf + +Patch0001: 0001-Remove-ipaclustercheck.patch +Patch0002: 0002-Handle-files-that-don-t-exist-in-FileCheck.patch + +Requires: %{name}-core = %{version}-%{release} +Requires: %{prefix}-server +Requires: python3-ipalib +Requires: python3-ipaserver +Requires: python3-lib389 >= 1.4.2.14-1 +# cronie-anacron provides anacron +Requires: anacron +Requires: logrotate +Requires(post): systemd-units +Requires: %{name}-core = %{version}-%{release} +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: systemd-devel +%{?systemd_requires} +# packages for make check +%if %{with tests} +BuildRequires: python3-pytest +BuildRequires: python3-ipalib +BuildRequires: python3-ipaserver +%endif +BuildRequires: python3-lib389 +BuildRequires: python3-libsss_nss_idmap + +# Cross-provides for sibling OS +Provides: %{alt_name} = %{version} +Conflicts: %{alt_name} +Obsoletes: %{alt_name} < %{version} + +%description +The %{productname} health check tool provides a set of checks to +proactively detect defects in a FreeIPA cluster. + + +%package -n %{name}-core +Summary: Core plugin system for healthcheck + +# Cross-provides for sibling OS +Provides: %{alt_name}-core = %{version} +Conflicts: %{alt_name}-core +Obsoletes: %{alt_name}-core < %{version} + + +%description -n %{name}-core +Core plugin system for healthcheck, usable standalone with other +packages. + + +%prep +%autosetup -p1 -n freeipa-healthcheck-%{version} + + +%build +%py3_build + + +%install +%py3_install + +mkdir -p %{buildroot}%{_sysconfdir}/ipahealthcheck +install -m644 %{SOURCE1} %{buildroot}%{_sysconfdir}/ipahealthcheck + +mkdir -p %{buildroot}/%{_unitdir} +install -p -m644 %{_builddir}/freeipa-healthcheck-%{version}/systemd/ipa-healthcheck.service %{buildroot}%{_unitdir} +install -p -m644 %{_builddir}/freeipa-healthcheck-%{version}/systemd/ipa-healthcheck.timer %{buildroot}%{_unitdir} + +mkdir -p %{buildroot}/%{_libexecdir}/ipa +install -p -m755 %{_builddir}/freeipa-healthcheck-%{version}/systemd/ipa-healthcheck.sh %{buildroot}%{_libexecdir}/ipa/ + +mkdir -p %{buildroot}%{_sysconfdir}/logrotate.d +install -p -m644 %{_builddir}/freeipa-healthcheck-%{version}/logrotate/ipahealthcheck %{buildroot}%{_sysconfdir}/logrotate.d + +mkdir -p %{buildroot}/%{_localstatedir}/log/ipa/healthcheck + +mkdir -p %{buildroot}/%{_mandir}/man8 +mkdir -p %{buildroot}/%{_mandir}/man5 +install -p -m644 %{_builddir}/freeipa-healthcheck-%{version}/man/man8/ipa-healthcheck.8 %{buildroot}%{_mandir}/man8/ +install -p -m644 %{_builddir}/freeipa-healthcheck-%{version}/man/man5/ipahealthcheck.conf.5 %{buildroot}%{_mandir}/man5/ + +(cd %{buildroot}/%{python3_sitelib}/ipahealthcheck && find . -type f | \ + grep -v '^./core' | \ + grep -v 'opt-1' | \ + sed -e 's,\.py.*$,.*,g' | sort -u | \ + sed -e 's,\./,%%{python3_sitelib}/ipahealthcheck/,g' ) >healthcheck.list + + +%if %{with tests} +%check +PYTHONPATH=src PATH=$PATH:$RPM_BUILD_ROOT/usr/bin pytest-3 tests/test_* +%endif + + +%post +%systemd_post ipa-healthcheck.service + + +%preun +%systemd_preun ipa-healthcheck.service + + +%postun +%systemd_postun_with_restart ipa-healthcheck.service + + +%files -f healthcheck.list +%{!?_licensedir:%global license %%doc} +%license COPYING +%doc README.md +%{_bindir}/ipa-healthcheck +%dir %{_sysconfdir}/ipahealthcheck +%dir %{_localstatedir}/log/ipa/healthcheck +%config(noreplace) %{_sysconfdir}/ipahealthcheck/ipahealthcheck.conf +%config(noreplace) %{_sysconfdir}/logrotate.d/ipahealthcheck +%{python3_sitelib}/ipahealthcheck-%{version}-*.egg-info/ +%{python3_sitelib}/ipahealthcheck-%{version}-*-nspkg.pth +%{_unitdir}/* +%{_libexecdir}/* +%{_mandir}/man8/* +%{_mandir}/man5/* + + +%files -n %{name}-core +%{!?_licensedir:%global license %%doc} +%license COPYING +%doc README.md +%{python3_sitelib}/ipahealthcheck/core/ + + +%changelog +* Mon Aug 09 2021 Mohan Boddu - 0.9-2 +- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags + Related: rhbz#1991688 + +* Thu Jun 17 2021 Rob Crittenden - 0.9-1 +- Rebase to upstream 0.9 (#1969539) + +* Thu Apr 22 2021 Rob Crittenden - 0.8-7.2 +- rpminspect: specname match on suffix to allow for differing + spec/package naming (#1951733) + +* Mon Apr 19 2021 Rob Crittenden - 0.8-7.1 +- Switch from tox to pytest as the test runner. tox is being deprecated + in some distros. (#1942157) + +* Mon Apr 19 2021 Rob Crittenden - 0.8-7 +- Add check to validate the KRA Agent is correct (#1894781) + +* Thu Apr 15 2021 Mohan Boddu - 0.8-6.1 +- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937 + +* Fri Mar 12 2021 Alexander Bokovoy - 0.8-5.1 +- Re-enable package self-tests after bootstrap + +* Mon Mar 8 2021 François Cami - 0.8-5 +- Make the spec file distribution-agnostic (rhbz#1935773). + +* Tue Mar 2 2021 Alexander Scheel - 0.8-4 +- Make the spec file more distribution-agnostic +- Use tox as the test runner when tests are enabled + +* Tue Jan 26 2021 Fedora Release Engineering - 0.8-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild + +* Mon Jan 18 2021 Rob Crittenden - 0.8-2 +- A bad file group was reported as a python list, not a string + +* Wed Jan 13 2021 Rob Crittenden - 0.8-1 +- Update to upstream 0.8 +- Fix FTBFS in F34/rawhide (#1915256) + +* Wed Dec 16 2020 Rob Crittenden - 0.7-3 +- Include upstream patch to fix parsing input from json files + +* Tue Nov 17 2020 Rob Crittenden - 0.7-2 +- Include upstream patch to fix collection of AD trust domains +- Include upstream patch to fix failing not-valid-after test + +* Thu Oct 29 2020 Rob Crittenden - 0.7-1 +- Update to upstream 0.7 + +* Wed Jul 29 2020 Rob Crittenden - 0.6-4 +- Set minimum Requires on python3-lib389 +- Don't assume that all users of healthcheck-core provide the same + set of options. + +* Mon Jul 27 2020 Fedora Release Engineering - 0.6-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + +* Fri Jul 24 2020 Rob Crittenden - 0.6-2 +- Don't collect IPA servers in MetaCheck +- Skip if dirsrv not available in IPAMetaCheck + +* Wed Jul 1 2020 Rob Crittenden - 0.6-1 +- Update to upstream 0.6 +- Don't include cluster checking yet + +* Tue Jun 23 2020 Rob Crittenden - 0.5-5 +- Add BuildRequires on python3-setuptools + +* Tue May 26 2020 Miro Hrončok - 0.5-4 +- Rebuilt for Python 3.9 + +* Tue Jan 28 2020 Fedora Release Engineering - 0.5-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild + +* Mon Jan 27 2020 Rob Crittenden - 0.5-2 +- Rebuild + +* Thu Jan 2 2020 Rob Crittenden - 0.5-1 +- Update to upstream 0.5 + +* Mon Dec 2 2019 François Cami - 0.4-2 +- Create subpackage to split out core processing (#1771710) + +* Mon Dec 2 2019 François Cami - 0.4-1 +- Update to upstream 0.4 +- Change Source0 to something "spectool -g" can use. +- Correct URL (#1773512) +- Errors not translated to strings (#1752849) +- JSON output not indented by default (#1729043) +- Add dependencies to checks to avoid false-positives (#1727900) +- Verify expected DNS records (#1695125 + +* Thu Oct 03 2019 Miro Hrončok - 0.3-3 +- Rebuilt for Python 3.8.0rc1 (#1748018) + +* Mon Aug 19 2019 Miro Hrončok - 0.3-2 +- Rebuilt for Python 3.8 + +* Thu Jul 25 2019 François Cami - 0.3-1 +- Update to upstream 0.3 +- Add logrotate configs + depend on anacron and logrotate + +* Thu Jul 25 2019 François Cami - 0.2-6 +- Fix permissions + +* Thu Jul 25 2019 Fedora Release Engineering - 0.2-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild + +* Thu Jul 11 2019 François Cami - 0.2-4 +- Fix ipa-healthcheck.sh installation path (rhbz#1729188) +- Create and own log directory (rhbz#1729188) + +* Tue Apr 30 2019 François Cami - 0.2-3 +- Add python3-lib389 to BRs + +* Tue Apr 30 2019 François Cami - 0.2-2 +- Fix changelog + +* Thu Apr 25 2019 Rob Crittenden - 0.2-1 +- Update to upstream 0.2 + +* Thu Apr 4 2019 François Cami - 0.1-2 +- Explicitly list dependencies + +* Tue Apr 2 2019 François Cami - 0.1-1 +- Initial package import