2016-11-10 82 views
0

我想设置一个环境代理只为一个特定的任务如get_url模块从互联网上下载一些应用程序。其他所有任务应该在没有代理的情况下运行我如何完成这项任务。如何为特定的任务设置代理?

回答

0

您可以设置每个任务的代理,像这样:

get_url: 
    url=http://remote.host.com/file 
    dest=/tmp/file 
http_proxy: http://proxy.example.com:8080 
0

您可以为您的游戏环境变量和代理选项从get_url设置。

--- 
- hosts: all 

    environment: 
    http_proxy: http://127.0.0.1:1234 

    # You can also set it over https. 
    https_proxy: http://127.0.0.1:1234 

- name: Retrieve some repo 
    get_url: 
    url: https://repos.com/cool.repo 
    dest: /etc/yum.repos.d/cool.repo 
    use_proxy: yes 

use_proxydocumentation

如果[use_proxy设为]没有,也不会使用代理,即使一个在目标主机上的 环境变量定义。

所以,你会在上面的例子中做相反的事情。