aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--roles/postgres/tasks/main.yml9
1 files changed, 4 insertions, 5 deletions
diff --git a/roles/postgres/tasks/main.yml b/roles/postgres/tasks/main.yml
index 78f208c..a203574 100644
--- a/roles/postgres/tasks/main.yml
+++ b/roles/postgres/tasks/main.yml
@@ -33,14 +33,13 @@
follow: false
when: postgres_dir != "/var/postgresql"
- # NOTE: this tasks needs `pipelining` set to `false` to work correctly
- name: init postgres database # noqa: no-changed-when
- command:
- cmd: initdb -D "{{ postgres_dir }}/data/" -U "{{ postgres_db_user }}" --encoding=UTF-8 --locale=en_US.UTF-8
+ shell:
+ cmd: |
+ su "{{ postgres_user }}" \
+ -c 'initdb -D "{{ postgres_dir }}/data/" -U "{{ postgres_db_user }}" --encoding=UTF-8 --locale=en_US.UTF-8'
chdir: "{{ postgres_dir }}"
register: result
- become: true
- become_user: "{{ postgres_user }}"
failed_when:
- result.rc != 0
- "'exists but is not empty' not in result.stderr"
remember that computers suck.