diff --git a/roles/base/tasks/main.yml b/roles/base/tasks/main.yml index 7cd852e..646dae9 100644 --- a/roles/base/tasks/main.yml +++ b/roles/base/tasks/main.yml @@ -71,12 +71,6 @@ name: "django-debug-toolbar<3" virtualenv: "{{venv_py3}}" -- name: install psycopg2-binary - pip: - name: psycopg2-binary - version: 2.8.6 - virtualenv: "{{venv_py3}}" - - name: install pytest pip: name: pytest @@ -121,6 +115,25 @@ - name: execute getlasso command: "{{venv_py3_bin}}/getlasso.sh" +- name: clean psycopg2 pip installation + ansible.builtin.pip: + name: + - psycopg2-binary + - psycopg2 + state: absent + virtualenv: "{{venv_py3}}" + +- name: create getpsycopg2 scripts + ansible.builtin.template: + src: getpsycopg2.j2 + dest: "{{venv_py3_bin}}/getpsycopg2.sh" + mode: "u=rwx,g=rx,o=rx" + vars: + virtualenv_python: "{{venv_py3_python}}" + +- name: execute getpsycopg2 + ansible.builtin.command: "{{venv_py3_bin}}/getpsycopg2.sh" + - name: create get-uwsgidecorators scripts template: src: get-uwsgidecorators.j2 diff --git a/roles/base/templates/getpsycopg2.j2 b/roles/base/templates/getpsycopg2.j2 new file mode 100644 index 0000000..856fc00 --- /dev/null +++ b/roles/base/templates/getpsycopg2.j2 @@ -0,0 +1,17 @@ +#!/bin/sh + + +# Get venv site-packages path +DSTDIR=`{{virtualenv_python}} -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())'` + +# Clean up +rm -f $DSTDIR/psycopg2* + +# symlink +for PSYCOFILE in /usr/lib/python3/dist-packages/psycopg2* +do + ln -sv $PSYCOFILE $DSTDIR/ +done + +exit 0 +