Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 11 additions & 1 deletion plugins/lookup/supported.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@
- cloudera_manager
- cloudera_runtime
- cloudera_data_services
raw_filters:
description:
- Additional raw filters to add to the support matrix URL.
- Each filter will be appended to the URL, delimited by colons (C(;)).
type: list
elements: str
required: false
timeout:
description: Query timeout (seconds)
type: int
Expand Down Expand Up @@ -97,8 +104,11 @@ def run(self, terms, variables=None, **kwargs):
product = self.get_option("product")
version = self.get_option("version")
timeout = self.get_option("timeout")
raw_filters = self.get_option("raw_filters")
if raw_filters is None:
raw_filters = []

matrix_url, filters = support_matrix_url({product: version})
matrix_url, filters = support_matrix_url({product: version}, raw_filters)

display.v(f"[DEBUG] Support Matrix URL: {matrix_url}")

Expand Down
9 changes: 8 additions & 1 deletion plugins/module_utils/cldr_supported.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
}


def support_matrix_url(product_versions: dict[str, str]) -> Tuple[str, dict[str, str]]:
def support_matrix_url(
product_versions: dict[str, str],
raw_filters: list[str] = [],
) -> Tuple[str, dict[str, str]]:
"""Construct the URL to the Support Matrix server.

Args:
Expand Down Expand Up @@ -59,6 +62,10 @@ def support_matrix_url(product_versions: dict[str, str]) -> Tuple[str, dict[str,
product_condition = f"PRODUCT={','.join(products)}"
conditions.append(product_condition)

# Example of additional filters
# ?condition=PRODUCT=CDP%20Private%20Cloud%20Base-7.1.9%20SP1,Cloudera%20Manager-7.13.1;OPERATING_SYSTEM=RHEL-9.2;
conditions.extend(raw_filters)

if conditions:
# Add trailing semicolon as shown in the curl example
# Don't URL encode the entire condition string, only spaces are encoded
Expand Down
24 changes: 22 additions & 2 deletions plugins/modules/supported.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@
- Mutually exclusive with the O(cloudera_manager) and O(cloudera_runtime) parameters.
type: str
required: false
raw_filters:
description:
- Additional raw filters to add to the support matrix URL.
- Each filter will be appended to the URL, delimited by colons (C(;)).
type: list
elements: str
required: false
default: []
timeout:
description:
- HTTP request timeout in seconds.
Expand Down Expand Up @@ -72,6 +80,13 @@
cloudera.exe.supported:
cloudera_data_services: "1.5.4"
register: ds_support

- name: Get support matrix for Cloudera Manager version and OS
cloudera.exe.supported:
cloudera_manager: "7.13.1"
raw_filters:
- OPERATING_SYSTEMS=RHEL-9.2
register: ds_support
"""

RETURN = r"""
Expand Down Expand Up @@ -302,7 +317,8 @@ def __init__(self, module):
if version:
self.product_versions[param_name] = version

self.timeout = module.params.get("timeout", 30)
self.raw_filters = module.params.get("raw_filters")
self.timeout = module.params.get("timeout")

# Initialize return values
self.support_matrix_data = {}
Expand All @@ -318,7 +334,10 @@ def process(self):

try:
# Build the API URL
api_url, self.filters = support_matrix_url(self.product_versions)
api_url, self.filters = support_matrix_url(
self.product_versions,
raw_filters=self.raw_filters,
)

# Prepare headers
headers = {
Expand Down Expand Up @@ -387,6 +406,7 @@ def main():
cloudera_manager=dict(type="str", required=False),
cloudera_runtime=dict(type="str", required=False),
cloudera_data_services=dict(type="str", required=False),
raw_filters=dict(type="list", elements="str", required=False, default=[]),
timeout=dict(type="int", default=30),
),
mutually_exclusive=[
Expand Down
Loading