File tree Expand file tree Collapse file tree 7 files changed +28
-15
lines changed Expand file tree Collapse file tree 7 files changed +28
-15
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11metadata.json
22pkg /
3+ Gemfile.lock
4+ .rspec
Original file line number Diff line number Diff line change 1+ source "https://rubygems.org"
2+
3+ gem 'puppetlabs_spec_helper'
4+ gem 'puppet'
Original file line number Diff line number Diff line change @@ -8,13 +8,14 @@ providing defines to easily grab data via rsync.
88get files via rsync
99
1010## Parameters: ##
11- $source - source to copy from
12- $path - path to copy to, defaults to $name
13- $user - username on remote system
14- $purge - if set, rsync will use '--delete'
15- $exlude - string to be excluded
16- $keyfile - ssh key used to connect to remote host
17- $timeout - timeout in seconds, defaults to 900
11+ $source - source to copy from
12+ $path - path to copy to, defaults to $name
13+ $user - username on remote system
14+ $purge - if set, rsync will use '--delete'
15+ $exlude - string to be excluded
16+ $keyfile - ssh key used to connect to remote host
17+ $timeout - timeout in seconds, defaults to 900
18+ $execuser - user to run the command (passed to exec)
1819
1920## Actions: ##
2021 get files via rsync
Original file line number Diff line number Diff line change 3131 $purge = undef ,
3232 $exclude = undef ,
3333 $keyfile = undef ,
34- $timeout = ' 900'
34+ $timeout = ' 900' ,
35+ $execuser = ' root' ,
3536) {
3637
3738 if $keyfile {
6364 exec { "rsync ${name}" :
6465 command => " rsync -q ${rsync_options} " ,
6566 path => [ ' /bin' , ' /usr/bin' ],
67+ user => $execuser ,
6668 # perform a dry-run to determine if anything needs to be updated
6769 # this ensures that we only actually create a Puppet event if something needs to
6870 # be updated
Original file line number Diff line number Diff line change 1919 should contain_exec ( "rsync foobar" ) . with ( {
2020 'command' => 'rsync -q -a example.com foobar' ,
2121 'onlyif' => "test `rsync --dry-run --itemize-changes -a example.com foobar | wc -l` -gt 0" ,
22- 'timeout' => '900'
22+ 'timeout' => '900' ,
23+ 'user' => 'root'
2324 } )
2425 }
2526 end
2627
28+ describe "when setting the execuser" do
29+ let :params do
30+ common_params . merge ( { :execuser => 'username' } )
31+ end
32+
33+ it { should contain_exec ( "rsync foobar" ) . with ( { 'user' => 'username' } ) }
34+ end
35+
2736 describe "when setting the timeout" do
2837 let :params do
2938 common_params . merge ( { :timeout => '200' } )
Original file line number Diff line number Diff line change 6464 let :params do
6565 mandatory_params . merge ( { k => v } )
6666 end
67- it { should contain_file ( fragment_file ) . with_content ( /^#{ k . to_s . gsub ( '_' , ' ' ) } \s *=\s *#{ v . to_a . join ( ' ' ) } $/ ) }
67+ it { should contain_file ( fragment_file ) . with_content ( /^#{ k . to_s . gsub ( '_' , ' ' ) } \s *=\s *#{ Array ( v ) . join ( ' ' ) } $/ ) }
6868 end
6969 end
7070
You can’t perform that action at this time.
0 commit comments