mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #8311 from neersighted/wrap_distroversion
Wrap get_distribution_version() in the hostname module
This commit is contained in:
commit
6300ded89c
1 changed files with 14 additions and 2 deletions
|
@ -45,6 +45,18 @@ from distutils.version import LooseVersion
|
|||
from ansible.module_utils.basic import *
|
||||
|
||||
|
||||
# wrap get_distribution_version in case it returns a string
|
||||
def _get_distribution_version():
|
||||
distribution_version = get_distribution_version()
|
||||
|
||||
if type(distribution_version) is str:
|
||||
distribution_version = 0
|
||||
elif type(distribution_version) is None:
|
||||
distribution_version = 0
|
||||
|
||||
return distribution_version
|
||||
|
||||
|
||||
class UnimplementedStrategy(object):
|
||||
def __init__(self, module):
|
||||
self.module = module
|
||||
|
@ -299,7 +311,7 @@ class RedHat5Hostname(Hostname):
|
|||
class RedHatServerHostname(Hostname):
|
||||
platform = 'Linux'
|
||||
distribution = 'Red hat enterprise linux server'
|
||||
distribution_version = get_distribution_version()
|
||||
distribution_version = _get_distribution_version()
|
||||
if distribution_version and LooseVersion(distribution_version) >= LooseVersion("7"):
|
||||
strategy_class = FedoraStrategy
|
||||
else:
|
||||
|
@ -308,7 +320,7 @@ class RedHatServerHostname(Hostname):
|
|||
class RedHatWorkstationHostname(Hostname):
|
||||
platform = 'Linux'
|
||||
distribution = 'Red hat enterprise linux workstation'
|
||||
distribution_version = get_distribution_version()
|
||||
distribution_version = _get_distribution_version()
|
||||
if distribution_version and LooseVersion(distribution_version) >= LooseVersion("7"):
|
||||
strategy_class = FedoraStrategy
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue