move get_distribution_version() to basic.py

pull/7770/head
Ruggero Marchei 11 years ago
parent c53c6a507a
commit e3f5af377f

@ -142,6 +142,18 @@ def get_distribution():
distribution = None distribution = None
return distribution 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): def load_platform_subclass(cls, *args, **kwargs):
''' '''
used by modules like User to have different implementations based on detected platform. See User used by modules like User to have different implementations based on detected platform. See User

@ -39,20 +39,8 @@ EXAMPLES = '''
- hostname: name=web01 - hostname: name=web01
''' '''
import platform # import module snippets
from ansible.module_utils.basic import *
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
class UnimplementedStrategy(object): class UnimplementedStrategy(object):
@ -283,6 +271,9 @@ class FedoraStrategy(GenericStrategy):
self.module.fail_json(msg="Command failed rc=%d, out=%s, err=%s" % self.module.fail_json(msg="Command failed rc=%d, out=%s, err=%s" %
(rc, out, err)) (rc, out, err))
# ===========================================
class FedoraHostname(Hostname): class FedoraHostname(Hostname):
platform = 'Linux' platform = 'Linux'
distribution = 'Fedora' distribution = 'Fedora'
@ -380,6 +371,4 @@ def main():
module.exit_json(changed=changed, name=name) module.exit_json(changed=changed, name=name)
# import module snippets
from ansible.module_utils.basic import *
main() main()

Loading…
Cancel
Save