mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Add pkg_mgr fact to setup
This should help facilitate playbook decision making that are not strictly distribution specific, but more package manager.
This commit is contained in:
parent
7df0e5259f
commit
94eb11a6d7
1 changed files with 11 additions and 0 deletions
|
@ -54,6 +54,10 @@ class Facts(object):
|
|||
'/etc/vmware-release': 'VMwareESX' }
|
||||
SELINUX_MODE_DICT = { 1: 'enforcing', 0: 'permissive', -1: 'disabled' }
|
||||
|
||||
PKG_MGR_DICT = { '/usr/bin/yum' : 'yum',
|
||||
'/usr/bin/apt-get' : 'apt',
|
||||
'/usr/bin/zypper' : 'zypper' }
|
||||
|
||||
def __init__(self):
|
||||
self.facts = {}
|
||||
self.get_platform_facts()
|
||||
|
@ -61,6 +65,7 @@ class Facts(object):
|
|||
self.get_cmdline()
|
||||
self.get_public_ssh_host_keys()
|
||||
self.get_selinux_facts()
|
||||
self.get_pkg_mgr_facts()
|
||||
|
||||
def populate(self):
|
||||
return self.facts
|
||||
|
@ -133,6 +138,12 @@ class Facts(object):
|
|||
else:
|
||||
self.facts['ssh_host_key_rsa_public'] = rsa.split()[1]
|
||||
|
||||
def get_pkg_mgr_facts(self):
|
||||
self.facts['pkg_mgr'] = 'unknown'
|
||||
for (path, name) in Facts.PKG_MGR_DICT.items():
|
||||
if os.path.exists(path):
|
||||
self.facts['pkg_mgr'] = name
|
||||
|
||||
def get_selinux_facts(self):
|
||||
if not HAVE_SELINUX:
|
||||
self.facts['selinux'] = False
|
||||
|
|
Loading…
Reference in a new issue