I am trying to automate the installation of a PostgreSQL database using Ansible.
However, the following task:
- name: Initialize Postgres
command: /usr/pgsql-9.6/bin/postgresql96-setup initdb
become: true
Results in this error:
fatal: [nexus-staging.chop.edu]: FAILED! => {
"changed": true,
"cmd": "/usr/pgsql-9.6/bin/postgresql96-setup initdb",
"delta": "0:00:00.043311",
"end": "2017-02-16 23:39:12.512727",
"failed": true,
"invocation": {
"module_args": {
"_raw_params": "/usr/pgsql-9.6/bin/postgresql96-setup initdb",
"_uses_shell": true,
"chdir": null,
"creates": null,
"executable": null,
"removes": null,
"warn": true
},
"module_name": "command"
},
"rc": 1,
"start": "2017-02-16 23:39:12.469416",
"stderr": "",
"stdout": "Initializing database ... failed, see /var/lib/pgsql/9.6/initdb.log",
"stdout_lines": [
"Initializing database ... failed, see /var/lib/pgsql/9.6/initdb.log"
],
"warnings": []
}
The error in /var/lib/pgsql/9.6/initdb.log is:
/usr/pgsql-9.6/bin/postgresql96-setup: line 140: runuser: command not found
What is interesting is that if I run sudo /usr/pgsql-9.6/bin/postgresql96-setup initdb on the host, it runs successfully...
Any help would be appreciated.