# Unable to Install PostgreSQL using Ansible

**URL:** <https://forum.ansible.com/t/unable-to-install-postgresql-using-ansible/23097>\
**Category:** Ansible Project\
**Created:** [November 25, 2016, 1:33pm UTC](https://forum.ansible.com/t/unable-to-install-postgresql-using-ansible/23097 "2016-11-25T13:33:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gustavo\_da\_Silva\_Car](https://avatars.discourse-cdn.com/v4/letter/g/919ad9/32.png) [@Gustavo\_da\_Silva\_Car](https://forum.ansible.com/u/Gustavo_da_Silva_Car)\
**Post date:** [November 25, 2016, 1:33pm UTC](https://forum.ansible.com/t/unable-to-install-postgresql-using-ansible/23097/1 "2016-11-25T13:33:37Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Dick\_Davies](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Dick\_Davies](https://forum.ansible.com/u/Dick_Davies)\
**Post date:** [November 29, 2016, 2:34pm UTC](https://forum.ansible.com/t/unable-to-install-postgresql-using-ansible/23097/2 "2016-11-29T14:34:47Z")

</div>

> Hello Everyone,

....  
....

> > &nbsp;&nbsp;become\_user: postgres  
> > &nbsp;&nbsp;become: true

...  
...

> &nbsp;&nbsp;&nbsp;&nbsp;"module\_stdout": "sudo: a password is required\r\n",  
> &nbsp;&nbsp;&nbsp;&nbsp;"msg": "MODULE FAILURE"

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

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [November 29, 2016, 2:35pm UTC](https://forum.ansible.com/t/unable-to-install-postgresql-using-ansible/23097/3 "2016-11-29T14:35:44Z")

</div>

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