This commit is contained in:
ace 2023-03-29 23:47:01 +03:00
parent 41f598a238
commit 2ea9e25263
Signed by: ace
GPG Key ID: 2C08973DD37A76FD
4 changed files with 30 additions and 3 deletions

View File

@ -1,6 +1,7 @@
postgresql_version: "15.2"
# Options
postgresql_install_official_repo: true
postgresql_play_group: "postgresql"
postgresql_superuser_db: "postgres"
postgresql_superuser_username: "postgres"

View File

@ -6,6 +6,13 @@
group: "postgres"
state: directory
- name: Create configuration directory
file:
path: "{{ postgresql_config_dir }}/{{ postgresql_major_version }}/{{ postgresql_cluster_name }}"
owner: "postgres"
group: "postgres"
state: directory
- name: Merge user options for PostgreSQL config
set_fact:
postgresql_combined_parameters: "{{ postgresql_default_parameters | combine(postgresql_custom_parameters|default({}), recursive=true) }}"

View File

@ -9,6 +9,7 @@
url: "{{ item.url }}"
keyring: "{{ item.keyring }}"
loop: "{{ postgresql_apt_key }}"
when: postgresql_install_official_repo
- name: Add PostgreSQL repository
ansible.builtin.apt_repository:
@ -17,6 +18,23 @@
filename: "{{ item.filename }}"
update_cache: yes
loop: "{{ postgresql_apt_repository }}"
when: postgresql_install_official_repo
- 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:
@ -37,7 +55,7 @@
ansible.builtin.systemd:
name: "{{ postgresql_unit_name }}"
masked: yes
when: postgresql_package_name not in ansible_facts.packages or ansible_facts.packages[postgresql_package_name][0]['version'] != (postgresql_version + "-" + postgresql_version_build)
when: postgresql_package_name not in ansible_facts.packages or ansible_facts.packages[postgresql_package_name][0]['version'] != (postgresql_version|string + "-" + postgresql_version_build|string)
- name: "Install {{ postgresql_package_name }}-{{ postgresql_version }}-{{ postgresql_version_build }}"
apt:
@ -54,4 +72,4 @@
notify: Restart PostgreSQL
when:
- postgresql_package_name in ansible_facts.packages
- ansible_facts.packages[postgresql_package_name][0]['version'] != (postgresql_version + "-" + postgresql_version_build)
- ansible_facts.packages[postgresql_package_name][0]['version'] != (postgresql_version|string + "-" + postgresql_version_build|string)

View File

@ -15,6 +15,7 @@
name: "{{ postgresql_repo_package }}"
disable_gpg_check: yes
state: present
when: postgresql_install_official_repo
- name: "Install {{ postgresql_package_name }} {{ postgresql_version }}"
dnf: