I am setting up a dirvish backup system using puppet. Dirvish has the concept of a vault - a self-contained directory which contains the backup data and the configuration for what and how to backup. These vaults can be anywhere in the filesystem, so you need to explicitly list them in the master dirvish config file.
The way I have done this with puppet duplicates the information about the vaults, by first creating them as resources, and then passing a array of vault names to the master dirvish resource.
# Dirvish vaults, alphabetically sorted
dirvish::vault { 'server-a-full':
client => 'server-a',
tree => '/',
backup_root => $dirvish_backup_root
}
dirvish::vault { 'server-b-example.com':
client => 'server-b',
tree => '/srv/www/vhosts/example.com/backup',
rsync_option => '--copy-unsafe-links',
backup_root => $dirvish_backup_root
}
# TODO - we duplicate the vault definitions here, but I don't
# see a better way right now
class {'dirvish':
backup_root => $dirvish_backup_root,
vaults => ['server-a-full', 'server-b-example.com']
}
The dirvish::vault
class looks something like this
define dirvish::vault($tree, $client, $exclude = [], $rsync_option = '', $backup_root) {
file {"$backup_root/$name/dirvish/default.conf":
ensure => present,
content => template("dirvish/vault.conf.erb"),
require => File["$backup_root/$name/dirvish"]
}
}
The dirvish
class uses the vaults
variable in a template
Runall:
<% vaults.each do |vault| -%>
<%= vault %>
<% end -%>
How can I remove this duplication?