diff --git a/plugins/module_utils/ah_api_module.py b/plugins/module_utils/ah_api_module.py index 409c7e98..4ce63739 100644 --- a/plugins/module_utils/ah_api_module.py +++ b/plugins/module_utils/ah_api_module.py @@ -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 @@ -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: @@ -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" + )