2017-08-02 263 views
2

我試圖設置一個新的puppetmaster(v5.0.1),並且一切順利,除了一件事。呼叫失敗()失敗

我無法在我的清單中調用fail()。當它試圖運行任何fail()函數時,它會拋出一個評估錯誤。

這種情況發生在清單中,並且也適用於傀儡。

$ puppet apply -e 'fail("Failure")' --trace 

將返回以下錯誤和跟蹤:

Error: Evaluation Error: Error while evaluating a Function Call, Failure at line 1:1 on node *** /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/functions/fail.rb:3:in block in <top (required)>' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/functions.rb:174:in block (2 levels) in newfunction' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/profiler/around_profiler.rb:58:in profile' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/profiler.rb:51:in profile' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/functions.rb:167:in block in newfunction' :1:in stack' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/puppet_stack.rb:30:in eval' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/puppet_stack.rb:30:in stack' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/evaluator/runtime3_support.rb:316:in call_function' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/evaluator/evaluator_impl.rb:949:in call_function_with_block' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/evaluator/evaluator_impl.rb:918:in eval_CallNamedFunctionExpression' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/visitor.rb:48:in block in visit_this' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/visitor.rb:42:in each' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/visitor.rb:42:in visit_this' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/visitor.rb:92:in visit_this_1' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/evaluator/evaluator_impl.rb:81:in evaluate' :in stack' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/puppet_stack.rb:30:in eval' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/puppet_stack.rb:30:in stack' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/evaluator/evaluator_impl.rb:723:in eval_Program' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/visitor.rb:48:in block in visit_this' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/visitor.rb:42:in each' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/visitor.rb:42:in visit_this' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/visitor.rb:92:in visit_this_1' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/evaluator/evaluator_impl.rb:81:in evaluate' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/pops/parser/evaluating_parser.rb:63:in evaluate' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/ast/pops_bridge.rb:132:in evaluate' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/ast.rb:31:in safeevaluate' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource/type.rb:136:in evaluate_code' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/resource.rb:79:in block in evaluate' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/profiler/around_profiler.rb:58:in profile' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/profiler.rb:51:in profile' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/resource.rb:71:in evaluate' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/compiler.rb:589:in evaluate_main' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/compiler.rb:164:in block (2 levels) in compile' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/profiler/around_profiler.rb:58:in profile' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/profiler.rb:51:in profile' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/compiler.rb:164:in block in compile' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/context.rb:65:in override' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb:310:in override' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/compiler.rb:153:in compile' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/parser/compiler.rb:33:in compile' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/catalog/compiler.rb:282:in block (2 levels) in compile' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/profiler/around_profiler.rb:58:in profile' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/profiler.rb:51:in profile' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/catalog/compiler.rb:280:in block in compile' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:224:in block in benchmark' /opt/puppetlabs/puppet/lib/ruby/2.4.0/benchmark.rb:308:in realtime' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:223:in benchmark' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/catalog/compiler.rb:278:in compile' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/catalog/compiler.rb:52:in find' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/indirection.rb:195:in find' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/apply.rb:258:in block in main' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/context.rb:65:in override' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb:310:in override' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/apply.rb:229:in main' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/apply.rb:170:in run_command' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:358:in block in run' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:666:in exit_on_fail' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:358:in run' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:132:in run' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:72:in execute' /opt/puppetlabs/puppet/bin/puppet:5:in `'

我敢肯定,這是我,但我想不出是什麼原因導致這一點。

+1

呼叫失敗()失敗:所以它工作! =) –

回答

2

fail()函數按設計工作,但錯誤信息令人困惑。

fail()函數僅僅是圍繞raise Puppet::ParseError的一個包裝。通常,Puppet::ParseError是在Puppet函數而不是做它應該做的事情時引發的。在這種情況下,消息Error while evaluating a Function Call是有道理的。

但是,在這裏提出錯誤是因爲該函數正在執行的操作完全是應該做的 - 爲您產生錯誤。所以,這不是評估函數調用時的「錯誤」。

它一直是這樣的。

+0

我認爲把他扔掉的日誌是轉換Ruby'ParseError'異常類型的日誌。該消息雖然在第一行顯示,但可能被誤解爲句子的一部分。至少這會讓我失望。 –