Distributing directory trees

"To understand recursion, you must first understand recursion." — Saying

When you find yourself deploying several files with Puppet, all to the same directory, it might be worth considering a recursive file resource instead. If you set the recurse parameter on a directory, Puppet will copy the directory to the node along with its contents and all its subdirectories, shown as follows:

file { "/usr/lib/nagios/plugins/custom":
    source => "puppet:///modules/nagios/plugins",
    require => Package["nagios-plugins"],
    recurse => true,
     }

How to do it…

  1. Create a suitable directory tree in the Puppet repository as follows:
    # mkdir /etc/puppet/modules/admin/files/tree
    # mkdir /etc/puppet/modules/admin/files/tree/a
    # mkdir /etc/puppet/modules/admin/files/tree/b ...

Get Puppet 2.7 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.