Unable to Install PostgreSQL using Ansible

34 views
Skip to first unread message

Gustavo da Silva Carita

unread,
Nov 28, 2016, 7:05:30 PM11/28/16
to Ansible Project
Hello Everyone,

I'm new to Ansible, and I ended up having a problem with my playbook to install psql. I already tried everything and searched everywhere.

When I perform the following task:

- name: Ensure database is created
  become_user: postgres
  become: true
  postgresql_db: name={{ db_name }}
                 encoding='UTF-8'
                 lc_collate='en_US.UTF-8'
                 lc_ctype='en_US.UTF-8'
                 template='template0'
                 state=present

I keep getting erros like:

fatal: [X.X.X.X]: FAILED! => {
    "changed": false,
    "failed": true,
    "invocation": {
        "module_name": "postgresql_db"
    },
    "module_stderr": "OpenSSH_6.9p1, LibreSSL 2.1.8\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 21: Applying options for *\r\ndebug1: /etc/ssh/ssh_config line 56: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 82852\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 1\r\nShared connection to X.X.X.X closed.\r\n",
    "module_stdout": "sudo: a password is required\r\n",
    "msg": "MODULE FAILURE"

If needed I can post more code. I'm almost giving up and install this by hand.

Thank you!

Dick Davies

unread,
Nov 29, 2016, 9:34:53 AM11/29/16
to ansible list
On 25 November 2016 at 13:33, Gustavo da Silva Carita
<gustavosi...@gmail.com> wrote:
> Hello Everyone,
....
....
>> become_user: postgres
>> become: true
...
...
> "module_stdout": "sudo: a password is required\r\n",
> "msg": "MODULE FAILURE"

Ansible needs a password so it can sudo to the postgres user.

Kai Stian Olstad

unread,
Nov 29, 2016, 9:36:36 AM11/29/16
to ansible...@googlegroups.com
On 25. nov. 2016 14:33, Gustavo da Silva Carita wrote:
> "module_stdout": "sudo: a password is required\r\n",
>
> If needed I can post more code. I'm almost giving up and install this by
> hand.

As the error message says, you need to provide the sudo password, add
"ask_pass = True" og --become/-b on the commandline.

--
Kai Stian Olstad
Reply all
Reply to author
Forward
0 new messages