Debian Codegraph @

docs/src/cdist-troubleshooting.rst

raw
1 Troubleshooting
2 ===============
3
4 Error in manifest is not considered an error by cdist
5 -----------------------------------------------------
6 Situation: You are executing other scripts from a manifest.
7 This script fails, but cdist does not recognise the error.
8 An example script would be something like this:
9
10 .. code-block:: sh
11
12 % cat ~/.cdist/manifest/init
13 "$__manifest/special"
14 % cat ~/.cdist/manifest/special
15 #!/bin/sh
16 echo "Here is an unclean exiting script"
17 somecommandthatdoesnotexist
18 echo "I continue here although previous command failed"
19
20 We can clearly see that **somecommandthatdoesnotexist**
21 will fail in ~/.cdist/manifest/special. But as the custom
22 script is not called with the -e flag (exit on failure) of shell,
23 it does not lead to an error. And thus cdist sees the exit 0
24 code of the last echo line instead of the failing command.
25
26 All scripts executed by cdist carry the -e flag.
27 To prevent the above from happening, there are three solutions available,
28 two of which can be used in the calling script:
29
30 .. code-block:: sh
31
32 # Execute as before, but abort on failure
33 sh -e "$__manifest/special"
34
35 # Source the script in our namespace, runs in a set -e environment:
36 . "$__manifest/special"
37
38 The third solution is to include a shebang header in every script
39 you write to use the -e flag:
40
41 .. code-block:: sh
42
43 % cat ~/.cdist/manifest/special
44 #!/bin/sh -e
45 ...
46
47 Using debug dump helper script
48 ------------------------------
49 Since cdist stores data to local cache that can be used for debugging there
50 is a helper script that dumps data from local cache,
51 `cdist-dump <man1/cdist-dump.html>`_.
52
53 For more info see:
54
55 .. code-block:: sh
56
57 cdist-dump -h
58
59 Or from cdist git cloned directory:
60
61 .. code-block:: sh
62
63 ./scripts/cdist-dump -h
64