I am trying to figure out how to make my puppet module work such I need to test if file exists on the client, if it does, then copy another file over. If the file does not exist then do nothing. I can't seem to get it working. Here is my module:
class web-logs::config {
# PATH TO LOG FILES
$passenger='/var/tmp/puppet_test/passenger'
# PATH TO LOGROTATE CONFIGS
$passenger_logrotate='/var/tmp/puppet_test/logrotate.d/passenger'
exec { 'test1':
onlyif => "test -f $passenger",
path => ['/usr/bin','/usr/sbin','/bin','/sbin'],
refreshonly => true,
} ~>
exec { 'test2':
require => Class['web-logs::passenger']
}
And the Class['web-logs::passenger'] looks like this:
class web-logs::passenger {
file { 'passenger':
path => '/var/tmp/puppet_test/logrotate.d/passenger',
owner => 'root',
group => 'root',
mode => '0644',
source => "puppet://${puppetserver}/modules/web-logs/passenger.conf",
}
}
Any help would be appreciated thanks!
Remove
exec test2
. It isn't necessary. You need torequire
theexec test1
in thefile passenger
. Something like this :The exec is failing since you are missing the command to execute. Right now everything fails because of the failing exec requirement in the file resource. This one should do the trick:
If you get disturbed by the message that the command has been successfully executed on each run you could try to modify the exec like this