Skip to content

Commit 86b541c

Browse files
authored
Add cluster service, role, role group modules (#220)
* Add service module * Add service_info module * Add service_types_info module * Add service_config_info module * Add service_config module * Add service_role module * Add service_role_info module * Add service_role_config module * Add service_role_config_info module * Add service_role_config_group module * Add service_role_config_group_info module * Add service_role_config_group_config module * Add service_role_config_group_config_info module * Strip trailing forward slash and whitespace from the endpoint parameter * Add HTTP proxy parameter and user agent header to common API object * Update argument_spec signatures * Add service, role output filtering * Update API error handling messages * Add wait_command for CM command polling * Add function for parameter change sets * Add cloudera.css to docsbuild and add doc format Signed-off-by: Webster Mudge <[email protected]>
1 parent 49ba400 commit 86b541c

37 files changed

+7692
-58
lines changed

docsbuild/cloudera.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* Copyright 2024 Cloudera, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+

plugins/doc_fragments/cm_options.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,14 @@ class ModuleDocFragment(object):
9191
type: str
9292
required: False
9393
default: ClouderaFoundry
94+
aliases:
95+
- user_agent
96+
proxy_server:
97+
description:
98+
- Set the HTTP/S proxy server when interacting with the CM API endpoint.
99+
type: str
100+
required: False
101+
aliases:
102+
- proxy
103+
- http_proxy
94104
"""

plugins/doc_fragments/message.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
# Copyright 2024 Cloudera, Inc. All Rights Reserved.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
class ModuleDocFragment(object):
19+
DOCUMENTATION = r'''
20+
options:
21+
message:
22+
description:
23+
- Message to log for any changes to the entity.
24+
type: str
25+
required: False
26+
default: "Managed by Ansible"
27+
aliases:
28+
- msg
29+
'''

plugins/doc_fragments/purge.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
# Copyright 2024 Cloudera, Inc. All Rights Reserved.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
class ModuleDocFragment(object):
19+
DOCUMENTATION = r'''
20+
options:
21+
purge:
22+
description:
23+
- Set all parameters to either their default or declared values.
24+
type: bool
25+
required: False
26+
default: False
27+
'''

plugins/lookup/cm_service.py

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from __future__ import (absolute_import, division, print_function)
15+
from __future__ import absolute_import, division, print_function
16+
1617
__metaclass__ = type
1718

18-
DOCUMENTATION = '''
19+
DOCUMENTATION = """
1920
lookup: cm_service
2021
author: Webster Mudge (@wmudge) <[email protected]>
2122
short_description: Get the details for a service on a CDP Datahub cluster
@@ -83,35 +84,46 @@
8384
description: Value to return if no service is found on the cluster.
8485
type: any
8586
version:
86-
description: Version number of the Cloudera Manager API.
87+
description: Version of the Cloudera Manager API.
8788
type: string
88-
default: v40
8989
agent_header:
9090
description: Header string to identify the connection.
9191
type: string
9292
default: cm_service
9393
notes:
9494
- Requires C(cm_client).
95-
'''
95+
"""
9696

97-
from ansible_collections.cloudera.cluster.plugins.module_utils.cm_controller_utils import ClouderaManagerLookupBase
97+
from ansible_collections.cloudera.cluster.plugins.module_utils.cm_controller_utils import (
98+
ClouderaManagerLookupBase,
99+
)
98100

99101

100102
class LookupModule(ClouderaManagerLookupBase):
101103
def run(self, terms, variables=None, **kwargs):
102104
self.set_options(var_options=variables, direct=kwargs)
103-
105+
104106
self.initialize_client()
105-
all_services = {service['type']:service for service in self.get("%s/clusters/%s/services" % (self.get_option('version'), self.get_option('cluster')))}
106-
107+
all_services = {
108+
service["type"]: service
109+
for service in self.get(
110+
"/%s/clusters/%s/services"
111+
% (self.get_option("version"), self.get_option("cluster"))
112+
)
113+
}
114+
107115
results = []
108116
for term in LookupModule._flatten(terms):
109117
if term in all_services:
110-
results.append(all_services[term] if self.get_option('detailed') else all_services[term]['name'])
118+
results.append(
119+
all_services[term]
120+
if self.get_option("detailed")
121+
else all_services[term]["name"]
122+
)
111123
else:
112-
if self.get_option('default') is not None:
113-
results.append(self.get_option('default'))
114-
elif self.get_option('detailed'):
124+
if self.get_option("default") is not None:
125+
results.append(self.get_option("default"))
126+
elif self.get_option("detailed"):
115127
results.append({})
116128
else:
117129
results.append("")

plugins/module_utils/cm_controller_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def initialize_client(self):
6666

6767
# If provided a CM API endpoint URL, use it directly
6868
if self.get_option("endpoint"):
69-
config.host = self.get_option("endpoint")
69+
config.host = str(self.get_option("endpoint")).strip("/ ")
7070
# Otherwise, run discovery on missing parts
7171
else:
7272
config.host = self._discover_endpoint(config)

0 commit comments

Comments
 (0)