In Puppet 3.x you have to use the Define Wrapper "trick". It's not pretty, but without lambda functions it's all that you've got. If it's 4.x, see Henrik's post before.
$input_base => { input1 => { 'port' => '2001', 'component' => 'component1' }, input2 => { 'port' => '2002', 'component' => 'component2' } } $input_node => { input3 => { 'port' => '2003', 'component' => 'component3' }, [possibly input4... inputN] } $input_merged = merge($input_base, $input_node) file { 'input_merged_file': content => template("template_that_uses_input_merged") } #Uses $port and $component params in individual File resources define input_node_wrapper ($port, $component) { file { "a_file_for_input_node_${name}": path => 'somewhere', content => 'some_other_template', } } create_resources('input_node_wrapper', $input_merged) -- Luke Bigum Senior Systems Engineer Information Systems ----- Original Message ----- From: "Robert Poulson" <robpo...@gmail.com> To: "puppet-users" <puppet-users@googlegroups.com> Sent: Sunday, 5 June, 2016 18:56:48 Subject: [Puppet Users] merge hashes and create_resources Dear List, I've been using Puppet for over a year now and I'm quite enjoying it. I've learned some stuff but there is of course always room for improvement. Now I have a task which needs a nicer solution than I'm currently capable of. I have a hash of items with to key/value pairs, which is *the same for every node*: $input_base => { input1 => { 'port' => '2001', 'component' => 'component1' }, input2 => { 'port' => '2002', 'component' => 'component2' } } Then I have a second hash, which is different for every node. $input_node => { input3 => { 'port' => '2003', 'component' => 'component3' }, [possibly input4... inputN] } These all will be used in a single template. So I can simply do: $input_merged = merge($input_base, $input_node) The corresponding port/component entries will then be added in a configuration file with an $input_merged.each_pair - so far so good. Now the actual task: I need an extra configfile, generated from a template, for all the inputN elements of the $input_node - but only for them, not for the $input_base elements - like this: * /path/to/project_input3.conf * [/path/to/project_input4.conf...project_inputN.conf] This would be possible with create_resources: create_resources(file, $input_merged) but in order to do this, $input_merged should have the values of a file resource - at least "path" and "source => template()". This is not the case. I could define $input_node initially as a file resource hash - but in this case I can't merge it anymore with $input_base. Currently I have no other idea than manually map the input_node elements into a third hash, and use that with create_resources, but there should be a nicer solution. Do you have an idea? :-) Best, Rp -- 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/CANwwCtzSGFSUaJsraux2sAifauq%3D9%2BHuZT-kt6jpUBJWnvVZ%3DQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout. --- LMAX Exchange, Yellow Building, 1A Nicholas Road, London W11 4AN http://www.LMAX.com/ Recognised by the most prestigious business and technology awards 2016 Best Trading & Execution, HFM US Technology Awards 2016, 2015, 2014, 2013 Best FX Trading Venue - ECN/MTF, WSL Institutional Trading Awards 2015 Winner, Deloitte UK Technology Fast 50 2015, 2014, 2013, One of the UK's fastest growing technology firms, The Sunday Times Tech Track 100 2015 Winner, Deloitte EMEA Technology Fast 500 2015, 2014, 2013 Best Margin Sector Platform, Profit & Loss Readers' Choice Awards --- FX and CFDs are leveraged products that can result in losses exceeding your deposit. They are not suitable for everyone so please ensure you fully understand the risks involved. This message and its attachments are confidential, may not be disclosed or used by any person other than the addressee and are intended only for the named recipient(s). This message is not intended for any recipient(s) who based on their nationality, place of business, domicile or for any other reason, is/are subject to local laws or regulations which prohibit the provision of such products and services. This message is subject to the following terms (http://lmax.com/pdf/general-disclaimers.pdf), if you cannot access these, please notify us by replying to this email and we will send you the terms. If you are not the intended recipient, please notify the sender immediately and delete any copies of this message. LMAX Exchange is the trading name of LMAX Limited. LMAX Limited operates a multilateral trading facility. LMAX Limited is authorised and regulated by the Financial Conduct Authority (firm registration number 509778) and is a company registered in England and Wales (number 6505809). LMAX Hong Kong Limited is a wholly-owned subsidiary of LMAX Limited. LMAX Hong Kong is licensed by the Securities and Futures Commission in Hong Kong to conduct Type 3 (leveraged foreign exchange trading) regulated activity with CE Number BDV088. -- 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/754207562.4617421.1465201278090.JavaMail.zimbra%40lmax.com. For more options, visit https://groups.google.com/d/optout.