chocolatey-archive / puppet-chocolatey Goto Github PK
View Code? Open in Web Editor NEWChocolatey package provider
License: Apache License 2.0
Chocolatey package provider
License: Apache License 2.0
I have a nuget package that downloads an iso file 2.5GB and mounts the media in order to install. The whole process takes around 600 seconds and I was wondering if this module supports timeout. Otherwise, will have to use the exec resource type.
Hello There,
I have been working on developing a pe-agent upgrader. One thing that I noticed was chocolaty would do an upgrade when I ran the puppet agent in debug. So testing it out with just chocolatey:
C:\ProgramData\chocolatey\chocolateyInstall\chocolatey.cmd update pe-agent -source nuget-repo
Nothing to update.
So to test that my nuget package was right, I ran an install vs upgrade and it works as planned, with one lingering affect, puppet tries to change 3.3.2 to latest all the time (this I can likely fix in the puppet manifest with a version number vs latest)
Debug: Executing 'C:\ProgramData\chocolatey\chocolateyInstall\chocolatey.cmd upd
ate pe-agent -source nuget-repo'
Notice: /Stage[main]/Puppet_enterprise_agent_upgrade/Package[pe-agent]/ensure: e
nsure changed '3.3.2' to 'latest'
Debug: /Package[pe-agent]: The container Class[Puppet_enterprise_agent_upgrade]
will propagate my refresh event
Full details can be found on this google groups forum:
https://groups.google.com/forum/#!topic/puppet-users/SKCmygyNTnA
Thanks
Jason.
When a package has a source defined the the manifest, the source is used when installing the package, but it is not used when asking chocolatey to determine what version of the package is available on the source.
Debug: Executing '["C:\\Chocolatey\\chocolateyInstall\\chocolatey.cmd", " version DocumentUploadService | findstr /R \"latest\" | findstr /V \"latestCompare\" "]'
Debug: Executing 'C:\Chocolatey\chocolateyInstall\chocolatey.cmd update DocumentUploadService -params 'n=DocumentUploadService' -source http://xx.x.x.xx:8081/artifactory/api/nuget/puppet-local'
The check to version should pass in the source, otherwise puppet thinks the 'latest' is nothing.
This is from the puppet log:
ensure changed '3.7.0.4576' to '{}'
When determining the location of choco.exe, look more for the choco.exe to exist versus just directories (as the directories may not get cleaned up).
https://groups.google.com/d/msgid/chocolatey/a4b3c213-3a30-4932-b25a-56beed21376a%40googlegroups.com
Because of the following enhancement the provider does not work from the first time:
chocolatey-archive/chocolatey#452.
Running on Amazon Linux in EC2
Puppet master / agent setup.
If I install this module for our windows hosts, I get this error on our linux hosts when puppet is ran.
Error: Could not autoload puppet/provider/package/chocolatey: undefined method `+' for nil:NilClass
Error: Could not autoload puppet/type/package: Could not autoload puppet/provider/package/chocolatey: undefined method `+' for nil:NilClass
Error: Could not retrieve local facts: Could not autoload puppet/type/package: Could not autoload puppet/provider/package/chocolatey: undefined method `+' for nil:NilClass
Error: Failed to apply catalog: Could not retrieve local facts: Could not autoload puppet/type/package: Could not autoload puppet/provider/package/chocolatey: undefined method `+' for nil:NilClass
This problem is similar to #55 but the error is different. Upon a linux puppet agent run I get the following error:
facter -p operatingsystem
CentOS
[root@foss-agent1 /]# puppet agent --test
Info: Retrieving pluginfacts
Info: Retrieving plugin
Notice: /File[/var/lib/puppet/lib/facter/iis_version.rb]/ensure: defined content as '{md5}11c0899297882d8c4b1e6005688a339a'
Info: Loading facts
Error: Could not autoload puppet/provider/package/chocolatey: can't convert Hash into Integer
Error: Could not autoload puppet/type/package: Could not autoload puppet/provider/package/chocolatey: can't convert Hash into Integer
Error: Could not retrieve catalog from remote server: Could not intern from text/pson: Could not autoload puppet/type/package: Could not autoload puppet/provider/package/chocolatey: can't convert Hash into Integer
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
puppet --version
3.8.1 (FOSS)
Puppet Version : 4.0
Puppet Chocolatey Module Version: 0.4.1
Chocolatey Version: 0.9.9.5
I believe chocolatey.cmd was removed from the latest version of chocolatey and the module chocolatey for puppet needs to point to the right path
Debug: Puppet::Type::Package::ProviderChocolatey: file C:\ProgramData\chocolatey\chocolateyInstall\chocolatey.cmd does not exist
Per choco#158, choco list
may default to local only in the future. choco search
should be used instead to list all packages, including those not installed.
I have included a script inside "chocolateyinstall.ps1" which runs at the time of installation of the package. The package installs fine when I run it locally but does not work with puppet. The modules that I'm using in the "chocolateyinstall.ps1" are not available on the 32 bit command.
The problem maybe because chocolatey package provider is running on the 32 bit command.
My puppet reports show that chocolatey updated itself from from 0.9.8.33 to 0.9.9 yesterday and ever since I get "Provider chocolatey is not functional on this host". The full output is below... any ideas?
err /Package[zabbix-agent] Provider chocolatey is not functional on this host
err /Stage[main]/Base::Install/Package[chocolatey]/ensure change from 0.9.8.33 to 0.9.9 failed: Could not update: Execution of 'C:\ProgramData\chocolatey\chocolateyInstall\chocolatey.cmd update chocolatey ' returned 1: !!ATTENTION!! The next version of Chocolatey (v0.9.9) will require -y to perform behaviors that change state without prompting for confirmation. Start using it now in your automated scripts. For details on the all new Chocolatey, visit http://bit.ly/new_choco Updating chocolatey from 0.9.8.33 to 0.9.9 Chocolatey (v0.9.8.33) is installing 'chocolatey' and dependencies. By installing you accept the license for 'chocolatey' and each dependency you are installing. chocolatey v0.9.9 Chocolatey v0.9.9 Chocolatey is unpacking required files for use. Overwriting? True Creating ChocolateyInstall as an environment variable (targeting 'Machine') Setting ChocolateyInstall to 'C:\ProgramData\chocolatey' WARNING: It's very likely you will need to close and reopen your shell before you can use choco. Adding Modify permission for current user to 'C:\ProgramData\chocolatey' We are setting up the Chocolatey package repository. The packages themselves go to 'C:\ProgramData\chocolatey\lib' (i.e. C:\ProgramData\chocolatey\lib\yourPackageName). A shim file for the command line goes to 'C:\ProgramData\chocolatey\bin' and points to an executable in 'C:\ProgramData\chocolatey\lib\yourPackageName'. Creating Chocolatey folders if they do not already exist. WARNING: You can safely ignore errors related to missing log files when upgrading from a version of Chocolatey less than 0.9.9. 'Batch file could not be found' is also safe to ignore. 'The system cannot find the file specified' - also safe. Chocolatey v0.9.9 Chocolatey is unpacking required files for use. Overwriting? True Ensuring 'C:\ProgramData\chocolatey\lib\chocolatey' exists. Chocolatey (choco.exe) is now ready. You can call choco from anywhere, command line or powershell by typing choco. Run choco /? for a list of functions. You may need to shut down and restart powershell and/or consoles first prior to using choco. Finished installing 'chocolatey' and dependencies - if errors not shown in console, none detected. Check log for errors if unsure. The batch file cannot be found.
err Puppet Could not update: Execution of 'C:\ProgramData\chocolatey\chocolateyInstall\chocolatey.cmd update chocolatey ' returned 1: !!ATTENTION!! The next version of Chocolatey (v0.9.9) will require -y to perform behaviors that change state without prompting for confirmation. Start using it now in your automated scripts. For details on the all new Chocolatey, visit http://bit.ly/new_choco Updating chocolatey from 0.9.8.33 to 0.9.9 Chocolatey (v0.9.8.33) is installing 'chocolatey' and dependencies. By installing you accept the license for 'chocolatey' and each dependency you are installing. chocolatey v0.9.9 Chocolatey v0.9.9 Chocolatey is unpacking required files for use. Overwriting? True Creating ChocolateyInstall as an environment variable (targeting 'Machine') Setting ChocolateyInstall to 'C:\ProgramData\chocolatey' WARNING: It's very likely you will need to close and reopen your shell before you can use choco. Adding Modify permission for current user to 'C:\ProgramData\chocolatey' We are setting up the Chocolatey package repository. The packages themselves go to 'C:\ProgramData\chocolatey\lib' (i.e. C:\ProgramData\chocolatey\lib\yourPackageName). A shim file for the command line goes to 'C:\ProgramData\chocolatey\bin' and points to an executable in 'C:\ProgramData\chocolatey\lib\yourPackageName'. Creating Chocolatey folders if they do not already exist. WARNING: You can safely ignore errors related to missing log files when upgrading from a version of Chocolatey less than 0.9.9. 'Batch file could not be found' is also safe to ignore. 'The system cannot find the file specified' - also safe. Chocolatey v0.9.9 Chocolatey is unpacking required files for use. Overwriting? True Ensuring 'C:\ProgramData\chocolatey\lib\chocolatey' exists. Chocolatey (choco.exe) is now ready. You can call choco from anywhere, command line or powershell by typing choco. Run choco /? for a list of functions. You may need to shut down and restart powershell and/or consoles first prior to using choco. Finished installing 'chocolatey' and dependencies - if errors not shown in console, none detected. Check log for errors if unsure. The batch file cannot be found. Wrapped exception: Execution of 'C:\ProgramData\chocolatey\chocolateyInstall\chocolatey.cmd update chocolatey ' returned 1: !!ATTENTION!! The next version of Chocolatey (v0.9.9) will require -y to perform behaviors that change state without prompting for confirmation. Start using it now in your automated scripts. For details on the all new Chocolatey, visit http://bit.ly/new_choco Updating chocolatey from 0.9.8.33 to 0.9.9 Chocolatey (v0.9.8.33) is installing 'chocolatey' and dependencies. By installing you accept the license for 'chocolatey' and each dependency you are installing. chocolatey v0.9.9 Chocolatey v0.9.9 Chocolatey is unpacking required files for use. Overwriting? True Creating ChocolateyInstall as an environment variable (targeting 'Machine') Setting ChocolateyInstall to 'C:\ProgramData\chocolatey' WARNING: It's very likely you will need to close and reopen your shell before you can use choco. Adding Modify permission for current user to 'C:\ProgramData\chocolatey' We are setting up the Chocolatey package repository. The packages themselves go to 'C:\ProgramData\chocolatey\lib' (i.e. C:\ProgramData\chocolatey\lib\yourPackageName). A shim file for the command line goes to 'C:\ProgramData\chocolatey\bin' and points to an executable in 'C:\ProgramData\chocolatey\lib\yourPackageName'. Creating Chocolatey folders if they do not already exist. WARNING: You can safely ignore errors related to missing log files when upgrading from a version of Chocolatey less than 0.9.9. 'Batch file could not be found' is also safe to ignore. 'The system cannot find the file specified' - also safe. Chocolatey v0.9.9 Chocolatey is unpacking required files for use. Overwriting? True Ensuring 'C:\ProgramData\chocolatey\lib\chocolatey' exists. Chocolatey (choco.exe) is now ready. You can call choco from anywhere, command line or powershell by typing choco. Run choco /? for a list of functions. You may need to shut down and restart powershell and/or consoles first prior to using choco. Finished installing 'chocolatey' and dependencies - if errors not shown in console, none detected. Check log for errors if unsure. The batch file cannot be found.
On the same hosts, choco /?
and choco -v
work fine and return 0.9.9
.
Installation of chocolatey for master machine was not successful since, I guess, the paths in
Install Packages with Chocolatey section of
modules\atomia\manifests\windows_base.pp
are not set correctly.
Specifically,
exec { 'install-chocolatey':
command => "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))",
provider => powershell,
onlyif => 'Test-Path C:\Chocolatey'
}
exec { 'set-chocolatey-path':
command => 'c:\windows\system32\cmd.exe /c SET PATH=%PATH%;%systemdrive%\chocolatey\bin',
creates => "c:/install/chocolatey_installed.txt",
require => Exec['install-chocolatey'],
}
Actual paths are:
C:\ProgramData\chocolatey for 'install-chocolatey' and
path C:\ProgramData\chocolatey\bin for 'set-chocolatey-path'
chocolateyinstall.ps1
Install-ChocolateyPackage 'siteminder' 'exe' '' 'http://mywebserver/puppet/siteminder-12.51.6-win64.exe'
puppet
file { 'config' :
ensure => present,
path => "C:\\Temp\\${pkg}.properties",
content => template('siteminder/siteminder-win64.properties.erb'),
} ->
package { $pkg :
ensure => $version,
name => 'siteminder',
provider => 'chocolatey',
install_options => ['-override', '-installArgs', '"', 'f', '"C:\\Temp\\${pkg}.properties"','-i','silent', '"'],
}
log file
I have Chocolatey set to upgrade itself via Puppet but with the 0.9.9.7 release and now with the 0.9.9.8 release I get the following error:
PS C:\Windows\system32> puppet agent -t
Notice: Ignoring --listen on onetime run
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Error loading fact C:/ProgramData/PuppetLabs/puppet/var/lib/facter/facts.rb: cannot load such file -- util/sssd
Info: Caching catalog for adm-recruitdb.uwg.westga.edu
Info: Applying configuration version '1435590280'
←[1;31mError: Could not update: Execution of 'C:\ProgramData\chocolatey\bin\choco.exe upgrade chocolatey -dvy ' returned
1: Chocolatey v0.9.9.7
Chocolatey is running on Windows v 6.1.7601.65536
Attempting to delete file "C:/ProgramData/chocolatey/choco.exe.old".
This is try 1/3. Retrying after 300 milliseconds.
Error converted to warning:
System.UnauthorizedAccessException: Access to the path 'C:\ProgramData\chocolatey\choco.exe.old' is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.File.InternalDelete(String path, Boolean checkHost)
at chocolatey.infrastructure.tolerance.FaultTolerance.<>c__DisplayClass1.<retry>b__0()
at chocolatey.infrastructure.tolerance.FaultTolerance.retry[T](Int32 numberOfTries, Func`1 function, Int32 waitDurati
onMilliseconds, Int32 increaseRetryByMilliseconds)
This is try 2/3. Retrying after 400 milliseconds.
Error converted to warning:
System.UnauthorizedAccessException: Access to the path 'C:\ProgramData\chocolatey\choco.exe.old' is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.File.InternalDelete(String path, Boolean checkHost)
at chocolatey.infrastructure.tolerance.FaultTolerance.<>c__DisplayClass1.<retry>b__0()
at chocolatey.infrastructure.tolerance.FaultTolerance.retry[T](Int32 numberOfTries, Func`1 function, Int32 waitDurati
onMilliseconds, Int32 increaseRetryByMilliseconds)
Maximum tries of 3 reached. Throwing error.
Attempting to delete choco.exe.old ran into an issue:
Access to the path 'C:\ProgramData\chocolatey\choco.exe.old' is denied.
Command line: "C:\ProgramData\chocolatey\choco.exe" upgrade chocolatey -dvy
Received arguments: upgrade chocolatey -dvy
When investigating on systems that show this problem I see in task manager that there are two choco.exe processes still running. One just has "chocolatey" as its description but the other says "ShimGen generated shim". If I kill these then Puppet can upgrade things just fine.
I am seeing this problem on 2008 R2, 2012, and 2012 R2.
Running on Vagrant Windows Server 2012 R2 box gives the error Provider chocolately is not functional on this host
There is a small syntactical error in the README on how to set the default provider to chocolatey.
There should be a second set of brackets around the Package line so this
case $operatingsystem {
'windows':
Package { provider => chocolatey, }
}
should be this
case $operatingsystem {
'windows': {
Package { provider => chocolatey, }
}
}
Otherwise you get a syntax error.
I realized that this project does not have a license file included with it.
I would like to include one, and as such I am reaching out to all the contributors of the project to date to gain a consensus as to their thoughts on it.
@jumanjiman @ferventcoder @StuartWhelan @marcusmyers @georgievrado @DavidS @thomasbiddle
I am leaning towards the Apache 2.0 license as that is what PuppetLabs itself is using and the chocolatey project itself is using.
One key point I do request is that usage of this project conceptually, (puppet w/ a chocolatey provider) or the actual code contain some level of attribution back to rismoney (Rich Siegel). As many of you know this project started as rismoney/puppet-chocolatey and we merged it into the chocolatey organization to gain further community awareness. This has been fantastic and far exceeded my original expectations of me, just using the provider at my site personally. I want to continue its improvement and foster future growth and capabilities and think this is a reasonable request.
I have many other puppet providers that I plan on growing and improving as well, and think that the license addition and attribution requirement are critical to their success going forward. I look forward to a lot more puppet community development and enhancements for the windows ecosystem.
If anyone has any feedback or information they would like to discuss in regards to this, feel free to reply or contact me privately.
The provider method that parses chocolatey output for the list of installed packages uses case sensitive string matching. Chocolatey, like most of Windows, is not case sensitive. This can lead to a situation where the provider appears to work (the package gets installed), but it can't tell that the package is installed, so it tries to install it again every run, delaying the puppet agent run by a long time. This may also be the root cause of the apparently spurious messages discussed in issue #36.
I think the provider's check for installed packages should be case _in_sensitive for ease of use and reliability, especially because the correct case for packages names is somewhat obscure when browsing packages on chocolatey.org.
testing using choco 0.9.9.8 with the current master branch of the provider.
I am upgrading from an old rev of choco, and what i believe I see happening is that everything upgrades fine. no errors. however c:\chocolatey\chocolatey.config is still referenced because I think the environment variable doesn't get updated until a session close/reopen. if i close and reopen powershell and run puppet agent, it is solid. but if i stay within that session the puppet run bombs worse than horrendous (it tries to update against chocolatey.org vs our internal repo)
I have been managing chocolatey.config with a file resource referencing C:\programdata\chocolatey\config\chocolatey.config and that is updated fine.
So I think somewhere in the fold, $env:ChocolateyInstall� needs to be updated.
I thought someone had already mentioned this issue before?
If you don't install chocolatey on the node first, you get a not very helpful: 'Provider chocolatey is not functional' error. I assumed that the provider 'just worked'. I ended up using:
exec { 'install-chocolatey':
command => "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))",
provider => powershell,
}
Currently there is no provider to allow us to manage/configure the actual installation for chocolatey. For example if I want to add new choco sources via puppet I would have to execute powershell commands. I could see a bunch of types/providers to manage choco but for my immediate needs I only want to configure the sources.
It would be nice to do the following:
choco::source{'artifactory server':
ensure => present,
url => 'http://artifactory.company.corp:8223',
}
The package I am installing in an inhouse package; a windows service.
I need to pass some parameters to my install script.
The trouble is the only way I can see to do this is using the choco -params functionality, which I do not think is exposed by the puppet module in a way that I can use.
I tried to use install_options, but something (Not sure if it is puppet or the puppet-chocolatey module) is wrapping the install_options value in a quote if the install_options value contains a space.
To give a simplified example, if I try:
class document_upload_service{
package{ 'DocumentUploadService':
ensure => latest,
provider => 'chocolatey',
install_options => "-install",
source => 'http://10.0.2.63:8081/artifactory/api/nuget/puppet-local',
}
}
then in my logs I see:
Debug: Executing 'C:\Chocolatey\chocolateyInstall\chocolatey.cmd update DocumentUploadService -install -source http://10.0.2.63:8081/artifactory/api/nuget/puppet-local'
But if I use:
install_options => "-params -install",
I get
Debug: Executing 'C:\Chocolatey\chocolateyInstall\chocolatey.cmd update DocumentUploadService "-params -install" -source http://10.0.2.63:8081/artifactory/api/nuget/puppet-local'
Can we get a way to pass complex parameters without getting quoted?
I posted this on SO but figured I should ask here as well in case I'm doing something wrong.
I am trying to ensure that .NET 4.5 is installed on an agent. I am using the puppet-chocolatey provider:
package { 'DotNet4.5':
ensure => installed,
provider => 'chocolatey',
}
However, each time I run it, the log shows 1 change:
Notice: /Stage[main]//Node[mymachine1234]/Package[DotNet4.5]/ensure: created
Even though .NET 4.5 is installed, it still reports that 1 change has occurred as shown above.
I have also tried the value of 4.5
instead of installed
in the definition above, but whatever I apply it reports 1 change.
In contrast, when I use the same thing to ensure Node.js is installed, it works just fine and doesn't report 1 change each time.
Could someone update newest version (0.0.4) to https://forge.puppetlabs.com/
Update use to install git for me on a fresh system. Now it does nothing:
Old Behaviour:
$ /cygdrive/c/ProgramData/chocolatey/chocolateyinstall/chocolatey.cmd update git
Nothing to update.
Did you know we are rewriting Chocolatey? The new
version is much more stable and secure.
Find out more and support the future of Chocolatey
at https://bit.ly/chocolateykickstarter
Disable this message by changing ksMessage to false in chocolatey.config.
New Behaviour:
$ /cygdrive/c/Chocolatey/chocolateyinstall/chocolatey.cmd update git
Chocolatey (v0.9.8.23) is installing 'git' and dependencies. By installing you accept the license for 'git' and each dependency you are installing.
______ git.install v1.9.5.20150114 ______
Downloading git.install 32 bit (https://github.com/msysgit/msysgit/releases/download/Git-1.9.5-preview20141217/Git-1.9.5-preview20141217.exe) to C:\cygwin\tmp\chocolatey\git.install\git.installInstall.exe
Installing git.install...
Elevating Permissions and running C:\cygwin\tmp\chocolatey\git.install\git.installInstall.exe /VERYSILENT /NORESTART /NOCANCEL /SP- /NOICONS /COMPONENTS="icons,icons\quicklaunch,ext,ext\reg,ext\reg\shellhere,ext\reg\guihere,assoc,assoc_sh" /LOG . This may take awhile, depending on the statements.
git.install has been installed.
git.install has finished successfully! The chocolatey gods have answered your request!
PATH environment variable does not have C:\Program Files (x86)\Git\cmd in it. Adding...
Elevating Permissions and running C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -ExecutionPolicy unrestricted -Command "& import-module -name 'C:\Chocolatey\chocolateyinstall\helpers\chocolateyInstaller.psm1'; try{[Environment]::SetEnvironmentVariable('Path','C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Amazon\cfn-bootstrap\;C:\cygwin\bin;C:\chocolatey\bin;C:\Program Files (x86)\Puppet Labs\Puppet\bin;C:\Program Files (x86)\Git\cmd;', 'Machine'); start-sleep 6;}catch{write-error 'That was not sucessful';start-sleep 8;throw;}". This may take awhile, depending on the statements.
WARNING: Git installed - You may need to close and reopen your shell for PATH
changes to take effect.
______ git v1.9.5.20150114 ______
Finished installing 'git' and dependencies - if errors not shown in console, none detected. Check log for errors if unsure.
Reading environment variables from registry. Please wait... Done.
Both environments had no previous version of git installed and were running on Windows 2008r2. Not sure if this is expected or not sorry!
When environment variables are not set, provider throws an error (happens on linux masters every time)
Error: Could not autoload puppet/provider/package/chocolatey: undefined method `+' for nil:NilClass
/var/lib/puppet/lib/puppet/provider/package/chocolatey.rb:24:in `chocolatey_command'
/var/lib/puppet/lib/puppet/provider/package/chocolatey.rb:69:in `block in <top (required)>'
Which corresponds to https://github.com/chocolatey/puppet-chocolatey/blob/master/lib/puppet/provider/package/chocolatey.rb#L24
Only if it doesn't find the actual item on the source.
Repro:
package {'launchy':
ensure => latest,
install_options => ['-override', '-installArgs', '"', '/VERYSILENT', '/NORESTART', '"'],
source => 'C:\vagrant\resources\packages; https://chocolatey.org/api/v2/',
}
https://github.com/chocolatey/choco/wiki/CommandsReference#how-to-pass-options--switches
install_options => ['-override', '-installArgs', '"', '/somevalue=', '""', 'C:\program files\somewhere', '""', '"'],
}
When stating a specific version of a package choco.exe list -lo -r
should be used to determine if the package is already present, if present choco.exe upgrade $package -version $version -dvy
else choco.exe install $package -version $version -dvy
output of puppet agent -t --debug
Debug: Prefetching chocolatey resources for package
Debug: Executing 'C:\ProgramData\chocolatey\bin\choco.exe -v'
Debug: Executing 'C:\ProgramData\chocolatey\bin\choco.exe list -lo -r'
Debug: Executing 'C:\ProgramData\chocolatey\bin\choco.exe install win-pack-man -version 0.0.13 -dvy '
Notice: /Stage[main]/Win_pack_man/Package[win-pack-man]/ensure: ensure changed '0.0.9' to '0.0.13'
At the moment choco.exe install
is being used even if the package is already present, which is leading to strange behavior in the c:/programdata/chocolatey/lib directory, such as duplicate content.
choco.exe -v 0.9.9.6
output of puppet module list
/etc/puppetlabs/puppet/environments/production/modules
└── counsyl-windows (v1.0.0)
/etc/puppetlabs/puppet/modules
├── badgerious-windows_env (v2.2.1)
├── choco_inst (???)
├── chocolatey-chocolatey (v1.0.1)
├── counsyl-sys (v0.9.18)
├── hiscox-app_obx (v0.0.1)
├── jordan-windows_service (v0.0.4)
├── opentable-iis (v1.3.0)
├── programs_dotnet45 (???)
├── programs_wmf40 (???)
├── puppet-windowsfeature (v1.1.0)
├── puppetlabs-acl (v1.0.3)
├── puppetlabs-dism (v1.1.0)
├── puppetlabs-powershell (v1.0.4)
├── puppetlabs-registry (v1.1.0)
└── win_pack_man (???)
When stating a specific version of a package the provider should be able to determine if the package already exists and if the present package version is higher than the specified version, the present package is uninstalled and specified version is installed.
output of puppet agent -t --debug
Debug: Prefetching chocolatey resources for package
Debug: Executing 'C:\ProgramData\chocolatey\bin\choco.exe -v'
Debug: Executing 'C:\ProgramData\chocolatey\bin\choco.exe list -lo -r'
Debug: Executing 'C:\ProgramData\chocolatey\bin\choco.exe upgrade --noop chocolatey -r'
Debug: Class[Choco_inst]: The container Stage[main] will propagate my refresh event
Debug: Executing 'C:\ProgramData\chocolatey\bin\choco.exe upgrade win-pack-man -version 0.0.9 -dvy '
Notice: /Stage[main]/Win_pack_man/Package[win-pack-man]/ensure: ensure changed '0.0.13' to '0.0.9'
At the moment this results in present version remains and the specified version is ignored.
choco.exe -v 0.9.9.8
output of puppet module list
/etc/puppetlabs/puppet/environments/production/modules
└── counsyl-windows (v1.0.0)
/etc/puppetlabs/puppet/modules
├── badgerious-windows_env (v2.2.1)
├── choco_inst (???)
├── chocolatey-chocolatey (v1.0.2)
├── counsyl-sys (v0.9.18)
├── hiscox-app_obx (v0.0.1)
├── jordan-windows_service (v0.0.4)
├── opentable-iis (v1.3.0)
├── programs_dotnet45 (???)
├── programs_wmf40 (???)
├── puppet-windowsfeature (v1.1.0)
├── puppetlabs-acl (v1.0.3)
├── puppetlabs-dism (v1.1.0)
├── puppetlabs-powershell (v1.0.4)
├── puppetlabs-registry (v1.1.0)
└── win_pack_man (???)
I'm going to work on this myself but I wanted to put it out there in case anyone has any ideas for how to implement this
I'm currently using rismoney@efdf354
When my internal chocolatey server is down or has a hiccup chocolatey returns something like this
verMessage : System.Collections.DictionaryEntry does not appear to be on the source(s) specified:
latestCompare : 000000000000
name : windirstat
found :
latest :
foundCompare : 000000000000
No package found
Command 'version' failed (sometimes this indicates a partial failure). Additional info/packages: windirstat
The puppet provider handles this by returning nil, which causes puppet to try and update the package to 'latest'. Unfortunately I'm horrible at ruby, so my attempts to fix it have failed. The only (still probably not great) solution I could think of was somehow returning the current version instead of 'nil'? Although I couldn't work out how to do this in practice, iterate over the packages array?
I ran into this issue once during a puppet run using Vagrant -- after trying to run vagrant provision
again, the run succeeded... for some reason. Note the first time the run failed because of a syntax error, and this was on the 2nd attempt. A third attempt the run was successful.
Puppet Manifest:
package { 'UrlRewrite2':
ensure => present,
provider => 'chocolatey',
source => 'webpi',
}
Error Log:
==> default: Error: /Stage[main]/Main/Package[UrlRewrite2]/ensure: change from absent to present failed: Execution of 'C:\ProgramData\chocolatey\chocolateyInstall\chocolatey.cmd install UrlRewrite2 -source webpi' returned 1: WARNING: installmissing command is deprecated and will be removed. Install
==> default: provides the same functionality now.
==> default: Chocolatey (v0.9.8.27) is installing UrlRewrite2 and dependencies (using WebPI). By installing you accept the license for UrlRewrite2 and each dependency you are installing.
==> default: Opening minimized PowerShell window and calling 'cmd.exe /c webpicmd /Install /AcceptEula /SuppressReboot /Products:UrlRewrite2'. If progress is taking a long time, please check that window. It also may not be 100% silent...
==> default: Write-Error : [ERROR] Running C:\Windows\System32\WindowsPowerShell\v1.0\powers
==> default: hell.exe with cmd.exe /c webpicmd /Install /AcceptEula /SuppressReboot /Product
==> default: s:UrlRewrite2 | Tee-Object -FilePath 'C:\ProgramData\chocolatey\chocolateyinsta
==> default: ll\chocolateyWebPiInstall.log'; was not successful. Exit code was '1'.
==> default: At C:\ProgramData\chocolatey\chocolateyinstall\helpers\functions\Start-Chocolat
==> default: eyProcessAsAdmin.ps1:46 char:5
==> default: + Write-Error $errorMessage
==> default: + ~~~~~~~~~~~~~~~~~~~~~~~~~
==> default: + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorExcep
==> default: tion
==> default: + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorExceptio
==> default: n,Write-Error
==> default:
==> default: [ERROR] Running C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe with cmd.exe /c webpicmd /Install /AcceptEula /SuppressReboot /Products:UrlRewrite2 | Tee-Object -FilePath 'C:\ProgramData\chocolatey\chocolateyinstall\chocolateyWebPiInstall.log'; was not successful. Exit code was '1'.
==> default: Command 'install' failed (sometimes this indicates a partial failure). Additional info/packages: UrlRewrite2
Install Log:
The software that you obtain using the Web Platform Installer Command Line Tool is licensed to you by its owner. Microsoft grants you no rights for third party software.
.
..
...
.
Successfully loaded primary feed: https://go.microsoft.com/?linkid=9842185
The following products are not available on this machine or already installed: UrlRewrite2
No products to be installed (either not available or already installed)
My thought is that the key error message here is The following products are not available on this machine or already installed: UrlRewrite2
-- this is possibly the scenario where this error was thrown. Is there a way to test for this case and ensure it's handled correctly?
This may be a non-issue as well, but I just want to report it to see if you have any idea on how this would happen.
I've come across a problem that i can't seem to fix easily
I'm using the chocolatey provider to deploy applications on a few windows machines, and everything works very well on windows 7 and 8.1 and 2008 R2, but when run on XP 32bit or 2003 32 bit i get an error undefined method 'each' for nil:NilClass
:
fix_latest
branch, but the i've comme across the same issue with the master branchThe this the class used to install/update packages
class winbrowser {
$pkg = [ 'flashplayerplugin', 'firefox' ]
package { $pkg:
ensure => 'latest',
provider => 'chocolatey',
source => 'https://chocolatey.org/api/v2/'
}
}
Could not prefetch package provider 'chocolatey': undefined method 'each' for nil:NilClass
//Stage[main]/Winbrowser/Package[firefox]) Could not evaluate: undefined method 'each' for nil:NilClass
tl;dr: Workaround noted at #41 (comment)
Hello. I am trying to make sure the latest package is installed using the Puppet Package resource, and chocolatey provider. Every time the puppet agent checks in with the Puppet Master, we want to make sure that the app installed on the client is at the latest version. Here is the specific code inside our Puppet Installer class:
package { $appName:
ensure => latest,
provider => 'chocolatey',
source => $servicePackageRepo,
install_options => [ '-packageparameters', "$appRoot$appName\deploy.properties"]
}
When this executes, I find puppet running this command to find the latest version:
Debug: Executing 'C:\ProgramData\chocolatey\chocolateyInstall\chocolatey.cmd version TaskManager | findstr /R "latest" | findstr /V "latestCompare" '
This always results in a null return:
Debug: /Stage[main]/Profiles::Taskmanager::Install/Package[TaskManager]/ensure: TaskManager "1.1.3" is installed, latest is nil
I extracted this command from the debug output and ran it myself, but added the source directory where our nupkg packages are located on the local machine:
'C:\ProgramData\chocolatey\chocolateyInstall\chocolatey.cmd version TaskManager –source C:\ProgramData\MorphoTrust\PuppetDeploy | findstr /R "latest" | findstr /V "latestCompare"
This then successfully returned the latest version found in that directory. Is there a way to get the source into the command Puppet uses to find the latest version? Or is there something else that I should be doing to ensure the latest package is always installed?
This is related to #15
I'm new here so sorry ahead of time if my posting is not conforming to customs... I am replying inline to Rob :)
I get errors when updating Chocolatey via Puppet. I've tried using the puppet-chocolatey provider to upgrade to v0.9.9.5, and re-installing chocolatey from Puppet with command line or powershell (v0.9.9.5).
Rob: So do none of those cases work or just the case with Puppet?
Chocolatey update: from v0.9.8.25 (ChocolateyInstall=C:/ProgramData/chocolatey) to v0.9.9.5
My 1st try was to upgrade from old version to new using puppet-chocolatey provider, then from command line using "choco -f update chocolatey -version '0.9.9.5' -source '<our private repo>
' " and both methods failed. Of course the command line will be different now with the 'upgrade' command instead. (note: the command works if done manually, but not from puppet)
2nd I tried to just re-install over previous chocolatey installation by executing a batch file from puppet with the standard install command from command line...
@PowerShell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('<our private repo>
\chocoInstall.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
3rd try executes the chocolatey Install.ps1 directly with the puppet powershell provider...
My suspicion has been that the ChocolateyInstall variable is null, based on the install log ([DEBUG] Running 'Install-ChocolateyEnvironmentVariable' with variableName:'ChocolateyInstall' and variableValue:''). Possibly because puppet is running as the System user (the variable is set globally).
Rob: That is likely removing a value - unfortunately the message probably also needs to state the scope of the change - user versus system. We attempt to remove the user version if we are setting it globally, which for administrative install we are going for the global variable.
Makes sense. Does running as SYSTEM vs. an Administrator (which is technically a user running as admin -like sudo) get similar environment variables or different... I suspect a different environment, but I haven't looked into this yet.
The error in Puppets run messages:
message: "Chocolatey is unpacking required files for use. Overwriting? True"
message: "The OS handle's position is not what FileStream expected. Do not use a handle simultaneously in one FileStream and in Win32 code or another FileStream. This may cause data loss."
Rob: This seems a puppet-chocolatey issue, specifically #18.
Yes. I was looking at this one... possibly related, but effects more recent version of chocolatey.
Rob: This means something went wrong with the package install/upgrade, in this case the upgrade of Chocolatey itself.
It seems you are likely on a version less than 0.9.9 and upgrading to the latest.Rob: Some questions to help us get a better understanding:
What version of chocolatey are you upgrading from?
v0.9.8.25 to v0.9.9.5
Rob: What version of the puppet provider are you on?
puppet agent v3.7.2
Is there a trick by which packages installed by chocolatey that update the Machine Path (i.e. [System.Environment]::GetEnvironmentVariable("Path","Machine")
) can be used by subsequent Exec calls in the same puppet apply
run? I'm having difficulty with nodejs.install
and subsequently using the Powershell provider (puppetlabs/powershell
) to run npm
commands.
Any tricks to make this work? I've created an issue w/ the powershell provider as well, because I can't seem to provide an up-to-date path => ...
to the Exec, which seems like a shortcoming or bug of some sort.
In order to use our local nuget repository (hosted in artifactory) we need to use basic authentication.
nuget.exe supports -username and -password when running sources add, but this is not exposed the the chocolately wrapper of the sources command.
I created a Puppetfile, added this:
mod "puppet/chocolately",
:git => "https://github.com/chocolatey/puppet-chocolatey.git"
then did this: librarian-puppet install --verbose (version 1.3.2)
and got this output:
[Librarian] Ruby Version: 1.9.3
[Librarian] Ruby Platform: i386-mingw32
[Librarian] Rubygems Version: 1.8.28
[Librarian] Librarian Version: 0.1.2
[Librarian] Librarian Adapter: puppet
[Librarian] Librarian Adapter Version: 1.3.2
[Librarian] Project: C:/Users/ERic/setup
[Librarian] Specfile: Puppetfile
[Librarian] Lockfile: Puppetfile.lock
[Librarian] Git: C:/Program Files (x86)/Git/bin/git.EXE
[Librarian] Git Version: 1.9.4
[Librarian] Git Environment Variables:
Librarian
[Librarian] Pre-Cached Sources:
[Librarian] Post-Cached Sources:
[Librarian] [:git, "https://github.com/chocolatey/puppet-chocolatey.git", {}]
[Librarian] [:git, "https://git.vistaprint.net/scm/ppm/serviceplatform.git", {}]
[Librarian] [:git, "https://git.vistaprint.net/scm/ppm/logstash_windows.git", {}]
[Librarian] Resolving puppet-chocolately (>= 0) https://github.com/chocolatey/puppet-chocolatey.git#master
[Librarian] Checking manifests
[Librarian] --- No output
[Librarian] --- No output
[Librarian] --- No output
[Librarian] --- No output
[Librarian] --> origin
[Librarian] --> origin/HEAD -> origin/master
[Librarian] --> origin/fix_explicit_vers
[Librarian] --> origin/master
[Librarian] --> 52f972b
[Librarian] --> 52f972b
Module https://github.com/chocolatey/puppet-chocolatey.git#master does not have version, defaulting to 0.0.1
[Librarian] Checking puppet-chocolately/0.0.1 https://github.com/chocolatey/puppet-chocolatey.git#master
c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-puppet-1.3.2/lib/librarian/puppet/source/local.rb:45:in fetch_dependencies': undefined method
each' for nil:NilClass (NoMethodError)
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/manifest.rb:125:in fetch_dependencies!' from c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/manifest.rb:117:in
fetched_dependencies'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/manifest.rb:81:in dependencies' from c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/resolver/implementation.rb:117:in
block in check_manifest_for_cycles'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/resolver/implementation.rb:117:in each' from c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/resolver/implementation.rb:117:in
map'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/resolver/implementation.rb:117:in check_manifest_for_cycles' from c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/resolver/implementation.rb:64:in
block in recursive_resolve'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/resolver/implementation.rb:154:in block (3 levels) in resolving_dependency_map_find_manifests' from c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/resolver/implementation.rb:187:in
block in scope_checking_manifest'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/resolver/implementation.rb:223:in scope' from c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/resolver/implementation.rb:186:in
scope_checking_manifest'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/resolver/implementation.rb:153:in block (2 levels) in resolving_dependency_map_find_manifests' from c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/resolver/implementation.rb:211:in
block in map_find'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/resolver/implementation.rb:210:in each' from c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/resolver/implementation.rb:210:in
map_find'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/resolver/implementation.rb:152:in block in resolving_dependency_map_find_manifests' from c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/resolver/implementation.rb:165:in
block (2 levels) in scope_resolving_dependency'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/resolver/implementation.rb:179:in block in scope_checking_manifests' from c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/resolver/implementation.rb:223:in
scope'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/resolver/implementation.rb:178:in scope_checking_manifests' from c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/resolver/implementation.rb:164:in
block in scope_resolving_dependency'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/resolver/implementation.rb:223:in scope' from c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/resolver/implementation.rb:163:in
scope_resolving_dependency'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/resolver/implementation.rb:151:in resolving_dependency_map_find_manifests' from c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/resolver/implementation.rb:62:in
recursive_resolve'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/resolver/implementation.rb:50:in resolve' from c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/resolver.rb:23:in
resolve'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/action/resolve.rb:26:in run' from c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/cli.rb:169:in
resolve!'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-puppet-1.3.2/lib/librarian/puppet/cli.rb:67:in install' from c:/Ruby193/lib/ruby/gems/1.9.1/gems/thor-0.19.1/lib/thor/command.rb:27:in
run'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/thor-0.19.1/lib/thor/invocation.rb:126:in invoke_command' from c:/Ruby193/lib/ruby/gems/1.9.1/gems/thor-0.19.1/lib/thor.rb:359:in
dispatch'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/thor-0.19.1/lib/thor/base.rb:440:in start' from c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/cli.rb:26:in
block (2 levels) in bin!'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/cli.rb:31:in returning_status' from c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/cli.rb:26:in
block in bin!'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/cli.rb:47:in with_environment' from c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/cli.rb:26:in
bin!'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/librarian-puppet-1.3.2/bin/librarian-puppet:7:in <top (required)>' from c:/Ruby193/bin/librarian-puppet:23:in
load'
from c:/Ruby193/bin/librarian-puppet:23:in `
Unlike other package providers I've come across, when I select ensure => latest for a package chocolatey outputs a notice even if the package is already at the latest version.
Would it be possible to silently check for latest versions and only log a notice when a package is updated?
Thanks
Sam
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.