Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .gemfile

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
metadata.json
pkg/
Gemfile.lock
.rspec
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source "https://rubygems.org"

gem 'puppetlabs_spec_helper'
gem 'puppet'
15 changes: 8 additions & 7 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ providing defines to easily grab data via rsync.
get files via rsync

## Parameters: ##
$source - source to copy from
$path - path to copy to, defaults to $name
$user - username on remote system
$purge - if set, rsync will use '--delete'
$exlude - string to be excluded
$keyfile - ssh key used to connect to remote host
$timeout - timeout in seconds, defaults to 900
$source - source to copy from
$path - path to copy to, defaults to $name
$user - username on remote system
$purge - if set, rsync will use '--delete'
$exlude - string to be excluded
$keyfile - ssh key used to connect to remote host
$timeout - timeout in seconds, defaults to 900
$execuser - user to run the command (passed to exec)

## Actions: ##
get files via rsync
Expand Down
4 changes: 3 additions & 1 deletion manifests/get.pp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
$purge = undef,
$exclude = undef,
$keyfile = undef,
$timeout = '900'
$timeout = '900',
$execuser = 'root',
) {

if $keyfile {
Expand Down Expand Up @@ -63,6 +64,7 @@
exec { "rsync ${name}":
command => "rsync -q ${rsync_options}",
path => [ '/bin', '/usr/bin' ],
user => $execuser,
# perform a dry-run to determine if anything needs to be updated
# this ensures that we only actually create a Puppet event if something needs to
# be updated
Expand Down
11 changes: 10 additions & 1 deletion spec/defines/get_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,20 @@
should contain_exec("rsync foobar").with({
'command' => 'rsync -q -a example.com foobar',
'onlyif' => "test `rsync --dry-run --itemize-changes -a example.com foobar | wc -l` -gt 0",
'timeout' => '900'
'timeout' => '900',
'user' => 'root'
})
}
end

describe "when setting the execuser" do
let :params do
common_params.merge( { :execuser => 'username' } )
end

it{ should contain_exec("rsync foobar").with({ 'user' => 'username' }) }
end

describe "when setting the timeout" do
let :params do
common_params.merge( { :timeout => '200' } )
Expand Down
2 changes: 1 addition & 1 deletion spec/defines/server_module_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
let :params do
mandatory_params.merge({ k => v })
end
it { should contain_file(fragment_file).with_content(/^#{k.to_s.gsub('_', ' ')}\s*=\s*#{v.to_a.join(' ')}$/)}
it { should contain_file(fragment_file).with_content(/^#{k.to_s.gsub('_', ' ')}\s*=\s*#{Array(v).join(' ')}$/)}
end
end

Expand Down