Skip to content

Commit

Permalink
Add chmod and log-file options
Browse files Browse the repository at this point in the history
  • Loading branch information
esalberg committed Aug 3, 2016
1 parent 8cc3c6f commit 27decd1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ get files via rsync
$execuser - user to run the command (passed to exec)
$options - default options to pass to rsync (-a)
$chown - USER:GROUP simple username/groupname mapping
$chmod - file and/or directory permissions
$logfile - log file name
$onlyif - condition to run the rsync command

## Actions: ##
Expand Down
15 changes: 14 additions & 1 deletion manifests/get.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
# $keyfile - path to ssh key used to connect to remote host, defaults to /home/${user}/.ssh/id_rsa
# $timeout - timeout in seconds, defaults to 900
# $options - default options to pass to rsync (-a)
# $chown - ownership to pass to rsync (optional)
# $chmod - permissions to pass to rsync (optional)
# $logfile - logname to pass to rsync (optional)
# $onlyif - Condition to run the rsync command
#
# Actions:
Expand Down Expand Up @@ -44,6 +47,8 @@
$execuser = 'root',
$options = '-a',
$chown = undef,
$chmod = undef,
$logfile = undef,
$onlyif = undef,
) {

Expand Down Expand Up @@ -113,8 +118,16 @@
$myChown = undef
}

if $chmod {
$myChmod = "--chmod=${chmod}"
}

if $logfile {
$myLogfile = "--log-file=${logfile}"
}

$rsync_options = join(
delete_undef_values([$options, $myPurge, $myExclude, $myInclude, $myLinks, $myHardLinks, $myCopyLinks, $myTimes, $myRecursive, $myChown, "${myUser}${source}", $path]), ' ')
delete_undef_values([$options, $myPurge, $myExclude, $myInclude, $myLinks, $myHardLinks, $myCopyLinks, $myTimes, $myRecursive, $myChown, $myChmod, $myLogfile, "${myUser}${source}", $path]), ' ')

if !$onlyif {
$onlyif_real = "test `rsync --dry-run --itemize-changes ${rsync_options} | wc -l` -gt 0"
Expand Down

0 comments on commit 27decd1

Please sign in to comment.