Update to 2020-11-09 21:00

master
Daniel Berteaud 4 years ago
parent 079973a6ca
commit 1a7a45a131
  1. 4
      roles/postgresql_server/meta/main.yml
  2. 35
      roles/postgresql_server/tasks/main.yml
  3. 7
      roles/postgresql_server/vars/CentOS-7.yml
  4. 7
      roles/postgresql_server/vars/CentOS-8.yml
  5. 5
      roles/repo_postgresql/defaults/main.yml
  6. 8
      roles/repo_postgresql/tasks/main.yml
  7. 11
      roles/repo_postgresql/templates/postgresql.repo.j2

@ -0,0 +1,4 @@
---
dependencies:
- role: repo_postgresql

@ -1,31 +1,16 @@
---
- name: Configure PostgreSQL repository
yum_repository:
name: postgresql
description: PostgreSQL
baseurl: https://download.postgresql.org/pub/repos/yum/{{ pg_version }}/redhat/rhel-$releasever-$basearch
gpgcheck: True
gpgkey: https://download.postgresql.org/pub/repos/yum/RPM-GPG-KEY-PGDG-{{ pg_version }}
state: "{{ (pg_version != 'default') | ternary('present','absent') }}"
register: pg_repo
tags: pg,repo
- name: Clear PostgreSQL repo cache
file: path=/var/cache/yum/{{ ansible_architecture }}/{{ ansible_distribution_major_version }}/postgresql/{{ item }} state=absent
loop:
- cachecookie
- repomd.xml
when: pg_repo.changed
tags: pg
- name: Install dependencies
- include_vars: "{{ item }}"
with_first_found:
- vars/{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml
- vars/{{ ansible_distribution }}.yml
- vars/{{ ansible_os_family }}.yml
- vars/defaults.yml
tags: pg
- name: Install Postgresql packages
yum:
name:
- postgresql{{ (pg_version != 'default') | ternary(pg_version | string,'') }}
- postgresql{{ (pg_version != 'default') | ternary(pg_version | string,'') }}-server
- postgresql{{ (pg_version != 'default') | ternary(pg_version | string,'') }}-contrib
- python-psycopg2
name: "{{ pg_packages }}"
tags: pg
- name: Check if PG_VERSION exists

@ -0,0 +1,7 @@
---
pg_packages:
- postgresql{{ (pg_version != 'default') | ternary(pg_version | string,'') }}
- postgresql{{ (pg_version != 'default') | ternary(pg_version | string,'') }}-server
- postgresql{{ (pg_version != 'default') | ternary(pg_version | string,'') }}-contrib
- python-psycopg2

@ -0,0 +1,7 @@
---
pg_packages:
- postgresql{{ (pg_version != 'default') | ternary(pg_version | string,'') }}
- postgresql{{ (pg_version != 'default') | ternary(pg_version | string,'') }}-server
- postgresql{{ (pg_version != 'default') | ternary(pg_version | string,'') }}-contrib
- python3-psycopg2

@ -0,0 +1,5 @@
---
# Version of postgres to install. 'default' means takes the one from the standard repo
# If a version is specified (like 10, 11, 12, 13 etc.), upstream repository will be configured
pg_version: default

@ -0,0 +1,8 @@
---
# Here we use a template instead of yum_repository because
# we might need to set module_hotfixes = true for el8. And yum_repository
# doesn't support this setting
- name: Configure Postgres repo
template: src=postgresql.repo.j2 dest=/etc/yum.repos.d/postgresql.repo
tags: pg,repo

@ -0,0 +1,11 @@
{% if pg_version != 'default' %}
[postgresql]
baseurl = https://download.postgresql.org/pub/repos/yum/{{ pg_version }}/redhat/rhel-$releasever-$basearch
gpgcheck = 1
gpgkey = https://download.postgresql.org/pub/repos/yum/RPM-GPG-KEY-PGDG-{{ pg_version }}
name = PostgreSQL
{% if ansible_os_family == 'RedHat' and ansible_distribution_major_version is version('8', '>=') %}
# Workaround a bug in dnf which would make the default module mask packages from postgres repo
module_hotfixes = true
{% endif %}
{% endif %}
Loading…
Cancel
Save