Hi Helmut,
you could take this as a starting point (untested):

$profile_logging = $profiles.map | $p_name, $p_data | { $p_data.map |
$s_name, $s_data | { $s_data['syslog'] } }.flatten

p_ is the outer profile layer, s_ is the inner service layer.

Some notes on solving this kind of problems:
1) It can be much easier to develop these functions in a small minimal pp
file which only contains a sample dict as puppet code, the extraction code
and a notify to print the output. With such a file, you can test small
changes in the code without going through the puppet master.
2) Sometimes it can be easier to re-design the data structure than to write
complex extraction code. It is possible to describe complex setups in a
single yaml dict, but it may not be the best idea.
3) If you may have requirements like this repeatedly, I would recommend
dedicating some time into understanding the relevant puppet functions (map,
filter, then, group_by, ...). For someone who has not yet worked with
functional languages, this is quiete a change in mind that will take some
time to grasp and process.

Best regards
Karsten

-- 
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/CAL017hCZhrasXgnrTn6aFPQ68P8GvW3mQzZB5-WFOVX3qWnbDQ%40mail.gmail.com.

Reply via email to