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 # vim: ft=yaml.ansible
# code: language=ansible # code: language=ansible
--- ---
postgresql_version: 14
postgresql_pgdata: "{{ encrypted_fs }}/pgsql/{{ postgresql_version }}/data" postgresql_pgdata: "{{ encrypted_fs }}/pgsql/{{ postgresql_version }}/data"

View file

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

View file

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

View file

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

View file

@ -42,16 +42,10 @@
- name: Flush handlers - name: Flush handlers
ansible.builtin.meta: 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 - name: Initialize database
ansible.builtin.command: ansible.builtin.command:
cmd: /usr/pgsql-{{ postgresql_version }}/bin/postgresql-{{ postgresql_version }}-setup initdb 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 - name: Ensure PostgreSQL is enabled and running
ansible.builtin.service: ansible.builtin.service: