rgl / packer-plugin-windows-update

Packer plugin for installing Windows updates
Mozilla Public License 2.0
304 stars 71 forks source link

Doesn't work with environment_vars #10

Open slbailey opened 6 years ago

slbailey commented 6 years ago

We need to access a proxy server to get out for windows updates. Normally we use environment_vars to get powershell and windows_shell provisioners to work with our proxies.

Could we add something to this that allowed the use of environment_vars to work with proxies?

rgl commented 6 years ago

Can you provide an example on what variables are needed to configure windows updates for that?

Captain-Grumpy commented 5 years ago

Apologies for jumping on this, but this requirement would work for me. Example,

"environment_vars": "http_proxy=x.x.x.x:8080", "https_proxy=x.x.x.x:8080"

jpatigny commented 4 years ago

Hello, I would also need this feature. In order to download Windows Updates I have to go through a proxy. The quick and dirty solution would be to hardcode it into the windows-updates.ps1 using System.Net.WebProxy.

But indeed, having the possibility to set a proxy variable in the provisionner declaration would be great.

jpatigny commented 4 years ago

To add proxy config ps1, add ebproxy properties to variables $UpdateSession. :

while ($true) {
    try {
        $updateSession = New-Object -ComObject 'Microsoft.Update.Session'
        $updateSession.ClientApplicationID = 'packer-windows-update'
        $UpdateSession.WebProxy.Address = $proxy
        $UpdateSession.WebProxy.AutoDetect = $False
        $updateSearcher = $updateSession.CreateUpdateSearcher()
        $searchResult = $updateSearcher.Search($SearchCriteria)
        if ($searchResult.ResultCode -eq 2) {
            break
        }
        $searchStatus = LookupOperationResultCode($searchResult.ResultCode)
    } catch {        
        $searchStatus = $_.ToString()
    }    
    Write-Output "Search for Windows updates failed with '$searchStatus'. Retrying..."
    Start-Sleep -Seconds 5
}
aolsze commented 4 years ago

Hi everyone, we really need this feature of configuring a proxy. Can you please add this to the next release? Thanks a lot!