Hello,

I'm programming my own custom type. It is at https://github.com/amateo/puppet-omd/blob/feature/TLM-4087/lib/puppet/type/thruk_bp.rb and is mainly copied from concat provided in puppetlabs/concat.

My problem with this type is that it creates a file from a json and some parameters must support UTF-8 characters. With the implementation I have, if I use UTF-8 in some field, I get an error in the call JSON.pretty_generate(json):

Error: /Stage[main]/Main/Thruk_bp[atica/Autenticación de usuarios]: Failed to generate additional resources using 'eval_generate': "\xC3" from ASCII-8BIT to UTF-8

So I have forced all my params to be coded in UTF-8 using a force_encoding call. What I do is to inherit from NagiosParam in all parameters definition, where NagiosParam is:

 class NagiosParam < Puppet::Property
    class << self
      attr_accessor :boundaries, :default
    end

    def should
      if @should and @should[0] == :absent
        :absent
      else
        @should.join(',')
      end
    end

    munge do |value|
      if value == 'absent' or value == :absent
        return :absent
      elsif value == ''
        return :absent
      else
        if value.respond_to?('force_encoding') then
          value.force_encoding('ASCII-8BIT')
        end
        return super(value)
      end
    end
end

In this case, all resources are created without any problem, but I get the error

Error: Could not create resource file /opt/puppetlabs/puppet/cache/state/resources.txt: incompatible character encodings: ASCII-8BIT and UTF-8

        in every agent run.

        What is the correct way to handle with different language encodings?

--
Angel L. Mateo Martínez
Sección de Telemática
Área de Tecnologías de la Información
y las Comunicaciones Aplicadas (ATICA)
http://www.um.es/atica
Tfo: 868889150
Fax: 868888337

--
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/430368b8-a9c9-0bf1-efd6-5f0b8ed0716a%40um.es.
For more options, visit https://groups.google.com/d/optout.

Reply via email to