Hi all, I'm running hiera 1.3.1 and puppet 3.8.6.
I'd like to create resources based on some custom data structure. I'd like to group all data related to a tomcat instance in the same hash key in hiera: cert/hostname.yaml tomcatinst: instA: instance: server_control_port : '8001' http_port : '8011' ajp_port : '8111' ajp_params : tomcatAuthentication : 'false' manage_firewall : true warfile: path : '/var/lib/tomcats/instaA/webapps/sample.war' owner : tomcat group : root source : '/custom/sample.war' *InstA *is the common key for the tomcat instance plus its warfile. *(Instance is a ::tomcat::instance resource and warfile is a file resource).* There is a main class that creates the tomcat instance + the warfile using a custom define (my_tomcat::instances):: *my_tomcat/init.pp* create_resources ('my_tomcat::instances', hiera_hash(tomcatinst)) ** I need this define cause I'll be creating more than one insatnce per host.* The define where I called create_resource for the above resources (and here is where I have all the problems): *my_tomcat/instance.pp* define my_tomcat::instance ( $instance ='', $war = '', ) { $instance_hash={$name => $instance } create_resource('::tomcat::instance', "$instance_hash") $war_hash={$name => $war } create_resource('file', "$war_hash") Inside the define I don't have a hash that I can directly use in the creat_resource calls (such hash would make everything simple), $name is the key of the hash, and $name['insatnce'] and $name['warfile'] are the actual hashes that I must use for each resource. So, acording to my understanding, I must pass the hash { $name => $instance } and { $name => $war } to the create_resource function. but it fails to create the resources. AFAIU it fails cause in puppet 3 the creation of hashes with variables as keys is not working <https://tickets.puppetlabs.com/browse/PUP-2523> ( I tried to use static values as keys and my code works). But it could be that I'm misunderstanding the whole thing :-) . The workaround I'm implementing is a define that does not create resources with create_resources: define my_tomcat::instances ( $instance = '', $war = '', $extra = '', ) { #create_resources('::tomcat::instance', "{$name => $instance}", $defaults) tomcat::instance { "$name" : server_control_port => $instance['server_control_port'], http_port => $instance['http_port'], ajp_port => $instance['ajp_port'], ajp_params => $instance['ajp_params'], manage_firewall => $instance['manage_firewall'], } #$mywars = hiera("my_tomcat::instances::$name::wars") file { "$name" : path => $war['path'], owner => $war['owner'], group => $war['group'], source => $war['source'], } which works as expected. But I'm wondering if if there is way to use the create_resource function directy with the above HoH. TIA, Arnau -- 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/CAM69jx8gU1yFF%3DWMn60EoYcS99D5dru%3DMU7oGLQqKecdJXoHkQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.