GithubHelp home page GithubHelp logo

puppet-powershellmodule's People

Contributors

hbuckle avatar jpogran avatar michaeltlombardi avatar nmaludy avatar palintir avatar randomnoun7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

puppet-powershellmodule's Issues

Install-Module with Source will fail each time

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

Module does not work with powershell 5.0 and below

flush_command = "Set-PSRepository #{@resource[:name]}"

(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:

https://docs.microsoft.com/en-us/powershell/module/powershellget/set-psrepository?view=powershell-5.0

https://docs.microsoft.com/en-us/powershell/module/powershellget/set-psrepository?view=powershell-5.1

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.

Is this module still being maintained?

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?

Could not autoload puppet/type/package

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

provider windowspowershell must be versionable

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?

Proxy support

Registering repositories and installing modules should work through a proxy. Also need to find a way to handle proxy credentials

Could not find parent provider powershellcore of windowspowershell

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

Implement auto-requires or make docs more explicit?

The documentation says people should install the nuget packageprovider before attempting to install powershell modules from the PSGallery.

  1. Is it possible to implement an auto-requires to handle this automatically instead of relying on the default manifest ordering?
  2. If auto-requires isn't possible in this scenario should the documentation be updated to show the relationship being setup so it's more explicit and instead of implicit
pspackageprovider { 'Nuget':
    ensure => '2.8.5.208',
} -> Package <| provider == 'windowspowershell' |>

package { 'AWSPowerShell':
    ensure   => '3.3.563.1',
    provider => 'windowspowershell',
}

Lowercased SourceLocation

Hello,

is there a particular reason to have the SourceLocation lowercased?

In particular in these two situations:

and

'source_location' = $_.SourceLocation.ToLower()

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.

Keeps reporting that system is changing

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', }

cannot set version for windowspowershell provider

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?

Discuss Getting Module Approved

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?

Some dsc modules are created every time during the apply

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"}

Tag latest release

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.

Unexpected Token at 'WARNING: MSG:UnableToDownload...'

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.