Skip to content

Commit a9cdbe9

Browse files
authored
Update RDBMS PostgreSQL server role (#194)
* Rename default.yml to main.yml and add missing TLS parameters * Update tempdir for postgres user access * Add failed_when conditional for missing postgresql module stream for RHEL 8 or greater * Update PostgreSQL repository and key tasks * Update PostgreSQL global config options to use ternary filters * Add argument spec for cloudera.exe.rdbms_server * Add license headers * Add deprecation warning for cloudera.exe.rdbms.server and redirect to cloudera.exe.rdbms_server * Copy cloudera.exe.rdbms.server to cloudera.exe.rdbms_server Signed-off-by: Webster Mudge <[email protected]>
1 parent 1c66512 commit a9cdbe9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1058
-18
lines changed

meta/runtime.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,11 @@
1515
# limitations under the License.
1616

1717
requires_ansible: ">=2.10"
18+
19+
plugin_routing:
20+
role:
21+
rdbms.server:
22+
deprecation:
23+
removal_version: 3.0.0
24+
warning_text: Use cloudera.exe.rdbms_server instead of this nested role.
25+
redirect: cloudera.exe.rdbms_server

roles/rdbms/server/defaults/defaults.yml renamed to roles/rdbms/server/defaults/main.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,12 @@ database_tls: false
1818
database_type: postgresql
1919
database_version: 14
2020

21-
skip_rdbms_repo_setup: False
21+
skip_rdbms_repo_setup: false
2222

2323
# MYSQL
2424
mysql_require_secure_transport: "OFF" # If TLS-enabled, honor or not
2525

26-
# From cloudera.cluster.infrastructure.ca_common
27-
base_dir_security: /opt/cloudera/security
28-
base_dir_security_pki: "{{ base_dir_security }}/pki"
29-
26+
base_dir_security_pki: "/opt/cloudera/security/pki"
3027
tls_chain_path: "{{ base_dir_security_pki }}/chain.pem"
3128
tls_cert_path_generic: "{{ base_dir_security_pki }}/host.pem"
32-
tls_key_path_plaintext_generic: "{{ tls_key_path_generic }}.unenc"
29+
tls_key_path_plaintext_generic: "{{ base_dir_security_pki }}/host.key.unenc"

roles/rdbms/server/files/utf8-template.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
-- Copyright 2021 Cloudera, Inc.
1+
-- Copyright 2024 Cloudera, Inc.
22
--
33
-- Licensed under the Apache License, Version 2.0 (the "License");
44
-- you may not use this file except in compliance with the License.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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+
---
16+
17+
argument_specs:
18+
main:
19+
short_description: Install standalone RDBMS instance
20+
description:
21+
- Install and configure a standalone RDBMS instance for use with Cloudera Manager.
22+
- Database options include PostgreSQL, MySQL, and MariaDB.
23+
- Supports TLS connections.
24+
options:
25+
database_tls:
26+
description: Flag to enable TLS configuration.
27+
type: bool
28+
default: false
29+
database_type:
30+
description: Database product to install.
31+
type: str
32+
required: false
33+
default: postgresql
34+
choices:
35+
- postgresql
36+
- mysql
37+
- mariadb
38+
database_version:
39+
description: Database product version to install.
40+
type: str
41+
required: false
42+
default: 14
43+
skip_rdbms_repo_setup:
44+
description: Flag to enable RDBMS repository set up on target host.
45+
type: bool
46+
required: false
47+
default: false
48+
mysql_require_secure_transport:
49+
description: Value for the C(require_secure_transport) parameter in the C([mysqld]) configuration. (MySQL only)
50+
type: str
51+
required: false
52+
default: "OFF"
53+
base_dir_security_pki:
54+
description:
55+
- Directory on target host housing typical PKI files.
56+
- Used to establish a base directory for the other TLS options.
57+
type: path
58+
required: false
59+
default: "/opt/cloudera/security/pki"
60+
tls_chain_path:
61+
description: File on the target host consisting of an ordered list of certificates, including TLS certificates and Certificate Authority (CA) certificates.
62+
type: path
63+
required: false
64+
default: "O(base_dir_security_pki)/chain.pem"
65+
tls_cert_path_generic:
66+
description: File on the target host consisting of the TLS certificate for the server.
67+
type: path
68+
required: false
69+
default: "O(base_dir_security_pki)/host.pem"
70+
tls_key_path_plaintext_generic:
71+
description: File on the target host consisting of the unencrypted TLS private key for the server.
72+
type: path
73+
required: false
74+
default: "O(base_dir_security_pki)/host.key.unenc"

roles/rdbms/server/meta/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414

1515
---
16+
1617
galaxy_info:
1718
description: >
1819
Set up single database to support Cloudera Data Platform (CDP) Private Cloud

roles/rdbms/server/tasks/main.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
# limitations under the License.
1414

1515
---
16+
17+
- name: DEPRECATION WARNING
18+
ansible.builtin.debug:
19+
msg:
20+
- This role has been moved to M(cloudera.exe.rdbms_server).
21+
- Please update your playbooks and roles accordingly.
22+
1623
- name: Include database type variables
1724
ansible.builtin.include_vars:
1825
file: "{{ database_type }}/common.yml"

roles/rdbms/server/tasks/postgresql/Debian.yml

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

15+
- name: Install keyrings directory
16+
ansible.builtin.file:
17+
path: /etc/apt/keyrings
18+
state: directory
19+
1520
- name: Install PostgreSQL repository key
16-
ansible.builtin.apt_key:
21+
ansible.builtin.get_url:
1722
url: https://www.postgresql.org/media/keys/ACCC4CF8.asc
18-
state: present
23+
dest: /etc/apt/keyrings/postgresql.asc
1924
when: not skip_rdbms_repo_setup
2025

2126
- name: Install PostgreSQL repository
2227
ansible.builtin.apt_repository:
23-
repo: "deb https://apt.postgresql.org/pub/repos/apt {{ ansible_distribution_release }}-pgdg main"
28+
repo: "deb [arch=amd64 signed-by=/etc/apt/keyrings/postgresql.asc] https://apt.postgresql.org/pub/repos/apt {{ ansible_distribution_release }}-pgdg main"
2429
state: present
2530
when: not skip_rdbms_repo_setup
2631

roles/rdbms/server/tasks/postgresql/RedHat.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@
2828
gpgkey: https://download.postgresql.org/pub/repos/yum/keys/PGDG-RPM-GPG-KEY-RHEL
2929
when: not skip_rdbms_repo_setup
3030

31-
- name: Disable default Postgres module in RHEL 8
31+
- name: Disable default Postgres module in RHEL 8 or greater
3232
ansible.builtin.command: dnf module disable -y postgresql
3333
register: __postgres_module_result
3434
changed_when:
3535
- '"Disabling modules" in __postgres_module_result.stdout'
36+
failed_when:
37+
- __postgres_module_result.rc != 0 and __postgres_module_result.rc != 1
3638
when:
3739
- ansible_os_family == 'RedHat'
3840
- ansible_distribution_major_version | int >= 8

roles/rdbms/server/tasks/postgresql/template_fix.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,19 @@
1515
- name: Create a temporary SQL directory
1616
ansible.builtin.tempfile:
1717
state: directory
18-
suffix: sql
18+
suffix: "-sql"
1919
register: __sql
2020

21+
- name: Enable access for the postgres user
22+
ansible.builtin.file:
23+
path: "{{ __sql.path }}"
24+
owner: postgres
25+
group: postgres
26+
2127
- name: Copy SQL to change template to UTF-8
2228
ansible.builtin.copy:
2329
src: files/utf8-template.sql
24-
dest: "{{ __sql.path }}"
30+
dest: "{{ __sql.path }}/utf8-template.sql"
2531
owner: postgres
2632
group: postgres
2733
mode: 0660
@@ -36,4 +42,3 @@
3642
path: "{{ __sql.path }}"
3743
state: absent
3844
become: yes
39-
become_user: postgres

roles/rdbms/server/vars/mariadb/Debian.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
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+
115
---
16+
217
mysql_packages:
318
- mariadb-client
419
- mariadb-server

0 commit comments

Comments
 (0)