- Puppet 2.7 Cookbook
- John Arundel
- 224字
- 2021-04-02 18:20:03
Logging command output
"Computer says no."—Little Britain
Detailed feedback on problems can be helpful. When you use exec
resources to run commands on the node, it's not always easy to find out why they haven't worked. Puppet will give you an error message if a command returns a non-zero exit status. The error will be similar to the following:
err: /Stage[main]//Node[cookbook]/Exec[this-will-fail]/returns: change from notrun to 0 failed: /bin/ls file-that-doesnt-exist returned 2 instead of one of [0] at /etc/puppet/manifests/nodes.pp:10
Often we would like to see the actual output from the command that failed, rather than just the numerical exit status. You can do this with the logoutput
parameter.
How to do it…
Define an exec
resource with the logoutput
parameter as follows:
exec { "this-will-fail": command => "/bin/ls file-that-doesnt-exist", logoutput => on_failure, }
How it works…
Now, if the command fails, Puppet will also print its output:
notice: /Stage[main]//Node[cookbook]/Exec[this-will-fail]/returns: /bin/ls: cannot access file-that-doesnt-exist: No such file or directory err: /Stage[main]//Node[cookbook]/Exec[this-will-fail]/returns: change from notrun to 0 failed: /bin/ls file-that-doesnt-exist returned 2 instead of one of [0] at /etc/puppet/manifests/nodes.pp:11
There's more…
You can set this to be the default for all exec
resources by defining the following:
Exec { logoutput => on_failure, }
If you want to see the command output whether it succeeds or fails, use the following:
logoutput => true,
- Excel函數、公式、圖表、數據處理從新手到高手
- 中文版3ds Max 2012實用教程(第2版)
- Scratch 1.4: Beginner’s Guide
- Alice 3 Cookbook
- After Effects CC 2019 影視后期特效合成案例教程
- Procreate+ SketchUp +Photoshop建筑設計手繪表現技法
- ASP.NET jQuery Cookbook
- 3ds Max/VRay印象燈光/材質/渲染技術精粹Ⅲ
- 魔法詞典:AI繪畫關鍵詞圖鑒(Midjourney版)
- Altium Designer 21實戰從入門到精通
- Mobile Web Development
- Joomla! 1.5 Content Administration
- 中文版Photoshop CC 2018基礎培訓教程(全彩版)
- AutoCAD 2016中文版自學視頻教程(標準版)
- After Effects視頻特效實用教程