如何正确执行写任务?
- 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 }}"
如何设置2个环境(PATH和proxy_env)? 谢谢
答案 0 :(得分:0)
Ansible使您可以通过使用“环境”关键字轻松配置环境。这是一个示例:
- hosts: all
remote_user: root
tasks:
- apt: name=cobbler state=installed
environment:
http_proxy: http://proxy.example.com:8080
环境也可以存储在变量中,并按如下方式访问:
- 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}}"
在ansible文档中对整个内容进行了解释,您可以阅读here