2016-09-09 3 views
0

Ich muss psycopg zu einem alten Python (2.4) installieren. Alles funktioniert gut, außer das Einstellen der Umgebungsvariablen -> LD_LIBRARY_PATH.Ansible playbook, set Umgebungsvariablen nicht funktioniert

- name: install psycopg 
    shell: "{{ item }}" 
    environment: 
     CPPFLAGS: "-I/my_python/lib/python2.4/site-packages/mx/DateTime/mxDateTime" 
     LD_LIBRARY_PATH: "/path_to_postgresql/lib" 
    args: 
    chdir: "/path_to_psycopg_src/" 
    with_items: 
    - ./configure --prefix=/my_python --with-python=/my_python/bin/python --with-postgres-libraries=/path_to_postgresql/lib --with-postgres-includes=/path_postgresql/include --with-mxdatetime-includes=/my_python/lib/python2.4/site-packages/mx/DateTime/mxDateTime 
    - make 
    - make install 

Nach erfolgreicher Installation erhalte ich die folgende Fehlermeldung:

>>> import psycopg 
    ImportError: libpq.so.4: cannot open shared object file: No such file or directory 

Wenn ich es manuell zu exportieren, es funktioniert gut:

export LD_LIBRARY_PATH="/path_postgresql/lib" 
>>> import psycopg 
>>> psycopg 
<module 'psycopg' from '/my_python/lib/python2.4/site-packages/psycopgmodule.so'> 

Antwort

1

Da Sie die LD_LIBRARY_PATH nur für install psycopg Aufgabe gesetzt. Wenn Sie eine Umgebungsvariable nicht nur für Task/playbook setzen möchten, denke ich, dass Sie /etc/environment

+0

bearbeiten müssen So ist es in einem ansible playbook nicht möglich? – saromba

+0

Sie können/etc/environment in Ihrem ansible playbook bearbeiten – Abdulafaja

+0

Mein Problem ist, dass ich keine Rechte habe, um/etc/environment zu bearbeiten – saromba