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
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:
Any idea how to fix this?
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.
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