简体   繁体   English

Ansible剧本,设置环境变量不起作用

[英]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.

相关问题 Ansible playbook 在新的 Ubuntu/Ansible/Python 环境中停止工作 - Ansible playbook stops working in new Ubuntu/Ansible/Python environment 有没有办法在环绕Ansible playbook中的角色时设置环境变量? - Is there a way to set an environment variable while looping over a role in Ansible playbook? 在Ansible playbook中激活Conda环境 - Activating a Conda environment in Ansible playbook 是否可以使用ansible playbook创建python虚拟环境? - Is it possible to create python virtual environment with ansible playbook? 为什么ansible评估剧本中未使用的变量? - Why ansible evaluate variables which is not used in playbook? 将变量从 Ansible Playbook 传递到 Python - Passing variables from an Ansible Playbook to Python jinja2 &#39;{% set ... %}&#39; 在 ansible playbook 中处理 - jinja2 '{% set ... %}' processing in ansible playbook 执行Ansible Playbook AttributeError:“ str”对象没有属性“ set_playbook_basedir” - Executing ansible playbook AttributeError: 'str' object has no attribute 'set_playbook_basedir' Ansible Tower-如何获取环境变量列表 - Ansible Tower - How to get a list of the environment variables Python 和环境变量不起作用 - Python and environment variables not working
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM