convert hiera value to string array using lookup in hiera

338 views
Skip to first unread message

Tidhar Klein Orbach

unread,
Nov 13, 2023, 12:44:14 PM11/13/23
to 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

Martin Alfke

unread,
Nov 14, 2023, 2:35:10 AM11/14/23
to puppet...@googlegroups.com
Hi,

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

--
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...@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.

Tidhar Klein Orbach

unread,
Nov 15, 2023, 1:50:59 AM11/15/23
to puppet...@googlegroups.com
Thank you Martin, it's exactly what I was looking for.

Tidhar


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...@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.
Reply all
Reply to author
Forward
0 new messages