Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chocolatey.config broken after puppet provider execution #120

Open
bodyakov opened this issue Apr 1, 2016 · 16 comments
Open

chocolatey.config broken after puppet provider execution #120

bodyakov opened this issue Apr 1, 2016 · 16 comments

Comments

@bodyakov
Copy link

bodyakov commented Apr 1, 2016

During the execution puppet chocolatey provider if unavailable chocolatey repository configuration file is broken. It add some symbols to 1st line, and as result on check next packet in log will appear next error:
Could not evaluate: undefined method `each' for nil:NilClass

if execute choco list -lo in command prompt next error occur:
error deserializing response of type chocolatey.infrastructure.app.configuration.ConfigFileSettings:

Wrong choco config:
https://gist.github.com/bodyakov/65f25171cf3a2b8d1b43a213e1801f8b#file-config_bad

@ferventcoder
Copy link
Contributor

I'm guessing BOM characters. Did you place a file in before choco did?

@ferventcoder
Copy link
Contributor

What version of the puppet provider? What version of Chocolatey?

@bodyakov
Copy link
Author

bodyakov commented Apr 1, 2016

I control chocolatey.config by puppet. During execution puppet agent - error ocur, and choco not work. In the end of manifest puppet rewrite chocolatey.config to clean an ok state without "п»ї" in 1st line. And on next execution all is ok.
provider 1.2.1
chocolatey 0.9.9.11

@ferventcoder
Copy link
Contributor

Yeah, controlling the config outside of Chocolatey is not recommended. When choco sees a need to change the file it will. If you must control it, ensure your template is utf8 with the BOM (byte order mark). We are working on bringing all the config to types.

@ferventcoder
Copy link
Contributor

And every new version of choco is almost guaranteed to change the config. You need to ensure on your end you are not causing resource thrashing.

@ferventcoder
Copy link
Contributor

So it's best to run choco once to model the config changes for your template when taking on new versions.

@bodyakov
Copy link
Author

bodyakov commented Apr 1, 2016

All pc run chocolatey 0.9.9.11. I take on one valid chocolatey.config put them to puppet server. If i disable controlling chocolatey.config, chocolatey will be broken and in puppet log always will be - Could not evaluate: undefined method `each' for nil:NilClass.
If run cup all -y in command prompt after puppet deploy template config - all is ok

@ferventcoder
Copy link
Contributor

What version of Puppet? I knew I forgot to ask something.

@bodyakov
Copy link
Author

bodyakov commented Apr 1, 2016

puppet server and client - 3.8.6

@ferventcoder
Copy link
Contributor

I believe choco is smart enough not to try to change the encoding.

@bodyakov
Copy link
Author

bodyakov commented Apr 1, 2016

ensure your template is utf8 with the BOM (byte order mark).

I check config on puppet server. It is utf8 with BOM.
head -c3 chocolatey | LC_ALL=C grep -P '\xef\xbb\xbf'

Template can't be wrong because it works on many workstations. And only in some cases above error occur.

@bodyakov
Copy link
Author

bodyakov commented Apr 1, 2016

Puppet run in different env than choco. There are some problesm with ruby 1.9 and codepages in windows. BOM - 3 bytes and in my exampe there is 3 wrong symbols. I think it because puppet run choco with different codepage or something like this. And choco want to rewtite config and add BOM to 1st line, but because codepage wrong it add wrong 3 symbols.
Our windows is ru_ru localization.

@bodyakov
Copy link
Author

bodyakov commented Apr 4, 2016

My theory was wrong. The problem occur when puppet master unavaliable, and then agent use cached catalog. And when int compare current choco config and cached in catalog, it think that here different and rewrite config, but new config is bad with wrong BOM symbols.

What alternative now compare to controll choco config from puppet?

@ferventcoder
Copy link
Contributor

That last thing you mentioned is fixed in newer Puppet versions. I believe
the latest version, I remember commenting on the pull request for Puppet.
I'd check the release notes. :)

On Monday, April 4, 2016, bodyakov [email protected] wrote:

My theory was wrong. The problem occur when puppet master unavaliable, and
then agent use cached catalog. And when int compare current choco config
and cached in catalog it think that here different and rewrite config, but
new config is bad with wrong BOM symbols.


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#120 (comment)

Rob
"Be passionate in all you do"

http://codebetter.com/robreynolds
http://ferventcoder.com
https://twitter.com/ferventcoder

@bodyakov
Copy link
Author

bodyakov commented Apr 5, 2016

I believe the latest version

3.8.6 is last in 3.x branch.
in 4.x BOM is forbidden and puppet wil return error. https://docs.puppetlabs.com/puppet/4.4/reference/release_notes.html -> PUP-5819

@ferventcoder
Copy link
Contributor

Yes, BOM is forbidden if you are using source. I should adjust choco to only use BOM if necessary.

DavidS pushed a commit to DavidS/puppetlabs-chocolatey that referenced this issue Nov 15, 2019
(WIN-231) Change curl_on command to add path to cacert bundle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants