diff options
Diffstat (limited to 'roles/postgres')
-rw-r--r-- | roles/postgres/tasks/main.yml | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/roles/postgres/tasks/main.yml b/roles/postgres/tasks/main.yml index ecf8e5f..16fce30 100644 --- a/roles/postgres/tasks/main.yml +++ b/roles/postgres/tasks/main.yml @@ -58,10 +58,12 @@ - name: init postgres database shell: | initdb -D "{{ postgres_dir }}/data/" -U "{{ postgres_dbuser }}" --encoding=UTF-8 --locale=en_US.UTF-8 {# --auth=scram-sha-256 --pwprompt #} + su - _postgresql -c \ + 'initdb -D "{{ postgres_dir }}/data/" -U "{{ postgres_dbuser }}" \ + --encoding=UTF-8 \ + --locale=en_US.UTF-8' args: chdir: "{{ postgres_dir }}" - become: true - become_user: "{{ postgres_user }}" register: result failed_when: result.rc != 0 and result.stderr is defined and "exists but is not empty" not in result.stderr |