Puppet facter utf-8 error

246 views
Skip to first unread message

mobios

unread,
May 3, 2017, 8:08:24 AM5/3/17
to Puppet Users
Hello Puppet User,


Infos:
Puppet-client-version = 3.8.4
facter= 2.4.4

Puppetserver = 4.10.0


I wrote a fact to discover all firewallrules on a windows machine.
Factname is windows_firewallrules.rb and returnvalue is a nested hash.


if i execute following command.

facter -p windows_firewallrules

I can see all firewallrules correctly. But if i execute

puppet agent -tdv


I get a  error and the puppetrun stops.

Errormessage:
invalid byte sequence in UTF-8 


I found out the issue is caused from my windows_firewallrules fact.
I have already set the encoding fix to UTF-8.


for example:

name.encode!('UTF-8', :invalid => :replace)
key
.encode!('UTF-8', :invalid => :replace)
value
.encode!('UTF-8', :invalid => :replace)

windows_firewallrules
[name][key] = value




Strangely if i iterate through my nested hash (windows_firewallrules) i cant see anythink wrong.


for example:
windows_firewallrules.each do |k1, v1|
 
if k1.encoding.to_s != 'UTF-8'
    puts k1
.encoding
 
end

  v1
.each do |k2, v2|    
 
if k2.encoding.to_s != 'UTF-8'
    puts k2
.encoding
 
end

 
if v2.encoding.to_s != 'UTF-8'
    puts v2
.encoding
 
end
 
end
end



Has anyone a idea ?

Best regards
mobios






 






Rob Nelson

unread,
May 3, 2017, 9:00:05 AM5/3/17
to puppet...@googlegroups.com
Is there a chance the encoding on the file containing the custom fact itself is not UTF8? It won't matter if the output is UTF-8 if Puppet can't parse it to apply the code inside it. `file <filename>` usually starts with `ASCII` or `UTF-8 Unicode` if it's in the proper format.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/6b8f9821-2d9e-4538-a3cc-4134b83daa10%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

mobios

unread,
May 3, 2017, 9:27:48 AM5/3/17
to Puppet Users
  Thank for your reply Rob

I checked on the the puppetserver the file encoding
  
file windows_firewallrules.rb

   and the encoding was ASCII text.

 It seems the encoding is in right format :(
   
Reply all
Reply to author
Forward
0 new messages