rol*_*olz 6 proxy geturl ansible
我只想为特定的 ansible 任务(如get_url模块)设置一个环境代理,以便从 Internet 下载一些应用程序。其他所有任务都应该在没有任何代理的情况下运行。我如何完成这项任务。
Zle*_*ni 7
您可以为每个任务设置一个代理,如下所示:
get_url:
url=http://remote.host.com/file
dest=/tmp/file
environment:
http_proxy: http://proxy.example.com:8080
Run Code Online (Sandbox Code Playgroud)
您可以为您的游戏定义一个环境变量并从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
Run Code Online (Sandbox Code Playgroud)
从use_proxy该在文档:
如果 [
use_proxy设置为] no,则不会使用代理,即使在目标主机上的环境变量中定义了代理。
因此,您将在上面的示例中做相反的事情。