2023-04-16 00:28:23 +00:00
- name : Install deps packages
apt :
name : "{{ patroni_deps_packages }}"
state : present
update_cache : yes
2023-03-29 20:49:37 +00:00
- name : Install postgresql-common
apt :
name : postgresql-common
state : present
- name : Create dir createcluster.d
file :
path : /etc/postgresql-common/createcluster.d
state : directory
- name : Disable main cluster creation by default
copy :
dest : /etc/postgresql-common/createcluster.d/create-main-cluster.conf
content : |
create_main_cluster = false
- 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 : Mask PostgreSQL before install
ansible.builtin.systemd :
name : "{{ patroni_postgresql_unit_name }}"
masked : yes
when : patroni_postgresql_package_name not in ansible_facts.packages or ansible_facts.packages[patroni_postgresql_package_name][0]['version'] != (patroni_postgresql_version|string + "-" + patroni_postgresql_version_build|string)
- name : "Install {{ patroni_postgresql_package_name }}-{{ patroni_postgresql_version }}-{{ patroni_postgresql_version_build }}"
apt :
name : "{{ patroni_postgresql_package }}"
update_cache : yes
register : patroni_postgresql_setup
when : patroni_postgresql_package_name not in ansible_facts.packages
- name : "Update {{ patroni_postgresql_package_name }}-{{ patroni_postgresql_version }}-{{ patroni_postgresql_version_build }}"
apt :
name : "{{ patroni_postgresql_package }}"
update_cache : yes
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 + "-" + patroni_postgresql_version_build|string)
2023-05-12 22:19:23 +00:00
- name : Create folder for PostgreSQL logs
file :
name : "{{ item }}"
state : directory
owner : "root"
group : "postgres"
loop :
- "{{ patroni_postgresql_log_dir }}"