How do I recursively mirror a directory and its contents with puppet?

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?


Solution 1:

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,
}