Issue #22333 has been reported by Bill Sirinek.
----------------------------------------
Bug #22333: puppet corrupts file if non-ascii character found
https://projects.puppetlabs.com/issues/22333
* Author: Bill Sirinek
* Status: Unreviewed
* Priority: Normal
* Assignee:
* Category:
* Target version:
* Affected Puppet version:
* Keywords:
* Branch:
----------------------------------------
Puppet will wipe out the existing contents of a file if it cannot be parsed. I
have a module that ensures a host resource exists in that file. However, if the
/etc/hosts file has a non-printable character inside, the file is destroyed and
left only with the contents of the host resource.
This is easily repeatable:
1. ENTIRE CONTENTS OF /etc/inet/hosts (the "crazy character" is octal 0240)
<pre>
# Hosts file
# crazy character here "�"
192.168.100.224 lab02 lab02.intcx.net loghost
</pre>
2. A TEST MODULE WITH A SINGLE HOST RESOURCE:
<pre><code class="ruby">
class testhost {
host { 'sirinek':
ensure => 'present',
ip => '192.168.0.100'
}
}
include testhost
</code></pre>
3. APPLYING THE MODULE
<pre>
root@lab02 # puppet apply testhost.pp
Error: Puppet::Util::FileType::FileTypeFlat could not read /etc/inet/hosts:
invalid byte sequence in UTF-8
Error: Could not prefetch host provider 'parsed':
Puppet::Util::FileType::FileTypeFlat could not read /etc/inet/hosts: invalid
byte sequence in UTF-8
Notice: /Stage[main]/Testhost/Host[sirinek]/ensure: created
Notice: Finished catalog run in 0.21 seconds
</pre>
4. THE ENTIRE CONTENTS OF /etc/inet/hosts AFTER APPLYING THE RESOURCE (note the
original host entry is gone, only the newly added one exists)
<pre>
# HEADER: This file was autogenerated at 2013-08-28 19:42:06 -0400
# HEADER: by puppet. While it can still be managed manually, it
# HEADER: is definitely not recommended.
192.168.0.100 sirinek
</pre>
This is puppet 3.1.1 on Solaris 10 and ruby 1.9.3p125
--
You have received this notification because you have either subscribed to it,
or are involved in it.
To change your notification preferences, please click here:
http://projects.puppetlabs.com/my/account
--
You received this message because you are subscribed to the Google Groups
"Puppet Bugs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/groups/opt_out.