[英]How set 2 environment (PATH and proxy_env ) in ansible-playbook?
How correct write task ? 如何正确写任务?
- name: Install required python modules
pip:
name: "{{ item }}"
extra_args: "{{ pip_extra_args | default(omit) }}"
with_items: "{{pip_python_coreos_modules}}"
environment:
PATH: "some path"
environment: "{{ proxy_env }}"
How set 2 environment (PATH and proxy_env ) ? 如何设置2环境(PATH和proxy_env)? Thanks 谢谢
Ansible makes it easy for you to configure your environment by using the 'environment' keyword. Ansible使您可以轻松地通过使用“ environment”关键字来配置环境。 Here is an example: 这是一个例子:
- hosts: all
remote_user: root
tasks:
- apt: name=cobbler state=installed
environment:
http_proxy: http://proxy.example.com:8080
The environment can also be stored in a variable, and accessed like so: 环境也可以存储在变量中,并按以下方式访问:
- hosts: all
remote_user: root
# here we make a variable named "proxy_env" that is a dictionary
vars:
proxy_env:
http_proxy: http://proxy.example.com:8080
tasks:
- apt: name=cobbler state=installed
environment: "{{proxy_env}}"
Whole thing in explained in ansible docs, you can read it here 完整文档在Ansible文档中进行了解释,您可以在此处阅读
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.