File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change 2929from time import sleep
3030from ansible .module_utils .basic import AnsibleModule
3131from ansible .module_utils .common .dict_transformations import recursive_diff
32- from ansible .module_utils .common .text .converters import to_text
32+ from ansible .module_utils .common .text .converters import to_native , to_text
3333from time import sleep
3434from cm_client import (
3535 ApiClient ,
@@ -434,6 +434,12 @@ def discover_endpoint(self, config):
434434 if not self .version :
435435 pre_versioned = urljoin (rendered_url , "/api/version" )
436436 versioned = rest .pool_manager .request ("GET" , pre_versioned , headers = headers )
437+ if versioned .status != 200 :
438+ self .module .fail_json (
439+ "Unable to retrieve API version" ,
440+ status = to_native (versioned .status ),
441+ reason = to_native (versioned .reason ),
442+ )
437443 self .version = versioned .data .decode ("utf-8" )
438444
439445 # Construct the discovered API endpoint
Original file line number Diff line number Diff line change 2323}
2424
2525DOCUMENTATION = r"""
26- ---
2726module: cm_endpoint_info
2827short_description: Discover the Cloudera Manager API endpoint
2928description:
3837"""
3938
4039EXAMPLES = r"""
41- ---
4240# This will first try 'http://example.cloudera.com:7180' and will
4341# follow any redirects
4442- name: Gather details using auto-discovery
5048"""
5149
5250RETURN = r"""
53- ---
5451endpoint:
55- description: The discovered Cloudera Manager API endpoint
52+ description: The discovered Cloudera Manager API endpoint, i.e. the base URL.
5653 type: str
5754 returned: always
5855"""
You can’t perform that action at this time.
0 commit comments