summaryrefslogtreecommitdiffstats
path: root/roles/openshift_health_checker/openshift_checks/package_availability.py
blob: 090e438ff602a36a225a7c681f51290264c60ffe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
"""Check that required RPM packages are available."""

from openshift_checks import OpenShiftCheck
from openshift_checks.mixins import NotContainerizedMixin


class PackageAvailability(NotContainerizedMixin, OpenShiftCheck):
    """Check that required RPM packages are available."""

    name = "package_availability"
    tags = ["preflight"]

    def is_active(self):
        """Run only when yum is the package manager as the code is specific to it."""
        return super(PackageAvailability, self).is_active() and self.get_var("ansible_pkg_mgr") == "yum"

    def run(self):
        rpm_prefix = self.get_var("openshift", "common", "service_type")
        group_names = self.get_var("group_names", default=[])

        packages = set()

        if "oo_masters_to_config" in group_names:
            packages.update(self.master_packages(rpm_prefix))
        if "oo_nodes_to_config" in group_names:
            packages.update(self.node_packages(rpm_prefix))

        args = {"packages": sorted(set(packages))}
        return self.execute_module_with_retries("check_yum_update", args)

    @staticmethod
    def master_packages(rpm_prefix):
        """Return a list of RPMs that we expect a master install to have available."""
        return [
            "{rpm_prefix}".format(rpm_prefix=rpm_prefix),
            "{rpm_prefix}-clients".format(rpm_prefix=rpm_prefix),
            "{rpm_prefix}-master".format(rpm_prefix=rpm_prefix),
            "bash-completion",
            "cockpit-bridge",
            "cockpit-docker",
            "cockpit-system",
            "cockpit-ws",
            "etcd",
            "httpd-tools",
        ]

    @staticmethod
    def node_packages(rpm_prefix):
        """Return a list of RPMs that we expect a node install to have available."""
        return [
            "{rpm_prefix}".format(rpm_prefix=rpm_prefix),
            "{rpm_prefix}-node".format(rpm_prefix=rpm_prefix),
            "{rpm_prefix}-sdn-ovs".format(rpm_prefix=rpm_prefix),
            "bind",
            "ceph-common",
            "dnsmasq",
            "docker",
            "firewalld",
            "flannel",
            "glusterfs-fuse",
            "iptables-services",
            "iptables",
            "iscsi-initiator-utils",
            "libselinux-python",
            "nfs-utils",
            "ntp",
            "openssl",
            "pyparted",
            "python-httplib2",
            "PyYAML",
            "yum-utils",
        ]