Skip to content

Commit

Permalink
Disable 'pgdg' repo during system packages installation (RHEL). (#561)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitabaks authored Jan 24, 2024
1 parent 0ca74b7 commit e70836c
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 26 deletions.
41 changes: 33 additions & 8 deletions roles/packages/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,55 @@
tags: install_packages_from_file

- block: # RedHat (update cache)
- name: Clean yum cache
ansible.builtin.command: yum clean all
- name: Update yum cache
ansible.builtin.shell: yum clean all && yum -y makecache
args:
executable: /bin/bash
when: ansible_distribution_major_version == '7'

- name: Clean dnf cache
ansible.builtin.command: dnf clean all
when: ansible_distribution_major_version is version('8', '>=')
- name: Update dnf cache
ansible.builtin.shell: dnf clean all && dnf -y makecache
args:
executable: /bin/bash
when: ansible_distribution_major_version >= '8'
environment: "{{ proxy_env | default({}) }}"
when: ansible_os_family == "RedHat" and installation_method == "repo"
tags: install_packages, install_postgres

# Install packages from repository
# RedHat
- name: Install system packages
ansible.builtin.package:
ansible.builtin.yum:
name: "{{ item }}"
state: present
disablerepo: 'pgdg*'
loop: "{{ system_packages }}"
register: package_status
until: package_status is success
delay: 5
retries: 3
environment: "{{ proxy_env | default({}) }}"
when: ansible_os_family == "RedHat" and installation_method == "repo"
when:
- installation_method == "repo"
- ansible_os_family == "RedHat"
- ansible_distribution_major_version == '7'
tags: install_packages

- name: Install system packages
ansible.builtin.dnf:
name: "{{ item }}"
state: present
disablerepo: 'pgdg*'
loop: "{{ system_packages }}"
register: package_status
until: package_status is success
delay: 5
retries: 3
environment: "{{ proxy_env | default({}) }}"
when:
- installation_method == "repo"
- ansible_os_family == "RedHat"
- ansible_distribution_major_version >= '8'
tags: install_packages

# Debian
Expand Down Expand Up @@ -100,7 +125,7 @@
when: installation_method == "repo" and ansible_os_family == "Debian"
tags: install_postgres

# PostgreSQL prepare for install (for RHEL 8)
# PostgreSQL prepare for install (for RHEL)
- block:
- name: PostgreSQL | check if appstream module is enabled
ansible.builtin.command: 'dnf -y -C module list postgresql'
Expand Down
14 changes: 9 additions & 5 deletions roles/update/tasks/postgres.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
---
- name: Clean yum cache
ansible.builtin.command: yum clean all
- name: Update yum cache
ansible.builtin.shell: yum clean all && yum -y makecache
args:
executable: /bin/bash
when:
- ansible_os_family == "RedHat"
- ansible_distribution_major_version == '7'

- name: Clean dnf cache
ansible.builtin.command: dnf clean all
- name: Update dnf cache
ansible.builtin.shell: dnf clean all && dnf -y makecache
args:
executable: /bin/bash
when:
- ansible_os_family == "RedHat"
- ansible_distribution_major_version is version('8', '>=')
- ansible_distribution_major_version >= '8'

- name: Update apt cache
ansible.builtin.apt:
Expand Down
41 changes: 36 additions & 5 deletions roles/update/tasks/system.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
---
- name: Clean yum cache
ansible.builtin.command: yum clean all
- name: Update yum cache
ansible.builtin.shell: yum clean all && yum -y makecache
args:
executable: /bin/bash
when:
- ansible_os_family == "RedHat"
- ansible_distribution_major_version == '7'

- name: Clean dnf cache
ansible.builtin.command: dnf clean all
- name: Update dnf cache
ansible.builtin.shell: dnf clean all && dnf -y makecache
args:
executable: /bin/bash
when:
- ansible_os_family == "RedHat"
- ansible_distribution_major_version is version('8', '>=')
- ansible_distribution_major_version >= '8'

- name: Update apt cache
ansible.builtin.apt:
Expand All @@ -30,6 +34,33 @@
delay: 5
retries: 3
ignore_errors: true
when: ansible_os_family == "Debian"

- name: Update all system packages
ansible.builtin.yum:
name: '*'
state: latest
disablerepo: 'pgdg*'
register: package_status
until: package_status is success
delay: 5
retries: 3
when:
- ansible_os_family == "RedHat"
- ansible_distribution_major_version == '7'

- name: Update all system packages
ansible.builtin.dnf:
name: '*'
state: latest
disablerepo: 'pgdg*'
register: package_status
until: package_status is success
delay: 5
retries: 3
when:
- ansible_os_family == "RedHat"
- ansible_distribution_major_version >= '8'

- name: Check if a reboot is required
ansible.builtin.stat:
Expand Down
14 changes: 6 additions & 8 deletions update_pgcluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,15 @@
ansible.builtin.include_role:
name: update
tasks_from: postgres
when: target | lower == 'postgres'
when: target | lower == 'postgres' or target | lower == 'system'

- name: Update Patroni
ansible.builtin.include_role:
name: update
tasks_from: patroni
when: target | lower == 'patroni' or
(target | lower == 'system' and patroni_installation_method == "pip")
when: target | lower == 'patroni' or target | lower == 'system'

- name: Update all system packages (includes PostgreSQL and Patroni)
- name: Update all system packages
ansible.builtin.include_role:
name: update
tasks_from: system
Expand Down Expand Up @@ -161,16 +160,15 @@
ansible.builtin.include_role:
name: update
tasks_from: postgres
when: target | lower == 'postgres'
when: target | lower == 'postgres' or target | lower == 'system'

- name: Update Patroni
ansible.builtin.include_role:
name: update
tasks_from: patroni
when: target | lower == 'patroni' or
(target | lower == 'system' and patroni_installation_method == "pip")
when: target | lower == 'patroni' or target | lower == 'system'

- name: Update all system packages (includes PostgreSQL and Patroni)
- name: Update all system packages
ansible.builtin.include_role:
name: update
tasks_from: system
Expand Down

0 comments on commit e70836c

Please sign in to comment.