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
server_control_port : '8001'
tomcatAuthentication : 'false'
path : '/var/lib/tomcats/instaA/webapps/sample.war'
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.
The workaround I'm implementing is a define that does not create resources with create_resources:
define my_tomcat::instances (
#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")
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