Puppet-如果源不可用,则以静默方式退出
如果源文件不可用,是否可以静默退出 例如:Puppet-如果源不可用,则以静默方式退出,puppet,Puppet,如果源文件不可用,是否可以静默退出 例如: file {"/tmp/skin-${version}_${theme}.zip": source => "${file_location}/skin-${version}_${theme}.zip", ensure => file, mode => '0700' } -> exec {"commands": Here I will be pr
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.
}
在上面的示例中,如果文件->源url不可用,则应无提示地退出,不会出现任何错误。如果在exec上执行,则只有在测试成功时才会触发
exec { 'command':
onlyif => "test -f /tmp/skin-${version}_${theme}.zip"
}
此文件的宿主位置是哪里?如果它在模块中,那么它什么时候不存在?是的,它在模块中。假设在
skin.pp
文件中,代码在classdev:skin\u it
中,它是从其他模块调用的。那么该文件将始终存在于模块内的files
目录中,因此您很好。在运行时,我可以在控制台上看到错误,我希望给出正确的消息(notify)而不是错误。修复错误怎么样?${file_location}是一个url,test命令对url有效吗?不,抱歉,我读过头了。您必须检查文件以便进行测试:“test-f/tmp/skin-${version}{theme}.zip”