mirror of
https://github.com/krislamo/puppet-rsnapshot
synced 2024-11-10 00:00:35 +00:00
add custom function to allow for empty hashes in params (specify hostname only to pickup defaults)
This commit is contained in:
parent
f7922a2e4a
commit
fa88ccb1cb
@ -1,6 +1,6 @@
|
|||||||
module Puppet::Parser::Functions
|
module Puppet::Parser::Functions
|
||||||
newfunction(:pick_undef, :type => :rvalue, :doc => <<-EOS
|
newfunction(:pick_undef, :type => :rvalue, :doc => <<-EOS
|
||||||
This function is similar to pick_default, but will return or undefined values.
|
This function is similar to pick_default, but will return or undefined values.
|
||||||
EOS
|
EOS
|
||||||
) do |args|
|
) do |args|
|
||||||
fail "Must receive at least one argument." if args.empty?
|
fail "Must receive at least one argument." if args.empty?
|
||||||
|
@ -16,8 +16,21 @@ class rsnapshot::config (
|
|||||||
ensure => 'directory',
|
ensure => 'directory',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# $hosts_clean = $hosts.reduce( {} ) |$memo, $entry| {
|
||||||
|
# $key = $entry[0]
|
||||||
|
# $value = $entry[1]
|
||||||
|
# $new_value = $value ? {
|
||||||
|
# undef => {},
|
||||||
|
# default => $value,
|
||||||
|
# }
|
||||||
|
# $memo + { $key => $new_value }
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
$hosts_clean = assert_empty_hash($hosts)
|
||||||
notify {"Hosts is: $hosts ": }
|
notify {"Hosts is: $hosts ": }
|
||||||
$hosts.each |String $host, Hash $hash | {
|
notify {"Hosts_clean is: $hosts_clean ": }
|
||||||
|
|
||||||
|
$hosts_clean.each |String $host, Hash $hash | {
|
||||||
$snapshot_root = pick($hash['snapshot_root'], $rsnapshot::params::config_snapshot_root)
|
$snapshot_root = pick($hash['snapshot_root'], $rsnapshot::params::config_snapshot_root)
|
||||||
$backup = pick($hash['backup'], $rsnapshot::params::config_backup)
|
$backup = pick($hash['backup'], $rsnapshot::params::config_backup)
|
||||||
$backup_user = pick($hash['backup_user'], $rsnapshot::params::config_backup_user)
|
$backup_user = pick($hash['backup_user'], $rsnapshot::params::config_backup_user)
|
||||||
@ -27,7 +40,6 @@ class rsnapshot::config (
|
|||||||
} else {
|
} else {
|
||||||
$backups = $backup
|
$backups = $backup
|
||||||
}
|
}
|
||||||
|
|
||||||
$cmd_cp = pick($hash['cmd_cp'], $rsnapshot::params::config_cmd_cp)
|
$cmd_cp = pick($hash['cmd_cp'], $rsnapshot::params::config_cmd_cp)
|
||||||
$cmd_rm = pick($hash['cmd_rm'], $rsnapshot::params::config_cmd_rm)
|
$cmd_rm = pick($hash['cmd_rm'], $rsnapshot::params::config_cmd_rm)
|
||||||
$cmd_rsync = pick($hash['cmd_rsync'], $rsnapshot::params::config_cmd_rsync)
|
$cmd_rsync = pick($hash['cmd_rsync'], $rsnapshot::params::config_cmd_rsync)
|
||||||
|
Loading…
Reference in New Issue
Block a user