mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-22 22:11:44 -07:00
Fix pkg_mgr fact on OpenBSD (#30725)
* Fix pkg_mgr fact on OpenBSD Add a OpenBSDPkgMgrFactCollector that hardcodes pkg_mgr to 'openbsd_pkg'. The ansible collector will choose the OpenBSD collector if the system is OpenBSD and the 'Generic' one otherwise. This removes PkgMgrFactCollectors depenency on the 'system' fact being in collected_facts, which also avoids ordering issues (if the pkg mgr fact is collected before the system fact...) Fixes #30623
This commit is contained in:
parent
d122a693d1
commit
12404f470a
4 changed files with 73 additions and 9 deletions
|
@ -50,20 +50,28 @@ PKG_MGRS = [{'path': '/usr/bin/yum', 'name': 'yum'},
|
|||
]
|
||||
|
||||
|
||||
class OpenBSDPkgMgrFactCollector(BaseFactCollector):
|
||||
name = 'pkg_mgr'
|
||||
_fact_ids = set()
|
||||
_platform = 'OpenBSD'
|
||||
|
||||
def collect(self, module=None, collected_facts=None):
|
||||
facts_dict = {}
|
||||
|
||||
facts_dict['pkg_mgr'] = 'openbsd_pkg'
|
||||
return facts_dict
|
||||
|
||||
|
||||
# the fact ends up being 'pkg_mgr' so stick with that naming/spelling
|
||||
class PkgMgrFactCollector(BaseFactCollector):
|
||||
name = 'pkg_mgr'
|
||||
_fact_ids = set()
|
||||
_platform = 'Generic'
|
||||
|
||||
def collect(self, module=None, collected_facts=None):
|
||||
facts_dict = {}
|
||||
collected_facts = collected_facts or {}
|
||||
|
||||
pkg_mgr_name = None
|
||||
if collected_facts.get('system') == 'OpenBSD':
|
||||
facts_dict['pkg_mgr'] = 'openbsd_pkg'
|
||||
return facts_dict
|
||||
|
||||
pkg_mgr_name = 'unknown'
|
||||
for pkg in PKG_MGRS:
|
||||
if os.path.exists(pkg['path']):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue