Ansible-role-postgresql: psycopg2 module is required (module present)

Created on 27 Jul 2018  ·  6Comments  ·  Source: geerlingguy/ansible-role-postgresql

  1. pip list shows psycopg2 (2.7.5)
  2. yum shows this Package python-psycopg2-2.7.5-1.rhel7.x86_64 already installed and latest version
    2a: python --version: Python 2.7.5
  3. Ansible yml has this:
  roles:
    - role: ansible-role-postgresql
      become: yes
      postgresql_enablerepo: "pgdg96"
      postgresql_restarted_state: "restarted"
      postgresql_python_library: python-psycopg2
      postgresql_bin_path: /usr/pgsql-9.6/bin
      postgresql_daemon: postgresql-9.6.service 
  1. Error thrown is this:

TASK [ansible-role-postgresql : Ensure PostgreSQL databases are present.] **************************************************************************** failed: [clpaxd-iwh01.na.ad.rrd.com] (item={u'owner': u'manifold', u'login_user': u'manifold', u'name': u'manifoldcf', u'login_password': u'manifold'}) => {"changed": false, "item": {"login_password": "manifold", "login_user": "manifold", "name": "manifoldcf", "owner": "manifold"}, "msg": "the python psycopg2 module is required"}
Environment:

  1. Centos 7
  2. Python 2.7.5
  3. ansible 2.7.0.dev0 (stable-2.6 28d0a173db) last updated 2018/06/25 12:12:39 (GMT -500)

Any idea how to fix this?

stale

Most helpful comment

I already had python3-psycopg2 installed but it still failed with;
postgresql_python_library: python3-psycopg2

So i added the following to my playbook;
ansible_python_interpreter: /usr/bin/python3

Seems like by default it just used /usr/bin/python

On debian 10;
/usr/bin/python --version
Python 2.7.16

All 6 comments

try with pip install -U --no-cache-dir --force psycopg2

This bug is a little annoying to figure out as no_log is being used in the cases where it crops up e.g. creating users, obscuring the real problem.

I personally fixed it by using package to install python3-psycopg2 before the Postgres role is imported.

Old thread (but open) same issue here on Ubuntu. removing no_log gave me the error message of missing package. After manual install psycopg2 the task for users is working. An extra step to install required python package should resolve the issue.

I already had python3-psycopg2 installed but it still failed with;
postgresql_python_library: python3-psycopg2

So i added the following to my playbook;
ansible_python_interpreter: /usr/bin/python3

Seems like by default it just used /usr/bin/python

On debian 10;
/usr/bin/python --version
Python 2.7.16

This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!

Please read this blog post to see the reasons why I mark issues as stale.

This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NiftyMist picture NiftyMist  ·  5Comments

worldofchris picture worldofchris  ·  8Comments

GoodBoy962 picture GoodBoy962  ·  10Comments

breml picture breml  ·  9Comments

FilBot3 picture FilBot3  ·  18Comments