Skip to content

Commit

Permalink
update repos testing and validation
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahms committed Oct 7, 2023
1 parent 416624e commit 7b6ab2a
Show file tree
Hide file tree
Showing 7 changed files with 275 additions and 165 deletions.
96 changes: 79 additions & 17 deletions roles/setup_repo/tasks/PG_RedHat_rm_repos.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,38 @@
---
- name: Get repo list on RedHat
ansible.builtin.yum:
list: repos
become: true
register: yum_repos

- name: Get PGDG repos
ansible.builtin.set_fact:
pgdg_repo_list: "{{ yum_repos.results | selectattr('repoid', 'search', 'pgdg') \
| selectattr('state', 'equalto', 'enabled') | map(attribute='repoid') | list }}"
when: enable_pgdg_repo|bool

- name: Get EPEL repos
ansible.builtin.set_fact:
epel_repo_list: "{{ yum_repos.results | selectattr('repoid', 'search', 'pgdg') \
| selectattr('state', 'equalto', 'enabled') | map(attribute='repoid') | list }}"
when: enable_epel_repo|bool

- name: Get EDB Repos 1.0
ansible.builtin.set_fact:
edb_repos_1_list: "{{ yum_repos.results | selectattr('repoid', 'search', 'edb') \
| selectattr('state', 'equalto', 'enabled') | map(attribute='repoid') | list }}"
when:
- enable_edb_repo|bool
- repo_token|length <= 1

- name: Get EDB Repos 2.0
ansible.builtin.set_fact:
edb_repos_2_list: "{{ yum_repos.results | selectattr('repoid', 'search', 'enterprisedb') \
| selectattr('state', 'equalto', 'enabled') | map(attribute='repoid') | list }}"
when:
- enable_edb_repo|bool
- repo_token|length > 1

- name: Remove EDB GPG key for EL8
ansible.builtin.rpm_key:
key: "{{ edb_gpg_key_8 }}"
Expand Down Expand Up @@ -41,28 +75,47 @@
- ansible_distribution_major_version == '9'
become: true

- name: Remove repo file
ansible.builtin.file:
path: "{{ item_file }}"
- name: Remove PGDG repos
ansible.builtin.yum_repository:
name: "{{ item }}"
state: absent
with_items:
- "/etc/yum.repos.d/pgdg-redhat-all.repo"
- "/etc/yum.repos.d/edb.repo"
- "/etc/yum.repos.d/edb.repo.rpmsave"
- "/etc/yum.repos.d/enterprisedb-enterprise.repo"
- "/etc/yum.repos.d/enterprisedb-postgres_distributed.repo"
loop_control:
loop_var: item_file
become: true
loop: "{{ pgdg_repo_list }}"
when:
- enable_pgdg_repo|bool
- pgdg_repo_list|length > 0

- name: Remove PG/EDB repos and epel-release packages
ansible.builtin.package:
name:
- pgdg-redhat-repo
- epel-release
- edb-repo
- name: Remove EPEL repos
ansible.builtin.yum_repository:
name: "{{ item }}"
state: absent
become: true
loop: "{{ epel_repo_list }}"
when:
- enable_epel_repo|bool
- epel_repo_list|length > 0

- name: Remove EDB Repos 1.0
ansible.builtin.yum_repository:
name: "{{ item }}"
state: absent
become: true
loop: "{{ edb_repos_1_list }}"
when:
- enable_edb_repo|bool
- repo_token|length <= 1
- edb_repos_1_list|length > 0

- name: Remove EDB Repos 2.0
ansible.builtin.yum_repository:
name: "{{ item }}"
state: absent
become: true
loop: "{{ edb_repos_2_list }}"
when:
- enable_edb_repo|bool
- repo_token|length > 1
- edb_repos_2_list|length > 0

- name: Remove dnf-plugins-core for EL8/EL9
ansible.builtin.package:
Expand All @@ -71,6 +124,7 @@
become: true
when:
- ansible_distribution_major_version in ['8', '9']
- enable_epel_repo|bool

- name: Remove additional Redhat repositories
ansible.builtin.yum_repository:
Expand All @@ -79,3 +133,11 @@
become: true
loop: "{{ yum_additional_repos }}"
when: yum_additional_repos | length > 0

- name: Reset variables
ansible.builtin.set_fact:
yum_repos: null
pgdg_repo_list: null
epel_repo_list: null
edb_repos_1_list: null
edb_repos_2_list: null
171 changes: 88 additions & 83 deletions roles/setup_repo/tasks/PG_RedHat_setuprepos_aarch64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
state: latest
become: true

- name: Download EDB GPG key for EL8
ansible.builtin.rpm_key:
key: "{{ edb_gpg_key_8 }}"
state: present
when:
- ansible_distribution_major_version == '8'
- enable_edb_repo|bool
become: true
# EDB aarch64 repos coming soon
# - name: Download EDB GPG key for EL8
# ansible.builtin.rpm_key:
# key: "{{ edb_gpg_key_8 }}"
# state: present
# when:
# - ansible_distribution_major_version == '8'
# - enable_edb_repo|bool
# become: true

- name: Download PGDG GPG key for EL8
ansible.builtin.rpm_key:
Expand Down Expand Up @@ -122,24 +123,25 @@
- pg_type == 'PG'
- enable_pgdg_repo|bool

- name: Install EPAS repo for RedHat
ansible.builtin.package:
name: "{{ edb_rpm_repo }}"
state: present
become: true
when:
- enable_edb_repo|bool
- repo_token|length <= 1

- name: Set Credentials for EDB Yum Repo
ansible.builtin.replace:
path: /etc/yum.repos.d/edb.repo
regexp: '<username>:<password>'
replace: "{{ repo_username }}:{{ repo_password }}"
become: true
when:
- enable_edb_repo|bool
- repo_token|length <= 1
# EDB aarch64 repos coming soon
# - name: Install EPAS repo for RedHat
# ansible.builtin.package:
# name: "{{ edb_rpm_repo }}"
# state: present
# become: true
# when:
# - enable_edb_repo|bool
# - repo_token|length <= 1
#
# - name: Set Credentials for EDB Yum Repo
# ansible.builtin.replace:
# path: /etc/yum.repos.d/edb.repo
# regexp: '<username>:<password>'
# replace: "{{ repo_username }}:{{ repo_password }}"
# become: true
# when:
# - enable_edb_repo|bool
# - repo_token|length <= 1

- name: Add additional Redhat repositories
ansible.builtin.yum_repository:
Expand All @@ -166,61 +168,64 @@
failed_when: false
changed_when: updateinfo_output.rc != 0

# EDB aarch64 repos coming soon
# Adding PGD repository if PGD nodes are defined
- name: Install curl package if not available
ansible.builtin.package:
name: curl
state: present
become: true
when: ansible_distribution_major_version in ['7', '8']

- name: Install PGD4 packages repo if tpa_subscription_token is given
ansible.builtin.shell: >
set -o pipefail;
curl -sS "{{ edb_2q_base_repo_link }}/{{ item }}/{{ pg_version }}/rpm" | bash
args:
executable: /bin/bash
register: reposub
become: true
failed_when: >
reposub.rc != 0 or 'error: ' in reposub.stdout.lower()
changed_when: reposub.rc == '0'
when:
- enable_edb_repo|bool
- tpa_subscription_token|length > 0
- install_pgd|bool
- pg_version|int == 14
- pgd_version|int == 4
loop: "{{ edb_2q_repositories }}"

- name: Install PGD RPM packages repo
ansible.builtin.yum_repository:
name: "{{ item.name }}"
description: "{{ item.description }}"
file: "enterprisedb-postgres_distributed"
baseurl: "{{ item.repo_url }}"
gpgkey: "{{ edb_pgd_rpm_gpg_key }}"
repo_gpgcheck: true
enabled: true
when:
- enable_edb_repo|bool
- repo_token|length > 1
- install_pgd|bool
- pg_version|int >= 15
- pgd_version|int >= 5
loop: "{{ pgd_rpm_repo }}"

- name: Install EDB repository 2.0
ansible.builtin.shell: >
set -o pipefail;
curl -1sLf "{{ edb_repo_script_link }}" | bash
args:
executable: /bin/bash
register: reposub
become: true
failed_when: >
reposub.rc != 0 or 'error: ' in reposub.stdout.lower()
changed_when: reposub.rc == '0'
when:
- enable_edb_repo|bool
- repo_token|length > 1
# - name: Install curl package if not available
# ansible.builtin.package:
# name: curl
# state: present
# become: true
# when:
# - pgd_node_ips|length > 0
# - ansible_distribution_major_version in ['7', '8', '9']
#
# - name: Install PGD4 packages repo if tpa_subscription_token is given
# ansible.builtin.shell: >
# set -o pipefail;
# curl -sS "{{ edb_2q_base_repo_link }}/{{ item }}/{{ pg_version }}/rpm" | bash
# args:
# executable: /bin/bash
# register: reposub
# become: true
# failed_when: >
# reposub.rc != 0 or 'error: ' in reposub.stdout.lower()
# changed_when: reposub.rc == '0'
# when:
# - enable_edb_repo|bool
# - tpa_subscription_token|length > 0
# - install_pgd|bool
# - pg_version|int == 14
# - pgd_version|int == 4
# loop: "{{ edb_2q_repositories }}"
#
# - name: Install PGD RPM packages repo
# ansible.builtin.yum_repository:
# name: "{{ item.name }}"
# description: "{{ item.description }}"
# file: "enterprisedb-postgres_distributed"
# baseurl: "{{ item.repo_url }}"
# gpgkey: "{{ edb_pgd_rpm_gpg_key }}"
# repo_gpgcheck: true
# enabled: true
# when:
# - enable_edb_repo|bool
# - repo_token|length > 1
# - install_pgd|bool
# - pg_version|int >= 15
# - pgd_version|int >= 5
# loop: "{{ pgd_rpm_repo }}"
#
# - name: Install EDB repository 2.0
# ansible.builtin.shell: >
# set -o pipefail;
# curl -1sLf "{{ edb_repo_script_link }}" | bash
# args:
# executable: /bin/bash
# register: reposub
# become: true
# failed_when: >
# reposub.rc != 0 or 'error: ' in reposub.stdout.lower()
# changed_when: reposub.rc == '0'
# when:
# - enable_edb_repo|bool
# - repo_token|length > 1
4 changes: 3 additions & 1 deletion roles/setup_repo/tasks/PG_RedHat_setuprepos_x86_64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@
name: curl
state: present
become: true
when: ansible_distribution_major_version in ['7', '8']
when:
- pgd_node_ips|length > 0
- ansible_distribution_major_version in ['7', '8', '9']

- name: Install PGD4 packages repo if tpa_subscription_token is given
ansible.builtin.shell: >
Expand Down
Loading

0 comments on commit 7b6ab2a

Please sign in to comment.