[英]Ansible playbook, set environment variables not working
I have to install psycopg to an old python (2.4). 我必须将psycopg安装到旧的python(2.4)。 Everything works fine, except setting the environment variables -> LD_LIBRARY_PATH. 除了设置环境变量-> LD_LIBRARY_PATH外,其他所有方法都工作正常。
- 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
After successfull installation I get the following error: 成功安装后,出现以下错误:
>>> import psycopg
ImportError: libpq.so.4: cannot open shared object file: No such file or directory
When I export it manually, it works fine: 当我手动导出它时,它可以正常工作:
export LD_LIBRARY_PATH="/path_postgresql/lib"
>>> import psycopg
>>> psycopg
<module 'psycopg' from '/my_python/lib/python2.4/site-packages/psycopgmodule.so'>
Because you set the LD_LIBRARY_PATH
just for install psycopg
task. 因为您仅为install psycopg
任务设置了LD_LIBRARY_PATH
。 If you want to set an environment variable not just for task/playbook I think you need to edit /etc/environment
如果您不仅要为任务/剧本设置环境变量,我想您需要编辑/etc/environment
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.