Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cluster service and related resource modules #220

Merged
merged 36 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
d5b8760
Add cluster_service_info module
wmudge May 6, 2024
4996655
Add cluster_service_config_info module
wmudge May 6, 2024
6f23720
Add test for cluster_service_config_info
wmudge May 6, 2024
97713b2
Strip trailing forward slash and whitespace from the endpoint parameter
wmudge May 6, 2024
aabe5cb
Add cluster_service_types_info module
wmudge May 6, 2024
874ebfd
Add tests for cluster_service_info module
wmudge May 6, 2024
94dfbe1
* Add HTTP proxy parameter and user agent header
wmudge May 6, 2024
6036d2e
* Update cluster_service_type_info module with try/except on invalid …
wmudge May 6, 2024
477c987
Add mutation parameters
wmudge May 6, 2024
be0849a
Add cluster_service module
wmudge May 6, 2024
577018f
Add cluster_service_config module
wmudge May 6, 2024
4a6a851
Move service output filtering to cm_utils and fix parameter names
wmudge May 6, 2024
ec8693f
* Add service output filtering
wmudge May 6, 2024
18f9888
Add cluster_service_role_info module and test
wmudge May 6, 2024
d0596d6
Add purge doc_fragment
wmudge May 6, 2024
a0b39f7
* Update output filtering to handle role and service
wmudge May 6, 2024
521a033
Add service_role module and tests
wmudge May 6, 2024
e05d13a
Add service_role_config module and tests
wmudge May 6, 2024
01bee5b
Add service_role_config_info module and tests
wmudge May 6, 2024
a368643
Add cloudera.css to docsbuild and add doc format
wmudge May 6, 2024
c661ec8
Update service, role, and role config group parsers to simplify refer…
wmudge May 6, 2024
09937a8
Add service_role_config_group_info module and tests
wmudge May 6, 2024
eb3d19f
Add service_role_config_group_config module and tests
wmudge May 6, 2024
d851222
Add service_role_config_group_config_info module and tests
wmudge May 6, 2024
c3cda01
Add service_role_config_group module and tests
wmudge May 6, 2024
19613d7
Update call_api datatype test
wmudge May 6, 2024
3948d24
Update to use CM_ENDPOINT
wmudge May 6, 2024
983d531
Inline commands for stopping a role
wmudge May 6, 2024
3ad6f59
Add missing 'role' parameter in basic test
wmudge May 6, 2024
a3ff5e1
Remove invalid test
wmudge May 6, 2024
39d0b4c
Update to use correct module under test (updated tests TBD)
wmudge May 6, 2024
a8ae052
Add missing parameter in regex and missing role parameter
wmudge May 6, 2024
b556859
Comment out check mode in tests
wmudge May 6, 2024
cfa4704
Formatting
wmudge May 6, 2024
2fb70dd
Add parameters into basic spec checks
wmudge May 8, 2024
6fb7766
Update tests to include role parameter
wmudge May 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions docsbuild/cloudera.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Copyright 2024 Cloudera, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

10 changes: 10 additions & 0 deletions plugins/doc_fragments/cm_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,14 @@ class ModuleDocFragment(object):
type: str
required: False
default: ClouderaFoundry
aliases:
- user_agent
proxy_server:
description:
- Set the HTTP/S proxy server when interacting with the CM API endpoint.
type: str
required: False
aliases:
- proxy
- http_proxy
"""
29 changes: 29 additions & 0 deletions plugins/doc_fragments/message.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright 2024 Cloudera, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

class ModuleDocFragment(object):
DOCUMENTATION = r'''
options:
message:
description:
- Message to log for any changes to the entity.
type: str
required: False
default: "Managed by Ansible"
aliases:
- msg
'''
27 changes: 27 additions & 0 deletions plugins/doc_fragments/purge.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright 2024 Cloudera, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

class ModuleDocFragment(object):
DOCUMENTATION = r'''
options:
purge:
description:
- Set all parameters to either their default or declared values.
type: bool
required: False
default: False
'''
38 changes: 25 additions & 13 deletions plugins/lookup/cm_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import (absolute_import, division, print_function)
from __future__ import absolute_import, division, print_function

__metaclass__ = type

DOCUMENTATION = '''
DOCUMENTATION = """
lookup: cm_service
author: Webster Mudge (@wmudge) <wmudge@cloudera.com>
short_description: Get the details for a service on a CDP Datahub cluster
Expand Down Expand Up @@ -83,35 +84,46 @@
description: Value to return if no service is found on the cluster.
type: any
version:
description: Version number of the Cloudera Manager API.
description: Version of the Cloudera Manager API.
type: string
default: v40
agent_header:
description: Header string to identify the connection.
type: string
default: cm_service
notes:
- Requires C(cm_client).
'''
"""

from ansible_collections.cloudera.cluster.plugins.module_utils.cm_controller_utils import ClouderaManagerLookupBase
from ansible_collections.cloudera.cluster.plugins.module_utils.cm_controller_utils import (
ClouderaManagerLookupBase,
)


class LookupModule(ClouderaManagerLookupBase):
def run(self, terms, variables=None, **kwargs):
self.set_options(var_options=variables, direct=kwargs)

self.initialize_client()
all_services = {service['type']:service for service in self.get("%s/clusters/%s/services" % (self.get_option('version'), self.get_option('cluster')))}

all_services = {
service["type"]: service
for service in self.get(
"/%s/clusters/%s/services"
% (self.get_option("version"), self.get_option("cluster"))
)
}

results = []
for term in LookupModule._flatten(terms):
if term in all_services:
results.append(all_services[term] if self.get_option('detailed') else all_services[term]['name'])
results.append(
all_services[term]
if self.get_option("detailed")
else all_services[term]["name"]
)
else:
if self.get_option('default') is not None:
results.append(self.get_option('default'))
elif self.get_option('detailed'):
if self.get_option("default") is not None:
results.append(self.get_option("default"))
elif self.get_option("detailed"):
results.append({})
else:
results.append("")
Expand Down
2 changes: 1 addition & 1 deletion plugins/module_utils/cm_controller_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def initialize_client(self):

# If provided a CM API endpoint URL, use it directly
if self.get_option("endpoint"):
config.host = self.get_option("endpoint")
config.host = str(self.get_option("endpoint")).strip("/ ")
# Otherwise, run discovery on missing parts
else:
config.host = self._discover_endpoint(config)
Expand Down
Loading
Loading