<h1><spanclass="section-number">14. </span>Manifest<aclass="headerlink"href="#manifest"title="Permalink to this heading">¶</a></h1>
<sectionid="description">
<h2><spanclass="section-number">14.1. </span>Description<aclass="headerlink"href="#description"title="Permalink to this heading">¶</a></h2>
<p>Manifests are used to define which objects to create.
Objects are instances of <strong>types</strong>, like in object oriented programming languages.
An object is represented by the combination of
<strong>type + slash + object name</strong>: <strong>__file/etc/cdist-configured</strong> is an
object of the type <strong>__file</strong> with the name <strong>etc/cdist-configured</strong>.</p>
<p>All available types can be found in the <strong>cdist/conf/type/</strong> directory,
use <strong>ls cdist/conf/type</strong> to get the list of available types. If you have
setup the MANPATH correctly, you can use <strong>man cdist-reference</strong> to access
the reference with pointers to the manpages.</p>
<p>Types in manifests are used like normal command line tools. Let's have a look
at an example:</p>
<divclass="highlight-default notranslate"><divclass="highlight"><pre><span></span><spanclass="c1"># Create object of type __package with the parameter state = absent</span>
<p>These two lines create objects, which will later be used to realise the
configuration on the target host.</p>
<p>Manifests are executed locally as a shell script using <strong>/bin/sh -e</strong>.
The resulting objects are stored in an internal database.</p>
<p>The same object can be redefined in multiple different manifests as long as
the parameters are exactly the same.</p>
<p>In general, manifests are used to define which types are used depending
on given conditions.</p>
</section>
<sectionid="initial-and-type-manifests">
<h2><spanclass="section-number">14.2. </span>Initial and type manifests<aclass="headerlink"href="#initial-and-type-manifests"title="Permalink to this heading">¶</a></h2>
<p>Cdist knows about two types of manifests: The initial manifest and type
manifests. The initial manifest is used to define, which configurations
to apply to which hosts. The type manifests are used to create objects
from types. More about manifests in types can be found in <aclass="reference external"href="cdist-type.html">cdist type</a>.</p>
<h2><spanclass="section-number">14.3. </span>Define state in the initial manifest<aclass="headerlink"href="#define-state-in-the-initial-manifest"title="Permalink to this heading">¶</a></h2>
<p>The <strong>initial manifest</strong> is the entry point for cdist to find out, which
<strong>objects</strong> to configure on the selected host.
Cdist expects the initial manifest at <strong>cdist/conf/manifest/init</strong>.</p>
<p>Within this initial manifest you define which objects should be
created on which host. To distinguish between hosts, you can use the
<p>This manifest says: Independent of the host, always use the type
<strong>__cdistmarker</strong>, which creates the file <strong>/etc/cdist-configured</strong>,
with the timestamp as content.
The directory <strong>/home/services/kvm-vm</strong>, including all parent directories,
is only created on the host <strong>localhost</strong>.</p>
<p>As you can see, there is no magic involved, the manifest is simple shell code that
utilises cdist types. Every available type can be executed like a normal
command.</p>
</section>
<sectionid="splitting-up-the-initial-manifest">
<h2><spanclass="section-number">14.4. </span>Splitting up the initial manifest<aclass="headerlink"href="#splitting-up-the-initial-manifest"title="Permalink to this heading">¶</a></h2>
<p>If you want to split up your initial manifest, you can create other shell
scripts in <strong>cdist/conf/manifest/</strong> and include them in <strong>cdist/conf/manifest/init</strong>.
Cdist provides the environment variable <strong>__manifest</strong> to reference
the directory containing the initial manifest (see <aclass="reference external"href="cdist-reference.html">cdist reference</a>).</p>
<p>The following example would include every file with a <strong>.sh</strong> suffix:</p>
<divclass="highlight-default notranslate"><divclass="highlight"><pre><span></span># Include *.sh
for manifest in $__manifest/*.sh; do
# And source scripts into our shell environment
. "$manifest"
done
</pre></div>
</div>
</section>
<sectionid="dependencies">
<h2><spanclass="section-number">14.5. </span>Dependencies<aclass="headerlink"href="#dependencies"title="Permalink to this heading">¶</a></h2>
<p>If you want to describe that something requires something else, just
setup the variable "require" to contain the requirements. Multiple
requirements can be added separated with (optionally consecutive)
delimiters including space, tab and newline.</p>
<divclass="highlight-default notranslate"><divclass="highlight"><pre><span></span><spanclass="mi">1</span><spanclass="c1"># No dependency</span>
<p>All objects that are created in a type manifest are automatically required
from the type that is calling them. This is called "autorequirement" in
cdist jargon.</p>
<p>You can find a more in depth description of the flow execution of manifests
in <aclass="reference external"href="cdist-stages.html">cdist execution stages</a> and of how types work in <aclass="reference external"href="cdist-type.html">cdist type</a>.</p>
<h2><spanclass="section-number">14.6. </span>Create dependencies from execution order<aclass="headerlink"href="#create-dependencies-from-execution-order"title="Permalink to this heading">¶</a></h2>
<p>You can tell cdist to execute all types in the order in which they are created
in the manifest by setting up the variable CDIST_ORDER_DEPENDENCY.
When cdist sees that this variable is setup, the current created object
automatically depends on the previously created object.</p>
<p>It essentially helps you to build up blocks of code that build upon each other
(like first creating the directory xyz than the file below the directory).</p>
<p>Read also about <aclass="reference external"href="cdist-best-practice.html#notes-on-cdist-order-dependency">notes on CDIST_ORDER_DEPENDENCY</a>.</p>
<p>In version 6.2.0 semantic CDIST_ORDER_DEPENDENCY is finally fixed and well defined.</p>
<p>CDIST_ORDER_DEPENDENCY defines type order dependency context. Order dependency context
starts when CDIST_ORDER_DEPENDENCY is set, and ends when it is unset. After each
manifest execution finishes, any existing order dependency context is automatically
unset. This ensures that CDIST_ORDER_DEPENDENCY is valid within the manifest where it
is used. When order dependency context is defined then cdist executes types in the
order in which they are created in the manifest inside order dependency context.</p>
<p>Sometimes the best way to see how something works is to see examples.</p>
<p>Suppose you have defined <strong>initial manifest</strong>:</p>
<p>and there are no other dependencies from this manifest.</p>
</section>
<sectionid="overrides">
<h2><spanclass="section-number">14.7. </span>Overrides<aclass="headerlink"href="#overrides"title="Permalink to this heading">¶</a></h2>
<p>In some special cases, you would like to create an already defined object
with different parameters. In normal situations this leads to an error in cdist.
If you wish, you can setup the environment variable CDIST_OVERRIDE
(any value or even empty is ok) to tell cdist, that this object override is
wanted and should be accepted.
ATTENTION: Only use this feature if you are 100% sure in which order
cdist encounters the affected objects, otherwise this results
in an undefined situation.</p>
<p>If CDIST_OVERRIDE and CDIST_ORDER_DEPENDENCY are set for an object,
CDIST_ORDER_DEPENDENCY will be ignored, because adding a dependency in case of
overrides would result in circular dependencies, which is an error.</p>
</section>
<sectionid="examples">
<h2><spanclass="section-number">14.8. </span>Examples<aclass="headerlink"href="#examples"title="Permalink to this heading">¶</a></h2>
<p>The initial manifest may for instance contain the following code:</p>
<divclass="highlight-sh notranslate"><divclass="highlight"><pre><span></span><spanclass="c1"># Always create this file, so other sysadmins know cdist is used.</span>
<spanclass="c1"># it's only an override, means the parameter --home is not touched</span>
<spanclass="c1"># and stays at the original value of /home/foobarexample</span>
</pre></div>
</div>
<p>Dependencies defined by execution order work as following:</p>
<divclass="highlight-sh notranslate"><divclass="highlight"><pre><span></span><spanclass="c1"># Tells cdist to execute all types in the order in which they are created ...</span>