541 lines
No EOL
34 KiB
HTML
541 lines
No EOL
34 KiB
HTML
|
|
|
|
<!DOCTYPE html>
|
|
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
|
|
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
|
|
<head>
|
|
<meta charset="utf-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
<title>6. cdist-manifest(7) — cdist 4.1.0 documentation</title>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
|
|
|
|
|
|
|
|
|
|
|
|
<link rel="top" title="cdist 4.1.0 documentation" href="../index.html"/>
|
|
<link rel="next" title="7. cdist-messaging(7)" href="cdist-messaging.html"/>
|
|
<link rel="prev" title="5. cdist-hacker(7)" href="cdist-hacker.html"/>
|
|
|
|
|
|
<script src="../_static/js/modernizr.min.js"></script>
|
|
|
|
</head>
|
|
|
|
<body class="wy-body-for-nav" role="document">
|
|
|
|
<div class="wy-grid-for-nav">
|
|
|
|
|
|
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
|
<div class="wy-side-scroll">
|
|
<div class="wy-side-nav-search">
|
|
|
|
|
|
|
|
<a href="../index.html" class="icon icon-home"> cdist
|
|
|
|
|
|
|
|
</a>
|
|
|
|
|
|
|
|
|
|
<div class="version">
|
|
4.1.0
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div role="search">
|
|
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
|
|
<input type="text" name="q" placeholder="Search docs" />
|
|
<input type="hidden" name="check_keywords" value="yes" />
|
|
<input type="hidden" name="area" value="default" />
|
|
</form>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
|
|
|
|
|
|
|
|
<ul class="current">
|
|
<li class="toctree-l1"><a class="reference internal" href="../man1/cdist.html">1. cdist(1)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-best-practice.html">2. cdist-best-practice(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-bootstrap.html">3. cdist-bootstrap(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-explorer.html">4. cdist-explorer(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-hacker.html">5. cdist-hacker(7)</a></li>
|
|
<li class="toctree-l1 current"><a class="current reference internal" href="#">6. cdist-manifest(7)</a><ul class="simple">
|
|
</ul>
|
|
</li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-messaging.html">7. cdist-messaging(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-quickstart.html">8. cdist-quickstart(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-reference.html">9. cdist-reference(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-remote-exec-copy.html">10. cdist-remote-exec-copy(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-stages.html">11. cdist-stages(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-troubleshooting.html">12. cdist-troubleshooting(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-tutorial.html">13. cdist-tutorial(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type.html">14. cdist-type(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__apt_key.html">15. cdist-type__apt_key(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__apt_key_uri.html">16. cdist-type__apt_key_uri(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__apt_norecommends.html">17. cdist-type__apt_norecommends(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__apt_ppa.html">18. cdist-type__apt_ppa(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__apt_source.html">19. cdist-type__apt_source(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__apt_update_index.html">20. cdist-type__apt_update_index(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__block.html">21. cdist-type__block(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__ccollect_source.html">22. cdist-type__ccollect_source(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__cdist.html">23. cdist-type__cdist(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__cdistmarker.html">24. cdist-type__cdistmarker(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__config_file.html">25. cdist-type__config_file(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__consul.html">26. cdist-type__consul(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__consul_agent.html">27. cdist-type__consul_agent(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__consul_check.html">28. cdist-type__consul_check(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__consul_reload.html">29. cdist-type__consul_reload(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__consul_service.html">30. cdist-type__consul_service(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__consul_template.html">31. cdist-type__consul_template(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__consul_template_template.html">32. cdist-type__consul_template_template(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__consul_watch_checks.html">33. cdist-type__consul_watch_checks(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__consul_watch_event.html">34. cdist-type__consul_watch_event(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__consul_watch_key.html">35. cdist-type__consul_watch_key(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__consul_watch_keyprefix.html">36. cdist-type__consul_watch_keyprefix(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__consul_watch_nodes.html">37. cdist-type__consul_watch_nodes(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__consul_watch_service.html">38. cdist-type__consul_watch_service(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__consul_watch_services.html">39. cdist-type__consul_watch_services(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__cron.html">40. cdist-type__cron(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__debconf_set_selections.html">41. cdist-type__debconf_set_selections(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__directory.html">42. cdist-type__directory(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__dog_vdi.html">43. cdist-type__dog_vdi(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__file.html">44. cdist-type__file(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__firewalld_rule.html">45. cdist-type__firewalld_rule(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__git.html">46. cdist-type__git(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__group.html">47. cdist-type__group(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__hostname.html">48. cdist-type__hostname(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__iptables_apply.html">49. cdist-type__iptables_apply(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__iptables_rule.html">50. cdist-type__iptables_rule(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__issue.html">51. cdist-type__issue(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__jail.html">52. cdist-type__jail(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__key_value.html">53. cdist-type__key_value(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__line.html">54. cdist-type__line(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__link.html">55. cdist-type__link(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__locale.html">56. cdist-type__locale(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__motd.html">57. cdist-type__motd(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__mount.html">58. cdist-type__mount(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__mysql_database.html">59. cdist-type__mysql_database(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__package.html">60. cdist-type__package(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__package_apt.html">61. cdist-type__package_apt(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__package_emerge.html">62. cdist-type__package_emerge(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__package_emerge_dependencies.html">63. cdist-type__package_emerge_dependencies(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__package_luarocks.html">64. cdist-type__package_luarocks(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__package_opkg.html">65. cdist-type__package_opkg(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__package_pacman.html">66. cdist-type__package_pacman(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__package_pip.html">67. cdist-type__package_pip(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__package_pkg_freebsd.html">68. cdist-type__package_pkg_freebsd(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__package_pkg_openbsd.html">69. cdist-type__package_pkg(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__package_pkgng_freebsd.html">70. cdist-type__package_pkgng_freebsd(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__package_rubygem.html">71. cdist-type__package_rubygem(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__package_update_index.html">72. cdist-type__package_update_index(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__package_upgrade_all.html">73. cdist-type__package_upgrade_all(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__package_yum.html">74. cdist-type__package_yum(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__package_zypper.html">75. cdist-type__package_zypper(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__pacman_conf.html">76. cdist-type__pacman_conf(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__pacman_conf_integrate.html">77. cdist-type__pacman_conf_integrate(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__pf_apply.html">78. cdist-type__pf_apply(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__pf_ruleset.html">79. cdist-type__pf_ruleset(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__postfix.html">80. cdist-type__postfix(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__postfix_master.html">81. cdist-type__postfix_master(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__postfix_postconf.html">82. cdist-type__postfix_postconf(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__postfix_postmap.html">83. cdist-type__postfix_postmap(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__postfix_reload.html">84. cdist-type__postfix_reload(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__postgres_database.html">85. cdist-type__postgres_database(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__postgres_role.html">86. cdist-type__postgres_role(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__process.html">87. cdist-type__process(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__pyvenv.html">88. cdist-type__pyvenv(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__qemu_img.html">89. cdist-type__qemu_img(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__rbenv.html">90. cdist-type__rbenv(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__rsync.html">91. cdist-type__rsync(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__rvm.html">92. cdist-type__rvm(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__rvm_gem.html">93. cdist-type__rvm_gemset(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__rvm_gemset.html">94. cdist-type__rvm_gemset(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__rvm_ruby.html">95. cdist-type__rvm_ruby(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__ssh_authorized_key.html">96. cdist-type__ssh_authorized_key(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__ssh_authorized_keys.html">97. cdist-type__ssh_authorized_keys(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__ssh_dot_ssh.html">98. cdist-type__ssh_dot_ssh(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__staged_file.html">99. cdist-type__staged_file(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__start_on_boot.html">100. cdist-type__start_on_boot(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__timezone.html">101. cdist-type__timezone(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__update_alternatives.html">102. cdist-type__update_alternatives(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__user.html">103. cdist-type__user(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__user_groups.html">104. cdist-type__user_groups(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__yum_repo.html">105. cdist-type__yum_repo(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__zypper_repo.html">106. cdist-type__zypper_repo(7)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type__zypper_service.html">107. cdist-type__zypper_service(7)</a></li>
|
|
</ul>
|
|
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
|
|
|
|
|
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
|
|
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
|
<a href="../index.html">cdist</a>
|
|
</nav>
|
|
|
|
|
|
|
|
<div class="wy-nav-content">
|
|
<div class="rst-content">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div role="navigation" aria-label="breadcrumbs navigation">
|
|
<ul class="wy-breadcrumbs">
|
|
<li><a href="../index.html">Docs</a> »</li>
|
|
|
|
<li>6. cdist-manifest(7)</li>
|
|
<li class="wy-breadcrumbs-aside">
|
|
|
|
|
|
<a href="../_sources/man7/cdist-manifest.txt" rel="nofollow"> View page source</a>
|
|
|
|
|
|
</li>
|
|
</ul>
|
|
<hr/>
|
|
</div>
|
|
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
|
<div itemprop="articleBody">
|
|
|
|
<div class="section" id="cdist-manifest-7">
|
|
<h1>6. cdist-manifest(7)<a class="headerlink" href="#cdist-manifest-7" title="Permalink to this headline">¶</a></h1>
|
|
<p>(Re-)Use types</p>
|
|
<p>Nico Schottelius <<a class="reference external" href="mailto:nico-cdist--%40--schottelius.org">nico-cdist--<span>@</span>--schottelius<span>.</span>org</a>></p>
|
|
<div class="section" id="description">
|
|
<h2>6.1. DESCRIPTION<a class="headerlink" href="#description" title="Permalink to this headline">¶</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>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="c1"># Create object of type __package with the parameter state = absent</span>
|
|
<span class="n">__package</span> <span class="n">apache2</span> <span class="o">--</span><span class="n">state</span> <span class="n">absent</span>
|
|
|
|
<span class="c1"># Same with the __directory type</span>
|
|
<span class="n">__directory</span> <span class="o">/</span><span class="n">tmp</span><span class="o">/</span><span class="n">cdist</span> <span class="o">--</span><span class="n">state</span> <span class="n">present</span>
|
|
</pre></div>
|
|
</div>
|
|
<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>
|
|
</div>
|
|
<div class="section" id="initial-and-type-manifests">
|
|
<h2>6.2. INITIAL AND TYPE MANIFESTS<a class="headerlink" href="#initial-and-type-manifests" title="Permalink to this headline">¶</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 cdist-type(7).</p>
|
|
</div>
|
|
<div class="section" id="define-state-in-the-initial-manifest">
|
|
<h2>6.3. DEFINE STATE IN THE INITIAL MANIFEST<a class="headerlink" href="#define-state-in-the-initial-manifest" title="Permalink to this headline">¶</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
|
|
environment variable <strong>__target_host</strong>. Let’s have a look at a simple
|
|
example:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">__cdistmarker</span>
|
|
|
|
<span class="n">case</span> <span class="s2">"$__target_host"</span> <span class="ow">in</span>
|
|
<span class="n">localhost</span><span class="p">)</span>
|
|
<span class="n">__directory</span> <span class="o">/</span><span class="n">home</span><span class="o">/</span><span class="n">services</span><span class="o">/</span><span class="n">kvm</span><span class="o">-</span><span class="n">vm</span> <span class="o">--</span><span class="n">parents</span> <span class="n">yes</span>
|
|
<span class="p">;;</span>
|
|
<span class="n">esac</span>
|
|
</pre></div>
|
|
</div>
|
|
<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>
|
|
</div>
|
|
<div class="section" id="splitting-up-the-initial-manifest">
|
|
<h2>6.4. SPLITTING UP THE INITIAL MANIFEST<a class="headerlink" href="#splitting-up-the-initial-manifest" title="Permalink to this headline">¶</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 cdist-reference(7)).</p>
|
|
<p>The following example would include every file with a <strong>.sh</strong> suffix:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span># Include *.sh
|
|
for manifest in $__manifest/*.sh; do
|
|
# And source scripts into our shell environment
|
|
. "$manifest"
|
|
done
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="dependencies">
|
|
<h2>6.5. DEPENDENCIES<a class="headerlink" href="#dependencies" title="Permalink to this headline">¶</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 white space separated.</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span> <span class="mi">1</span> <span class="c1"># No dependency</span>
|
|
<span class="mi">2</span> <span class="n">__file</span> <span class="o">/</span><span class="n">etc</span><span class="o">/</span><span class="n">cdist</span><span class="o">-</span><span class="n">configured</span>
|
|
<span class="mi">3</span>
|
|
<span class="mi">4</span> <span class="c1"># Require above object</span>
|
|
<span class="mi">5</span> <span class="n">require</span><span class="o">=</span><span class="s2">"__file/etc/cdist-configured"</span> <span class="n">__link</span> <span class="o">/</span><span class="n">tmp</span><span class="o">/</span><span class="n">cdist</span><span class="o">-</span><span class="n">testfile</span> \
|
|
<span class="mi">6</span> <span class="o">--</span><span class="n">source</span> <span class="o">/</span><span class="n">etc</span><span class="o">/</span><span class="n">cdist</span><span class="o">-</span><span class="n">configured</span> <span class="o">--</span><span class="nb">type</span> <span class="n">symbolic</span>
|
|
<span class="mi">7</span>
|
|
<span class="mi">8</span> <span class="c1"># Require two objects</span>
|
|
<span class="mi">9</span> <span class="n">require</span><span class="o">=</span><span class="s2">"__file/etc/cdist-configured __link/tmp/cdist-testfile"</span> \
|
|
<span class="mi">10</span> <span class="n">__file</span> <span class="o">/</span><span class="n">tmp</span><span class="o">/</span><span class="n">cdist</span><span class="o">-</span><span class="n">another</span><span class="o">-</span><span class="n">testfile</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>Above the “require” variable is only set for the command that is
|
|
immediately following it. Dependencies should always be declared that way.</p>
|
|
<p>On line 4 you can see that the instantion of a type “__link” object needs
|
|
the object “__file/etc/cdist-configured” to be present, before it can proceed.</p>
|
|
<p>This also means that the “__link” command must make sure, that either
|
|
“__file/etc/cdist-configured” allready is present, or, if it’s not, it needs
|
|
to be created. The task of cdist is to make sure, that the dependency will be
|
|
resolved appropriately and thus “__file/etc/cdist-configured” be created
|
|
if necessary before “__link” proceeds (or to abort execution with an error).</p>
|
|
<p>If you really need to make all types depend on a common dependency, you can
|
|
export the “require” variable as well. But then, if you need to add extra
|
|
dependencies to a specific type, you have to make sure that you append these
|
|
to the globally already defined one.</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="c1"># First of all, update the package index</span>
|
|
<span class="n">__package_update_index</span>
|
|
<span class="c1"># Upgrade all the installed packages afterwards</span>
|
|
<span class="n">require</span><span class="o">=</span><span class="s2">"__package_update_index"</span> <span class="n">__package_upgrade_all</span>
|
|
<span class="c1"># Create a common dependency for all the next types so that they get to</span>
|
|
<span class="c1"># be executed only after the package upgrade has finished</span>
|
|
<span class="n">export</span> <span class="n">require</span><span class="o">=</span><span class="s2">"__package_upgrade_all"</span>
|
|
|
|
<span class="c1"># Ensure that lighttpd is installed after we have upgraded all the packages</span>
|
|
<span class="n">__package</span> <span class="n">lighttpd</span> <span class="o">--</span><span class="n">state</span> <span class="n">present</span>
|
|
<span class="c1"># Ensure that munin is installed after lighttpd is present and after all</span>
|
|
<span class="c1"># the packages are upgraded</span>
|
|
<span class="n">require</span><span class="o">=</span><span class="s2">"$require __package/lighttpd"</span> <span class="n">__package</span> <span class="n">munin</span> <span class="o">--</span><span class="n">state</span> <span class="n">present</span>
|
|
</pre></div>
|
|
</div>
|
|
<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 an more in depth description of the flow execution of manifests
|
|
in cdist-stages(7) and of how types work in cdist-type(7).</p>
|
|
</div>
|
|
<div class="section" id="create-dependencies-from-execution-order">
|
|
<h2>6.6. CREATE DEPENDENCIES FROM EXECUTION ORDER<a class="headerlink" href="#create-dependencies-from-execution-order" title="Permalink to this headline">¶</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>
|
|
</div>
|
|
<div class="section" id="overrides">
|
|
<h2>6.7. OVERRIDES<a class="headerlink" href="#overrides" title="Permalink to this headline">¶</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>
|
|
</div>
|
|
<div class="section" id="examples">
|
|
<h2>6.8. EXAMPLES<a class="headerlink" href="#examples" title="Permalink to this headline">¶</a></h2>
|
|
<p>The initial manifest may for instance contain the following code:</p>
|
|
<div class="highlight-sh"><div class="highlight"><pre><span></span><span class="c1"># Always create this file, so other sysadmins know cdist is used.</span>
|
|
__file /etc/cdist-configured
|
|
|
|
<span class="k">case</span> <span class="s2">"</span><span class="nv">$__target_host</span><span class="s2">"</span> in
|
|
my.server.name<span class="o">)</span>
|
|
__directory /root/bin/
|
|
__file /etc/issue.net --source <span class="s2">"</span><span class="nv">$__manifest</span><span class="s2">/issue.net</span>
|
|
<span class="s2"> ;;</span>
|
|
<span class="s2">esac</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>The manifest of the type “nologin” may look like this:</p>
|
|
<div class="highlight-sh"><div class="highlight"><pre><span></span>__file /etc/nologin --source <span class="s2">"</span><span class="nv">$__type</span><span class="s2">/files/default.nologin"</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>This example makes use of dependencies:</p>
|
|
<div class="highlight-sh"><div class="highlight"><pre><span></span><span class="c1"># Ensure that lighttpd is installed</span>
|
|
__package lighttpd --state present
|
|
<span class="c1"># Ensure that munin makes use of lighttpd instead of the default webserver</span>
|
|
<span class="c1"># package as decided by the package manager</span>
|
|
<span class="nv">require</span><span class="o">=</span><span class="s2">"__package/lighttpd"</span> __package munin --state present
|
|
</pre></div>
|
|
</div>
|
|
<p>How to override objects:</p>
|
|
<div class="highlight-sh"><div class="highlight"><pre><span></span><span class="c1"># for example in the inital manifest</span>
|
|
|
|
<span class="c1"># create user account foobar with some hash for password</span>
|
|
__user foobar --password <span class="s1">'some_fancy_hash'</span> --home /home/foobarexample
|
|
|
|
<span class="c1"># ... many statements and includes in the manifest later ...</span>
|
|
<span class="c1"># somewhere in a conditionally sourced manifest</span>
|
|
<span class="c1"># (e.g. for example only sourced if a special application is on the target host)</span>
|
|
|
|
<span class="c1"># this leads to an error ...</span>
|
|
__user foobar --password <span class="s1">'some_other_hash'</span>
|
|
|
|
<span class="c1"># this tells cdist, that you know that this is an override and should be accepted</span>
|
|
<span class="nv">CDIST_OVERRIDE</span><span class="o">=</span>yes __user foobar --password <span class="s1">'some_other_hash'</span>
|
|
<span class="c1"># it's only an override, means the parameter --home is not touched</span>
|
|
<span class="c1"># and stays at the original value of /home/foobarexample</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>Dependencies defined by execution order work as following:</p>
|
|
<div class="highlight-sh"><div class="highlight"><pre><span></span><span class="c1"># Tells cdist to execute all types in the order in which they are created ...</span>
|
|
<span class="nb">export</span> <span class="nv">CDIST_ORDER_DEPENDENCY</span><span class="o">=</span>on
|
|
__sample_type 1
|
|
<span class="nv">require</span><span class="o">=</span><span class="s2">"__some_type_somewhere/id"</span> __sample_type 2
|
|
__example_type 23
|
|
<span class="c1"># Now this types are executed in the creation order until the variable is unset</span>
|
|
<span class="nb">unset</span> CDIST_ORDER_DEPENDENCY
|
|
<span class="c1"># all now following types cdist makes the order ..</span>
|
|
__not_in_order_type 42
|
|
|
|
<span class="c1"># how it works :</span>
|
|
<span class="c1"># this lines above are translated to:</span>
|
|
__sample_type 1
|
|
<span class="nv">require</span><span class="o">=</span><span class="s2">"__some_type_somewhere/id __sample_type/1"</span> __sample_type 2
|
|
<span class="nv">require</span><span class="o">=</span><span class="s2">"__sample_type/2"</span> __example_type 23
|
|
__not_in_order_type 42
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="see-also">
|
|
<h2>6.9. SEE ALSO<a class="headerlink" href="#see-also" title="Permalink to this headline">¶</a></h2>
|
|
<ul class="simple">
|
|
<li><a class="reference external" href="cdist-tutorial.html">cdist-tutorial(7)</a></li>
|
|
<li><a class="reference external" href="cdist-type.html">cdist-type(7)</a></li>
|
|
</ul>
|
|
</div>
|
|
<div class="section" id="copying">
|
|
<h2>6.10. COPYING<a class="headerlink" href="#copying" title="Permalink to this headline">¶</a></h2>
|
|
<p>Copyright (C) 2010-2014 Nico Schottelius. Free use of this software is
|
|
granted under the terms of the GNU General Public License version 3 (GPLv3).</p>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<footer>
|
|
|
|
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
|
|
|
|
<a href="cdist-messaging.html" class="btn btn-neutral float-right" title="7. cdist-messaging(7)" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
|
|
|
|
|
|
<a href="cdist-hacker.html" class="btn btn-neutral" title="5. cdist-hacker(7)" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
|
|
|
|
</div>
|
|
|
|
|
|
<hr/>
|
|
|
|
<div role="contentinfo">
|
|
<p>
|
|
© Copyright .
|
|
|
|
</p>
|
|
</div>
|
|
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
|
|
|
</footer>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
var DOCUMENTATION_OPTIONS = {
|
|
URL_ROOT:'../',
|
|
VERSION:'4.1.0',
|
|
COLLAPSE_INDEX:false,
|
|
FILE_SUFFIX:'.html',
|
|
HAS_SOURCE: true
|
|
};
|
|
</script>
|
|
<script type="text/javascript" src="../_static/jquery.js"></script>
|
|
<script type="text/javascript" src="../_static/underscore.js"></script>
|
|
<script type="text/javascript" src="../_static/doctools.js"></script>
|
|
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript" src="../_static/js/theme.js"></script>
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
jQuery(function () {
|
|
SphinxRtdTheme.StickyNav.enable();
|
|
});
|
|
</script>
|
|
|
|
|
|
</body>
|
|
</html> |