Comments (6)
was there a fix for this?
from puppet-powershellmodule.
@bishopbm1 or @gsperry2011 can you guys look into this? i don't have Windows anymore to check it out.
from puppet-powershellmodule.
I will provide a lot of information: I am on windows2016 server core:
"${env:ProgramFiles}\PackageManagement\ProviderAssemblies\Microsoft.PackageManagement.NuGetProvider.dll
is present
My error is:
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 = 'psgallery-virtual'
SourceLocation = 'https://chocolatey.example.com/chocolatey'
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/master/modules/os/manifests/powershell.pp, line: 3)
This only happens on a handful of nodes, so it is not consistent.
Contents of PSRepositories.xml in the c$\Windows\System32\config\systemprofile\AppData\Local\Microsoft\Windows\PowerShell\PowerShellGet
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04">
<Obj RefId="0">
<TN RefId="0">
<T>System.Collections.Hashtable</T>
<T>System.Object</T>
</TN>
<DCT>
<En>
<S N="Key">psgallery-virtual</S>
<Obj N="Value" RefId="1">
<TN RefId="1">
<T>Microsoft.PowerShell.Commands.PSRepository</T>
<T>System.Management.Automation.PSCustomObject</T>
<T>System.Object</T>
</TN>
<MS>
<S N="Name">psgallery-virtual</S>
<S N="SourceLocation">https://chocolatey.example.com/chocolatey</S>
<Nil N="PublishLocation" />
<Nil N="ScriptSourceLocation" />
<Nil N="ScriptPublishLocation" />
<B N="Trusted">true</B>
<B N="Registered">true</B>
<S N="InstallationPolicy">Trusted</S>
<S N="PackageManagementProvider">NuGet</S>
<Obj N="ProviderOptions" RefId="2">
<TNRef RefId="0" />
<DCT />
</Obj>
</MS>
</Obj>
</En>
</DCT>
</Obj>
</Objs>
psrepository { 'psgallery-virtual':
ensure => present,
source_location => 'https://chocolatey.example.com/chocolatey',
installation_policy => 'trusted',
}
sanitized domain names
from puppet-powershellmodule.
What's the output look like if you run this in powershell (please make sure it's "run as administrator"), also please change the $params
to match whatever you have specified in hiera.
$ProgressPreference = 'SilentlyContinue'; $ErrorActionPreference = 'Stop'; [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12; $params = @{
Name = 'psgallery-virtual'
SourceLocation = 'https://chocolatey.example.com/chocolatey'
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')
# debug statement
write-host "is PSrepo"
Register-PSRepository -Default @params
} else {
# debug statement
write-host "NOT a PSrepo"
# For all non-PSGallery repos..
Register-PSRepository @params
}
from puppet-powershellmodule.
unregister-psrepository psgallery-virtual.
run above:
NOT a PSrepo.
Rerun:
NOT a PSrepo
PackageManagement\Register-PackageSource : Module Repository 'psgallery-virtual' exists.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:11587 char:17
- ... $null = PackageManagement\Register-PackageSource @PSBoundParamete ...
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : ResourceExists: (Microsoft.Power...erPackageSource:RegisterPackageSource) [Register-PackageSource], Exception
- FullyQualifiedErrorId : PackageSourceExists,Microsoft.PowerShell.PackageManagement.Cmdlets.RegisterPackageSource
from puppet-powershellmodule.
Hello,
I added a try - catch on the block "create_command" when it tries to "Register-PSRepository @params" in lib\puppet\provider\psrepository\powershellcore.rb as the error seems to come from the fact that the repository is tried to be re-added if it exists already.
Another weird behavior I noticed is that the stdout from the "self.instances_command" block is not returning anything.
I found that the repository discovery block "self.instances_command" was not generating any return at first run, seems like it's due to the -WarningAction Stop
. If the WarningAction behavior is set to Ignore, as warnings comming from Get-PSRepository
on first run can be ignored, it generates an output and the error disappear.
So far it fixed the issue and seems a better solution than adding a try catch block as stated earlier.
cheers
from puppet-powershellmodule.
Related Issues (13)
- Consider getting module approved? HOT 3
- TLS12 causes systems that are online to go into a corrective change loop HOT 1
- Module not found when 'Source' is not specified HOT 1
- Convert module over to ruby-pwsh
- install_options proxy not working
- Support supply credentials for psrepository and package
- Proxy support HOT 1
- psrepository trusted or untrusted HOT 1
- Request: Add support for downloading preview modules
- Support for Puppet 7?
- Setup PDK and travis tests on this repo HOT 1
- Support TLS 1.2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from puppet-powershellmodule.