On 02/02/18 12:16, Ilya wrote:
Hi, how use in correct way puppet data types when you use call_function and lookup in templates, for example

puppet server version 4.9


In this way there is an error.

Yes, that will not work because 'Array' is a string and not an instance of a data type. There is a type parser that can be used to turn strings into data type instances. Strongly recommend to use EPP instead of ERB though - as that would completely remove the problem and you would simply write:

<%= lookup('somekey', Array, 'deep') %>

If you really need to stay with ERB you can call the type parser (give type as string) or the type factory, or work directly with the types.

Using the type parser is recommended and specifying the types as strings
as that is how it is done in the 4.x function API and the code is the
easiest to read.

For example (using type parser):


or example (using type factory):


In your particular case you could use an available constant for Array[Any] like this:

    ['somekey', Puppet::Pops::Types::PArrayType::DEFAULT, 'deep'])-%>

but calling the types directly is only convenient when the DEFAULT is suitable.

Hope this helps.
- henrik


Visit my Blog "Puppet on the Edge"

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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
For more options, visit https://groups.google.com/d/optout.

Reply via email to