# Creation of tables failing when done SHELL Module of Ansible on PostgreSQL

**URL:** <https://forum.ansible.com/t/creation-of-tables-failing-when-done-shell-module-of-ansible-on-postgresql/27038>\
**Category:** Ansible Developer\
**Created:** [March 19, 2018, 1:36pm UTC](https://forum.ansible.com/t/creation-of-tables-failing-when-done-shell-module-of-ansible-on-postgresql/27038 "2018-03-19T13:36:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tushar\_Dudhade](https://avatars.discourse-cdn.com/v4/letter/t/ec9cab/32.png) [@Tushar\_Dudhade](https://forum.ansible.com/u/Tushar_Dudhade)\
**Post date:** [March 19, 2018, 1:36pm UTC](https://forum.ansible.com/t/creation-of-tables-failing-when-done-shell-module-of-ansible-on-postgresql/27038/1 "2018-03-19T13:36:24Z")

</div>

I wrote the shell script to be run over the PostgreSQL to create tables in a particular database schema. For users, db and schema creation I am using PostgrSQL Ansible modules but for tables creation I am using the shell module which runs a shell script and creates the tables.

For normal user to create this, I have used setting trust in pg\_hba.conf using pg\_ident.conf file, but this would be a security override for a normal DB user.

Would anybody suggest how can I use password to run this script over the database? P.S.: I even tried using PGPASSWORD, but it is not being picked up to run this shell script which in turn runs SQL file which has calls to multiple different SQL files.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Mike\_Sawyers](https://avatars.discourse-cdn.com/v4/letter/m/e9a140/32.png) [@Mike\_Sawyers](https://forum.ansible.com/u/Mike_Sawyers)\
**Post date:** [March 20, 2018, 1:55pm UTC](https://forum.ansible.com/t/creation-of-tables-failing-when-done-shell-module-of-ansible-on-postgresql/27038/2 "2018-03-20T13:55:03Z")

</div>

Did you try:

- Providing a pg\_hba.conf that is trusting enough to create the schema
- Replace pg\_hba.conf with your default secure version
- Reload the database to assert the correct rules

I’ve had to do just that manually in the past for other reasons and it worked for me as a quick solution

---

<div class="post-metadata">

**Author:** ![Tushar\_Dudhade](https://avatars.discourse-cdn.com/v4/letter/t/ec9cab/32.png) [@Tushar\_Dudhade](https://forum.ansible.com/u/Tushar_Dudhade)\
**Post date:** [March 21, 2018, 2:20pm UTC](https://forum.ansible.com/t/creation-of-tables-failing-when-done-shell-module-of-ansible-on-postgresql/27038/3 "2018-03-21T14:20:24Z")

</div>

Hi Mike,  
Thanks for your reply.  
I got the solution for this issue with the environment variables’ usage for now.  
Looking at the security constraint, environment variables usage is not allowed. Will have to make some robust way of doing it.

Thanks and Regards,  
Tushar.
