Merge pull request #1051 from sfromm/wile-e-coyote

Add pkg_mgr fact to setup (take 2)
This commit is contained in:
Michael DeHaan 2012-09-17 16:59:12 -07:00
commit 5da4ab2d90

View file

@ -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