| 1 |
# This code is part of Ansible, but is an independent component. |
| 2 |
# This particular file snippet, and this file snippet only, is BSD licensed. |
| 3 |
# Modules you write using this snippet, which is embedded dynamically by Ansible |
| 4 |
# still belong to the author of the module, and may assign their own license |
| 5 |
# to the complete work. |
| 6 |
# |
| 7 |
# (c) 2017 Red Hat Inc. |
| 8 |
# |
| 9 |
# Redistribution and use in source and binary forms, with or without modification, |
| 10 |
# are permitted provided that the following conditions are met: |
| 11 |
# |
| 12 |
# * Redistributions of source code must retain the above copyright |
| 13 |
# notice, this list of conditions and the following disclaimer. |
| 14 |
# * Redistributions in binary form must reproduce the above copyright notice, |
| 15 |
# this list of conditions and the following disclaimer in the documentation |
| 16 |
# and/or other materials provided with the distribution. |
| 17 |
# |
| 18 |
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 19 |
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 20 |
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 21 |
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 22 |
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 23 |
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 24 |
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 25 |
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE |
| 26 |
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 |
# |
| 28 |
from __future__ import annotations |
| 29 |
|
| 30 |
import typing as t |
| 31 |
|
| 32 |
from ansible.module_utils.facts.collector import BaseFactCollector |
| 33 |
|
| 34 |
from ansible.module_utils.facts.other.facter import FacterFactCollector |
| 35 |
from ansible.module_utils.facts.other.ohai import OhaiFactCollector |
| 36 |
|
| 37 |
from ansible.module_utils.facts.system.apparmor import ApparmorFactCollector |
| 38 |
from ansible.module_utils.facts.system.caps import SystemCapabilitiesFactCollector |
| 39 |
from ansible.module_utils.facts.system.chroot import ChrootFactCollector |
| 40 |
from ansible.module_utils.facts.system.cmdline import CmdLineFactCollector |
| 41 |
from ansible.module_utils.facts.system.distribution import DistributionFactCollector |
| 42 |
from ansible.module_utils.facts.system.date_time import DateTimeFactCollector |
| 43 |
from ansible.module_utils.facts.system.env import EnvFactCollector |
| 44 |
from ansible.module_utils.facts.system.dns import DnsFactCollector |
| 45 |
from ansible.module_utils.facts.system.fips import FipsFactCollector |
| 46 |
from ansible.module_utils.facts.system.loadavg import LoadAvgFactCollector |
| 47 |
from ansible.module_utils.facts.system.local import LocalFactCollector |
| 48 |
from ansible.module_utils.facts.system.lsb import LSBFactCollector |
| 49 |
from ansible.module_utils.facts.system.pkg_mgr import PkgMgrFactCollector |
| 50 |
from ansible.module_utils.facts.system.pkg_mgr import OpenBSDPkgMgrFactCollector |
| 51 |
from ansible.module_utils.facts.system.platform import PlatformFactCollector |
| 52 |
from ansible.module_utils.facts.system.python import PythonFactCollector |
| 53 |
from ansible.module_utils.facts.system.selinux import SelinuxFactCollector |
| 54 |
from ansible.module_utils.facts.system.service_mgr import ServiceMgrFactCollector |
| 55 |
from ansible.module_utils.facts.system.ssh_pub_keys import SshPubKeyFactCollector |
| 56 |
from ansible.module_utils.facts.system.systemd import SystemdFactCollector |
| 57 |
from ansible.module_utils.facts.system.user import UserFactCollector |
| 58 |
|
| 59 |
from ansible.module_utils.facts.hardware.base import HardwareCollector |
| 60 |
from ansible.module_utils.facts.hardware.aix import AIXHardwareCollector |
| 61 |
from ansible.module_utils.facts.hardware.darwin import DarwinHardwareCollector |
| 62 |
from ansible.module_utils.facts.hardware.dragonfly import DragonFlyHardwareCollector |
| 63 |
from ansible.module_utils.facts.hardware.freebsd import FreeBSDHardwareCollector |
| 64 |
from ansible.module_utils.facts.hardware.hpux import HPUXHardwareCollector |
| 65 |
from ansible.module_utils.facts.hardware.hurd import HurdHardwareCollector |
| 66 |
from ansible.module_utils.facts.hardware.linux import LinuxHardwareCollector |
| 67 |
from ansible.module_utils.facts.hardware.netbsd import NetBSDHardwareCollector |
| 68 |
from ansible.module_utils.facts.hardware.openbsd import OpenBSDHardwareCollector |
| 69 |
from ansible.module_utils.facts.hardware.sunos import SunOSHardwareCollector |
| 70 |
|
| 71 |
from ansible.module_utils.facts.network.base import NetworkCollector |
| 72 |
from ansible.module_utils.facts.network.aix import AIXNetworkCollector |
| 73 |
from ansible.module_utils.facts.network.darwin import DarwinNetworkCollector |
| 74 |
from ansible.module_utils.facts.network.dragonfly import DragonFlyNetworkCollector |
| 75 |
from ansible.module_utils.facts.network.fc_wwn import FcWwnInitiatorFactCollector |
| 76 |
from ansible.module_utils.facts.network.freebsd import FreeBSDNetworkCollector |
| 77 |
from ansible.module_utils.facts.network.hpux import HPUXNetworkCollector |
| 78 |
from ansible.module_utils.facts.network.hurd import HurdNetworkCollector |
| 79 |
from ansible.module_utils.facts.network.linux import LinuxNetworkCollector |
| 80 |
from ansible.module_utils.facts.network.iscsi import IscsiInitiatorNetworkCollector |
| 81 |
from ansible.module_utils.facts.network.nvme import NvmeInitiatorNetworkCollector |
| 82 |
from ansible.module_utils.facts.network.netbsd import NetBSDNetworkCollector |
| 83 |
from ansible.module_utils.facts.network.openbsd import OpenBSDNetworkCollector |
| 84 |
from ansible.module_utils.facts.network.sunos import SunOSNetworkCollector |
| 85 |
|
| 86 |
from ansible.module_utils.facts.virtual.base import VirtualCollector |
| 87 |
from ansible.module_utils.facts.virtual.dragonfly import DragonFlyVirtualCollector |
| 88 |
from ansible.module_utils.facts.virtual.freebsd import FreeBSDVirtualCollector |
| 89 |
from ansible.module_utils.facts.virtual.hpux import HPUXVirtualCollector |
| 90 |
from ansible.module_utils.facts.virtual.linux import LinuxVirtualCollector |
| 91 |
from ansible.module_utils.facts.virtual.netbsd import NetBSDVirtualCollector |
| 92 |
from ansible.module_utils.facts.virtual.openbsd import OpenBSDVirtualCollector |
| 93 |
from ansible.module_utils.facts.virtual.sunos import SunOSVirtualCollector |
| 94 |
|
| 95 |
# these should always be first due to most other facts depending on them |
| 96 |
_base = [ |
| 97 |
PlatformFactCollector, |
| 98 |
DistributionFactCollector, |
| 99 |
LSBFactCollector |
| 100 |
] # type: t.List[t.Type[BaseFactCollector]] |
| 101 |
|
| 102 |
# These restrict what is possible in others |
| 103 |
_restrictive = [ |
| 104 |
SelinuxFactCollector, |
| 105 |
ApparmorFactCollector, |
| 106 |
ChrootFactCollector, |
| 107 |
FipsFactCollector |
| 108 |
] # type: t.List[t.Type[BaseFactCollector]] |
| 109 |
|
| 110 |
# general info, not required but probably useful for other facts |
| 111 |
_general = [ |
| 112 |
PythonFactCollector, |
| 113 |
SystemCapabilitiesFactCollector, |
| 114 |
PkgMgrFactCollector, |
| 115 |
OpenBSDPkgMgrFactCollector, |
| 116 |
ServiceMgrFactCollector, |
| 117 |
CmdLineFactCollector, |
| 118 |
DateTimeFactCollector, |
| 119 |
EnvFactCollector, |
| 120 |
LoadAvgFactCollector, |
| 121 |
SshPubKeyFactCollector, |
| 122 |
UserFactCollector, |
| 123 |
SystemdFactCollector |
| 124 |
] # type: t.List[t.Type[BaseFactCollector]] |
| 125 |
|
| 126 |
# virtual, this might also limit hardware/networking |
| 127 |
_virtual = [ |
| 128 |
VirtualCollector, |
| 129 |
DragonFlyVirtualCollector, |
| 130 |
FreeBSDVirtualCollector, |
| 131 |
LinuxVirtualCollector, |
| 132 |
OpenBSDVirtualCollector, |
| 133 |
NetBSDVirtualCollector, |
| 134 |
SunOSVirtualCollector, |
| 135 |
HPUXVirtualCollector |
| 136 |
] # type: t.List[t.Type[BaseFactCollector]] |
| 137 |
|
| 138 |
_hardware = [ |
| 139 |
HardwareCollector, |
| 140 |
AIXHardwareCollector, |
| 141 |
DarwinHardwareCollector, |
| 142 |
DragonFlyHardwareCollector, |
| 143 |
FreeBSDHardwareCollector, |
| 144 |
HPUXHardwareCollector, |
| 145 |
HurdHardwareCollector, |
| 146 |
LinuxHardwareCollector, |
| 147 |
NetBSDHardwareCollector, |
| 148 |
OpenBSDHardwareCollector, |
| 149 |
SunOSHardwareCollector |
| 150 |
] # type: t.List[t.Type[BaseFactCollector]] |
| 151 |
|
| 152 |
_network = [ |
| 153 |
DnsFactCollector, |
| 154 |
FcWwnInitiatorFactCollector, |
| 155 |
NetworkCollector, |
| 156 |
AIXNetworkCollector, |
| 157 |
DarwinNetworkCollector, |
| 158 |
DragonFlyNetworkCollector, |
| 159 |
FreeBSDNetworkCollector, |
| 160 |
HPUXNetworkCollector, |
| 161 |
HurdNetworkCollector, |
| 162 |
IscsiInitiatorNetworkCollector, |
| 163 |
NvmeInitiatorNetworkCollector, |
| 164 |
LinuxNetworkCollector, |
| 165 |
NetBSDNetworkCollector, |
| 166 |
OpenBSDNetworkCollector, |
| 167 |
SunOSNetworkCollector |
| 168 |
] # type: t.List[t.Type[BaseFactCollector]] |
| 169 |
|
| 170 |
# other fact sources |
| 171 |
_extra_facts = [ |
| 172 |
LocalFactCollector, |
| 173 |
FacterFactCollector, |
| 174 |
OhaiFactCollector |
| 175 |
] # type: t.List[t.Type[BaseFactCollector]] |
| 176 |
|
| 177 |
# TODO: make config driven |
| 178 |
collectors = _base + _restrictive + _general + _virtual + _hardware + _network + _extra_facts |