|
3 | 3 | # get files via rsync |
4 | 4 | # |
5 | 5 | # Parameters: |
6 | | -# $source - source to copy from |
7 | | -# $path - path to copy to, defaults to $name |
8 | | -# $user - username on remote system |
9 | | -# $purge - if set, rsync will use '--delete' |
10 | | -# $exlude - string (or array) to be excluded |
11 | | -# $include - string (or array) to be included |
| 6 | +# $source - source to copy from |
| 7 | +# $path - path to copy to, defaults to $name |
| 8 | +# $user - username on remote system |
| 9 | +# $purge - if set, rsync will use '--delete' |
| 10 | +# $exlude - string (or array) to be excluded |
| 11 | +# $include - string (or array) to be included |
12 | 12 | # $exclude_first - if 'true' (default) then first exclude and then include; the other way around if 'false' |
13 | | -# $keyfile - path to ssh key used to connect to remote host, defaults to /home/${user}/.ssh/id_rsa |
14 | | -# $timeout - timeout in seconds, defaults to 900 |
15 | | -# $options - default options to pass to rsync (-a) |
16 | | -# $onlyif - Condition to run the rsync command |
| 13 | +# $keyfile - path to ssh key used to connect to remote host, defaults to /home/${user}/.ssh/id_rsa |
| 14 | +# $timeout - timeout in seconds, defaults to 900 |
| 15 | +# $options - default options to pass to rsync (-a) |
| 16 | +# $chown - ownership to pass to rsync (optional; requires rsync 3.1.0+) |
| 17 | +# $chmod - permissions to pass to rsync (optional) |
| 18 | +# $logfile - logname to pass to rsync (optional) |
| 19 | +# $onlyif - Condition to run the rsync command |
17 | 20 | # |
18 | 21 | # Actions: |
19 | 22 | # get files via rsync |
|
38 | 41 | $hardlinks = undef, |
39 | 42 | $copylinks = undef, |
40 | 43 | $times = undef, |
41 | | - $exclude = undef, |
42 | 44 | $include = undef, |
| 45 | + $exclude = undef, |
43 | 46 | $exclude_first = true, |
44 | 47 | $keyfile = undef, |
45 | 48 | $timeout = '900', |
46 | 49 | $execuser = 'root', |
47 | 50 | $options = '-a', |
48 | 51 | $chown = undef, |
| 52 | + $chmod = undef, |
| 53 | + $logfile = undef, |
49 | 54 | $onlyif = undef, |
50 | 55 | ) { |
51 | 56 |
|
|
115 | 120 | $mychown = undef |
116 | 121 | } |
117 | 122 |
|
| 123 | + if $chmod { |
| 124 | + $mychmod = "--chmod=${chmod}" |
| 125 | + } else { |
| 126 | + $mychmod = undef |
| 127 | + } |
| 128 | + |
| 129 | + if $logfile { |
| 130 | + $mylogfile = "--log-file=${logfile}" |
| 131 | + } else { |
| 132 | + $mylogfile = undef |
| 133 | + } |
| 134 | + |
118 | 135 | if $include or $exclude { |
119 | 136 | if $exclude_first { |
120 | 137 | $excludeandinclude = join(delete_undef_values([$myexclude, $myinclude]), ' ') |
|
127 | 144 |
|
128 | 145 | $rsync_options = join( |
129 | 146 | delete_undef_values([$options, $mypurge, $excludeandinclude, $mylinks, $myhardlinks, $mycopylinks, $mytimes, |
130 | | - $myrecursive, $mychown, "${myuser}${source}", $path]), ' ') |
| 147 | + $myrecursive, $mychown, $mychmod, $mylogfile, "${myuser}${source}", $path]), ' ') |
131 | 148 |
|
132 | 149 | if !$onlyif { |
133 | 150 | $onlyif_real = "test `rsync --dry-run --itemize-changes ${rsync_options} | wc -l` -gt 0" |
|
0 commit comments