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
9 changes: 6 additions & 3 deletions plugins/filter/core_exe.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# 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, annotations

__metaclass__ = type

Expand Down Expand Up @@ -60,13 +60,16 @@ def combine_onto(*terms, **kwargs):
return result


def cldr_version(version: str):
def cldr_version(*terms, **kwargs):
"""
Parse a Cloudera version string into its parts.
"""

if not terms:
return {}

try:
parsed_version = ClouderaVersion(version)
parsed_version = ClouderaVersion(terms[0])
return dict(
major=parsed_version.major,
minor=parsed_version.minor,
Expand Down
8 changes: 6 additions & 2 deletions plugins/module_utils/cldr_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import absolute_import, division, print_function, annotations

__metaclass__ = type

import re

from ansible.module_utils.compat.version import LooseVersion, Version
Expand Down Expand Up @@ -60,7 +64,7 @@ class ClouderaVersion(Version):

version_re = CLDR_RE

def __init__(self, vstring=None):
def __init__(self, vstring: str = None):
self.vstring = vstring
self.major = None
self.minor = None
Expand Down Expand Up @@ -141,7 +145,7 @@ def parse(self, vstring) -> None:
)

@property
def core(self) -> tuple[int | None, int | None, int | None]:
def core(self) -> tuple:
return self.major, self.minor, self.patch

@property
Expand Down
29 changes: 12 additions & 17 deletions roles/cm_repo/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.

- name: Load support matrix variables for OS
ansible.builtin.include_vars: "{{ item }}"
with_first_found:
- "../../prereq_supported/vars/{{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_version'] }}.yml"
- "../../prereq_supported/vars/{{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_major_version'] }}.yml"
- "../../prereq_supported/vars/{{ ansible_facts['distribution'] }}.yml"
- "../../prereq_supported/vars/{{ ansible_facts['os_family'] }}-{{ ansible_facts['distribution_version'] }}.yml"
- "../../prereq_supported/vars/{{ ansible_facts['os_family'] }}-{{ ansible_facts['distribution_major_version'] }}.yml"
- "../../prereq_supported/vars/{{ ansible_facts['os_family'] }}.yml"
- "../../prereq_supported/vars/default.yml"
- name: Gather distribution details
ansible.builtin.setup:
gather_subset: distribution

- name: Assert that OS is supported for Cloudera Manager version
- name: Assert OS support for Cloudera Manager versions
ansible.builtin.assert:
that:
- support_matrix | selectattr('manager_version', 'version', cloudera_manager_version, 'le') | length > 0
fail_msg: >
Cloudera Manager version {{ cloudera_manager_version }} not supported for
OS {{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_version'] }}.
quiet: true
- supported_cms |
selectattr('family', 'eq', cm_repo_supported_distribution_map[ansible_facts['distribution']] | default(ansible_facts['distribution'])) |
selectattr('version', 'eq', ansible_facts['distribution_version']) |
length > 0
fail_msg: "OS {{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_version'] }} not supported."
vars:
supported_cms: "{{ lookup('cloudera.exe.supported', 'operating_systems', product='cloudera_manager', version=cloudera_manager_version) }}"

- name: Load Cloudera Manager package repository variables for OS and CM version
ansible.builtin.include_vars: "{{ item }}"
Expand All @@ -44,7 +39,7 @@
- "{{ ansible_facts['os_family'] }}.yml"
- "default.yml"
vars:
cm_version: "{{ cloudera_manager_version | cloudera.exe.cm_version }}"
cm_version: "{{ cloudera_manager_version | cloudera.exe.version }}"

- name: Configure Cloudera Manager package repository
ansible.builtin.include_tasks:
Expand Down
2 changes: 1 addition & 1 deletion roles/cm_repo/vars/RedHat-CM5.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ __cm_repo_enterprise_url: >-
[
__cm_repo_default_url,
'p',
'cm' + (cloudera_manager_version | cloudera.exe.cm_version).major,
'cm' + (cloudera_manager_version | cloudera.exe.version).major | string,
(ansible_os_family | lower),
ansible_distribution_major_version,
ansible_architecture,
Expand Down
2 changes: 1 addition & 1 deletion roles/cm_repo/vars/RedHat-CM6.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ __cm_repo_enterprise_url: >-
[
__cm_repo_default_url,
'p',
'cm' + (cloudera_manager_version | cloudera.exe.cm_version).major,
'cm' + (cloudera_manager_version | cloudera.exe.version).major | string,
cloudera_manager_version,
(ansible_os_family | lower) + ansible_distribution_major_version,
'yum'
Expand Down
4 changes: 2 additions & 2 deletions roles/cm_repo/vars/RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ __cm_repo_trial_url: >-
{{
[
__cm_repo_default_url,
'cm' + (__cm_trial_version | cloudera.exe.cm_version).major,
'cm' + (__cm_trial_version | cloudera.exe.version).major | string,
__cm_trial_version,
(ansible_os_family | lower) + ansible_distribution_major_version,
'yum'
Expand All @@ -32,7 +32,7 @@ __cm_repo_enterprise_url: >-
[
__cm_repo_default_url,
'p',
'cm' + (cloudera_manager_version | cloudera.exe.cm_version).major,
'cm' + (cloudera_manager_version | cloudera.exe.version).major | string,
cloudera_manager_version,
(ansible_os_family | lower) + ansible_distribution_major_version,
'yum'
Expand Down
4 changes: 4 additions & 0 deletions roles/cm_repo/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@
# limitations under the License.

__cm_repo_default_url: https://archive.cloudera.com

# Map of ansible_distribution -> support matrix 'family'
cm_repo_supported_distribution_map:
RedHat: RHEL
Loading