# postgresql\_info fails

**URL:** <https://forum.ansible.com/t/postgresql-info-fails/32494>\
**Category:** Ansible Project\
**Created:** [March 18, 2020, 1:54pm UTC](https://forum.ansible.com/t/postgresql-info-fails/32494 "2020-03-18T13:54:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hesam\_Bahmanabadi](https://avatars.discourse-cdn.com/v4/letter/h/41988e/32.png) [@Hesam\_Bahmanabadi](https://forum.ansible.com/u/Hesam_Bahmanabadi)\
**Post date:** [March 18, 2020, 1:54pm UTC](https://forum.ansible.com/t/postgresql-info-fails/32494/1 "2020-03-18T13:54:37Z")

</div>

Hello I am trying to get this working,but getting following error. is it from ansible or moudle?

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [March 18, 2020, 2:01pm UTC](https://forum.ansible.com/t/postgresql-info-fails/32494/2 "2020-03-18T14:01:41Z")

</div>

> Hello I am trying to get this working,but getting following error. is it from ansible or moudle?

Good question, but try to tell Ansible to use Python 3 on the target:

ansible\_python\_interpreter: /usr/bin/python3

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<div class="post-metadata">

**Author:** ![Hesam\_Bahmanabadi](https://avatars.discourse-cdn.com/v4/letter/h/41988e/32.png) [@Hesam\_Bahmanabadi](https://forum.ansible.com/u/Hesam_Bahmanabadi)\
**Post date:** [March 18, 2020, 2:19pm UTC](https://forum.ansible.com/t/postgresql-info-fails/32494/3 "2020-03-18T14:19:06Z")

</div>

Thank you for fast reply

Passed the var from comman line

ansible-playbook postgres.yml -e ‘ansible\_python\_interpreter=/usr/bin/python3’ -vvv

Error Output:

fatal: [staging]: FAILED! =\> {  
“ansible\_facts”: {},  
“changed”: false,  
“failed\_modules”: {  
“setup”: {  
“exception”: “Traceback (most recent call last):\r\n File "/root/.ansible/tmp/ansible-tmp-1584540952.95-42346186184755/AnsiballZ\_setup.py", line 102, in \r\n \_ansiballz\_main()\r\n File "/root/.ansible/tmp/ansible-tmp-1584540952.95-42346186184755/AnsiballZ\_setup.py", line 94, in \_ansiballz\_main\r\n invoke\_module(zipped\_mod, temp\_path, ANSIBALLZ\_PARAMS)\r\n File "/root/.ansible/tmp/ansible-tmp-1584540952.95-42346186184755/AnsiballZ\_setup.py", line 40, in invoke\_module\r\n runpy.run\_module(mod\_name=‘ansible.modules.setup’, init\_globals=None, run\_name=‘ **main** ’, alter\_sys=True)\r\n File "/usr/lib/python3.5/runpy.py", line 196, in run\_module\r\n return \_run\_module\_code(code, init\_globals, run\_name, mod\_spec)\r\n File "/usr/lib/python3.5/runpy.py", line 96, in \_run\_module\_code\r\n mod\_name, mod\_spec, pkg\_name, script\_name)\r\n File "/usr/lib/python3.5/runpy.py", line 85, in \_run\_code\r\n exec(code, run\_globals)\r\n File "/tmp/ansible\_setup\_payload\_kteaw1zg/ansible\_setup\_payload.zip/ansible/modules/setup.py", line 136, in \r\nValueError: attempted relative import beyond top-level package\r\n”,  
“failed”: true,  
“module\_stderr”: “Shared connection to 138.548.458.6 closed.\r\n”,  
“module\_stdout”: “Traceback (most recent call last):\r\n File "/root/.ansible/tmp/ansible-tmp-1584540952.95-42346186184755/AnsiballZ\_setup.py", line 102, in \r\n \_ansiballz\_main()\r\n File "/root/.ansible/tmp/ansible-tmp-1584540952.95-42346186184755/AnsiballZ\_setup.py", line 94, in \_ansiballz\_main\r\n invoke\_module(zipped\_mod, temp\_path, ANSIBALLZ\_PARAMS)\r\n File "/root/.ansible/tmp/ansible-tmp-1584540952.95-42346186184755/AnsiballZ\_setup.py", line 40, in invoke\_module\r\n runpy.run\_module(mod\_name=‘ansible.modules.setup’, init\_globals=None, run\_name=‘ **main** ’, alter\_sys=True)\r\n File "/usr/lib/python3.5/runpy.py", line 196, in run\_module\r\n return \_run\_module\_code(code, init\_globals, run\_name, mod\_spec)\r\n File "/usr/lib/python3.5/runpy.py", line 96, in \_run\_module\_code\r\n mod\_name, mod\_spec, pkg\_name, script\_name)\r\n File "/usr/lib/python3.5/runpy.py", line 85, in \_run\_code\r\n exec(code, run\_globals)\r\n File "/tmp/ansible\_setup\_payload\_kteaw1zg/ansible\_setup\_payload.zip/ansible/modules/setup.py", line 136, in \r\nValueError: attempted relative import beyond top-level package\r\n”,  
“msg”: “MODULE FAILURE\nSee stdout/stderr for the exact error”,  
“rc”: 1  
}  
},  
“msg”: “The following modules failed to execute: setup\n”  
}

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
support-staging : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [March 18, 2020, 2:37pm UTC](https://forum.ansible.com/t/postgresql-info-fails/32494/4 "2020-03-18T14:37:22Z")

</div>

Can you try adding this to the playbook:

gather\_facts: false

---

<div class="post-metadata">

**Author:** ![Hesam\_Bahmanabadi1](https://avatars.discourse-cdn.com/v4/letter/h/a8b319/32.png) [@Hesam\_Bahmanabadi1](https://forum.ansible.com/u/Hesam_Bahmanabadi1)\
**Post date:** [March 18, 2020, 3:43pm UTC](https://forum.ansible.com/t/postgresql-info-fails/32494/5 "2020-03-18T15:43:09Z")

</div>

Great. Thank you. hat helped to resolve the issue.

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [March 18, 2020, 3:54pm UTC](https://forum.ansible.com/t/postgresql-info-fails/32494/6 "2020-03-18T15:54:24Z")

</div>

Right.... your issue with THIS task may be solved, but there is still  
ANOTHER problem on your target host that prevents the setup module  
from running.  
You should address that because it will come back and bite you later....

---

<div class="post-metadata">

**Author:** ![Hesam\_Bahmanabadi1](https://avatars.discourse-cdn.com/v4/letter/h/a8b319/32.png) [@Hesam\_Bahmanabadi1](https://forum.ansible.com/u/Hesam_Bahmanabadi1)\
**Post date:** [March 18, 2020, 6:17pm UTC](https://forum.ansible.com/t/postgresql-info-fails/32494/7 "2020-03-18T18:17:25Z")

</div>

Yes, I had to install the following on the servers.

```auto
python3-pip libpq-dev python-pip
pip3 install psycopg2
pip install psycopg2

```
