Description
Affected Puppet, Ruby, OS and module versions/distributions
- Puppet: 5.5.21
- Ruby:
- Distribution: Ubuntu Xenial
- Module version: 2.0.0
How to reproduce (e.g Puppet code you use)
The problem is triggered when installing plugins, for which the manifest contains UTF-8 sequences. This is the case, for example, when jenkins::plugins_hash contains the ws-cleanup plugin in version 0.38.
The problem can then be reproduced in two ways:
- Invoking puppet agent with a non utf8 locale, like C.
- Invoking facter without any modifications to the locale configuration.
LANG=C puppet agent -t
When invoking facter directly, the problem seems to be independent from the locale, so just running
facter -p jenkins_plugins
should be enough to reproduce it.
What are you seeing
When running puppet it will try to install some plugins again and again. In the facter output the plugins will be missing.
What behaviour did you expect instead
I would expect the plugin to install modules only once and the jenkins_plugins fact to return all facts.
Any additional information you'd like to impart
We are running puppet as part of bootstrapping machines via cloud-init. In this constellation puppet runs with a very minimal environment and in this case this means that no LANG variable is set.
The problem can be traced down to the code that reads the manifest file (https://github.com/voxpupuli/puppet-jenkins/blob/master/lib/puppet/jenkins/plugins.rb#L57). In files that contain UTF-8 sequences this would trigger an exception which leads to the plugin being excluded from the output.
A possible fix is to to change the File.read invocation like this:
File.read(manifest, :encoding => 'UTF-8')