move get_distribution_version() to basic.py

This commit is contained in:
Ruggero Marchei 2014-06-16 15:06:50 +02:00
parent c53c6a507a
commit e3f5af377f
2 changed files with 17 additions and 16 deletions

View file

@ -142,6 +142,18 @@ def get_distribution():
distribution = None
return distribution
def get_distribution_version():
''' return the distribution version '''
if platform.system() == 'Linux':
try:
distribution_version = platform.linux_distribution()[1]
except:
# FIXME: MethodMissing, I assume?
distribution_version = platform.dist()[1]
else:
distribution_version = None
return distribution_version
def load_platform_subclass(cls, *args, **kwargs):
'''
used by modules like User to have different implementations based on detected platform. See User

21
library/system/hostname Normal file → Executable file
View file

@ -39,20 +39,8 @@ EXAMPLES = '''
- hostname: name=web01
'''
import platform
def get_distribution_version():
''' return the distribution version '''
if platform.system() == 'Linux':
try:
distribution_version = platform.linux_distribution()[1]
except:
# FIXME: MethodMissing, I assume?
distribution_version = platform.dist()[1]
else:
distribution_version = None
return distribution_version
# import module snippets
from ansible.module_utils.basic import *
class UnimplementedStrategy(object):
@ -283,6 +271,9 @@ class FedoraStrategy(GenericStrategy):
self.module.fail_json(msg="Command failed rc=%d, out=%s, err=%s" %
(rc, out, err))
# ===========================================
class FedoraHostname(Hostname):
platform = 'Linux'
distribution = 'Fedora'
@ -380,6 +371,4 @@ def main():
module.exit_json(changed=changed, name=name)
# import module snippets
from ansible.module_utils.basic import *
main()