patroni/tasks/RedHat/postgresql_install.yaml

53 lines
1.6 KiB
YAML
Raw Normal View History

2023-03-29 20:49:37 +00:00
- name: Disable PostgreSQL module
shell: dnf module disable -y postgresql
register: disable_postgresql_module
changed_when: "'Nothing to do' not in disable_postgresql_module.stdout"
2023-04-16 00:28:23 +00:00
- name: Install deps packages
dnf:
name: "{{ patroni_deps_packages }}"
state: present
update_cache: yes
2023-03-29 20:49:37 +00:00
- name: Gather packages
package_facts:
manager: auto
- name: Set fact about PostgreSQL package
set_fact:
patroni_postgresql_installed_package: "{{ ansible_facts.packages[patroni_postgresql_package_name][0]['name'] }}"
when: patroni_postgresql_package_name in ansible_facts.packages
- name: Print installed PostgreSQL version
debug:
msg: "{{ ansible_facts.packages[patroni_postgresql_package_name][0]['version'] }}"
verbosity: 2
when: patroni_postgresql_installed_package is defined
- name: "Install {{ patroni_postgresql_package_name }}-{{ patroni_postgresql_version }}"
dnf:
name: "{{ item }}"
loop:
- "{{ patroni_postgresql_packages }}"
register: patroni_postgresql_setup
when: patroni_postgresql_package_name not in ansible_facts.packages
- name: "Update {{ patroni_postgresql_package_name }}-{{ patroni_postgresql_version }}"
dnf:
name: "{{ item }}"
loop:
- "{{ patroni_postgresql_packages }}"
register: patroni_postgresql_update
when:
- patroni_postgresql_package_name in ansible_facts.packages
- ansible_facts.packages[patroni_postgresql_package_name][0]['version'] != patroni_postgresql_version|string
2023-05-12 22:19:23 +00:00
- name: Create folder for PostgreSQL logs
file:
name: "{{ item }}"
state: directory
owner: "postgres"
group: "postgres"
loop:
- "{{ patroni_postgresql_log_dir }}"