简体   繁体   English

Puppet - 如果源不可用则静默退出

[英]Puppet - silently exit if the source is not available

Is it possible to silently exit if the source file is not available.如果源文件不可用,是否可以静默退出。

For example:例如:

file {"/tmp/skin-${version}_${theme}.zip":
        source => "${file_location}/skin-${version}_${theme}.zip",
        ensure  => file,
        mode    => '0700'
    }
->
exec {"commands":  
         Here I will be processing the above downloaded file, if the url is not valid this block should not execute.
    }

In the above example if the file -> source url is not available, this should silently exit without any error.在上面的示例中,如果文件 -> 源 url 不可用,则应该无提示地退出而不会出现任何错误。

With an onlyif on your exec it will only trigger if the test succeeds.在您的 exec 上使用onlyif它只会在测试成功时触发。

  exec { 'command':
    onlyif => "test -f /tmp/skin-${version}_${theme}.zip"
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM