Skip to content

Commit

Permalink
Fix version comparison (#337)
Browse files Browse the repository at this point in the history
fix #334

alternative implementarion for #335
  • Loading branch information
rochacbruno authored Nov 17, 2023
1 parent faae504 commit 19bc192
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions plugins/module_utils/ah_api_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import time

from ansible.module_utils.basic import AnsibleModule, env_fallback
from ansible.module_utils.compat.version import LooseVersion as Version
from ansible.module_utils._text import to_bytes, to_text

from ansible.module_utils.six.moves.urllib.parse import urlparse, urlencode
Expand Down Expand Up @@ -485,9 +486,9 @@ def exit_json(self, **kwargs):
def get_server_version(self):
"""Return the automation hub/galaxy server version.
:return: the server version ("4.2.5" for example) or an empty string if
:return: the server Version("4.2.5") for example or Version("0") if
that information is not available.
:rtype: str
:rtype: Version
"""
url = self._build_url(self.galaxy_path_prefix)
try:
Expand All @@ -501,4 +502,6 @@ def get_server_version(self):
else:
fail_msg = "Unable to get server version: {code}".format(code=response["status_code"])
self.fail_json(msg=fail_msg)
return response["json"]["server_version"].replace('dev', '') if "server_version" in response["json"] else ""
return Version(
response["json"]["server_version"].replace('dev', '') if "server_version" in response["json"] else "0"
)

0 comments on commit 19bc192

Please sign in to comment.