14

Let's say I have a module with files/etc/foo/{conf0, conf1, conf2, conf3, etc}. It's simple enough to place each of these files when the number of them is small:

file { 'conf0':
    path => '/etc/foo/conf0',
    ensure => true,
    source => 'puppet:///.../etc/foo/conf0',
}

and repeat. But there's a fair bit of duplication involved, and it's tedious to maintain if there are several configuration files. I would like to ensure that files/etc/foo/ is mirrored onto a given path. That is to say,

file { 'etc foo confs':
   path => '/etc/foo',
   ensure => recursive,
   source => 'puppet:///.../etc/foo',
}

would create /etc/foo/conf0, /etc/foo/conf1 and so on. Is this possible?

22

Sure - the files type has a recurse option (and recurselimit if you want to limit how deep into the directory it goes).

file { 'etc foo confs':
   path => '/etc/foo',
   source => 'puppet:///.../etc/foo',
   recurse => true,
}
  • 5
    The other thing to keep in mind if doing this is the number of files that Puppet is going to have to maintain connections for. It would not take long to run out of file descriptors and puppet start running into trouble. I've ran into this problem before trying to do this very task. – Jeremy Bouse Oct 20 '11 at 1:13
  • @JeremyBouse Thank you; that's very useful information. – troutwine Oct 20 '11 at 1:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.