postgresql_info fails

37 views
Skip to first unread message

Hesam Bahmanabadi

unread,
Mar 18, 2020, 9:54:37 AM3/18/20
to Ansible Project
Hello I am  trying to get this working,but getting following error. is it from ansible or moudle?


---
- hosts: staging
  tasks:
    - name: Collect all info except databases
      become: yes
      become_user: postgres
      postgresql_info:
        filter:
        - "!databases"
       
       


Error OUTPUT
 fatal: [support-staging]: FAILED! => {
    "ansible_facts": {},
    "changed": false,
    "failed_modules": {
        "setup": {
            "ansible_facts": {
                "discovered_interpreter_python": "/usr/bin/python"
            },
            "deprecations": [
                {
                    "msg": "Distribution Ubuntu 16.04 on host staging should use /usr/bin/python3, but is using /usr/bin/python for backward compatibility with prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information",
                    "version": "2.12"
                }
            ],
            "exception": "Traceback (most recent call last):\r\n  File \"/root/.ansible/tmp/ansible-tmp-1584539519.0-58561432581937/AnsiballZ_setup.py\", line 102, in <module>\r\n    _ansiballz_main()\r\n  File \"/root/.ansible/tmp/ansible-tmp-1584539519.0-58561432581937/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-1584539519.0-58561432581937/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/python2.7/runpy.py\", line 188, in run_module\r\n    fname, loader, pkg_name)\r\n  File \"/usr/lib/python2.7/runpy.py\", line 82, in _run_module_code\r\n    mod_name, mod_fname, mod_loader, pkg_name)\r\n  File \"/usr/lib/python2.7/runpy.py\", line 72, in _run_code\r\n    exec code in run_globals\r\n  File \"/tmp/ansible_setup_payload_Fvldd3/ansible_setup_payload.zip/ansible/modules/setup.py\", line 136, in <module>\r\nValueError: Attempted relative import beyond toplevel package\r\n",
            "failed": true,
            "module_stderr": "Shared connection to 138.197.140.174 closed.\r\n",
            "module_stdout": "Traceback (most recent call last):\r\n  File \"/root/.ansible/tmp/ansible-tmp-1584539519.0-58561432581937/AnsiballZ_setup.py\", line 102, in <module>\r\n    _ansiballz_main()\r\n  File \"/root/.ansible/tmp/ansible-tmp-1584539519.0-58561432581937/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-1584539519.0-58561432581937/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/python2.7/runpy.py\", line 188, in run_module\r\n    fname, loader, pkg_name)\r\n  File \"/usr/lib/python2.7/runpy.py\", line 82, in _run_module_code\r\n    mod_name, mod_fname, mod_loader, pkg_name)\r\n  File \"/usr/lib/python2.7/runpy.py\", line 72, in _run_code\r\n    exec code in run_globals\r\n  File \"/tmp/ansible_setup_payload_Fvldd3/ansible_setup_payload.zip/ansible/modules/setup.py\", line 136, in <module>\r\nValueError: Attempted relative import beyond toplevel 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  

Stefan Hornburg (Racke)

unread,
Mar 18, 2020, 10:02:21 AM3/18/20
to ansible...@googlegroups.com
On 3/18/20 2:54 PM, Hesam Bahmanabadi wrote:
> 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
Racke
> CONFIDENTIALITY STATEMENT. The information contained in this e-mail message, including attachments, is the confidential
> information of, and/or is the property of, Blended Perspectives. The information is intended for use solely by the
> individual or entity named in the message. If you are not an intended recipient or you received this in error, then any
> review, printing, copying, or distribution of any such information is prohibited, and please notify the sender
> immediately by reply e-mail and then delete this e-mail from your system. 
>
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/a9ef0a51-ea0c-4d7c-a35a-b737d26e7977%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/a9ef0a51-ea0c-4d7c-a35a-b737d26e7977%40googlegroups.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

signature.asc

Hesam Bahmanabadi

unread,
Mar 18, 2020, 10:19:07 AM3/18/20
to Ansible Project
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 <module>\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 <module>\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 <module>\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 <module>\r\nValueError: attempted relative import beyond top-level package\r\n",

Dick Visser

unread,
Mar 18, 2020, 10:37:53 AM3/18/20
to ansible...@googlegroups.com
Can you try adding this to the playbook:

gather_facts: false



> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/a9ef0a51-ea0c-4d7c-a35a-b737d26e7977%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/a9ef0a51-ea0c-4d7c-a35a-b737d26e7977%40googlegroups.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

CONFIDENTIALITY STATEMENT. The information contained in this e-mail message, including attachments, is the confidential information of, and/or is the property of, Blended Perspectives. The information is intended for use solely by the individual or entity named in the message. If you are not an intended recipient or you received this in error, then any review, printing, copying, or distribution of any such information is prohibited, and please notify the sender immediately by reply e-mail and then delete this e-mail from your system. 

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/47d2835f-9f62-4cbc-9af3-5787099d70d2%40googlegroups.com.


--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

Hesam Bahmanabadi

unread,
Mar 18, 2020, 11:43:50 AM3/18/20
to ansible...@googlegroups.com
Great. Thank you. hat helped to resolve the issue.



--
Sincerely,
Hesam Bahmanabadi
Systems Administrator

+1(855) 366-8444 - Extension 705
+1(416) 890-9879
www.blendedperspectives.com

Dick Visser

unread,
Mar 18, 2020, 11:54:56 AM3/18/20
to ansible...@googlegroups.com
On Wed, 18 Mar 2020 at 16:43, Hesam Bahmanabadi
<He...@blendedperspectives.com> wrote:

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

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....

Hesam Bahmanabadi

unread,
Mar 18, 2020, 2:17:55 PM3/18/20
to ansible...@googlegroups.com
Yes, I had to install the following on the servers.

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

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages