Use 'creates' and specify postgresql_version per environment

This commit is contained in:
Sam A. 2023-11-12 21:46:25 +01:00
parent 7885de776c
commit f11126df9f
Signed by: samsapti
GPG Key ID: CBBBE7371E81C4EA
5 changed files with 6 additions and 9 deletions

View File

@ -1,5 +1,4 @@
# vim: ft=yaml.ansible
# code: language=ansible
---
postgresql_version: 14
postgresql_pgdata: "{{ encrypted_fs }}/pgsql/{{ postgresql_version }}/data"

View File

@ -1,5 +1,7 @@
# vim: ft=yaml.ansible
# code: language=ansible
---
postgresql_version: 14
db_passwords:
nextcloud: "{{ vault_db_passwords.nextcloud }}"

View File

@ -1,5 +1,7 @@
# vim: ft=yaml.ansible
# code: language=ansible
---
postgresql_version: 14
db_passwords:
nextcloud: "{{ vault_db_passwords.nextcloud }}"

View File

@ -1,7 +1,7 @@
# vim: ft=yaml.ansible
# code: language=ansible
---
postgresql_version: 14
postgresql_version: 16
postgresql_pgdata_default: /var/lib/pgsql/{{ postgresql_version }}/data
postgresql_pgdata: "{{ postgresql_pgdata_default }}"
postgresql_service: postgresql-{{ postgresql_version }}

View File

@ -42,16 +42,10 @@
- name: Flush handlers
ansible.builtin.meta: flush_handlers
- name: Check if pgdata directory is initialized
ansible.builtin.stat:
path: "{{ postgresql_pgdata }}/base"
register: pgdata_stat
failed_when: false
- name: Initialize database
ansible.builtin.command:
cmd: /usr/pgsql-{{ postgresql_version }}/bin/postgresql-{{ postgresql_version }}-setup initdb
when: pgdata_stat.stat.isdir is not defined or not pgdata_stat.stat.isdir
creates: "{{ postgresql_pgdata }}/base"
- name: Ensure PostgreSQL is enabled and running
ansible.builtin.service: