Hello,
I was looking for a clean way to specify tidy resources in my hiera
hierarchy. Basically, I wanted to be able to specify common tidy
resources, or tidy resources specific to a host without editing a module or
class each time, essentially separating the data from the logic. Here I'm
using this for tidy, but the same model could be used for other resources.
I came up with a solution using create_resources that works so I thought
I'd share.
assuming the two following yaml files.
common.yaml ###
---
tidyup:
/tmp:
age: '4w'
backup: 'false'
recurse: 'true'
myhost.yaml #
---
classes : [ 'tidyup' ]
tidyup:
/tmp/dir1:
age: '1s'
backup: 'false'
recurse: 'true'
/tmp/dir3:
age: '1s'
backup: 'false'
recurse: 'true'
I created a module named 'tidyup' that contains one class.
class tidyup {
$tidydirs = hiera_hash('tidyup', [])
create_resources('tidy',$tidydirs)
}
This class gathers up the tidyup resources defined at all levels of the
hierarchy and performs the specified tidy tasks. You can see what is
returned by running 'hiera' on the command line.
hiera -h tidyup hostname=myhost
result:
{/tmp/dir3={age=1s, backup=false, recurse=true},
/tmp/dir1={age=1s, backup=false, recurse=true},
/tmp={age=4w, backup=false, recurse=true}}
--
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 post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.