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
This commit is contained in:
T.Kuramochi 2015-08-28 14:46:08 +09:00 committed by Matt Clay
parent 7a492764d0
commit dfda2e9f57
2 changed files with 44 additions and 0 deletions

View file

@ -44,6 +44,10 @@ $skip_certificate_validation = Get-Attr $params "skip_certificate_validation" $f
$username = Get-Attr $params "username" $username = Get-Attr $params "username"
$password = Get-Attr $params "password" $password = Get-Attr $params "password"
$proxy_url = $params.proxy_url
$proxy_username = $params.proxy_username
$proxy_password = $params.proxy_password
if($skip_certificate_validation){ if($skip_certificate_validation){
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true} [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)) { If ($force -or -not (Test-Path $dest)) {
$client = New-Object System.Net.WebClient $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){ if($username -and $password){
$client.Credentials = New-Object System.Net.NetworkCredential($username, $password) $client.Credentials = New-Object System.Net.NetworkCredential($username, $password)

View file

@ -65,6 +65,30 @@ options:
- Skip SSL certificate validation if true - Skip SSL certificate validation if true
required: false required: false
default: 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 = ''' 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' url: 'http://www.example.com/earthrise.jpg'
dest: 'C:\Users\RandomUser\earthrise.jpg' dest: 'C:\Users\RandomUser\earthrise.jpg'
force: no 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'
''' '''