hbuckle / puppet-powershellmodule Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
using source param will fail each time, as that is passed to the install block:
def install_command
command = "Install-Module #{@resource[:name]} -Force"
command << " -RequiredVersion #{@resource[:ensure]}" unless [:present, :latest].include? @resource[:ensure]
command << " -Source #{@resource[:source]}" if @resource[:source]
command
end
is going to call -Source
each time and will fail each time since -Source
is not a valid parameter for Install-Module
should set with -Repository after having user set the -Repository name via psrepository
https://docs.microsoft.com/en-us/powershell/module/powershellget/install-module?view=powershell-5.1
(Probably another file, this is initial investigation)
Because of how the source code is written, it always executes a command with first parameter being the name of the resource.
In the working example you provide it says it should work with powershell 5 and 6 (https://github.com/hbuckle/puppet-powershellmodule/blob/master/README.md), however, it only works with powershell 5.1, with 5.0 it doesn't.
The issue is that the command "Set-PSRepository" doesn't take the first string as a parameter in powershell 5.0. Also, there would be an issue if you were to set a 'name' parameter inside puppet, it errors, because there are 2 name
parameters.
Command's Set-PSRepository' required parameter 'name
as positional parameter '0' is only introduced in 5.1 as seen here:
Possible solution is not to include resource name in the flush command, so you would always have to explicitly say the name of the PSRepository
and it would work with powershell 5.0 and below.
Support for installing modules from repositories that require authentication
Unfortunately Puppet have not migrated the DSC PackageManagement resource over so there is no equivalent for this module in Puppet. And certainly nothing for working with PowerShell Core on any OS.
There are a lot of old issues and PR's in this repo and the Puppet Forge module hasn't been updated for a couple of years.
So is this still being maintained?
I'm running the following puppet code:
pspackageprovider {'Nuget':
ensure => 'present',
}
psrepository { 'PSGallery':
ensure => present,
source_location => 'https://www.powershellgallery.com/api/v2/',
installation_policy => 'trusted',
}
package { 'VMware.PowerCLI':
ensure => latest,
provider => 'windowspowershell',
source => 'PSGallery',
}
And receiving the following error
Error: Could not retrieve catalog from remote server:
Error 500 on SERVER: Server Error: Evaluation Error:
Error while evaluating a Resource Statement, Could not autoload puppet/type/package:
Could not autoload puppet/provider/package/powershellcore: /etc/puppetlabs/code/environments/production/modules/powershellmodule/lib/puppet/provider/package/powershellcore.rb:63: unknown type of %string
command << " -RequiredVersion #{@resource[:ensure]}" unless %i[present latest].include? @resource[:ensure]
Puppet versions:
Puppet = 5.5.3
Puppet Server = 5.3.5
Hello,
I might be missing something but I'm getting the following error:
Error: Failed to apply catalog: Parameter ensure failed on Package[StorageDsc]: Provider windowspowershell must have features 'versionable' to set 'ensure' to '4.1.0'
The code I'm using is the following:
package { 'StorageDsc':
ensure => '4.1.0',
source => 'PSGalleryProxy',
provider => 'windowspowershell',
}
Using this works:
package { 'StorageDsc':
ensure => present,
source => 'PSGalleryProxy',
provider => 'windowspowershell',
}
From the README.md this seems to be possible, though.
package { 'nameOfInternallyDevelopedModule':
ensure => '1.0.5',
source => 'my-internal-repo',
provider => 'windowspowershell',
}
Am I missing something?
Registering repositories and installing modules should work through a proxy. Also need to find a way to handle proxy credentials
Getting the following error when running puppet
Could not autoload puppet/provider/pspackageprovider/windowspowershell: Could not find parent provider powershellcore of windowspowershell
pspackageprovider { 'Nuget':
ensure => 'present',
}
and
pspackageprovider { 'Nuget':
ensure => 'present',
provider => 'windowspowershell',
}
Runtime environment: puppet_version=5.5.16, ruby_version=2.4.5, run_mode=agent
PSVersion = 5.1.18362.1
PowershellGet-version, tried with both 2.2.1.0 & 1.0.0.1
Nuget-Version, tried with 3.0.0.1 & 2.8.5.208
The documentation says people should install the nuget packageprovider before attempting to install powershell modules from the PSGallery.
pspackageprovider { 'Nuget':
ensure => '2.8.5.208',
} -> Package <| provider == 'windowspowershell' |>
package { 'AWSPowerShell':
ensure => '3.3.563.1',
provider => 'windowspowershell',
}
Hello,
is there a particular reason to have the SourceLocation lowercased?
In particular in these two situations:
and
Since I think most of the webserver out there doesn't rewrite urls (e.g. Nexus Sonatype doesn't do it), I was wondering if removing these parameter alteration would be a thing.
Every run I do the system is reporting itself as changed, even though I can't see any obvious reason why this would be
Notice: /Stage[main]/Profile::Base::Windows/Psrepository[PSGallery]/source_location: source_location changed 'https://www.powershellgallery.com/api/v2' to 'https://www.powershellgallery.com/api/v2/' Notice: /Stage[main]/Profile::Base::Windows/Psrepository[PSGallery]/installation_policy: installation_policy changed 'untrusted' to 'trusted'
The manifest itself is basically straight from the examples:
psrepository { 'PSGallery': ensure => present, source_location => 'https://www.powershellgallery.com/api/v2/', installation_policy => 'trusted', } package { 'PSGelf': ensure => latest, provider => 'powershellcore', source => 'PSGallery', }
Module version: 1.0.0
OS: Windows 2016 1607 (Build: 14393.2312)
Powershell Version: 5.1.14393.2312
Ruby: ruby 2.4.2p198 (2017-09-14 revision 59899) [x64-mingw32]
Puppet: 5.3.3
psrepository { 'PSGallery':
ensure => present,
source_location => 'https://www.powershellgallery.com/api/v2/',
installation_policy => 'trusted',
provider => 'windowspowershell',
}
package { 'PSWindowsUpdate':
ensure => '2.0.0.4',
source => 'PSGallery',
provider => 'windowspowershell',
}
produces:
Error: Failed to apply catalog: Parameter ensure failed on Package[PSWindowsUpdate]: Provider windowspowershell must have features 'versionable' to set 'ensure' to '2.0.4' at /etc/puppetlabs/code/environments/production/site/profile/manifests/windows/update/install.pp:11
If i use latest
, it works.
Don't know much about ruby and creating custom providers, but if I'm not wrong, you are inheriting the provider windowspowershell
from the powershellcore
which has versionable as feature defined.
Seems not to be inherited?
Hello,
I don't know if you've noticed, but we recently released the DSC_Lite module. But one of the challenges with that module is getting the DSC Modules onto the box for the Puppet module to use.
We think that your module here would serve that function nicely, but customers often have reservations about using modules in their environments that aren't at least "Approved".
We were hoping that you would be interested in having a conversation about how to get your module up to approved status. We would much rather do that than stomp on and duplicate this work that you've done here.
Would you consider joining the Puppet Slack Team so we can talk about this a little more easily?
Notice: /Stage[main]/Main/Package[NetworkingDSC]/ensure: created
Notice: /Stage[main]/Main/Package[ComputerManagementDSC]/ensure: created
Notice: /Stage[main]/Main/Package[CertificateDSC]/ensure: created
Debug:
Debug: Executing: 'C:/Windows/System32/WindowsPowerShell/v1.0/powershell.EXE -NoProfile -ExecutionPolicy Bypass -NonInteractive -NoLogo -Command $ProgressPreference = 'SilentlyContinue'; $ErrorActionPreference = 'Stop'; @(Get-PackageProvider).foreach({
[ordered]@{
'name' = $.Name.ToLower()
'version' = $.Version.ToString()
} | ConvertTo-Json -Depth 99 -Compress
})
'
Debug: Prefetching windowspowershell resources for package
Debug: Executing: 'C:/Windows/System32/WindowsPowerShell/v1.0/powershell.EXE -NoProfile -ExecutionPolicy Bypass -NonInteractive -NoLogo -Command $ProgressPreference = 'SilentlyContinue'; $ErrorActionPreference = 'Stop'; Get-Package -AllVersions -ProviderName PowerShellGet -Scope AllUsers -Type Module |
Group-Object -Property Name | % {
[ordered]@{
'name' = $.Name
'ensure' = @(($.Group).Version)
'provider' = 'windowspowershell'
} | ConvertTo-Json -Depth 99 -Compress
}
'
Debug: Executing: 'C:/Windows/System32/WindowsPowerShell/v1.0/powershell.EXE -NoProfile -ExecutionPolicy Bypass -NonInteractive -NoLogo -Command $ProgressPreference = 'SilentlyContinue'; $ErrorActionPreference = 'Stop'; Install-Module NetworkingDSC -Scope AllUsers -Force -Repository PSGallery'
Notice: /Stage[main]/Main/Package[NetworkingDSC]/ensure: created
Debug: /Package[NetworkingDSC]: The container Class[Main] will propagate my refresh event
Debug: Executing: 'C:/Windows/System32/WindowsPowerShell/v1.0/powershell.EXE -NoProfile -ExecutionPolicy Bypass -NonInteractive -NoLogo -Command $ProgressPreference = 'SilentlyContinue'; $ErrorActionPreference = 'Stop'; Install-Module ComputerManagementDSC -Scope AllUsers -Force -Repository PSGallery'
Notice: /Stage[main]/Main/Package[ComputerManagementDSC]/ensure: created
Debug: /Package[ComputerManagementDSC]: The container Class[Main] will propagate my refresh event
Debug: Executing: 'C:/Windows/System32/WindowsPowerShell/v1.0/powershell.EXE -NoProfile -ExecutionPolicy Bypass -NonInteractive -NoLogo -Command $ProgressPreference = 'SilentlyContinue'; $ErrorActionPreference = 'Stop'; Install-Module CertificateDSC -Scope AllUsers -Force -Repository PSGallery'
Notice: /Stage[main]/Main/Package[CertificateDSC]/ensure: created
Funny part is that other packages are not created everytime
package { 'SecurityPolicyDsc':
ensure => latest,
provider => 'windowspowershell',
source => 'PSGallery',
}->
get-package -allversions -providername powershellget -scope allusers -type Module | group-object -property name | % { [ordered]@{'name'=$.name;'ensure'=@(($.Group).version);'provider'='windowspowershell'} | ConvertTo-Json -Depth 99 -Compress }
{"name":"CertificateDsc","ensure":["4.2.0.0"],"provider":"windowspowershell"}
{"name":"ComputerManagementDsc","ensure":["5.2.0.0"],"provider":"windowspowershell"}
{"name":"NetworkingDsc","ensure":["6.1.0.0"],"provider":"windowspowershell"}
{"name":"SecurityPolicyDsc","ensure":["2.5.0.0"],"provider":"windowspowershell"}
{"name":"xActiveDirectory","ensure":["2.21.0.0"],"provider":"windowspowershell"}
{"name":"xPendingReboot","ensure":["0.4.0.0"],"provider":"windowspowershell"}
First off: thanks for the module, it is helping a lot!
One thing that would make this module slightly easier to consume downstream would be to tag it. I know quite a few things got merged in on master since the 1.0.0 tag.
The following error is encountered when using this module on a system that is isolated from the internet.
Debug: Prefetching windowspowershell resources for psrepository
Debug: Executing: 'C:/WINDOWS/System32/WindowsPowerShell/v1.0/powershell.EXE -noprofile -executionpolicy bypass -command
@(Get-PSRepository).foreach({
[ordered]@{
'name' = $_.Name
'source_location' = $_.SourceLocation
'installation_policy' = $_.InstallationPolicy.ToLower()
} | ConvertTo-Json -Depth 99 -Compress
})
'
Debug: Storing state
Debug: Pruned old state cache entries in 0.00 seconds
Debug: Stored state in 0.06 seconds
Error: Failed to apply catalog: 751: unexpected token at 'WARNING: MSG:UnableToDownload https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409'
OS: Windows Server 2019
PSVersion: 5.1.17763.1
Get-PackageProvider -Name NuGet
returns NuGet 2.8.5.208
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.