cdist-web/src/extra/manuals/4.0.0pre1/man7/cdist-troubleshooting.html

28 lines
3.7 KiB
HTML
Raw Normal View History

2019-04-23 18:55:23 +00:00
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>cdist-troubleshooting(7)</title><link rel="stylesheet" type="text/css" href="docbook-xsl.css" /><meta name="generator" content="DocBook XSL Stylesheets V1.78.1" /></head><body><div xml:lang="en" class="article" lang="en"><div class="titlepage"><div><div><h2 class="title"><a id="idm140546776673296"></a>cdist-troubleshooting(7)</h2></div><div><div class="author"><h3 class="author"><span class="firstname">Nico</span> <span class="surname">Schottelius</span></h3><code class="email">&lt;<a class="email" href="mailto:nico-cdist--@--schottelius.org">nico-cdist--@--schottelius.org</a>&gt;</code></div></div></div><hr /></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="section"><a href="#_name">1. NAME</a></span></dt><dt><span class="section"><a href="#_error_in_manifest_is_not_considered_an_error_by_cdist">2. ERROR IN MANIFEST IS NOT CONSIDERED AN ERROR BY CDIST</a></span></dt><dt><span class="section"><a href="#_see_also">3. SEE ALSO</a></span></dt><dt><span class="section"><a href="#_copying">4. COPYING</a></span></dt></dl></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_name"></a>1. NAME</h2></div></div></div><p>cdist-troubleshooting - common problems and their solutions</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_error_in_manifest_is_not_considered_an_error_by_cdist"></a>2. ERROR IN MANIFEST IS NOT CONSIDERED AN ERROR BY CDIST</h2></div></div></div><p>Situation: You are executing other scripts from a manifest.
This script fails, but cdist does not recognise the error.
An example script would be something like this:</p><pre class="screen">% cat ~/.cdist/manifest/init
"$__manifest/special"
% cat ~/.cdist/manifest/special
#!/bin/sh
echo "Here is an unclean exiting script"
somecommandthatdoesnotexist
echo "I continue here although previous command failed"</pre><p>We can clearly see that <span class="strong"><strong>somecommandthatdoesnotexist</strong></span>
will fail in ~/.cdist/manifest/special. But as the custom
script is not called with the -e flag (exit on failure) of shell,
it does not lead to an error. And thus cdist sees the exit 0
code of the last echo line instead of the failing command.</p><p>All scripts executed by cdist carry the -e flag.
To prevent the above from happening, there are three solutions available,
two of which can be used in the calling script:</p><pre class="screen"># Execute as before, but abort on failure
sh -e "$__manifest/special"
# Source the script in our namespace, runs in a set -e environment:
. "$__manifest/special"</pre><p>The third solution is to include a shebang header in every script
you write to use the -e flag:</p><pre class="screen">% cat ~/.cdist/manifest/special
#!/bin/sh -e
...</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_see_also"></a>3. SEE ALSO</h2></div></div></div><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
cdist(1)
</li><li class="listitem">
cdist-tutorial(7)
</li></ul></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_copying"></a>4. COPYING</h2></div></div></div><p>Copyright (C) 2013 Nico Schottelius. Free use of this software is
granted under the terms of the GNU General Public License version 3 (GPLv3).</p></div></div></body></html>