Skip to content

Commit feb742e

Browse files
committed
Merge pull request #90 from eputnam/esalberglog
includes addition of chmod and log-file options updates fixtures yml and closes module dependencies in metadata.json also closes #89
2 parents 23c31f1 + 801e15b commit feb742e

File tree

5 files changed

+76
-18
lines changed

5 files changed

+76
-18
lines changed

.fixtures.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
fixtures:
2-
forge_modules:
2+
repositories:
33
xinetd:
4-
repo: 'puppetlabs/xinetd'
4+
repo: 'https://www.github.com/puppetlabs/puppetlabs-xinetd'
55
concat:
6-
repo: 'puppetlabs/concat'
6+
repo: 'https://www.github.com/puppetlabs/puppetlabs-concat'
77
stdlib:
8-
repo: 'puppetlabs/stdlib'
8+
repo: 'https://www.github.com/puppetlabs/puppetlabs-stdlib'
99
symlinks:
1010
"rsync": "#{source_dir}"

README.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ get files via rsync
3636
$execuser - user to run the command (passed to exec)
3737
$options - default options to pass to rsync (-a)
3838
$chown - USER:GROUP simple username/groupname mapping
39+
$chmod - file and/or directory permissions
40+
$logfile - log file name
3941
$onlyif - condition to run the rsync command
4042

4143
## Actions: ##

manifests/get.pp

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,20 @@
33
# get files via rsync
44
#
55
# 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
1212
# $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
1720
#
1821
# Actions:
1922
# get files via rsync
@@ -38,14 +41,16 @@
3841
$hardlinks = undef,
3942
$copylinks = undef,
4043
$times = undef,
41-
$exclude = undef,
4244
$include = undef,
45+
$exclude = undef,
4346
$exclude_first = true,
4447
$keyfile = undef,
4548
$timeout = '900',
4649
$execuser = 'root',
4750
$options = '-a',
4851
$chown = undef,
52+
$chmod = undef,
53+
$logfile = undef,
4954
$onlyif = undef,
5055
) {
5156

@@ -115,6 +120,18 @@
115120
$mychown = undef
116121
}
117122

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+
118135
if $include or $exclude {
119136
if $exclude_first {
120137
$excludeandinclude = join(delete_undef_values([$myexclude, $myinclude]), ' ')
@@ -127,7 +144,7 @@
127144

128145
$rsync_options = join(
129146
delete_undef_values([$options, $mypurge, $excludeandinclude, $mylinks, $myhardlinks, $mycopylinks, $mytimes,
130-
$myrecursive, $mychown, "${myuser}${source}", $path]), ' ')
147+
$myrecursive, $mychown, $mychmod, $mylogfile, "${myuser}${source}", $path]), ' ')
131148

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

metadata.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"project_page": "https://github.com/puppetlabs/puppetlabs-rsync",
99
"issues_url": "https://tickets.puppetlabs.com/browse/MODULES",
1010
"dependencies": [
11-
{"name":"puppetlabs/stdlib","version_requirement":">=4.2.0"},
11+
{"name":"puppetlabs/stdlib","version_requirement":">=4.2.0 <5.0.0"},
1212
{"name":"puppetlabs/xinetd","version_requirement":">=1.1.0"},
13-
{"name":"puppetlabs/concat","version_requirement":">= 1.1.1"}
13+
{"name":"puppetlabs/concat","version_requirement":">= 1.1.1 <5.0.0"}
1414
]
1515
}

spec/defines/get_spec.rb

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,4 +280,43 @@
280280
}
281281
end
282282

283+
describe "when setting chown" do
284+
let :params do
285+
common_params.merge({ :chown => 'user:group' })
286+
end
287+
288+
it {
289+
is_expected.to contain_exec("rsync foobar").with({
290+
'command' => 'rsync -q -a --chown=user:group example.com foobar',
291+
'onlyif' => "test `rsync --dry-run --itemize-changes -a --chown=user:group example.com foobar | wc -l` -gt 0"
292+
})
293+
}
294+
end
295+
296+
describe "when setting chmod" do
297+
let :params do
298+
common_params.merge({ :chmod => 'Dg-s,u+w,go-w,+X,+x' })
299+
end
300+
301+
it {
302+
is_expected.to contain_exec("rsync foobar").with({
303+
'command' => 'rsync -q -a --chmod=Dg-s,u+w,go-w,+X,+x example.com foobar',
304+
'onlyif' => "test `rsync --dry-run --itemize-changes -a --chmod=Dg-s,u+w,go-w,+X,+x example.com foobar | wc -l` -gt 0"
305+
})
306+
}
307+
end
308+
309+
describe "when setting logfile" do
310+
let :params do
311+
common_params.merge({ :logfile => '/tmp/logfile.out' })
312+
end
313+
314+
it {
315+
is_expected.to contain_exec("rsync foobar").with({
316+
'command' => 'rsync -q -a --log-file=/tmp/logfile.out example.com foobar',
317+
'onlyif' => "test `rsync --dry-run --itemize-changes -a --log-file=/tmp/logfile.out example.com foobar | wc -l` -gt 0"
318+
})
319+
}
320+
end
321+
283322
end

0 commit comments

Comments
 (0)