Skip to content

Commit

Permalink
Fully qualify role names and normalize to use default 'when' conditional
Browse files Browse the repository at this point in the history
Signed-off-by: Webster Mudge <[email protected]>
  • Loading branch information
wmudge committed Aug 21, 2024
1 parent df963b0 commit 18ae977
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 56 deletions.
6 changes: 3 additions & 3 deletions roles/rdbms/server/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@

---
- name: Include database type variables
include_vars:
ansible.builtin.include_vars:
file: "{{ database_type }}/common.yml"

- name: Include database type and OS specific variables
include_vars:
ansible.builtin.include_vars:
file: "{{ item }}"
with_first_found:
- "{{ database_type }}/{{ ansible_os_family }}-{{ ansible_distribution_major_version }}.yml"
- "{{ database_type }}/{{ ansible_os_family }}.yml"

- name: Install database
include_tasks:
ansible.builtin.include_tasks:
file: "{{ item }}"
with_first_found:
- "{{ database_type }}/{{ ansible_os_family }}-{{ ansible_distribution_major_version }}.yml"
Expand Down
14 changes: 6 additions & 8 deletions roles/rdbms/server/tasks/mariadb/Debian.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 Cloudera, Inc. All Rights Reserved.
# Copyright 2024 Cloudera, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -12,20 +12,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.

---

- name: Install MariaDB apt key
apt_key:
ansible.builtin.apt_key:
url: https://mariadb.org/mariadb_release_signing_key.asc
state: present
when: not (skip_rdbms_repo_setup | default(False))
when: not skip_rdbms_repo_setup

- name: Install MariaDB apt repository
apt_repository:
ansible.builtin.apt_repository:
repo: deb [arch=amd64,arm64,ppc64el] https://downloads.mariadb.com/MariaDB/mariadb-{{ database_version }}/repo/ubuntu/ bionic main
state: present
when: not (skip_rdbms_repo_setup | default(False))
when: not skip_rdbms_repo_setup

- name: Install MariaDB
include_role:
ansible.builtin.include_role:
name: ansible-role-mysql
16 changes: 7 additions & 9 deletions roles/rdbms/server/tasks/mariadb/RedHat.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 Cloudera, Inc. All Rights Reserved.
# Copyright 2024 Cloudera, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -12,22 +12,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.

---

- name: Install MariaDB repository
yum_repository:
ansible.builtin.yum_repository:
name: MariaDB
description: MariaDB {{ database_version }} repository for RHEL
baseurl: https://yum.mariadb.org/{{ database_version }}/rhel{{ ansible_distribution_major_version }}-amd64
gpgkey: https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
when: not (skip_rdbms_repo_setup | default(False))
when: not skip_rdbms_repo_setup

- name: Disable modularity appstream, when el8
command: yum -y module disable mysql mariadb
- name: Disable modularity appstream, when RHEL 8
ansible.builtin.command: yum -y module disable mysql mariadb
when:
- not (skip_rdbms_repo_setup | default(False))
- not skip_rdbms_repo_setup
- ansible_distribution_major_version == "8"

- name: Install Mariadb
include_role:
ansible.builtin.include_role:
name: ansible-role-mysql
22 changes: 9 additions & 13 deletions roles/rdbms/server/tasks/mysql/RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,26 @@
# See the License for the specific language governing permissions and
# limitations under the License.

---

- name: Import GPG Key
rpm_key:
- name: Import MySQL repository GPG Key
ansible.builtin.rpm_key:
key: "{{ mysql_repo_key }}"
state: present
when:
- not (skip_rdbms_repo_setup | default(False))
when: not skip_rdbms_repo_setup

- name: Install MySQL repository
yum:
ansible.builtin.yum:
name: "{{ mysql_repo }}"
update_cache: true
lock_timeout: 180
state: present
when:
- not (skip_rdbms_repo_setup | default(False))
when: not skip_rdbms_repo_setup

- name: Disable modularity appstream, when el8
command: yum -y module disable mysql mariadb
- name: Disable modularity appstream, when RHEL 8
ansible.builtin.command: yum -y module disable mysql mariadb
when:
- not (skip_rdbms_repo_setup | default(False))
- not skip_rdbms_repo_setup
- ansible_distribution_major_version == "8"

- name: Install MySQL
include_role:
ansible.builtin.include_role:
name: ansible-role-mysql
20 changes: 9 additions & 11 deletions roles/rdbms/server/tasks/postgresql/Debian.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 Cloudera, Inc. All Rights Reserved.
# Copyright 2024 Cloudera, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -12,22 +12,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.

---

- name: Install PostgreSQL apt key
apt_key:
- name: Install PostgreSQL repository key
ansible.builtin.apt_key:
url: https://www.postgresql.org/media/keys/ACCC4CF8.asc
state: present
when: not (skip_rdbms_repo_setup | default(False))
when: not skip_rdbms_repo_setup

- name: Install PostgreSQL apt repository
apt_repository:
- name: Install PostgreSQL repository
ansible.builtin.apt_repository:
repo: "deb https://apt.postgresql.org/pub/repos/apt {{ ansible_distribution_release }}-pgdg main"
state: present
when: not (skip_rdbms_repo_setup | default(False))
when: not skip_rdbms_repo_setup

- name: Install PostgreSQL
include_role:
ansible.builtin.include_role:
name: geerlingguy.postgresql

- name: Install python-psycopg2
Expand All @@ -36,5 +34,5 @@
state: latest

- name: Fix UTF-8 template
include_tasks:
ansible.builtin.include_tasks:
file: template_fix.yml
22 changes: 10 additions & 12 deletions roles/rdbms/server/tasks/postgresql/RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,24 @@
# See the License for the specific language governing permissions and
# limitations under the License.

---

- name: Install PostgreSQL common repository
yum_repository:
ansible.builtin.yum_repository:
name: pgdg-common
description: PostgreSQL common for RHEL/CentOS
baseurl: https://download.postgresql.org/pub/repos/yum/common/redhat/rhel-$releasever-$basearch
gpgkey: https://download.postgresql.org/pub/repos/yum/keys/PGDG-RPM-GPG-KEY-RHEL
when: not (skip_rdbms_repo_setup | default(False))
when: not skip_rdbms_repo_setup

- name: Install PostgreSQL version repository
yum_repository:
ansible.builtin.yum_repository:
name: pgdg
description: PostgreSQL {{ postgresql_version }} for RHEL/CentOS
baseurl: https://download.postgresql.org/pub/repos/yum/{{ postgresql_version }}/redhat/rhel-$releasever-$basearch
gpgkey: https://download.postgresql.org/pub/repos/yum/keys/PGDG-RPM-GPG-KEY-RHEL
when: not (skip_rdbms_repo_setup | default(False))
when: not skip_rdbms_repo_setup

- name: disable default Postgres module in Rhel 8
command: dnf module disable -y postgresql
- name: Disable default Postgres module in RHEL 8
ansible.builtin.command: dnf module disable -y postgresql
register: __postgres_module_result
changed_when:
- '"Disabling modules" in __postgres_module_result.stdout'
Expand All @@ -40,19 +38,19 @@
- ansible_distribution_major_version | int >= 8

- name: Install PostgreSQL
include_role:
ansible.builtin.include_role:
name: geerlingguy.postgresql

- name: Fix UTF-8 template
include_tasks:
ansible.builtin.include_tasks:
file: postgresql/template_fix.yml

- name: Remove repositories and clean metadata
yum_repository:
ansible.builtin.yum_repository:
name: "{{ item }}"
state: absent
with_items:
- pgdg-common
- pgdg
when: not (skip_rdbms_repo_setup | default(False))
when: not skip_rdbms_repo_setup
notify: yum clean metadata

0 comments on commit 18ae977

Please sign in to comment.