From 10d42e0c76db3f5b1443c96ec382ca188f516212 Mon Sep 17 00:00:00 2001 From: Corey Ralph Date: Thu, 24 Sep 2020 16:24:55 +1000 Subject: [PATCH] Add password option --- manifests/get.pp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/manifests/get.pp b/manifests/get.pp index a448124..da4ef6e 100644 --- a/manifests/get.pp +++ b/manifests/get.pp @@ -17,6 +17,7 @@ # $chmod - permissions to pass to rsync (optional) # $logfile - logname to pass to rsync (optional) # $onlyif - Condition to run the rsync command +# $password - password to be passed via the RSYNC_PASSWORD environment variable # # Actions: # get files via rsync @@ -52,6 +53,7 @@ $chmod = undef, $logfile = undef, $onlyif = undef, + $password = undef, ) { if $keyfile { @@ -152,11 +154,17 @@ $onlyif_real = $onlyif } + if $password { + $env = [ "RSYNC_PASSWORD=${password}" ] + } else { + $env = undef + } exec { "rsync ${name}": - command => "rsync -q ${rsync_options}", - path => [ '/bin', '/usr/bin', '/usr/local/bin' ], - user => $execuser, + command => "rsync -q ${rsync_options}", + path => [ '/bin', '/usr/bin', '/usr/local/bin' ], + user => $execuser, + environment => $env, # 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