mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #1051 from sfromm/wile-e-coyote
Add pkg_mgr fact to setup (take 2)
This commit is contained in:
commit
5da4ab2d90
1 changed files with 14 additions and 0 deletions
|
@ -54,6 +54,13 @@ class Facts(object):
|
|||
'/etc/vmware-release': 'VMwareESX' }
|
||||
SELINUX_MODE_DICT = { 1: 'enforcing', 0: 'permissive', -1: 'disabled' }
|
||||
|
||||
# A list of dicts. If there is a platform with more than one
|
||||
# package manager, put the preferred one last. If there is an
|
||||
# ansible module, use that as the value for the 'name' key.
|
||||
PKG_MGRS = [ { 'path' : '/usr/bin/yum', 'name' : 'yum' },
|
||||
{ 'path' : '/usr/bin/apt-get', 'name' : 'apt' },
|
||||
{ 'path' : '/usr/bin/zypper', 'name' : 'zypper' } ]
|
||||
|
||||
def __init__(self):
|
||||
self.facts = {}
|
||||
self.get_platform_facts()
|
||||
|
@ -61,6 +68,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 +141,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 pkg in Facts.PKG_MGRS:
|
||||
if os.path.exists(pkg['path']):
|
||||
self.facts['pkg_mgr'] = pkg['name']
|
||||
|
||||
def get_selinux_facts(self):
|
||||
if not HAVE_SELINUX:
|
||||
self.facts['selinux'] = False
|
||||
|
|
Loading…
Reference in a new issue