Skip to content

psrepository fails after initial corrective action #32

Description

@norbertstoll

Hi,

I ran into an issue while checking psrepository after it has been created successfully at first puppet run. We run an offline environment.

Side note:
The NuGet package provider has been installed manually before (copy Microsoft.PackageManagement.NuGetProvider.dll) and can't be checked successfully via pspackageprovider:

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

Back to topic:

Our used modules:

mod 'puppetlabs-dsc_lite', '3.1.0'
mod 'puppetlabs-pwshlib', '0.8.0'
mod 'encore-powershellmodule', '2.2.1'

hiera-config:

profile::powershell::psrepository:
  'PowerShell_DEV':
    ensure:                     present
    source_location:      'https://hostname.domain/nuget/PowerShell_DEV'
    installation_policy:  'trusted'
    provider:                  'windowspowershell'

Output of puppet run:

PS C:\> puppet agent -t
Info: Using configured environment 'windows_test'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Info: Loading facts
Info: Caching catalog for hostname.domain
Info: Applying configuration version '76fb657ed72a947eb8a75faa0f9c2f9a1aea8783'
Notice: /Stage[main]/Profile::Powershell/Psrepository[PowerShell_DEV]/ensure: created (corrective)
Notice: Applied catalog in 5.14 seconds
PS C:\> puppet agent -t
Info: Using configured environment 'windows_test'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Info: Loading facts
Info: Caching catalog for hostname.domain
Info: Applying configuration version '76fb657ed72a947eb8a75faa0f9c2f9a1aea8783'
Error: Could not set 'present' on ensure: Error when executing command: $ProgressPreference = 'SilentlyContinue'; $ErrorActionPreference = 'Stop'; [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12;     $params = @{
      Name = 'PowerShell_DEV'
      SourceLocation = 'https://reposerver/nuget/PowerShell_DEV'
      InstallationPolicy = 'trusted'
    }

    # Detecting if this is Powershell Gallery repo or not
    if ($params.Name -eq 'PSGallery' -or $params.SourceLocation -match 'powershellgallery') {
      # Trim these params or the splatting will fail
      $params.Remove('Name')
      $params.Remove('SourceLocation')
      Register-PSRepository -Default @params
    } else {
      # For all non-PSGallery repos..
      Register-PSRepository @params
    }

 stdout =
 stderr = [] (file: /etc/puppetlabs/code/environments/windows_test/site/profile/manifests/powershell.pp, line: 14)
Error: Could not set 'present' on ensure: Error when executing command: $ProgressPreference = 'SilentlyContinue'; $ErrorActionPreference = 'Stop'; [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12;     $params = @{
      Name = 'PowerShell_DEV'
      SourceLocation = 'https://reposerver/nuget/PowerShell_DEV'
      InstallationPolicy = 'trusted'
    }

    # Detecting if this is Powershell Gallery repo or not
    if ($params.Name -eq 'PSGallery' -or $params.SourceLocation -match 'powershellgallery') {
      # Trim these params or the splatting will fail
      $params.Remove('Name')
      $params.Remove('SourceLocation')
      Register-PSRepository -Default @params
    } else {
      # For all non-PSGallery repos..
      Register-PSRepository @params
    }

 stdout =
 stderr = [] (file: /etc/puppetlabs/code/environments/windows_test/site/profile/manifests/powershell.pp, line: 14)
Wrapped exception:
Error when executing command: $ProgressPreference = 'SilentlyContinue'; $ErrorActionPreference = 'Stop'; [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12;     $params = @{
      Name = 'PowerShell_DEV'
      SourceLocation = 'https://reposerver/nuget/PowerShell_DEV'
      InstallationPolicy = 'trusted'
    }

    # Detecting if this is Powershell Gallery repo or not
    if ($params.Name -eq 'PSGallery' -or $params.SourceLocation -match 'powershellgallery') {
      # Trim these params or the splatting will fail
      $params.Remove('Name')
      $params.Remove('SourceLocation')
      Register-PSRepository -Default @params
    } else {
      # For all non-PSGallery repos..
      Register-PSRepository @params
    }

 stdout =
 stderr = []
Error: /Stage[main]/Profile::Powershell/Psrepository[PowerShell_DEV]/ensure: change from 'absent' to 'present' failed: Could not set 'present' on ensure: Error when executing command: $ProgressPreference = 'SilentlyContinue'; $ErrorActionPreference = 'Stop'; [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12;     $params = @{
      Name = 'PowerShell_DEV'
      SourceLocation = 'https://reposerver/nuget/PowerShell_DEV'
      InstallationPolicy = 'trusted'
    }

    # Detecting if this is Powershell Gallery repo or not
    if ($params.Name -eq 'PSGallery' -or $params.SourceLocation -match 'powershellgallery') {
      # Trim these params or the splatting will fail
      $params.Remove('Name')
      $params.Remove('SourceLocation')
      Register-PSRepository -Default @params
    } else {
      # For all non-PSGallery repos..
      Register-PSRepository @params
    }

 stdout =
 stderr = [] (file: /etc/puppetlabs/code/environments/windows_test/site/profile/manifests/powershell.pp, line: 14) (corrective)
Notice: Applied catalog in 5.02 seconds
PS C:\>

The corrective action can be verified successfully in a new PowerShell-session:

PS C:\> Get-PSRepository
WARNING: MSG:UnableToDownload «https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409» «»
WARNING: Unable to download the list of available providers. Check your internet connection.

Name                      InstallationPolicy   SourceLocation
----                      ------------------   --------------
PowerShell_DEV            Trusted              https://hostname.domain/nuget/PowerShell_DEV
PS C:\> Get-PackageProvider nuget

Name                     Version          DynamicOptions
----                     -------          --------------
NuGet                    2.8.5.208        Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag...

Any help is much appreciated :)

Regards,
Norbert

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions