How to cope with accented characters in DisplayName using Puppet 3.8.x on Windows XP?

73 views
Skip to first unread message

Tiago Delboni

unread,
Jan 8, 2016, 8:25:41 AM1/8/16
to Puppet Users
Hi!

On Windows 7 we have Puppet 4.2.x and, in order to deal with accented characters commonly found in registry key DisplayName, we use unicode escape sequences in our manifests such as "\u00FA".

However, on Windows XP,  we couldn't install Puppet 4.2.x so we use 3.8.x instead. When running the same manifest with escape sequences, Puppet complains: "Unrecognised escape sequence '\u' in file ...".

Puppet 3.8.x documentation states that it "treats strings as sequences of bytes. It does not recognize encodings or translate between them, and non-printing characters are preserved."

So, how can I deal with software that have accented characters in their DisplayName? Assuming that registry's encoding is the same on WXP and W7, I could probably make it work by using Puppet 4.2.x on Windows XP, but I just don't know how to install it successfully.

Henrik Lindberg

unread,
Jan 8, 2016, 10:38:25 AM1/8/16
to puppet...@googlegroups.com
On 2016-08-01 14:23, Tiago Delboni wrote:
> Hi!
>
> On Windows 7 we have Puppet 4.2.x and, in order to deal with accented
> characters commonly found in registry key DisplayName, we use unicode
> escape sequences in our manifests such as "\u00FA".
>
> However, on Windows XP, we couldn't install Puppet 4.2.x so we use
> 3.8.x instead. When running the same manifest with escape sequences,
> Puppet complains: "Unrecognised escape sequence '\u' in file ...".
>
Have you tried using 3.8.x with parser=future turned on? That would give
you support for \u the same way as in puppet 4.x.

> Puppet 3.8.x documentation states that it "treats strings as sequences
> of bytes. It does not recognize encodings or translate between them, and
> non-printing characters are preserved."
>
Yes, when you get the waring for \u, it means there will be a literal
backslash and a literal u in the resulting string. (That is with the
regular parser since it (as it says) does not support the \u escape for
unicode chars).

> So, how can I deal with software that have accented characters in their
> DisplayName? Assuming that registry's encoding is the same on WXP and
> W7, I could probably make it work by using Puppet 4.2.x on Windows XP,
> but I just don't know how to install it successfully.
>

Use puppet 3.8.x (latest) as noted above. The other approach (ugly, and
horrible work around) is to simply copy/paste the actual character into
the source file, but that is not guaranteed to work for all characters.

Hope that helps
- henrik

> --
> You received this message because you are subscribed to the Google
> Groups "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to puppet-users...@googlegroups.com
> <mailto:puppet-users...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/12713369-5970-4a43-804a-ca57a400afd0%40googlegroups.com
> <https://groups.google.com/d/msgid/puppet-users/12713369-5970-4a43-804a-ca57a400afd0%40googlegroups..com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.


--

Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/

Tiago Delboni

unread,
Jan 8, 2016, 11:20:27 AM1/8/16
to Puppet Users
With parser=future it doesn't complain about the escape sequence, but keeps creating the package every run. :(

Copying the accented character to the manifest does not work (tried many ways).

Josh Cooper

unread,
Jan 8, 2016, 12:24:27 PM1/8/16
to puppet...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/6084ba68-3ac0-458a-ab7c-292d11663e6b%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Puppet 3.8.x ships with ruby 1.9.3 (32-bit) and 2.0.0 (64-bit), both of which use ANSI versions of Win32 registry APIs (and not the wide/unicode versions). Puppet uses those methods to scan the registry looking for installed applications, and is likely the cause for the problem you're seeing. See https://tickets.puppetlabs.com/browse/PUP-2937?focusedCommentId=87973&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-87973 for more information.

Puppet 4.x ships with ruby 2.1.x, which switched to using wide versions of the registry APIs, so I think that's why it's working in that case.

Josh

--
Josh Cooper
Developer, Puppet Labs

Tiago Delboni

unread,
Jan 11, 2016, 6:30:46 AM1/11/16
to Puppet Users
Hi Josh, thanks for the enlightenment!
Any chances I can easily upgrade 3.8.x 's Ruby to fix this issue without breaking current manifests and behaviour?

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/6084ba68-3ac0-458a-ab7c-292d11663e6b%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Puppet 3.8.x ships with ruby 1.9.3 (32-bit) and 2.0.0 (64-bit), both of which use ANSI versions of Win32 registry APIs (and not the wide/unicode versions). Puppet uses those methods to scan the registry looking for installed applications, and is likely the cause for the problem you're seeing. See https://tickets.puppetlabs.com/browse/PUP-2937?focusedCommentId=87973&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-87973 for more information.

Tiago Delboni

unread,
Jan 11, 2016, 11:28:11 AM1/11/16
to Puppet Users
I was able to build Ruby 2.1.7 on XP using mingw32, along with the gems listed in %ProgramFiles%\Puppet Labs\Puppet\sys\ruby\lib\ruby\gems\1.9.0\gems
However, as I am illiterate on Ruby, I'm not sure I dealt properly with the dependencies. Simply replacing %ProgramFiles%\Puppet Labs\Puppet\sys\ruby with the new built does not work:

C:\>puppet --version
C:/Arquivos de programas/Puppet Labs/Puppet/sys/ruby/lib/ruby/gems/2.1.0/gems/win32-security-0.3.2/lib/win32/security.rb:61:in `block in elevated_security?': ParÔmetro incorreto. - GetTokenInformation (SystemCallError)
        from C:/Arquivos de programas/Puppet Labs/Puppet/sys/ruby/lib/ruby/gems/2.1.0/gems/win32-security-0.3.2/lib/win32/security.rb:41:in `initialize'
        from C:/Arquivos de programas/Puppet Labs/Puppet/sys/ruby/lib/ruby/gems/2.1.0/gems/win32-security-0.3.2/lib/win32/security.rb:41:in `new'
        from C:/Arquivos de programas/Puppet Labs/Puppet/sys/ruby/lib/ruby/gems/2.1.0/gems/win32-security-0.3.2/lib/win32/security.rb:41:in `elevated_security?'
        from C:/Arquivos de programas/Puppet Labs/Puppet/facter/lib/facter/util/windows_root.rb:5:in `root?'
        from C:/Arquivos de programas/Puppet Labs/Puppet/facter/lib/facter/util/config.rb:41:in `setup_default_ext_facts_dirs'
        from C:/Arquivos de programas/Puppet Labs/Puppet/facter/lib/facter/util/config.rb:69:in `<module:Config>'
        from C:/Arquivos de programas/Puppet Labs/Puppet/facter/lib/facter/util/config.rb:5:in `<top (required)>'
        from C:/Arquivos de programas/Puppet Labs/Puppet/sys/ruby/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from C:/Arquivos de programas/Puppet Labs/Puppet/sys/ruby/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from C:/Arquivos de programas/Puppet Labs/Puppet/facter/lib/facter/util/resolution.rb:2:in `<top (required)>'
        from C:/Arquivos de programas/Puppet Labs/Puppet/sys/ruby/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from C:/Arquivos de programas/Puppet Labs/Puppet/sys/ruby/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from C:/Arquivos de programas/Puppet Labs/Puppet/facter/lib/facter/util/fact.rb:2:in `<top (required)>'
        from C:/Arquivos de programas/Puppet Labs/Puppet/sys/ruby/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from C:/Arquivos de programas/Puppet Labs/Puppet/sys/ruby/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from C:/Arquivos de programas/Puppet Labs/Puppet/facter/lib/facter.rb:35:in `<module:Facter>'
        from C:/Arquivos de programas/Puppet Labs/Puppet/facter/lib/facter.rb:30:in `<top (required)>'
        from C:/Arquivos de programas/Puppet Labs/Puppet/sys/ruby/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from C:/Arquivos de programas/Puppet Labs/Puppet/sys/ruby/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from C:/Arquivos de programas/Puppet Labs/Puppet/puppet/lib/puppet.rb:6:in `<top (required)>'
        from C:/Arquivos de programas/Puppet Labs/Puppet/sys/ruby/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from C:/Arquivos de programas/Puppet Labs/Puppet/sys/ruby/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from C:/Arquivos de programas/Puppet Labs/Puppet/puppet/lib/puppet/util/command_line.rb:12:in `<top (required)>'
        from C:/Arquivos de programas/Puppet Labs/Puppet/sys/ruby/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from C:/Arquivos de programas/Puppet Labs/Puppet/sys/ruby/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from C:/Arquivos de programas/Puppet Labs/Puppet/puppet/bin/puppet:7:in `<main>'

Tiago Delboni

unread,
Jan 12, 2016, 11:13:14 AM1/12/16
to Puppet Users
UPDATE:

We were able to build Ruby 2.1.7 on XP and run Puppet successfully with it.

However, we observed the same behaviour regarding accented characters in DisplayName: Puppet 3.8.4, even with Ruby 2.1.7, keeps installing the package on every run. :(

Josh Cooper

unread,
Jan 21, 2016, 2:47:57 AM1/21/16
to puppet...@googlegroups.com
On Tue, Jan 12, 2016 at 8:13 AM, Tiago Delboni <del...@gmail.com> wrote:
UPDATE:

We were able to build Ruby 2.1.7 on XP and run Puppet successfully with it.
"
However, we observed the same behaviour regarding accented characters in DisplayName: Puppet 3.8.4, even with Ruby 2.1.7, keeps installing the package on every run. :(



One thing to check is whether `puppet resource package` reports the same name and version as what you're specifying in your manifest? If the name or version don't match exactly, then puppet will think the package is not installed, and will try to (re)install each time.

The next thing I'd try is to programmatically call puppet to get a package listing. Run the "Start Command Prompt for Puppet" (as an administrator on UAC systems), and execute the following:

C:\Windows\system32>irb
irb(main):001:0> require 'puppet'
=> true
irb(main):002:0> require 'puppet/type/package'
=> true
irb(main):003:0> require 'pp'
=> true
irb(main):004:0> pp Puppet::Type::Package::ProviderWindows.instances.map {|provider| "#{provider.package.name}, #{provider.package.version}" }
["doxygen 1.8.8, 1.8.8",
 "Microsoft Visual J# 2.0 Redistributable Package - SE (x64), ",
 "Microsoft Windows SDK for Windows 7 (7.0), 7.0.7600.16385.40715",
 "Windows Azure Emulator - v2.2  \u2013  \u2013  \u2013, 2.2.6492.2",
 "NSClient++ (x64), 0.3.9.328",
  ...
]

More than likely you are running into yet another ruby registry bug that we worked around in https://tickets.puppetlabs.com/browse/PUP-3837, The particular issue is that calling Win32::Registry#each_key does not correctly handle unicode. See https://tickets.puppetlabs.com/browse/PUP-3837?focusedCommentId=131991&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-131991 for more details.
 

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/6084ba68-3ac0-458a-ab7c-292d11663e6b%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Puppet 3.8.x ships with ruby 1.9.3 (32-bit) and 2.0.0 (64-bit), both of which use ANSI versions of Win32 registry APIs (and not the wide/unicode versions). Puppet uses those methods to scan the registry looking for installed applications, and is likely the cause for the problem you're seeing. See https://tickets.puppetlabs.com/browse/PUP-2937?focusedCommentId=87973&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-87973 for more information.

Puppet 4.x ships with ruby 2.1.x, which switched to using wide versions of the registry APIs, so I think that's why it's working in that case.

Josh

--
Josh Cooper
Developer, Puppet Labs

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Reply all
Reply to author
Forward
0 new messages