From 3281cad95e6cf4fa2f213c641102bf4d7bc16b2f Mon Sep 17 00:00:00 2001 From: "T.Kuramochi" Date: Fri, 28 Aug 2015 14:46:08 +0900 Subject: [PATCH] Add HTTP Proxy options Update a document file for win_get_url.ps1. Update add a prefix proxy_ for this variables Update a document file for win_get_url.ps1. Update win_get_url.ps1 20150907 --- windows/win_get_url.ps1 | 12 ++++++++++++ windows/win_get_url.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/windows/win_get_url.ps1 b/windows/win_get_url.ps1 index a83ad2633b0..b7b1a1ed445 100644 --- a/windows/win_get_url.ps1 +++ b/windows/win_get_url.ps1 @@ -44,6 +44,10 @@ $skip_certificate_validation = Get-Attr $params "skip_certificate_validation" $f $username = Get-Attr $params "username" $password = Get-Attr $params "password" +$proxy_url = $params.proxy_url +$proxy_username = $params.proxy_username +$proxy_password = $params.proxy_password + if($skip_certificate_validation){ [System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true} } @@ -52,6 +56,14 @@ $force = Get-Attr -obj $params -name "force" "yes" | ConvertTo-Bool If ($force -or -not (Test-Path $dest)) { $client = New-Object System.Net.WebClient + if($params.proxy_url) { + $proxy_url = $params.proxy_url + if($proxy_username -and $proxy_password){ + $proxy_credential = New-Object System.Net.NetworkCredential($proxy_username, $proxy_password) + $proxy_server.Credentials = $proxy_credential + } + $client.Proxy = $proxy_server + } if($username -and $password){ $client.Credentials = New-Object System.Net.NetworkCredential($username, $password) diff --git a/windows/win_get_url.py b/windows/win_get_url.py index 5c3e994d418..cfe93982f61 100644 --- a/windows/win_get_url.py +++ b/windows/win_get_url.py @@ -65,6 +65,30 @@ options: - Skip SSL certificate validation if true required: false default: false + proxy_url: + description: + - The full URL of the proxy server a file to download through it. + version_added: "2.0" + required: false + choices: null + default: null + proxy_username: + description: + - Name of the user for authorization of the proxy server. + version_added: "2.0" + required: false + choices: null + default: null + proxy_password: + description: + - Password of the user for authorization of the proxy server. + version_added: "2.0" + required: false + choices: null + default: null +author: + - "Paul Durivage (@angstwad)" + - "Takeshi Kuramochi (tksarah)" ''' EXAMPLES = ''' @@ -83,4 +107,12 @@ $ ansible -i hosts -c winrm -m win_get_url -a "url=http://www.example.com/earthr url: 'http://www.example.com/earthrise.jpg' dest: 'C:\Users\RandomUser\earthrise.jpg' force: no + +- name: Download earthrise.jpg to 'C:\Users\RandomUser\earthrise.jpg' through the proxy server. + win_get_url: + url: 'http://www.example.com/earthrise.jpg' + dest: 'C:\Users\RandomUser\earthrise.jpg' + proxy_url: 'http://10.0.0.1:8080' + proxy_username: 'username' + proxy_password: 'password' '''