Ansible modules executed on a Windows host are unable to access the internet via an HTTP Proxy. Ideally modules would function similarly to setting the environment on Linux hosts, i.e
environment:
http_proxy: http://gateway:port
https_proxy: http://gateway:port
The following workarounds have been attempted:
netsh winhttp set proxy proxy-server="http://gateway:port")- name: Fire and forget iexplore.exe
win_shell: set HTTP_PROXY=http://management-gateway.c.ansible-proj.internal:3128 & powershell.exe curl http://www.google.com
args:
executable: cmd
NOTE: The local administrator account is being used and a formal session via RDP is never initiated.
Attempt to curl an external website via win_shell. Some examples:
- name: run
hosts: windows-host
tasks:
- name: Fire and forget notepad.exe
win_shell: notepad.exe
args:
exectable: cmd
async: 60
poll: 0
- name: Set registry
win_shell: "{{ item }}"
with_items: - set-itemproperty -path "hkcu:Software\Microsoft\Windows\CurrentVersion\Internet Settings" -name ProxyServer -value "http=gateway:port;https=gateway:port; -type string
- set-itemproperty -path "hkcu:Software\Microsoft\Windows\CurrentVersion\Internet Settings" -name ProxyEnable -value "1"
- name: Run curl
win_shell: curl http://www.google.com
register: result