split vars for RedHat and Debian os family

This commit is contained in:
ace 2023-04-19 00:12:30 +03:00
parent 654135fb2c
commit e119bab25c
Signed by: ace
GPG Key ID: 2C08973DD37A76FD
8 changed files with 99 additions and 35 deletions

View File

@ -1 +1,6 @@
Setup WAL-G for RHEL8 Setup WAL-G
Tested with OS:
- AlmaLinux 8/9
- Debian 11
- Ubuntu 20.04/22.04

View File

@ -1,4 +1,5 @@
wal_g_version: "2.0.1-3.el{{ ansible_distribution_major_version }}" wal_g_version: "2.0.1"
wal_g_install_repo: true
wal_g_pg: false wal_g_pg: false
wal_g_restore: false wal_g_restore: false
@ -17,6 +18,11 @@ wal_g_backup_retention_schedule: ""
wal_g_backup_retention_number: 7 wal_g_backup_retention_number: 7
wal_g_backup_permanent_schedule: "" wal_g_backup_permanent_schedule: ""
wal_g_postgresql_supported_versions:
- 13
- 14
- 15
wal_g_default_config: # more options see https://github.com/wal-g/wal-g#configuration wal_g_default_config: # more options see https://github.com/wal-g/wal-g#configuration
# AWS_ACCESS_KEY_ID: "secret-key" # AWS_ACCESS_KEY_ID: "secret-key"
# AWS_SECRET_ACCESS_KEY: "access-key" # AWS_SECRET_ACCESS_KEY: "access-key"

View File

@ -1,10 +1,3 @@
- name: Install curl and jq
dnf:
name:
- jq
- curl
state: present
- name: Template backup script - name: Template backup script
template: template:
src: backup.sh.j2 src: backup.sh.j2

View File

@ -1,10 +1,3 @@
- name: Install curl and jq
dnf:
name:
- jq
- curl
state: present
- name: Template backup permanent script - name: Template backup permanent script
template: template:
src: backup-permanent.sh.j2 src: backup-permanent.sh.j2

View File

@ -1,10 +1,3 @@
- name: Install curl and jq
dnf:
name:
- jq
- curl
state: present
- name: Template backup retention script - name: Template backup retention script
template: template:
src: backup-retention.sh.j2 src: backup-retention.sh.j2

View File

@ -1,16 +1,68 @@
--- ---
- name: "Install EPEL" - name: RHEL based distros
dnf: when: ansible_os_family == "RedHat"
name: "epel-release" block:
state: present - name: Install WAL-G repository
ansible.builtin.yum_repository:
name: "{{ item.name }}"
description: "{{ item.description }}"
file: "{{ item.file }}"
baseurl: "{{ item.baseurl }}"
gpgcheck: "{{ item.gpgcheck | default('no') }}"
enabled: "{{ item.enabled | default('yes') }}"
repo_gpgcheck: "{{ item.repo_gpgcheck | default('no') }}"
gpgkey: "{{ item.gpgkey | default('omit') }}"
loop: "{{ wal_g_rpm_repository }}"
when: wal_g_install_repo
- name: "Install WAL-G {{ wal_g_version }} for PostgreSQL" - name: "Install WAL-G {{ wal_g_version }}"
dnf: dnf:
name: "wal-g{{ ('-' ~ wal_g_version) | default('') }}" name: "{{ wal_g_package }}"
state: installed state: present
update_cache: yes update_cache: yes
allow_downgrade: yes allow_downgrade: yes
tags: wal-g, wal_g, wal_g_install tags: wal-g, wal_g, wal_g_install
- name: "Install curl and jq"
dnf:
name:
- curl
- jq
state: present
update_cache: yes
- name: Debian based distros
when: ansible_os_family == "Debian"
block:
- name: Install apt-transport-https
apt:
name: apt-transport-https
state: present
- name: Add WAL-G repository
ansible.builtin.apt_repository:
repo: "{{ item.repo }}"
state: present
filename: "{{ item.filename }}"
update_cache: yes
loop: "{{ wal_g_apt_repository }}"
when: wal_g_install_repo
- name: "Install WAL-G {{ wal_g_version }}"
apt:
name: "{{ wal_g_package }}"
state: present
update_cache: yes
allow_downgrade: yes
tags: wal-g, wal_g, wal_g_install
- name: "Install curl and jq"
apt:
name:
- curl
- jq
state: present
update_cache: yes
- name: "Gather packages" - name: "Gather packages"
package_facts: package_facts:
@ -18,7 +70,7 @@
- name: "Set fact about PostgreSQL package" - name: "Set fact about PostgreSQL package"
set_fact: set_fact:
wal_g_postgresql_package: "{{ ansible_facts.packages | list | select('match', wal_g_pg_package_name_regex) | first }}" wal_g_postgresql_package: "{{ ansible_facts.packages | list | select('match', wal_g_postgresql_package_name_regex) | first }}"
- name: "Get PostgreSQL major version" - name: "Get PostgreSQL major version"
set_fact: set_fact:

View File

@ -1,3 +1,13 @@
wal_g_apt_repository:
- repo: deb [trusted=yes] https://mirror.0xace.cc/debian/custom/ default all
filename: mirror.0xace.cc
wal_g_pg_home_dir: "/var/lib/postgresql" wal_g_pg_home_dir: "/var/lib/postgresql"
wal_g_pg_data_dir: "{{ wal_g_pg_home_dir }}/{{ wal_g_pg_major_version }}/{{ wal_g_pg_cluster_name }}" wal_g_pg_data_dir: "{{ wal_g_pg_home_dir }}/{{ wal_g_pg_major_version }}/{{ wal_g_pg_cluster_name }}"
wal_g_pg_cluster_name: "main" wal_g_pg_cluster_name: "main"
wal_g_postgresql_package_name_regex: 'postgresql-.[{{ wal_g_postgresql_supported_versions | join(",") }}]'
wal_g_package_name: "wal-g"
wal_g_package: "{{ wal_g_package_name }}={{ wal_g_version }}-{{ wal_g_version_build }}"
wal_g_version_build: "4"

View File

@ -1,2 +1,14 @@
wal_g_rpm_repository:
- name: "mirror.0xace.cc"
file: "mirror.0xace.cc"
description: "0xace.cc repository"
baseurl: "https://mirror.0xace.cc/rhel/$releasever/custom/"
gpgcheck: no
wal_g_pg_home_dir: "/var/lib/pgsql" wal_g_pg_home_dir: "/var/lib/pgsql"
wal_g_pg_data_dir: "{{ wal_g_pg_home_dir }}/{{ wal_g_pg_major_version }}/data" wal_g_pg_data_dir: "{{ wal_g_pg_home_dir }}/{{ wal_g_pg_major_version }}/data"
wal_g_postgresql_package_name_regex: 'postgresql.[{{ wal_g_postgresql_supported_versions | join(",") }}]-server'
wal_g_package_name: "wal-g"
wal_g_package: "{{ wal_g_package_name }}-{{ wal_g_version }}"