コード例 #1
0
ファイル: sys_info.py プロジェクト: goneri/ansible.community
def get_distribution_codename():
    '''
    Return the code name for this Linux Distribution

    :rtype: NativeString or None
    :returns: A string representation of the distribution's codename or None if not a Linux distro
    '''
    codename = None
    if platform.system() == 'Linux':
        # Until this gets merged and we update our bundled copy of distro:
        # https://github.com/nir0s/distro/pull/230
        # Fixes Fedora 28+ not having a code name and Ubuntu Xenial Xerus needing to be "xenial"
        os_release_info = distro.os_release_info()
        codename = os_release_info.get('version_codename')

        if codename is None:
            codename = os_release_info.get('ubuntu_codename')

        if codename is None and distro.id() == 'ubuntu':
            lsb_release_info = distro.lsb_release_info()
            codename = lsb_release_info.get('codename')

        if codename is None:
            codename = distro.codename()
            if codename == u'':
                codename = None

    return codename
コード例 #2
0
        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()
if release:
    output['platform.release'] = release