Support for amazon linux distribution facts.

This commit is contained in:
James Martin 2013-02-13 13:28:50 -05:00 committed by Michael DeHaan
parent 0cd0a7fda3
commit 5646bc278b
2 changed files with 9 additions and 1 deletions

View file

@ -97,6 +97,9 @@ def get_distribution():
if platform.system() == 'Linux': if platform.system() == 'Linux':
try: try:
distribution = platform.linux_distribution()[0].capitalize() distribution = platform.linux_distribution()[0].capitalize()
if distribution == 'NA':
if os.path.is_file('/etc/system-release'):
distribution = 'Amazon'
except: except:
# FIXME: MethodMissing, I assume? # FIXME: MethodMissing, I assume?
distribution = platform.dist()[0].capitalize() distribution = platform.dist()[0].capitalize()

View file

@ -76,7 +76,8 @@ class Facts(object):
# For the most part, we assume that platform.dist() will tell the truth. # For the most part, we assume that platform.dist() will tell the truth.
# This is the fallback to handle unknowns or exceptions # This is the fallback to handle unknowns or exceptions
OSDIST_DICT = { '/etc/redhat-release': 'RedHat', OSDIST_DICT = { '/etc/redhat-release': 'RedHat',
'/etc/vmware-release': 'VMwareESX' } '/etc/vmware-release': 'VMwareESX',
'/etc/system-release': 'Amazon' }
SELINUX_MODE_DICT = { 1: 'enforcing', 0: 'permissive', -1: 'disabled' } SELINUX_MODE_DICT = { 1: 'enforcing', 0: 'permissive', -1: 'disabled' }
# A list of dicts. If there is a platform with more than one # A list of dicts. If there is a platform with more than one
@ -132,6 +133,10 @@ class Facts(object):
if os.path.exists(path): if os.path.exists(path):
if self.facts['distribution'] == 'Fedora': if self.facts['distribution'] == 'Fedora':
pass pass
elif name == 'Amazon':
self.facts['distribution'] = 'Amazon'
data = get_file_content(path)
self.facts['distribution_version'] = data.split()[-1]
elif name == 'RedHat': elif name == 'RedHat':
data = get_file_content(path) data = get_file_content(path)
if 'Red Hat' in data: if 'Red Hat' in data: