15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'manifests/get.pp', line 15
define rsync::get (
String $source,
String $path = $name,
Optional[String] $user = undef,
String $keyfile = "/home/${user}/.ssh/id_rsa",
String $timeout = '900',
String $execuser = 'root',
String $options = '-a',
Optional[String] $onlyif = undef,
) {
if $user {
$myuser = "-e 'ssh -i ${keyfile} -l ${user}' ${user}@"
} else {
$myuser = undef
}
$rsync_options = join(
delete_undef_values([$options, "${myuser}${source}", $path]), ' ')
if !$onlyif {
$onlyif_real = "test `rsync --dry-run --itemize-changes ${rsync_options} | wc -l` -gt 0"
} else {
$onlyif_real = $onlyif
}
exec { "rsync ${name}":
command => "rsync -q ${rsync_options}",
path => ['/bin', '/usr/bin', '/usr/local/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
# TODO - it may make senes to do an actual run here (instead of a dry run)
# and relace the command with an echo statement or something to ensure
# that we only actually run rsync once
onlyif => $onlyif_real,
timeout => $timeout,
}
}
|