Re: [Puppet Users] convert hiera value to string array using lookup in hiera

2023-11-14 Thread 'Tidhar Klein Orbach' via Puppet Users
Thank you Martin, it's exactly what I was looking for.

Tidhar


On Tue, Nov 14, 2023 at 9:35 AM Martin Alfke  wrote:

> Hi,
>
> Lookup always returns strings.
> You can use alias to retrieve the original value data type.
>
> https://www.puppet.com/docs/puppet/7/hiera_merging.html#alias-function
>
>
> Hth,
> Martin
>
> On 13. Nov 2023, at 17:35, 'Tidhar Klein Orbach' via Puppet Users <
> puppet-users@googlegroups.com> wrote:
>
> Hi,
>
> I have a hiera file that belongs to a server group. in that file there is
> a key that expects a list of services.
> for example
>
> job_name: "my-job"
> feature:
>   services:
> - 'foo'
> - 'bar'
> - 'baz'
>
> I want to be able to override the values, so I tried to define a default
> key like:
> feature::services:: 'foo,bar,baz'
>
> and then use it:
> job_name: "my-job"
> feature:
>services: "%{lookup(feature::services)}"
>
> I tried different value variations:
> feature::services:: foo,bar,baz
> feature::services:: ['foo','bar','baz']
> and  also using
> lookup_options:
> feature::services:
> convert_to:
> - "Array"
> - true
>
> but it seems I can't convert the value to string array.
>
> is it possible at all? if so, how can I do it?
>
> thanks,
> Tidhar
>
>
> --
> 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
> https://groups.google.com/d/msgid/puppet-users/d57c9444-8b38-4394-a03b-8442c42a3662n%40googlegroups.com
> 
> .
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Puppet Users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/puppet-users/xOUOK2JJpGQ/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> puppet-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/430CE6A5-3999-4F2D-B302-6FA7E7C3D081%40gmail.com
> 
> .
>

-- 
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 
https://groups.google.com/d/msgid/puppet-users/CAB%2BDr5GYupgenrhRSxR-mdxTzcLEBU1Y%3Dq_LxJbBzavQy5cnyw%40mail.gmail.com.


Re: [Puppet Users] convert hiera value to string array using lookup in hiera

2023-11-13 Thread Martin Alfke
Hi,

Lookup always returns strings.
You can use alias to retrieve the original value data type.

https://www.puppet.com/docs/puppet/7/hiera_merging.html#alias-function


Hth,
Martin

> On 13. Nov 2023, at 17:35, 'Tidhar Klein Orbach' via Puppet Users 
>  wrote:
> 
> Hi,
> 
> I have a hiera file that belongs to a server group. in that file there is a 
> key that expects a list of services.
> for example
> 
> job_name: "my-job"
> feature:
>   services:
> - 'foo'
> - 'bar'
> - 'baz'
> 
> I want to be able to override the values, so I tried to define a default key 
> like:
> feature::services:: 'foo,bar,baz'
> 
> and then use it:
> job_name: "my-job"
> feature:
>services: "%{lookup(feature::services)}"
> 
> I tried different value variations:
> feature::services:: foo,bar,baz 
> feature::services:: ['foo','bar','baz']  
> and  also using
> lookup_options:
>   feature::services:
> convert_to:
>   - "Array"
>   - true
> 
> but it seems I can't convert the value to string array.
> 
> is it possible at all? if so, how can I do it?
> 
> thanks,
> Tidhar
> 
> 
> -- 
> 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 
> https://groups.google.com/d/msgid/puppet-users/d57c9444-8b38-4394-a03b-8442c42a3662n%40googlegroups.com
>  
> .

-- 
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 
https://groups.google.com/d/msgid/puppet-users/430CE6A5-3999-4F2D-B302-6FA7E7C3D081%40gmail.com.


[Puppet Users] convert hiera value to string array using lookup in hiera

2023-11-13 Thread 'Tidhar Klein Orbach' via Puppet Users
Hi,

I have a hiera file that belongs to a server group. in that file there is a 
key that expects a list of services.
for example

job_name: "my-job"
feature:
  services:
- 'foo'
- 'bar'
- 'baz'

I want to be able to override the values, so I tried to define a default 
key like:
feature::services:: 'foo,bar,baz'

and then use it:
job_name: "my-job"
feature:
   services: "%{lookup(feature::services)}"

I tried different value variations:
feature::services:: foo,bar,baz 
feature::services:: ['foo','bar','baz']  
and  also using
lookup_options:
feature::services:
convert_to:
- "Array"
- true

but it seems I can't convert the value to string array.

is it possible at all? if so, how can I do it?

thanks,
Tidhar

-- 
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 
https://groups.google.com/d/msgid/puppet-users/d57c9444-8b38-4394-a03b-8442c42a3662n%40googlegroups.com.