diff --git a/tasks/Debian/main.yaml b/tasks/Debian/main.yaml index 879d0df..1ca61cb 100644 --- a/tasks/Debian/main.yaml +++ b/tasks/Debian/main.yaml @@ -18,7 +18,7 @@ - name: "PostgreSQL initdb" become_user: "{{ postgresql_superuser_username }}" - shell: "/usr/lib/postgresql/{{ postgresql_major_version }}/bin/initdb -D {{ postgresql_data_dir }} --auth-local peer --auth-host {{ postgresql_password_encryption_algorithm }} --no-instructions" + shell: "/usr/lib/postgresql/{{ postgresql_major_version }}/bin/initdb -D {{ postgresql_data_dir }} --username {{ postgresql_superuser_username }} --auth-local peer --auth-host {{ postgresql_password_encryption_algorithm }} --no-instructions" register: initdb changed_when: "'exists but is not empty' not in initdb.stderr" failed_when: false diff --git a/tasks/RedHat/main.yaml b/tasks/RedHat/main.yaml index 3b163f1..9ce33a9 100644 --- a/tasks/RedHat/main.yaml +++ b/tasks/RedHat/main.yaml @@ -42,7 +42,7 @@ when: postgresql_wal_g_restore - name: PostgreSQL Initdb - shell: "/usr/pgsql-{{ postgresql_major_version }}/bin/postgresql-{{ postgresql_major_version }}-setup initdb" + shell: "/usr/pgsql-{{ postgresql_major_version }}/bin/postgresql-{{ postgresql_major_version }}-setup initdb --username {{ postgresql_superuser_username }} --auth-host {{ postgresql_password_encryption_algorithm }}" register: initdb changed_when: "'Data directory is not empty!' not in initdb.stdout" failed_when: false