1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Replace LooseVersion comparison with int/float comparison. Fixes #35435 (#35519)

This commit is contained in:
Matt Martz 2018-01-30 15:27:22 -06:00 committed by GitHub
parent fda09a75d3
commit c282e4e00f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View file

@ -39,7 +39,6 @@ EXAMPLES = '''
import os
import socket
import traceback
from distutils.version import LooseVersion
from ansible.module_utils.basic import (
AnsibleModule,
@ -567,10 +566,14 @@ class FedoraHostname(Hostname):
class SLESHostname(Hostname):
platform = 'Linux'
distribution = 'Suse linux enterprise server '
distribution_version = get_distribution_version()
if distribution_version and LooseVersion("10") <= LooseVersion(distribution_version) <= LooseVersion("12"):
strategy_class = SLESStrategy
else:
try:
distribution_version = get_distribution_version()
# cast to float may raise ValueError on non SLES, we use float for a little more safety over int
if distribution_version and 10 <= float(distribution_version) <= 12:
strategy_class = SLESStrategy
else:
raise ValueError()
except ValueError:
strategy_class = UnimplementedStrategy

View file

@ -5,4 +5,3 @@ lib/ansible/modules/cloud/webfaction/webfaction_domain.py
lib/ansible/modules/cloud/webfaction/webfaction_mailbox.py
lib/ansible/modules/cloud/webfaction/webfaction_site.py
lib/ansible/modules/packaging/os/yum_repository.py
lib/ansible/modules/system/hostname.py