From 04edbf561c44e28753cbbaa3870b23b220cc644c Mon Sep 17 00:00:00 2001 From: Luke Hoersten Date: Sun, 4 Feb 2024 20:27:19 -0600 Subject: Tons of updates to fix migration to new server. --- postgresql/defaults/main.yaml | 1 + postgresql/tasks/main.yaml | 11 +++++++++++ 2 files changed, 12 insertions(+) (limited to 'postgresql') diff --git a/postgresql/defaults/main.yaml b/postgresql/defaults/main.yaml index 8a208b7..de97031 100644 --- a/postgresql/defaults/main.yaml +++ b/postgresql/defaults/main.yaml @@ -2,6 +2,7 @@ # migrate PG version with pg_upgradecluster (see manpage) postgresql_version: "14" +postgresql_initidb_path: "/usr/lib/postgresql/{{postgresql_version}}/bin/initdb" postgresql_config_path: "/etc/postgresql/{{postgresql_version}}/main/postgresql.conf" postgresql_data_dir: "/var/lib/postgresql/{{postgresql_version}}/main" postgresql_apt_packages: diff --git a/postgresql/tasks/main.yaml b/postgresql/tasks/main.yaml index 6195840..6efa491 100644 --- a/postgresql/tasks/main.yaml +++ b/postgresql/tasks/main.yaml @@ -22,6 +22,17 @@ group: "postgres" notify: restart postgres +- name: check if postgresql data dir is new + become: yes + find: path='{{postgresql_data_dir}}' + register: filesFound + +- name: initialize pg data dir + become: yes + become_user: "postgres" + command: "{{postgresql_initidb_path}} -D {{postgresql_data_dir}}" + when: filesFound == 0 + - name: ensure postgresql is started become: yes systemd: name="postgresql" enabled="yes" state="started" -- cgit v1.2.3