简体   繁体   English

当清单中有错误时,木偶工作流程会停止吗?

[英]Can puppet workflow stop when there is an error in manifest?

I am looking out options for making my puppet run stop as in when I see some failure in some check inside a manifest. 我正在寻找使我的木偶运行停止的选项,就像我在清单中看到一些检查失败一样。

When I execute puppet agent -t on the node, if there is some error in manifest, it should stop the execution rather than proceeding with the remaining manifest. 当我在节点上执行puppet agent -t时,如果manifest中有一些错误,它应该停止执行而不是继续执行剩余的清单。

I tried the command "fail", if the file cannot be found on the node, but I got this error 我尝试了命令“fail”,如果在节点上找不到该文件,但是我收到了这个错误

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Function Call

I was trying something similar below, if the file exist then notify I am present else fail and stop the execution 我正在尝试下面类似的东西,如果文件存在然后通知我现在其他失败并停止执行

$file = "/tmp/file"
exec { "chk_${file}_exist":
  command => "true",
  path    =>  ["/usr/bin","/usr/sbin", "/bin"],
  onlyif  => "test -f ${file}"
}
-> if !(Exec["chk_${file}_exist"]) {
      fail('I am failing')
        }
else {
      notify { 'I am present  ":}
}

To the best of my knowledge, there is no general-purpose mechanism in Puppet to make catalog application abort completely upon failure of a single resource, though such a feature has been requested before . 据我所知,Puppet中没有通用机制使目录应用程序在单个资源出现故障时完全中止,尽管之前已经请求了这样的功能。 One generally approaches such a question with a bit more precision, via one facet or another of resource relationships . 人们通常通过一个方面或另一个资源关系来更精确地处理这样的问题。

If you have one resource whose correct application depends on another specific resource having successfully been applied first, then you describe that to Puppet by declaring a relationship between the two, using either one of the chaining operators or one of the resource metaparameters designated for that purpose ( before , require , notify , subscribe ). 如果您有一个资源,其正确的应用程序依赖于先成功应用的另一个特定资源,那么您可以通过使用链接运算符之一或为此目的指定的资源元参数之一声明两者之间的关系来向Puppet描述( beforerequirenotifysubscribe )。 That will ensure both the relative order of application of those resources, and that no attempt is made to apply the dependent one if applying the dependency fails. 这将确保这些资源的相对应用顺序,并且如果应用依赖性失败,则不会尝试应用从属资源。 You can apply that concept to groups of resources by establishing relationships with classes or defined-type instances on one or both sides, or even by bringing run stages to bear. 您可以通过在一侧或双方与类或定义类型实例建立关系,甚至通过运行运行阶段来将该概念应用于资源

There is currently no way, however, to make catalog application overall to halt immediately upon resource failure when there remain resources that are eligible to be applied. 但是,当存在有资格应用的资源时,目前无法在资源失败时立即使目录应用程序立即停止。

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

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