61 lines
5.6 KiB
HTML
61 lines
5.6 KiB
HTML
|
<?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-messaging(7)</title><link rel="stylesheet" type="text/css" href="docbook-xsl.css" /><meta name="generator" content="DocBook XSL Stylesheets V1.76.1" /></head><body><div xml:lang="en" class="article" title="cdist-messaging(7)" lang="en"><div class="titlepage"><div><div><h2 class="title"><a id="idp64742480"></a>cdist-messaging(7)</h2></div><div><div class="author"><h3 class="author"><span class="firstname">Nico</span> <span class="surname">Schottelius</span></h3><code class="email"><<a class="email" href="mailto:nico-cdist--@--schottelius.org">nico-cdist--@--schottelius.org</a>></code></div></div></div><hr /></div><div class="toc"><p><strong>Table of Contents</strong></p><dl><dt><span class="section"><a href="#_name">1. NAME</a></span></dt><dt><span class="section"><a href="#_description">2. DESCRIPTION</a></span></dt><dt><span class="section"><a href="#_availability">3. AVAILABILITY</a></span></dt><dt><span class="section"><a href="#_examples">4. EXAMPLES</a></span></dt><dt><span class="section"><a href="#_see_also">5. SEE ALSO</a></span></dt><dt><span class="section"><a href="#_copying">6. COPYING</a></span></dt></dl></div><div class="section" title="1. NAME"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_name"></a>1. NAME</h2></div></div></div><p>cdist-messaging - How the initial manifest and types can communication</p></div><div class="section" title="2. DESCRIPTION"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_description"></a>2. DESCRIPTION</h2></div></div></div><p>cdist has a simple but powerful way of allowing communication between
|
|||
|
the initial manifest and types as well as types and types.</p><p>Whenever execution is passed from cdist to one of the
|
|||
|
scripts described below, cdist generate 2 new temporary files
|
|||
|
and exports the environment variables <span class="emphasis"><em>messages_in and
|
|||
|
</em></span>messages_out to point to them.</p><p>Before handing over the control, the content of the global message
|
|||
|
file is copied into the file referenced by $__messages_in.</p><p>After cdist gained control back, the content of the file referenced
|
|||
|
by $__messages_out is appended to the global message file.</p><p>This way overwriting any of the two files by accident does not
|
|||
|
interfere with other types.</p><p>The order of execution is not defined unless you create dependencies
|
|||
|
between the different objects (see <a href="../man7/cdist-manifest.html">cdist-manifest(7)</a>) and thus you
|
|||
|
can only react reliably on messages by objects that you depend on.</p></div><div class="section" title="3. AVAILABILITY"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_availability"></a>3. AVAILABILITY</h2></div></div></div><p>Messaging is possible between all <span class="strong"><strong>local</strong></span> scripts:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
|
|||
|
initial manifest
|
|||
|
</li><li class="listitem">
|
|||
|
type/manifest
|
|||
|
</li><li class="listitem">
|
|||
|
type/gencode-local
|
|||
|
</li><li class="listitem">
|
|||
|
type/gencode-remote
|
|||
|
</li></ul></div></div><div class="section" title="4. EXAMPLES"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_examples"></a>4. EXAMPLES</h2></div></div></div><p>When you want to emit a message use:</p><pre class="screen">echo "something" >> "$__messages_out"</pre><p>When you want to react on a message use:</p><pre class="screen">if grep -q "^__your_type/object/id:something" "$__messages_in"; then
|
|||
|
echo "I do something else"
|
|||
|
fi</pre><p>Some real life examples:</p><pre class="screen"># Reacting on changes from block for keepalive
|
|||
|
if grep -q "^__block/keepalive-vrrp" "$__messages_in"; then
|
|||
|
echo /etc/init.d/keepalived restart
|
|||
|
fi
|
|||
|
|
|||
|
# Reacting on changes of configuration files
|
|||
|
if grep -q "^__file/etc/one" $__messages_in; then
|
|||
|
echo 'for init in /etc/init.d/opennebula*; do $init restart; done'
|
|||
|
fi</pre><p>Restart sshd on changes</p><pre class="screen">os="$(cat "$__global/explorer/os")"
|
|||
|
|
|||
|
case "$os" in
|
|||
|
centos|redhat|suse)
|
|||
|
restart="/etc/init.d/sshd restart"
|
|||
|
;;
|
|||
|
debian|ubuntu)
|
|||
|
restart="/etc/init.d/ssh restart"
|
|||
|
;;
|
|||
|
*)
|
|||
|
cat << eof >&2
|
|||
|
Unsupported os $os.
|
|||
|
If you would like to have this type running on $os,
|
|||
|
you can either develop the changes and send a pull
|
|||
|
request or ask for a quote at www.ungleich.ch
|
|||
|
eof
|
|||
|
exit 1
|
|||
|
;;
|
|||
|
esac
|
|||
|
|
|||
|
if grep -q "^__key_value/PermitRootLogin" "$__messages_in"; then
|
|||
|
echo $restart
|
|||
|
fi</pre></div><div class="section" title="5. SEE ALSO"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_see_also"></a>5. SEE ALSO</h2></div></div></div><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
|
|||
|
<a href="../man1/cdist.html">cdist(1)</a>
|
|||
|
</li><li class="listitem">
|
|||
|
<a href="../man7/cdist-manifest.html">cdist-manifest(7)</a>
|
|||
|
</li><li class="listitem">
|
|||
|
<a href="../man7/cdist-reference.html">cdist-reference(7)</a>
|
|||
|
</li><li class="listitem">
|
|||
|
<a href="../man7/cdist-type.html">cdist-type(7)</a>
|
|||
|
</li></ul></div></div><div class="section" title="6. COPYING"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_copying"></a>6. 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>
|