|
This issue isn't specific to Windows and occurs on Linux as well. Basically, what is happening is that when the puppet agent loads a cached catalog from disk, it assigns a string encoding equal to whatever locale Ruby's Encoding.default_external is set to. This usually isn't noticeable on Linux because the server and agents are likely using the same locale and both likely using UTF-8. Windows agents are likely to be using a different locale than a Linux master. For example, my 2012 R2 box lists "IBM 437" as the default encoding:
C:\ProgramData\PuppetLabs\puppet\etc>cd "C:\Program Files\Puppet Labs\Puppet\sys\ruby\bin"
|
|
C:\Program Files\Puppet Labs\Puppet\sys\ruby\bin>ruby -e 'puts Encoding.default_external'
|
IBM437
|
IBM 437 is backwards-compatible with ASCII but not UTF-8. Therefore any UTF-8 content produced by the master will be garbled if rendered as IBM 437.
Re-production Case
Add the following file resource to site.pp:
$test_path = $::osfamily ? {
|
'Windows' => 'C:/tmp/utf_test',
|
default => '/tmp/utf_test',
|
}
|
|
file { $test_path:
|
content => @(UTF8)
|
Mønti Pythøn ik den Hølie Gräilen
|
Røtern nik Akten Di
|
Wik
|
Alsø wik
|
Alsø alsø wik
|
Wi nøt trei a høliday in Sweden this yër?
|
See the løveli lakes
|
The wøndërful telephøne system
|
And mäni interesting furry animals
|
Including the majestik møøse
|
A Møøse once bit my sister...
|
No realli! She was Karving her initials on the møøse with the sharpened end of an interspace tøøthbrush given her by Svenge - her brother-in-law - an Oslo dentist and star of many Norwegian møvies: "The Høt Hands of an Oslo Dentist", "Fillings of Passion", "The Huge Mølars of Horst Nordfink"...
|
|
We apologise for the fault in the subtitles. Those responsible have been sacked.
|
| UTF8
|
}
|
Run puppet agent -t. The correct contents should appear in /tmp/test.
Run puppet agent -t --use_cached_catalog on Windows. On Linux, shift the agent into a ISO-8859-1 (or other non-UTF locale from locale -a) by running LC_ALL=en_GB.iso88591 puppet agent -t --use_cached_catalog. The contents of /tmp/test will be replaced with corrupted text.
|