且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

up:如果存在一个文件,则复制另一个文件

更新时间:2022-12-09 15:49:33

执行程序由于您失踪而失败要执行的命令。现在,由于文件资源中的exec要求失败,一切都失败了。这应该可以解决问题:

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:

exec { 'test1':
   command => "/bin/true",                                             
   onlyif  => "test -f $passenger",                            
   path    => ['/usr/bin','/usr/sbin','/bin','/sbin'],
}

# Check if passenger file exists then push logrotate module for 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",
    require => Exec["test1"],
}

如果您对以下消息感到不安,命令已在每次运行中成功执行,您可以尝试修改exec

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

exec { 'test1':
  command => "/bin/false",                                             
  unless  => "test -f $passenger",                            
  path    => ['/usr/bin','/usr/sbin','/bin','/sbin'],
}