From 53d2e322aac5295ad39f600c641c41240c801c87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Gon=C3=A7alves?= Date: Thu, 29 Apr 2021 20:23:58 +0200 Subject: roles/postgres: Bypass become fail --- roles/postgres/tasks/main.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'roles') 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 -- cgit v1.2.3