2023-02-07 23:18:19 +00:00
|
|
|
---
|
2023-04-18 21:12:30 +00:00
|
|
|
- name: RHEL based distros
|
|
|
|
when: ansible_os_family == "RedHat"
|
|
|
|
block:
|
|
|
|
- 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 }}"
|
|
|
|
dnf:
|
|
|
|
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"
|
|
|
|
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
|
|
|
|
|
2023-04-19 11:24:54 +00:00
|
|
|
- name: "Install WAL-G {{ wal_g_version }} and deps"
|
2023-04-18 21:12:30 +00:00
|
|
|
apt:
|
2023-04-19 11:24:54 +00:00
|
|
|
name:
|
|
|
|
- "{{ wal_g_package }}"
|
|
|
|
- libsodium23
|
|
|
|
- liblzo2-2
|
2023-04-18 21:12:30 +00:00
|
|
|
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
|
2023-02-07 23:18:19 +00:00
|
|
|
|
|
|
|
- name: "Gather packages"
|
|
|
|
package_facts:
|
|
|
|
manager: auto
|
|
|
|
|
|
|
|
- name: "Set fact about PostgreSQL package"
|
|
|
|
set_fact:
|
2023-04-18 21:12:30 +00:00
|
|
|
wal_g_postgresql_package: "{{ ansible_facts.packages | list | select('match', wal_g_postgresql_package_name_regex) | first }}"
|
2023-02-07 23:18:19 +00:00
|
|
|
|
|
|
|
- name: "Get PostgreSQL major version"
|
|
|
|
set_fact:
|
2023-02-20 19:54:43 +00:00
|
|
|
wal_g_pg_major_version: "{{ ansible_facts.packages[wal_g_postgresql_package][0]['version'] | split('.') | first }}"
|
2023-02-07 23:18:19 +00:00
|
|
|
|
|
|
|
- name: Merge user options for WAL-G part of config
|
|
|
|
set_fact:
|
|
|
|
wal_g_combined_config: "{{ wal_g_default_config | combine(wal_g_config|default({}), recursive=true) }}"
|
|
|
|
|
|
|
|
- name: "Generate conf file walg.json"
|
|
|
|
copy:
|
|
|
|
content: "{{ wal_g_combined_config | to_nice_json }}"
|
2023-02-20 09:44:18 +00:00
|
|
|
dest: "{{ wal_g_pg_home_dir }}/{{ wal_g_config_name }}"
|
2023-02-07 23:18:19 +00:00
|
|
|
owner: "{{ wal_g_pg_config_owner }}"
|
|
|
|
group: "{{ wal_g_pg_config_group }}"
|
|
|
|
mode: 0644
|
|
|
|
tags: wal-g, wal_g, wal_g_conf
|
|
|
|
|
2023-02-20 09:44:18 +00:00
|
|
|
- name: Create wal-g restore config
|
|
|
|
when: wal_g_restore
|
|
|
|
block:
|
|
|
|
- name: Merge user options for WAL-G part of restore config
|
|
|
|
set_fact:
|
|
|
|
wal_g_restore_combined_config: "{{ wal_g_default_restore_config | combine(wal_g_restore_config|default({}), recursive=true) }}"
|
|
|
|
|
|
|
|
- name: "Generate conf file walg-restore.json"
|
|
|
|
copy:
|
|
|
|
content: "{{ wal_g_restore_combined_config | to_nice_json }}"
|
|
|
|
dest: "{{ wal_g_pg_home_dir }}/{{ wal_g_restore_config_name }}"
|
|
|
|
owner: "{{ wal_g_pg_config_owner }}"
|
|
|
|
group: "{{ wal_g_pg_config_group }}"
|
|
|
|
mode: 0644
|