You are passing a hash as the resource title, a resource title is
either a string or array of string.
> Here's the define ...
>
> define backuppc::sqldump () {
>
> file {
> "$name[dump_dir]":
> ensure => directory,
> owner => 'root',
> group => 'root',
> mode => '0770',
> }
> }
>
> Is this something that's even possible? The error I get doesn't make
> any sense to me...
Not in the current form, what you are looking for is probably best
described here:
http://projects.puppetlabs.com/issues/8670
However a small change should allow this to work. (disclaimer,
untested, but I've done something similar).
define backuppc::sqldump ($var) {
$value = $var[$name]
file {
"$value[dump_dir]":
ensure => directory,
owner => 'root',
group => 'root',
mode => '0770',
}
}
backuppc::sqldump { ['redmine', 'general']:
var =>$backuppc_db_dumps,
}
If you have a functions that gets an array of the first level hash
keys, you can use that instead of specifying redmine, general.
HTH,
Nan
Pretty sure you can be backport to 2.6 since it's just a function:
https://github.com/puppetlabs/puppetlabs-create_resources
> I tried you suggestion, but get this error...
>
> err: Could not retrieve catalog from remote server: Error 400 on
> SERVER: Invalid tag "dump_dir/backups/redmine-
> sqldumpsdatabasesredminebackup_dir/var/www/rails/redmine" at /etc/
> puppet/modules/backuppc/manifests/definitions/sqldump.pp:11 on
> node ...
Can't say for sure without more code, but this simple example should
demonstrate how this works:
$myhash = {
var1 => {
message => 'hi'
},
var2 => {
message => 'bye'
}
}
define my_notify ($var) {
notify { $name:
message => $var[$name]['message']
}
}
my_notify { ['var1', 'var2']:
var => $myhash
}
> Also I am not sure what you mean by "functions that get an array of
> first level hash keys".
I mean if you need this to work with any hash without manually
providing an array of resource titles write a custom puppet function
that returns hash keys as a custom puppet function.
Thanks,
Nan