Skip to content

Commit d9540e3

Browse files
authored
Update cm_repo role to use supported lookup (#264)
* Fix cloudera.exe.version filter parameters and allow for type checking * Update cm_repo to use supported lookup Signed-off-by: Webster Mudge <[email protected]>
1 parent 4946250 commit d9540e3

File tree

7 files changed

+32
-26
lines changed

7 files changed

+32
-26
lines changed

plugins/filter/core_exe.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717

18-
from __future__ import absolute_import, division, print_function
18+
from __future__ import absolute_import, division, print_function, annotations
1919

2020
__metaclass__ = type
2121

@@ -60,13 +60,16 @@ def combine_onto(*terms, **kwargs):
6060
return result
6161

6262

63-
def cldr_version(version: str):
63+
def cldr_version(*terms, **kwargs):
6464
"""
6565
Parse a Cloudera version string into its parts.
6666
"""
6767

68+
if not terms:
69+
return {}
70+
6871
try:
69-
parsed_version = ClouderaVersion(version)
72+
parsed_version = ClouderaVersion(terms[0])
7073
return dict(
7174
major=parsed_version.major,
7275
minor=parsed_version.minor,

plugins/module_utils/cldr_version.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17+
from __future__ import absolute_import, division, print_function, annotations
18+
19+
__metaclass__ = type
20+
1721
import re
1822

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

6165
version_re = CLDR_RE
6266

63-
def __init__(self, vstring=None):
67+
def __init__(self, vstring: str = None):
6468
self.vstring = vstring
6569
self.major = None
6670
self.minor = None
@@ -141,7 +145,7 @@ def parse(self, vstring) -> None:
141145
)
142146

143147
@property
144-
def core(self) -> tuple[int | None, int | None, int | None]:
148+
def core(self) -> tuple:
145149
return self.major, self.minor, self.patch
146150

147151
@property

roles/cm_repo/tasks/main.yml

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

16-
- name: Load support matrix variables for OS
17-
ansible.builtin.include_vars: "{{ item }}"
18-
with_first_found:
19-
- "../../prereq_supported/vars/{{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_version'] }}.yml"
20-
- "../../prereq_supported/vars/{{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_major_version'] }}.yml"
21-
- "../../prereq_supported/vars/{{ ansible_facts['distribution'] }}.yml"
22-
- "../../prereq_supported/vars/{{ ansible_facts['os_family'] }}-{{ ansible_facts['distribution_version'] }}.yml"
23-
- "../../prereq_supported/vars/{{ ansible_facts['os_family'] }}-{{ ansible_facts['distribution_major_version'] }}.yml"
24-
- "../../prereq_supported/vars/{{ ansible_facts['os_family'] }}.yml"
25-
- "../../prereq_supported/vars/default.yml"
16+
- name: Gather distribution details
17+
ansible.builtin.setup:
18+
gather_subset: distribution
2619

27-
- name: Assert that OS is supported for Cloudera Manager version
20+
- name: Assert OS support for Cloudera Manager versions
2821
ansible.builtin.assert:
2922
that:
30-
- support_matrix | selectattr('manager_version', 'version', cloudera_manager_version, 'le') | length > 0
31-
fail_msg: >
32-
Cloudera Manager version {{ cloudera_manager_version }} not supported for
33-
OS {{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_version'] }}.
34-
quiet: true
23+
- supported_cms |
24+
selectattr('family', 'eq', cm_repo_supported_distribution_map[ansible_facts['distribution']] | default(ansible_facts['distribution'])) |
25+
selectattr('version', 'eq', ansible_facts['distribution_version']) |
26+
length > 0
27+
fail_msg: "OS {{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_version'] }} not supported."
28+
vars:
29+
supported_cms: "{{ lookup('cloudera.exe.supported', 'operating_systems', product='cloudera_manager', version=cloudera_manager_version) }}"
3530

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

4944
- name: Configure Cloudera Manager package repository
5045
ansible.builtin.include_tasks:

roles/cm_repo/vars/RedHat-CM5.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ __cm_repo_enterprise_url: >-
2020
[
2121
__cm_repo_default_url,
2222
'p',
23-
'cm' + (cloudera_manager_version | cloudera.exe.cm_version).major,
23+
'cm' + (cloudera_manager_version | cloudera.exe.version).major | string,
2424
(ansible_os_family | lower),
2525
ansible_distribution_major_version,
2626
ansible_architecture,

roles/cm_repo/vars/RedHat-CM6.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ __cm_repo_enterprise_url: >-
2020
[
2121
__cm_repo_default_url,
2222
'p',
23-
'cm' + (cloudera_manager_version | cloudera.exe.cm_version).major,
23+
'cm' + (cloudera_manager_version | cloudera.exe.version).major | string,
2424
cloudera_manager_version,
2525
(ansible_os_family | lower) + ansible_distribution_major_version,
2626
'yum'

roles/cm_repo/vars/RedHat.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ __cm_repo_trial_url: >-
2020
{{
2121
[
2222
__cm_repo_default_url,
23-
'cm' + (__cm_trial_version | cloudera.exe.cm_version).major,
23+
'cm' + (__cm_trial_version | cloudera.exe.version).major | string,
2424
__cm_trial_version,
2525
(ansible_os_family | lower) + ansible_distribution_major_version,
2626
'yum'
@@ -32,7 +32,7 @@ __cm_repo_enterprise_url: >-
3232
[
3333
__cm_repo_default_url,
3434
'p',
35-
'cm' + (cloudera_manager_version | cloudera.exe.cm_version).major,
35+
'cm' + (cloudera_manager_version | cloudera.exe.version).major | string,
3636
cloudera_manager_version,
3737
(ansible_os_family | lower) + ansible_distribution_major_version,
3838
'yum'

roles/cm_repo/vars/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@
1414
# limitations under the License.
1515

1616
__cm_repo_default_url: https://archive.cloudera.com
17+
18+
# Map of ansible_distribution -> support matrix 'family'
19+
cm_repo_supported_distribution_map:
20+
RedHat: RHEL

0 commit comments

Comments
 (0)