Пример #1
0
def get_distribution():
    '''
    :rtype: NativeString or None
    :returns: Name of the distribution the module is running on
    '''
    distribution = None

    if platform.system() == 'Linux':
        distribution = distro.name().capitalize()

        # FIXME: Would we need to normalize these if we used: id() instead of name()?
        distribution_words = distribution.split()
        if 'Amazon' in distribution_words:
            distribution = 'Amazon'
        elif not distribution:
            distribution = 'OtherLinux'

    return distribution
Пример #2
0
def get_distribution():
    '''
    Return the name of the distribution the module is running on

    :rtype: NativeString or None
    :returns: Name of the distribution the module is running on

    This function attempts to determine what Linux distribution the code is running on and return
    a string representing that value.  If the distribution cannot be determined, it returns
    ``OtherLinux``.  If not run on Linux it returns None.
    '''
    distribution = None

    if platform.system() == 'Linux':
        distribution = distro.name().capitalize()

        # FIXME: Would we need to normalize these if we used: id() instead of name()?
        distribution_words = distribution.split()
        if 'Amazon' in distribution_words:
            distribution = 'Amazon'
        elif not distribution:
            distribution = 'OtherLinux'

    return distribution
Пример #3
0
 def test_opensuse_leap_id(self):
     name = distro.name()
     if name == 'openSUSE Leap':
         id = distro.id()
         assert id == 'opensuse', "OpenSUSE Leap did not return 'opensuse' as id"
Пример #4
0
ansible_facts = {}
for fact in facts:
    try:
        ansible_facts[fact] = parsed['ansible_facts']['ansible_' + fact]
    except Exception:
        ansible_facts[fact] = "N/A"

nicename = ansible_facts['distribution'] + ' ' + ansible_facts[
    'distribution_version']

output = {
    'name': nicename,
    'distro': {
        'codename': distro.codename(),
        'id': distro.id(),
        'name': distro.name(),
        'version': distro.version(),
        'version_best': distro.version(best=True),
        'lsb_release_info': distro.lsb_release_info(),
        'os_release_info': distro.os_release_info(),
    },
    'input': fcont,
    'platform.dist': dist,
    'result': ansible_facts,
}

system = platform.system()
if system != 'Linux':
    output['platform.system'] = system

release = platform.release()