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.


Rob Nelson
[email protected]

On Wed, May 3, 2017 at 7:37 AM, mobios <[email protected]> wrote:

> 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
>
>
>
>
>
>
>
>
>
>
>
>
>
> --
> 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 [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/puppet-users/6b8f9821-2d9e-4538-a3cc-4134b83daa10%40googlegroups.com
> <https://groups.google.com/d/msgid/puppet-users/6b8f9821-2d9e-4538-a3cc-4134b83daa10%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAC76iT9mVz_BDDvKRnOb52wV_d_ZhGajuVJ8VT9FieSEZDG%2BZg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to