diff --git a/defaults/main.yaml b/defaults/main.yaml index 8b0cddf..e67f9c1 100644 --- a/defaults/main.yaml +++ b/defaults/main.yaml @@ -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" diff --git a/tasks/Debian/config.yaml b/tasks/Debian/config.yaml index 0278c10..bd64e7a 100644 --- a/tasks/Debian/config.yaml +++ b/tasks/Debian/config.yaml @@ -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) }}" diff --git a/tasks/Debian/install.yaml b/tasks/Debian/install.yaml index 9b036ca..30ea509 100644 --- a/tasks/Debian/install.yaml +++ b/tasks/Debian/install.yaml @@ -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: @@ -16,7 +17,24 @@ state: present filename: "{{ item.filename }}" update_cache: yes - loop: "{{ postgresql_apt_repository }}" + 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) diff --git a/tasks/RedHat/main.yaml b/tasks/RedHat/main.yaml index 4ca73a9..3300cb8 100644 --- a/tasks/RedHat/main.yaml +++ b/tasks/RedHat/main.yaml @@ -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: