I have a playbook to install postgresql on a rhel8 target

one TASK should start the initdb process ...
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
- name: configure postgres - create database
command: "{{ postgres_home }}/bin/initdb -D {{ postgres_data }}"
args:
creates: "{{ postgres_data }}/PG_VERSION"
become: yes
become_user: postgres
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\


but fails with an "initdb: error: cannot be run as root" error  *details below

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
TASK [configure postgres - create database] 
**********************************************************************
fatal: [vm-51150-0180.step.zrz.dvz.cn-mv.de]: FAILED! => changed=true
cmd:
- /opt/db/postgres/postgresql/bin/initdb
- -D
- /opt/db/data/postgres/data
delta: '0:00:00.009346'
end: '2021-10-27 11:54:25.210944'
msg: non-zero return code
rc: 1
start: '2021-10-27 11:54:25.201598'
stderr: |-
initdb: error: cannot be run as root
Please log in (using, e.g., "su") as the (unprivileged) user that will
own the server process.
stderr_lines: <omitted>
stdout: ''
stdout_lines: <omitted>
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

the TASK however has a particular become_user: postgres specified. Furthermore 
Selinux is set to @permissive in an erlier TASK.

Manually running /opt/db/postgres/postgresql/bin/initdb -D 
/opt/db/data/postgres/data/ on the target as user postgres works, so I can not 
make much sense of this. It's kind of obvious the become process does not work, 
but I can't figure out why. Plaid a bit with indentation, but did not find any 
solution that works

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/776382835.43477.1635335720976%40office.mailbox.org.

Reply via email to