Using "OtherLinux" in module_commons, cleander detection in setup.
This commit is contained in:
parent
5646bc278b
commit
7129a9e355
2 changed files with 23 additions and 22 deletions
|
@ -99,7 +99,7 @@ def get_distribution():
|
|||
distribution = platform.linux_distribution()[0].capitalize()
|
||||
if distribution == 'NA':
|
||||
if os.path.is_file('/etc/system-release'):
|
||||
distribution = 'Amazon'
|
||||
distribution = 'OtherLinux'
|
||||
except:
|
||||
# FIXME: MethodMissing, I assume?
|
||||
distribution = platform.dist()[0].capitalize()
|
||||
|
@ -108,7 +108,7 @@ def get_distribution():
|
|||
return distribution
|
||||
|
||||
def load_platform_subclass(cls, *args, **kwargs):
|
||||
'''
|
||||
'''
|
||||
used by modules like User to have different implementations based on detected platform. See User
|
||||
module for an example.
|
||||
'''
|
||||
|
@ -116,7 +116,7 @@ def load_platform_subclass(cls, *args, **kwargs):
|
|||
this_platform = get_platform()
|
||||
distribution = get_distribution()
|
||||
subclass = None
|
||||
|
||||
|
||||
# get the most specific superclass for this platform
|
||||
if distribution is not None:
|
||||
for sc in cls.__subclasses__():
|
||||
|
@ -174,7 +174,7 @@ class AnsibleModule(object):
|
|||
self._log_invocation()
|
||||
|
||||
def load_file_common_arguments(self, params):
|
||||
'''
|
||||
'''
|
||||
many modules deal with files, this encapsulates common
|
||||
options that the file module accepts such that it is directly
|
||||
available to all modules and they can share code.
|
||||
|
@ -194,7 +194,7 @@ class AnsibleModule(object):
|
|||
setype = params.get('setype', None)
|
||||
selevel = params.get('serange', 's0')
|
||||
secontext = [seuser, serole, setype]
|
||||
|
||||
|
||||
if self.selinux_mls_enabled():
|
||||
secontext.append(selevel)
|
||||
|
||||
|
@ -204,9 +204,9 @@ class AnsibleModule(object):
|
|||
secontext[i] = default_secontext[i]
|
||||
|
||||
return dict(
|
||||
path=path, mode=mode, owner=owner, group=group,
|
||||
path=path, mode=mode, owner=owner, group=group,
|
||||
seuser=seuser, serole=serole, setype=setype,
|
||||
selevel=selevel, secontext=secontext,
|
||||
selevel=selevel, secontext=secontext,
|
||||
)
|
||||
|
||||
|
||||
|
@ -274,11 +274,11 @@ class AnsibleModule(object):
|
|||
st = os.stat(filename)
|
||||
uid = st.st_uid
|
||||
gid = st.st_gid
|
||||
try:
|
||||
try:
|
||||
user = pwd.getpwuid(uid)[0]
|
||||
except KeyError:
|
||||
user = str(uid)
|
||||
try:
|
||||
try:
|
||||
group = grp.getgrgid(gid)[0]
|
||||
except KeyError:
|
||||
group = str(gid)
|
||||
|
@ -293,7 +293,7 @@ class AnsibleModule(object):
|
|||
def set_context_if_different(self, path, context, changed):
|
||||
|
||||
if not HAVE_SELINUX or not self.selinux_enabled():
|
||||
return changed
|
||||
return changed
|
||||
cur_context = self.selinux_context(path)
|
||||
new_context = list(cur_context)
|
||||
# Iterate over the current context instead of the
|
||||
|
@ -416,9 +416,9 @@ class AnsibleModule(object):
|
|||
return changed
|
||||
|
||||
def add_path_info(self, kwargs):
|
||||
'''
|
||||
'''
|
||||
for results that are files, supplement the info about the file
|
||||
in the return path with stats about the file path.
|
||||
in the return path with stats about the file path.
|
||||
'''
|
||||
|
||||
path = kwargs.get('path', kwargs.get('dest', None))
|
||||
|
@ -730,7 +730,7 @@ class AnsibleModule(object):
|
|||
shell=shell,
|
||||
close_fds=close_fds,
|
||||
stdin=st_in,
|
||||
stdout=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE)
|
||||
if data:
|
||||
cmd.stdin.write(data)
|
||||
|
|
|
@ -31,13 +31,13 @@ DOCUMENTATION = '''
|
|||
module: setup
|
||||
short_description: Gathers facts about remote hosts
|
||||
options: {}
|
||||
description:
|
||||
description:
|
||||
- This module is automatically called by playbooks to gather useful
|
||||
variables about remote hosts that can be used in playbooks. It can also be
|
||||
executed directly by C(/usr/bin/ansible) to check what variables are
|
||||
available to a host. Ansible provides many I(facts) about the system,
|
||||
automatically.
|
||||
notes:
|
||||
notes:
|
||||
- More ansible facts will be added with successive releases. If I(facter) or
|
||||
I(ohai) are installed, variables from these programs will also be snapshotted
|
||||
into the JSON file for usage in templating. These variables are prefixed
|
||||
|
@ -77,7 +77,7 @@ class Facts(object):
|
|||
# This is the fallback to handle unknowns or exceptions
|
||||
OSDIST_DICT = { '/etc/redhat-release': 'RedHat',
|
||||
'/etc/vmware-release': 'VMwareESX',
|
||||
'/etc/system-release': 'Amazon' }
|
||||
'/etc/system-release': 'OtherLinux' }
|
||||
SELINUX_MODE_DICT = { 1: 'enforcing', 0: 'permissive', -1: 'disabled' }
|
||||
|
||||
# A list of dicts. If there is a platform with more than one
|
||||
|
@ -86,7 +86,7 @@ class Facts(object):
|
|||
PKG_MGRS = [ { 'path' : '/usr/bin/yum', 'name' : 'yum' },
|
||||
{ 'path' : '/usr/bin/apt-get', 'name' : 'apt' },
|
||||
{ 'path' : '/usr/bin/zypper', 'name' : 'zypper' },
|
||||
{ 'path' : '/usr/bin/pacman', 'name' : 'pacman' },
|
||||
{ 'path' : '/usr/bin/pacman', 'name' : 'pacman' },
|
||||
{ 'path' : '/opt/local/bin/pkgin', 'name' : 'pkgin' } ]
|
||||
|
||||
def __init__(self):
|
||||
|
@ -133,10 +133,11 @@ class Facts(object):
|
|||
if os.path.exists(path):
|
||||
if self.facts['distribution'] == 'Fedora':
|
||||
pass
|
||||
elif name == 'Amazon':
|
||||
self.facts['distribution'] = 'Amazon'
|
||||
elif name == 'OtherLinux':
|
||||
data = get_file_content(path)
|
||||
self.facts['distribution_version'] = data.split()[-1]
|
||||
if 'Amazon' in data:
|
||||
self.facts['distribution'] = 'Amazon'
|
||||
self.facts['distribution_version'] = data.split()[-1]
|
||||
elif name == 'RedHat':
|
||||
data = get_file_content(path)
|
||||
if 'Red Hat' in data:
|
||||
|
@ -682,7 +683,7 @@ class LinuxNetwork(Network):
|
|||
continue
|
||||
rc, out, err = module.run_command(command[v])
|
||||
if not out:
|
||||
# v6 routing may result in
|
||||
# v6 routing may result in
|
||||
# RTNETLINK answers: Invalid argument
|
||||
continue
|
||||
words = out.split('\n')[0].split()
|
||||
|
@ -843,7 +844,7 @@ class LinuxVirtual(Virtual):
|
|||
except IOError:
|
||||
pass
|
||||
return
|
||||
|
||||
|
||||
if os.path.exists('/proc/vz'):
|
||||
self.facts['virtualization_type'] = 'openvz'
|
||||
if os.path.exists('/proc/bc'):
|
||||
|
|
Loading…
Reference in a new issue