FAQ
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+unsubscribe@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.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedOct 11, '13 at 7:28p
activeOct 11, '13 at 7:28p
posts1
users1
websitepuppetlabs.com

1 user in discussion

Derek Dresser: 1 post

People

Translate

site design / logo © 2021 Grokbase