Merge branch 'master' of bitbucket.org:tmakinen/puppet

This commit is contained in:
Ossi Salmi 2013-11-06 10:48:25 +02:00
commit 39362b2393
3 changed files with 16 additions and 6 deletions

View file

@ -43,6 +43,10 @@ class portmap::server {
service { "portmap": service { "portmap":
ensure => running, ensure => running,
name => $service, name => $service,
start => $::operatingsystem ? {
"openbsd" => "/usr/sbin/portmap",
default => undef,
},
enable => true, enable => true,
} }

View file

@ -144,7 +144,8 @@ define rsync::backup_job (
false => $source_dirs, false => $source_dirs,
} }
$_source = "${source_host}:${_source_dirs}" $_source = "${source_host}:${_source_dirs}"
} elsif $source_dir { $_log_host = $source_host
} elsif $source_dirs {
$_source = is_array($source_dirs) ? { $_source = is_array($source_dirs) ? {
true => inline_template("<%= @source_dirs.join(\" \") -%>"), true => inline_template("<%= @source_dirs.join(\" \") -%>"),
false => $source_dirs, false => $source_dirs,
@ -155,17 +156,22 @@ define rsync::backup_job (
if $target_host and $target_dir { if $target_host and $target_dir {
$_target = "${target_host}:${target_dir}" $_target = "${target_host}:${target_dir}"
$_log_host = $target_host
} elsif $target_dir { } elsif $target_dir {
$_target = "${target_dir}" $_target = "${target_dir}"
} else { } else {
fail("You need to specify target_dir (and optionally target_host)") fail("You need to specify target_dir (and optionally target_host)")
} }
if !$_log_host {
$_log_host = "localhost"
}
if is_array($excludes) { if is_array($excludes) {
$_excludes = inline_template('<%= @excludes.map {|x| "--exclude=\"" + x + "\""}.join(" ") -%>') $_excludes = inline_template('<%= @excludes.map {|x| "--exclude \'" + x + "\'"}.join(" ") -%>')
} elsif $excludes { } elsif $excludes {
# We assume string here # We assume string here
$_excludes = '--exclude="$excludes"' $_excludes = "--exclude='$excludes'"
} else { } else {
$_excludes = "" $_excludes = ""
} }

View file

@ -1,19 +1,19 @@
#!/bin/bash #!/bin/bash
LOGFILE="/srv/rsync-log/<%= @source_host -%>-$(date +"%F-%T").log" LOGFILE="/srv/rsync-log/<%= @_log_host -%>-$(date +"%F-%T").log"
FLOCK="/usr/bin/flock" FLOCK="/usr/bin/flock"
FLOCK_OPTS="--exclusive --nonblock" FLOCK_OPTS="--exclusive --nonblock"
FLOCK_FILE="/var/lock/<%= @name -%>" FLOCK_FILE="/var/lock/<%= @name -%>"
RSYNC="/usr/bin/rsync" RSYNC="/usr/bin/rsync"
RSYNC_OPTS="-ax <%= @acl ? "-A" : "" -%> --delete --itemize-changes <%= @_excludes -%>" RSYNC_OPTS=( -ax <%= @acl ? "-A" : "" -%> --delete --itemize-changes <%= @_excludes -%> )
( (
$FLOCK $FLOCK_OPTS 200 || exit $? $FLOCK $FLOCK_OPTS 200 || exit $?
/usr/bin/printf "***** <%= @_source -%> -> <%= @_target -%>\n" /usr/bin/printf "***** <%= @_source -%> -> <%= @_target -%>\n"
/usr/bin/printf "***** Backup started %s\n\n" "$(date +"%F %T UTC")" /usr/bin/printf "***** Backup started %s\n\n" "$(date +"%F %T UTC")"
/usr/bin/time -p $RSYNC $RSYNC_OPTS <%= @_source -%> <%= @_target %> /usr/bin/time -p $RSYNC "${RSYNC_OPTS[@]}" <%= @_source -%> <%= @_target %>
RSYNCEXIT=$? RSYNCEXIT=$?
if [ $RSYNCEXIT -ne 0 ]; then if [ $RSYNCEXIT -ne 0 ]; then
echo "ERROR: rsync job (<%= @name -%>) process returned $RSYNCEXIT" echo "ERROR: rsync job (<%= @name -%>) process returned $RSYNCEXIT"