Skip to content

Commit 7fbb8a4

Browse files
authored
Add CM repository installation role (#224)
Signed-off-by: Webster Mudge <[email protected]>
1 parent c2a3135 commit 7fbb8a4

File tree

18 files changed

+1205
-0
lines changed

18 files changed

+1205
-0
lines changed

roles/cm_repo/README.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# cm_repo
2+
3+
Manage the package repository for Cloudera Manager.
4+
5+
This role manages the configuration of the package repository used for downloading and installing Cloudera Manager binaries. It provides flexible options to configure access to various repository types, including Cloudera's trial archives, enterprise archives requiring authentication, and custom private repositories.
6+
7+
The role will:
8+
- Add or configure the appropriate package repository (e.g., YUM/APT) for Cloudera Manager.
9+
- Handle authentication for enterprise or custom repositories using provided username and password.
10+
- Optionally configure GPG key validation for repository contents.
11+
- Enable the repository for package installation.
12+
13+
# Requirements
14+
15+
- Internet access from the target host to the specified package repository URL.
16+
- Appropriate system permissions to manage package repositories (e.g., root access or sudo privileges).
17+
18+
# Dependencies
19+
20+
None.
21+
22+
# Parameters
23+
24+
| Variable | Type | Required | Default | Description |
25+
| --- | --- | --- | --- | --- |
26+
| `cloudera_manager_version` | `str` | `False` | `7.11.3` | Version of Cloudera Manager for which the repository is being configured. If not defined and `cloudera_manager_repo_username` is not set, it will typically default to a trial version like `7.4.4`, if compatible with the OS distribution and if the `cloudera_manager_repo_url` is not explicitly set to an enterprise archive. |
27+
| `cloudera_manager_repo_url` | `str` | `False` | - | Base URL for the package repository. If not defined and `cloudera_manager_repo_username` is set, it will default to the Cloudera enterprise archive URL for the specified version. Otherwise, it defaults to the Cloudera trial archive URL. |
28+
| `cloudera_manager_repo_username` | `str` | `False` | | Username for authenticating to the package repository. For Cloudera enterprise licenses, this corresponds to the `uuid` value provided by Cloudera. |
29+
| `cloudera_manager_repo_password` | `str` | `False` | | Password for authenticating to the package repository. For Cloudera enterprise licenses, this corresponds to the derived `password` value associated with your `uuid`. |
30+
| `cloudera_manager_repo_key` | `str` | `False` | | URL to the package repository's GPG public key for content validation. |
31+
| `cloudera_manager_repo_gpgcheck` | `bool` | `False` | - | Flag to manage validation checks (GPG checks) of the repository contents. Set to `true` to enable GPG signature verification during package installation. |
32+
33+
# Example Playbook
34+
35+
```yaml
36+
- hosts: all
37+
tasks:
38+
- name: Configure Cloudera Manager trial repository (default version)
39+
ansible.builtin.import_role:
40+
name: cloudera.exe.cm_repo
41+
vars:
42+
# cloudera_manager_version and cloudera_manager_repo_url will use their implicit defaults for trial.
43+
# No username/password needed.
44+
45+
- name: Configure Cloudera Manager enterprise repository for a specific version
46+
ansible.builtin.import_role:
47+
name: cloudera.exe.cm_repo
48+
vars:
49+
cloudera_manager_version: 7.11.3
50+
cloudera_manager_repo_username: "YOUR_UUID_HERE" # Replace with your actual UUID
51+
cloudera_manager_repo_password: "YOUR_PASSWORD_HERE" # Replace with your actual password
52+
# cloudera_manager_repo_url will default to the enterprise archive for 7.11.3
53+
54+
- name: Configure a custom Cloudera Manager repository
55+
ansible.builtin.import_role:
56+
name: cloudera.exe.cm_repo
57+
vars:
58+
cloudera_manager_version: 7.11.1 # Example specific version
59+
cloudera_manager_repo_url: "http://my-internal-repo.example.com/cm/7.11.1/"
60+
cloudera_manager_repo_username: "internal_user"
61+
cloudera_manager_repo_password: "internal_password"
62+
cloudera_manager_repo_key: "http://my-internal-repo.example.com/gpg/repo.key"
63+
cloudera_manager_repo_gpgcheck: true
64+
```
65+
66+
## License
67+
68+
```
69+
Copyright 2024 Cloudera, Inc.
70+
71+
Licensed under the Apache License, Version 2.0 (the "License");
72+
you may not use this file except in compliance with the License.
73+
You may obtain a copy of the License at
74+
75+
https://www.apache.org/licenses/LICENSE-2.0
76+
77+
Unless required by applicable law or agreed to in writing, software
78+
distributed under the License is distributed on an "AS IS" BASIS,
79+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
80+
See the License for the specific language governing permissions and
81+
limitations under the License.
82+
```

roles/cm_repo/defaults/main.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright 2024 Cloudera, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
cloudera_manager_version: 7.11.3
16+
17+
# cloudera_manager_repo_url:
18+
# cloudera_manager_repo_username:
19+
# cloudera_manager_repo_password:
20+
# cloudera_manager_repo_key:
21+
# cloudera_manager_repo_gpgcheck: true
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# -*- coding: utf-8 -*-
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+
# https://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+
from __future__ import absolute_import, division, print_function
17+
18+
__metaclass__ = type
19+
20+
DOCUMENTATION = """
21+
name: cm_version
22+
author: Webster Mudge (@wmudge) <[email protected]>
23+
short_description: Parse a Cloudera Manager version string
24+
description:
25+
- Cloudera Manager version string parsing.
26+
- Returns a dictionary of the version parts.
27+
positional: _input
28+
options:
29+
_input:
30+
description: A version string to parse.
31+
type: dict
32+
required: True
33+
"""
34+
35+
EXAMPLES = """
36+
# Parse a standard version string
37+
standard: "{{ '1.2.3' | cm_version }}"
38+
39+
# Parse a version plus build number
40+
build: "{{ '1.2.3.4' | cm_version }}"
41+
42+
# Parse a version plus build metadata string
43+
build: "{{ '1.2.3+build7' | cm_version }}"
44+
45+
# Parse a version plus prerelease and build string
46+
full: "{{ '1.2.3-rc1+build7' | cm_version }}"
47+
"""
48+
49+
RETURN = """
50+
_value:
51+
description:
52+
- A dictionary of the version parts.
53+
- If unable to parse the string, returns C(None).
54+
type: dict
55+
options:
56+
major:
57+
description: Major version
58+
minor:
59+
description: Minor version
60+
patch:
61+
description: Patch version
62+
prerelease:
63+
description: Prerelease version
64+
returned: when supported
65+
buildmetadata:
66+
description: Build metadata version
67+
returned: when supported
68+
"""
69+
70+
import re
71+
72+
from ansible.errors import AnsibleFilterError
73+
74+
CM_REGEX = re.compile(
75+
"^(?P<major>0|[1-9]\\d*)"
76+
+ "\\.(?P<minor>0|[1-9]\\d*)"
77+
+ "\\.(?P<patch>0|[1-9]\\d*)"
78+
+ "(?:-(?P<prerelease>(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?"
79+
+ "(?:[\\+|\\.](?P<buildmetadata>[0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$",
80+
)
81+
82+
83+
def cm_version(version: str):
84+
"""
85+
Parse a Cloudera Manager version string into its parts.
86+
"""
87+
88+
try:
89+
ver = re.fullmatch(CM_REGEX, version)
90+
except Exception as e:
91+
raise AnsibleFilterError(orig_exc=e)
92+
93+
if ver is not None:
94+
return ver.groupdict()
95+
96+
97+
class FilterModule(object):
98+
def filters(self):
99+
filters = {"cm_version": cm_version}
100+
101+
return filters
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# -*- coding: utf-8 -*-
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+
# https://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+
from __future__ import absolute_import, division, print_function
17+
18+
__metaclass__ = type
19+
20+
DOCUMENTATION = """
21+
name: semantic_version
22+
author: Webster Mudge (@wmudge) <[email protected]>
23+
short_description: Parse a semantic version string
24+
description:
25+
- Semantic version string parsing.
26+
- Returns a dictionary of the semantic version parts.
27+
- See https://semver.org
28+
positional: _input
29+
options:
30+
_input:
31+
description: A semantic version string to parse.
32+
type: dict
33+
required: True
34+
"""
35+
36+
EXAMPLES = """
37+
# Parse a standard version string
38+
standard: "{{ '1.2.3' | semantic_version }}"
39+
40+
# Parse a version plus prerelease string
41+
prerelease: "{{ '1.2.3-rc1' | semantic_version }}"
42+
43+
# Parse a version plus build metadata string
44+
build: "{{ '1.2.3+build7' | semantic_version }}"
45+
46+
# Parse a version plus prerelease and build string
47+
full: "{{ '1.2.3-rc1+build7' | semantic_version }}"
48+
"""
49+
50+
RETURN = """
51+
_value:
52+
description:
53+
- A dictionary of the semantic version parts.
54+
- If unable to parse the string, returns C(None).
55+
type: dict
56+
options:
57+
major:
58+
description: Major version
59+
minor:
60+
description: Minor version
61+
patch:
62+
description: Patch version
63+
prerelease:
64+
description: Prerelease version
65+
returned: when supported
66+
buildmetadata:
67+
description: Build metadata version
68+
returned: when supported
69+
"""
70+
71+
import re
72+
73+
from ansible.errors import AnsibleFilterError
74+
75+
SEMVER_REGEX = re.compile(
76+
"^(?P<major>0|[1-9]\\d*)\\.(?P<minor>0|[1-9]\\d*)\\.(?P<patch>0|[1-9]\\d*)(?:-(?P<prerelease>(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$",
77+
)
78+
79+
80+
def semantic_version(version: str):
81+
"""
82+
Parse a semantic version string into its parts.
83+
84+
See: https://semver.org/
85+
"""
86+
87+
try:
88+
semver = re.fullmatch(SEMVER_REGEX, version)
89+
except Exception as e:
90+
raise AnsibleFilterError(orig_exc=e)
91+
92+
if semver is not None:
93+
return semver.groupdict()
94+
95+
96+
class FilterModule(object):
97+
def filters(self):
98+
filters = {"semantic_version": semantic_version}
99+
100+
return filters
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Copyright 2024 Cloudera, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
argument_specs:
16+
main:
17+
short_description: Manage the package repository for Cloudera Manager.
18+
description:
19+
- Manage the package repository for downloading and installing Cloudera Manager binaries.
20+
- Handles trial, enterprise, and custom repositories.
21+
author:
22+
- "Webster Mudge <[email protected]>"
23+
version_added: "5.0.0"
24+
options:
25+
cloudera_manager_version:
26+
description:
27+
- Version of Cloudera Manager.
28+
- If not defined and C(cloudera_manager_repo_username) is not defined, will default to the C(7.4.4) trial version,
29+
if compatiable with the OS distribution.
30+
default: 7.11.3
31+
cloudera_manager_repo_url:
32+
description:
33+
- Base URL for the package repository.
34+
- If not defined and C(cloudera_manager_repo_username) is set, will default to the Cloudera enterprise archive.
35+
- Defaults to the Cloudera trial archive.
36+
cloudera_manager_repo_username:
37+
description:
38+
- Package repository username.
39+
- For Cloudera enterprise licenses, this is the C(uuid) value.
40+
cloudera_manager_repo_password:
41+
description:
42+
- Package repository password.
43+
- For Cloudera enterprise licenses, this is the derived C(password) value.
44+
cloudera_manager_repo_key:
45+
description: Package repository validation key URL.
46+
cloudera_manager_repo_gpgcheck:
47+
description: Flag to manage validation checks of the repository contents.
48+
type: bool
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright 2024 Cloudera, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# TODO Test against named hosts based on OS distro
16+
17+
- name: Converge
18+
hosts: all
19+
gather_facts: true
20+
become: true
21+
tasks:
22+
- name: Set up Cloudera Manager 7.x enterprise repository
23+
ansible.builtin.import_role:
24+
name: cloudera.exe.cm_repo

0 commit comments

Comments
 (0)