Distributing directory trees
Puppet's file
resource has another trick. It can deploy not just a single file, but a whole directory; in fact, a whole tree of files, directories, subdirectories, and so on, all with just one parameter, recurse
.
How to do it…
Here's how to use the recurse
parameter with file
resources:
Create a suitable directory tree in the Puppet repo:
ubuntu@cookbook:~/puppet$ mkdir -p modules/admin/files/tree/a/b/c/d/e/f
Modify your
manifests/nodes.pp
file as follows:node 'cookbook' { file { '/tmp/tree': source => 'puppet:///modules/admin/tree', recurse => true, } }
Run Puppet:
ubuntu@cookbook:~/puppet$ papply Notice: /Stage[main]//Node[cookbook]/File[/tmp/tree]/ensure: created Notice: /File[/tmp/tree/a]/ensure: created Notice: /File[/tmp/tree/a/b]/ensure: created Notice: /File[/tmp/tree/a/b/c]/ensure: created Notice: /File[/tmp/tree/a/b/c/d]/ensure: created Notice: /File[/tmp/tree/a/b/c/d/e]/ensure: created Notice: /File[/tmp/tree/a/b/c/d/e/f]/ensure: created...