From 4202b1ae9443adf86d4d02fd2b5d2115dac70fd9 Mon Sep 17 00:00:00 2001 From: olevole Date: Sun, 14 Oct 2018 06:36:46 +0300 Subject: [PATCH] add FreeBSD support changes for FreeBSD are trivial and mainly relate to an alternative path to configuration and executable files. So, the standard way for 3rd-party config files in FreeBSD: /usr/local/etc{/rsnapshot} and for binaries: /usr/local Also, define @cmd_rsnapshot in cron.erb via config_cmd_rsnapshot --- manifests/config.pp | 14 ++++++++------ manifests/params.pp | 26 ++++++++++++++++++++------ templates/cron.erb | 2 +- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index c208f95..e535229 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -190,6 +190,8 @@ class rsnapshot::config ( # create cron files for each backup level # merge possible cron definitions to one $real_cron = deep_merge($rsnapshot::params::cron, $rsnapshot::cron, $hash[cron]) + $cmd_rsnapshot = pick($rsnapshot::cmd_rsnapshot, $rsnapshot::params::config_cmd_rsnapshot) + concat::fragment { "mailto for ${host}": content => "#This file is managed by puppet\nMAILTO=${real_cron[mailto]}\n\n", target => $cronfile, @@ -197,12 +199,12 @@ class rsnapshot::config ( } $backup_levels.each |String $level| { - $mailto = $real_cron[mailto] - $minute = rand_from_array($real_cron[$level][minute], "${host}.${level}.minute") - $hour = rand_from_array($real_cron[$level][hour], "${host}.${level}.hour") - $monthday = rand_from_array($real_cron[$level][monthday], "${host}.${level}.monthday") - $month = rand_from_array($real_cron[$level][month], "${host}.${level}.month") - $weekday = rand_from_array($real_cron[$level][weekday], "${host}.${level}.weekday") + $mailto = $real_cron[mailto] + $minute = rand_from_array($real_cron[$level][minute], "${host}.${level}.minute") + $hour = rand_from_array($real_cron[$level][hour], "${host}.${level}.hour") + $monthday = rand_from_array($real_cron[$level][monthday], "${host}.${level}.monthday") + $month = rand_from_array($real_cron[$level][month], "${host}.${level}.month") + $weekday = rand_from_array($real_cron[$level][weekday], "${host}.${level}.weekday") concat::fragment { "${host}.${level}": target => $cronfile, diff --git a/manifests/params.pp b/manifests/params.pp index d28fbcb..6a37030 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -3,14 +3,18 @@ # default params class rsnapshot::params { $hosts = undef - $conf_d = '/etc/rsnapshot' # the place where the host specific configs are stored + $conf_d = $::osfamily ? { + 'FreeBSD' => '/usr/local/etc/rsnapshot', # the place where the host specific configs are stored + default => '/etc/rsnapshot,' # the place where the host specific configs are stored + } $config_backup_user = 'root' $package_name = 'rsnapshot' $package_ensure = 'present' $cron_service_name = $::osfamily ? { - 'RedHat' => 'crond', - 'Debian' => 'cron', - default => '', + 'RedHat' => 'crond', + 'Debian' => 'cron', + 'FreeBSD' => 'cron', + default => '', } $manage_cron = true $cron_dir = '/etc/cron.d' @@ -20,11 +24,21 @@ class rsnapshot::params { $config_check_mk_job = false $config_cmd_cp = '/bin/cp' $config_cmd_rm = '/bin/rm' - $config_cmd_rsync = '/usr/bin/rsync' + $config_cmd_rsync = $::osfamily ? { + 'FreeBSD' => '/usr/local/bin/rsync', + default => '/usr/bin/rsync', + } $config_cmd_ssh = '/usr/bin/ssh' $config_cmd_logger = '/usr/bin/logger' $config_cmd_du = '/usr/bin/du' - $config_cmd_rsnapshot_diff = '/usr/bin/rsnapshot-diff' + $config_cmd_rsnapshot = $::osfamily ? { + 'FreeBSD' => '/usr/local/bin/rsnapshot', + default => '/usr/bin/rsnapshot', + } + $config_cmd_rsnapshot_diff = $::osfamily ? { + 'FreeBSD' => '/usr/local/bin/rsnapshot-diff', + default => '/usr/bin/rsnapshot-diff', + } $config_cmd_preexec = undef $config_cmd_postexec = undef $config_cronfile_prefix = 'rsnapshot_' diff --git a/templates/cron.erb b/templates/cron.erb index 56ae348..7a94cc0 100644 --- a/templates/cron.erb +++ b/templates/cron.erb @@ -1 +1 @@ -<%= @minute %> <%= @hour %> <%= @monthday %> <%= @month %> <%= @weekday %> root<% if scope['rsnapshot::check_mk_job'] == true -%> mk-job rsnapshot_<%= @host %>_<%= @level %><% end -%> /usr/bin/rsnapshot -c <%= @config %> <%= @level %> +<%= @minute %> <%= @hour %> <%= @monthday %> <%= @month %> <%= @weekday %> root<% if scope['rsnapshot::check_mk_job'] == true -%> mk-job rsnapshot_<%= @host %>_<%= @level %><% end -%> <%= @cmd_rsnapshot %> -c <%= @config %> <%= @level %>