cdist-backup/docs/src/cdist-troubleshooting.rst

65 lines
1.8 KiB
ReStructuredText
Raw Normal View History

Troubleshooting
===============
Error in manifest is not considered an error by cdist
-----------------------------------------------------
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:
2016-05-20 06:50:56 +00:00
.. code-block:: sh
% 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"
We can clearly see that **somecommandthatdoesnotexist**
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.
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:
2016-05-20 06:50:56 +00:00
.. code-block:: sh
# 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"
The third solution is to include a shebang header in every script
you write to use the -e flag:
2016-05-20 06:50:56 +00:00
.. code-block:: sh
% cat ~/.cdist/manifest/special
#!/bin/sh -e
...
2019-04-05 10:13:53 +00:00
Using debug dump helper script
------------------------------
Since cdist stores data to local cache that can be used for debugging there
2019-05-19 11:40:24 +00:00
is a helper script that dumps data from local cache,
`cdist-dump <man1/cdist-dump.html>`_.
2019-04-05 10:13:53 +00:00
For more info see:
.. code-block:: sh
2019-04-11 11:52:33 +00:00
cdist-dump -h
2019-04-05 10:13:53 +00:00
Or from cdist git cloned directory:
.. code-block:: sh
2019-04-11 11:52:33 +00:00
./scripts/cdist-dump -h
2019-04-05 10:13:53 +00:00