{"action":"created","issue":{"url":"https://api.github.com/repos/chocolatey/puppet-chocolatey/issues/60","labels_url":"https://api.github.com/repos/chocolatey/puppet-chocolatey/issues/60/labels{/name}","comments_url":"https://api.github.com/repos/chocolatey/puppet-chocolatey/issues/60/comments","events_url":"https://api.github.com/repos/chocolatey/puppet-chocolatey/issues/60/events","html_url":"https://github.com/chocolatey/puppet-chocolatey/issues/60","id":75376679,"number":60,"title":"Upgrade or Re-Install of Chocolatey Fails from Puppet","user":{"login":"trekytech7","id":12401756,"avatar_url":"https://avatars.githubusercontent.com/u/12401756?v=3","gravatar_id":"","url":"https://api.github.com/users/trekytech7","html_url":"https://github.com/trekytech7","followers_url":"https://api.github.com/users/trekytech7/followers","following_url":"https://api.github.com/users/trekytech7/following{/other_user}","gists_url":"https://api.github.com/users/trekytech7/gists{/gist_id}","starred_url":"https://api.github.com/users/trekytech7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trekytech7/subscriptions","organizations_url":"https://api.github.com/users/trekytech7/orgs","repos_url":"https://api.github.com/users/trekytech7/repos","events_url":"https://api.github.com/users/trekytech7/events{/privacy}","received_events_url":"https://api.github.com/users/trekytech7/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":24,"created_at":"2015-05-11T22:15:13Z","updated_at":"2015-05-27T17:06:13Z","closed_at":"2015-05-15T15:48:30Z","body":"I'm new here so sorry ahead of time if my posting is not conforming to customs... I am replying inline to Rob :)\r\n\r\n>> 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).\r\n\r\n> Rob: So do none of those cases work or just the case with Puppet?\r\n\r\nChocolatey update: from v0.9.8.25 (ChocolateyInstall=C:/ProgramData/chocolatey) to v0.9.9.5\r\nMy 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)\r\n\r\n2nd 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... \r\n@powershell -NoProfile -ExecutionPolicy unrestricted -Command \"iex ((new-object net.webclient).DownloadString('`<our private repo>`\\chocoInstall.ps1'))\" && SET PATH=%PATH%;%ALLUSERSPROFILE%\\chocolatey\\bin\r\n\r\n3rd try executes the chocolatey Install.ps1 directly with the puppet powershell provider...\r\n\r\n>> 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).\r\n\r\n> 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. \r\n\r\nMakes 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.\r\n\r\nThe error in Puppets run messages:\r\n\r\n```sh\r\nmessage: \"Chocolatey is unpacking required files for use. Overwriting? True\"\r\nmessage: \"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.\"\r\n```\r\n\r\n> Rob: This seems a puppet-chocolatey issue, specifically https://github.com/chocolatey/puppet-chocolatey/issues/18. \r\n\r\nYes. I was looking at this one... possibly related, but effects more recent version of chocolatey.\r\n\r\n> Rob: This means something went wrong with the package install/upgrade, in this case the upgrade of Chocolatey itself. \r\n> It seems you are likely on a version less than 0.9.9 and upgrading to the latest. \r\n\r\n> Rob: Some questions to help us get a better understanding:\r\n> What version of chocolatey are you upgrading from? \r\n\r\nv0.9.8.25 to v0.9.9.5\r\n> Rob: What version of the puppet provider are you on? \r\n\r\npuppet agent v3.7.2 "},"comment":{"url":"https://api.github.com/repos/chocolatey/puppet-chocolatey/issues/comments/105998448","html_url":"https://github.com/chocolatey/puppet-chocolatey/issues/60#issuecomment-105998448","issue_url":"https://api.github.com/repos/chocolatey/puppet-chocolatey/issues/60","id":105998448,"user":{"login":"trekytech7","id":12401756,"avatar_url":"https://avatars.githubusercontent.com/u/12401756?v=3","gravatar_id":"","url":"https://api.github.com/users/trekytech7","html_url":"https://github.com/trekytech7","followers_url":"https://api.github.com/users/trekytech7/followers","following_url":"https://api.github.com/users/trekytech7/following{/other_user}","gists_url":"https://api.github.com/users/trekytech7/gists{/gist_id}","starred_url":"https://api.github.com/users/trekytech7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trekytech7/subscriptions","organizations_url":"https://api.github.com/users/trekytech7/orgs","repos_url":"https://api.github.com/users/trekytech7/repos","events_url":"https://api.github.com/users/trekytech7/events{/privacy}","received_events_url":"https://api.github.com/users/trekytech7/received_events","type":"User","site_admin":false},"created_at":"2015-05-27T17:06:13Z","updated_at":"2015-05-27T17:06:13Z","body":"@ferventcoder Encountered another hitch while testing prior to turning puppet management back on in 8 undergrad labs. This issue may occur from time to time; if the Chocolatey install fails, for some reason or other :(. The unless statement below will not determine that the choco installation is incomplete (or whatever -I've NO time to look into it).\r\n\r\n```sh\r\n    unless      => 'if (Test-Path \"C:\\ProgramData\\chocolatey\\chocolateyinstall\\chocolatey.ps1\") { exit 1}',\r\n```\r\n\r\nMy other mistake here was to order a puppet agent upgrade before chocolatey upgrade, so it didn't even try to re-install chocolatey (& wouldn't) if the puppet upgrade failed... Ahh! I'm now changing the chocolatey to be before the puppet upgrade, including reboots.\r\n\r\nI may change the 'unless' to use a script instead, so I can validate the choco install too. Or perhaps, have the script check the install right after and then re-try if there was an issue. I'm currently undecided which method to use, but it should definitely be more robust (& automated, so every client fixes itself)."}}