community.windows.win_http_proxy 模块 – 管理 WinHTTP 的代理设置

注意

此模块是 community.windows 集合 (版本 2.3.0) 的一部分。

如果您正在使用 ansible 包,则可能已安装此集合。它不包含在 ansible-core 中。要检查它是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用: ansible-galaxy collection install community.windows

要在 playbook 中使用它,请指定: community.windows.win_http_proxy

概要

  • 用于设置、删除或导入 Windows HTTP 服务 WinHTTP 的代理设置。

  • WinHTTP 是应用程序或服务(通常是 .NET 应用程序或非交互式服务)用于发出 Web 请求的框架。

参数

参数

注释

bypass

列表 / 元素=字符串

访问时将绕过已设置代理的主机列表。

使用 <local> 来匹配不是完全限定域名的主机名。当需要仅使用主机名连接到内联网站点时,这很有用。

忽略、设置为 null 或空字符串/列表以删除绕过列表。

如果设置了此项,则也必须设置 *proxy*。

proxy

任意

指定要设置的代理的字符串或字典。

如果设置字符串,则应采用 hostnamehostname:portprotocol=hostname:port 的形式。

如果未定义端口,则使用正在使用的协议的默认端口。

如果设置字典,则键应为协议,值应为该协议的主机名和/或端口。

有效的协议是 httphttpsftpsocks

忽略、设置为 null 或空字符串以删除代理设置。

source

字符串

无需手动指定 *proxy* 和/或 *bypass*,将其设置为从 Internet Explorer 等设置的源导入代理。

使用 ie 将导入当前用户的当前活动网络连接的 Internet Explorer 代理设置。

只有 IE 的代理 URL 和绕过列表将被导入到 WinHTTP。

这类似于运行 netsh winhttp import proxy source=ie

模块运行时会导入该值,如果将来 IE 配置发生更改,则不会自动更新。必须再次运行模块才能同步最新的更改。

选项

  • "ie"

备注

注意

  • 这与 Internet Explorer 中设置的代理设置(也称为 WinINet)不同;请改用 community.windows.win_inet_proxy 模块来管理它。

  • 这些设置是系统范围的,而不是每个用户一个,运行需要管理员权限。

另请参见

另请参见

community.windows.win_inet_proxy

管理 WinINet 和 Internet Explorer 的代理设置。

示例

- name: Set a proxy to use for all protocols
  community.windows.win_http_proxy:
    proxy: hostname

- name: Set a proxy with a specific port with a bypass list
  community.windows.win_http_proxy:
    proxy: hostname:8080
    bypass:
      - server1
      - server2
      - <local>

- name: Set the proxy based on the IE proxy settings
  community.windows.win_http_proxy:
    source: ie

- name: Set a proxy for specific protocols
  community.windows.win_http_proxy:
    proxy:
      http: hostname:8080
      https: hostname:8443

- name: Set a proxy for specific protocols using a string
  community.windows.win_http_proxy:
    proxy: http=hostname:8080;https=hostname:8443
    bypass: server1,server2,<local>

- name: Remove any proxy settings
  community.windows.win_http_proxy:
    proxy: ''
    bypass: ''

作者

  • Jordan Borean (@jborean93)