EncoreTechnologies / puppet-powershellmodule

Apache License 2.0
6 stars 6 forks source link

install_options proxy not working #25

Open TomG83 opened 4 years ago

TomG83 commented 4 years ago

I'm using the parameter on a node that has nog direct internet access but can use our proxy server

package { 'Posh-ACME':
    ensure          => latest,
    provider        => 'windowspowershell',
    source          => 'PSGallery',
    install_options => [ '-AllowClobber',
            { '-proxy' => 'http://myproxy.mydomain.be:8080' } ]
}

which returns the error:

Error: Could not prefetch package provider 'windowspowershell': 751: unexpected token at 'WARNING: MSG:UnableToDownload «https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409» «»'
Error: Failed to apply catalog: 751: unexpected token at 'WARNING: MSG:UnableToDownload «https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409» «»'

When I install the module by hand:

Install-Module -Proxy "http://myproxy.mydomain.be:8080" -Name Posh-ACME

Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install
the modules from 'PSGallery'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): y

Everything works well. Upon consecutive Puppet agent run's after the module was installed by hand as in example above:

Error: Could not get latest version: Execution of 'C:/Windows/System32/WindowsPowerShell/v1.0/powershell.EXE -NoProfile -ExecutionPolicy Bypass -NonInteractive -NoLogo -Command $ProgressPreference = 'SilentlyContinue'; $ErrorActionPreference = 'Stop'; $mod = Find-Module Posh-ACME; $mod.Version.ToString()' returned 1: WARNING: Unable to resolve package source 'https://www.powershellgallery.com/api/v2'.
PackageManagement\Find-Package : No match was found for the specified search criteria and module name 'Posh-ACME'. Try Get-PSRepository to see all available registered module repositories.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1397 char:3
+         PackageManagement\Find-Package @PSBoundParameters | Microsoft ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power...ets.FindPackage:FindPackage) [Find-Package], Exception
    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.FindPackage
Error: /Stage[main]/Base_software_win::Manage_ps_modules/Package[Posh-ACME]/ensure: change from ['3.17.0'] to 'latest' failed: Could not get latest version: Execution of 'C:/Windows/System32/WindowsPowerShell/v1.0/powershell.EXE -NoProfile -ExecutionPolicy Bypass -NonInteractive -NoLogo -Command $ProgressPreference = 'SilentlyContinue'; $ErrorActionPreference = 'Stop'; $mod = Find-Module Posh-ACME; $mod.Version.ToString()' returned 1: WARNING: Unable to resolve package source 'https://www.powershellgallery.com/api/v2'.
PackageManagement\Find-Package : No match was found for the specified search criteria and module name 'Posh-ACME'. Try Get-PSRepository to see all available registered module repositories.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1397 char:3
+         PackageManagement\Find-Package @PSBoundParameters | Microsoft ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power...ets.FindPackage:FindPackage) [Find-Package], Exception
    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.FindPackage

When using same resource without install_options on a node that has direct internet access, installation works just fine.

Am I missing something here?