575 lines
No EOL
37 KiB
HTML
575 lines
No EOL
37 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>14. cdist-type(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="15. cdist-type__apt_key(7)" href="cdist-type__apt_key.html"/>
|
|
<link rel="prev" title="13. cdist-tutorial(7)" href="cdist-tutorial.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"><a class="reference internal" href="cdist-manifest.html">6. cdist-manifest(7)</a></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 current"><a class="current reference internal" href="#">14. cdist-type(7)</a><ul class="simple">
|
|
</ul>
|
|
</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>14. cdist-type(7)</li>
|
|
<li class="wy-breadcrumbs-aside">
|
|
|
|
|
|
<a href="../_sources/man7/cdist-type.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-type-7">
|
|
<h1>14. cdist-type(7)<a class="headerlink" href="#cdist-type-7" title="Permalink to this headline">¶</a></h1>
|
|
<p>Functionality bundled</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="synopsis">
|
|
<h2>14.1. SYNOPSIS<a class="headerlink" href="#synopsis" title="Permalink to this headline">¶</a></h2>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">__TYPE</span> <span class="n">ID</span> <span class="o">--</span><span class="n">parameter</span> <span class="n">value</span> <span class="p">[</span><span class="o">--</span><span class="n">parameter</span> <span class="n">value</span> <span class="o">...</span><span class="p">]</span>
|
|
<span class="n">__TYPE</span> <span class="o">--</span><span class="n">parameter</span> <span class="n">value</span> <span class="p">[</span><span class="o">--</span><span class="n">parameter</span> <span class="n">value</span> <span class="o">...</span><span class="p">]</span> <span class="p">(</span><span class="k">for</span> <span class="n">singletons</span><span class="p">)</span>
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="description">
|
|
<h2>14.2. DESCRIPTION<a class="headerlink" href="#description" title="Permalink to this headline">¶</a></h2>
|
|
<p>Types are the main component of cdist and define functionality. If you
|
|
use cdist, you’ll write a type for every functionality you would like
|
|
to use.</p>
|
|
</div>
|
|
<div class="section" id="how-to-use-a-type">
|
|
<h2>14.3. HOW TO USE A TYPE<a class="headerlink" href="#how-to-use-a-type" title="Permalink to this headline">¶</a></h2>
|
|
<p>You can use types from the initial manifest or the type manifest like a
|
|
normal shell command:</p>
|
|
<div class="highlight-sh"><div class="highlight"><pre><span></span><span class="c1"># Creates empty file /etc/cdist-configured</span>
|
|
__file /etc/cdist-configured --type file
|
|
|
|
<span class="c1"># Ensure tree is installed</span>
|
|
__package tree --state installed
|
|
</pre></div>
|
|
</div>
|
|
<p>A list of supported types can be found in the cdist-reference(7) manpage.</p>
|
|
</div>
|
|
<div class="section" id="singleton-types">
|
|
<h2>14.4. SINGLETON TYPES<a class="headerlink" href="#singleton-types" title="Permalink to this headline">¶</a></h2>
|
|
<p>If a type is flagged as a singleton, it may be used only
|
|
once per host. This is useful for types which can be used only once on a
|
|
system. Singleton types do not take an object name as argument.</p>
|
|
<p>Example:</p>
|
|
<div class="highlight-sh"><div class="highlight"><pre><span></span><span class="c1"># __issue type manages /etc/issue</span>
|
|
__issue
|
|
|
|
<span class="c1"># Probably your own type - singletons may use parameters</span>
|
|
__myfancysingleton --colour green
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="how-to-write-a-new-type">
|
|
<h2>14.5. HOW TO WRITE A NEW TYPE<a class="headerlink" href="#how-to-write-a-new-type" title="Permalink to this headline">¶</a></h2>
|
|
<p>A type consists of</p>
|
|
<ul class="simple">
|
|
<li>parameter (optional)</li>
|
|
<li>manifest (optional)</li>
|
|
<li>singleton (optional)</li>
|
|
<li>explorer (optional)</li>
|
|
<li>gencode (optional)</li>
|
|
</ul>
|
|
<p>Types are stored below cdist/conf/type/. Their name should always be prefixed with
|
|
two underscores (__) to prevent collisions with other executables in $PATH.</p>
|
|
<p>To implement a new type, create the directory <strong>cdist/conf/type/__NAME</strong>.</p>
|
|
</div>
|
|
<div class="section" id="defining-parameters">
|
|
<h2>14.6. DEFINING PARAMETERS<a class="headerlink" href="#defining-parameters" title="Permalink to this headline">¶</a></h2>
|
|
<p>Every type consists of required, optional and boolean parameters, which must
|
|
each be declared in a newline separated file in <strong>parameter/required</strong>,
|
|
<strong>parameter/required_multiple</strong>, <strong>parameter/optional</strong>,
|
|
<strong>parameter/optional_multiple</strong> and <strong>parameter/boolean</strong>.
|
|
Parameters which are allowed multiple times should be listed in
|
|
required_multiple or optional_multiple respectively. All other parameters
|
|
follow the standard unix behaviour “the last given wins”.
|
|
If either is missing, the type will have no required, no optional, no boolean
|
|
or no parameters at all.</p>
|
|
<p>Default values for optional parameters can be predefined in
|
|
<strong>parameter/default/<name></strong>.</p>
|
|
<p>Example:</p>
|
|
<div class="highlight-sh"><div class="highlight"><pre><span></span><span class="nb">echo</span> servername >> cdist/conf/type/__nginx_vhost/parameter/required
|
|
<span class="nb">echo</span> logdirectory >> cdist/conf/type/__nginx_vhost/parameter/optional
|
|
<span class="nb">echo</span> loglevel >> cdist/conf/type/__nginx_vhost/parameter/optional
|
|
mkdir cdist/conf/type/__nginx_vhost/parameter/default
|
|
<span class="nb">echo</span> warning > cdist/conf/type/__nginx_vhost/parameter/default/loglevel
|
|
<span class="nb">echo</span> server_alias >> cdist/conf/type/__nginx_vhost/parameter/optional_multiple
|
|
<span class="nb">echo</span> use_ssl >> cdist/conf/type/__nginx_vhost/parameter/boolean
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="using-parameters">
|
|
<h2>14.7. USING PARAMETERS<a class="headerlink" href="#using-parameters" title="Permalink to this headline">¶</a></h2>
|
|
<p>The parameters given to a type can be accessed and used in all type scripts
|
|
(e.g manifest, gencode, explorer). Note that boolean parameters are
|
|
represented by file existence. File exists -> True,
|
|
file does not exist -> False</p>
|
|
<p>Example: (e.g. in cdist/conf/type/__nginx_vhost/manifest)</p>
|
|
<div class="highlight-sh"><div class="highlight"><pre><span></span><span class="c1"># required parameter</span>
|
|
<span class="nv">servername</span><span class="o">=</span><span class="s2">"</span><span class="k">$(</span>cat <span class="s2">"</span><span class="nv">$__object</span><span class="s2">/parameter/servername"</span><span class="k">)</span><span class="s2">"</span>
|
|
|
|
<span class="c1"># optional parameter</span>
|
|
<span class="k">if</span> <span class="o">[</span> -f <span class="s2">"</span><span class="nv">$__object</span><span class="s2">/parameter/logdirectory"</span> <span class="o">]</span><span class="p">;</span> <span class="k">then</span>
|
|
<span class="nv">logdirectory</span><span class="o">=</span><span class="s2">"</span><span class="k">$(</span>cat <span class="s2">"</span><span class="nv">$__object</span><span class="s2">/parameter/logdirectory"</span><span class="k">)</span><span class="s2">"</span>
|
|
<span class="k">fi</span>
|
|
|
|
<span class="c1"># optional parameter with predefined default</span>
|
|
<span class="nv">loglevel</span><span class="o">=</span><span class="s2">"</span><span class="k">$(</span>cat <span class="s2">"</span><span class="nv">$__object</span><span class="s2">/parameter/loglevel"</span><span class="k">)</span><span class="s2">"</span>
|
|
|
|
<span class="c1"># boolean parameter</span>
|
|
<span class="k">if</span> <span class="o">[</span> -f <span class="s2">"</span><span class="nv">$__object</span><span class="s2">/parameter/use_ssl"</span> <span class="o">]</span><span class="p">;</span> <span class="k">then</span>
|
|
<span class="c1"># file exists -> True</span>
|
|
<span class="c1"># do some fancy ssl stuff</span>
|
|
<span class="k">fi</span>
|
|
|
|
<span class="c1"># parameter with multiple values</span>
|
|
<span class="k">if</span> <span class="o">[</span> -f <span class="s2">"</span><span class="nv">$__object</span><span class="s2">/parameter/server_alias"</span> <span class="o">]</span><span class="p">;</span> <span class="k">then</span>
|
|
<span class="k">for</span> <span class="nb">alias</span> in <span class="k">$(</span>cat <span class="s2">"</span><span class="nv">$__object</span><span class="s2">/parameter/server_alias"</span><span class="k">)</span><span class="p">;</span> <span class="k">do</span>
|
|
<span class="nb">echo</span> <span class="nv">$alias</span> > /some/where/usefull
|
|
<span class="k">done</span>
|
|
<span class="k">fi</span>
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="input-from-stdin">
|
|
<h2>14.8. INPUT FROM STDIN<a class="headerlink" href="#input-from-stdin" title="Permalink to this headline">¶</a></h2>
|
|
<p>Every type can access what has been written on stdin when it has been called.
|
|
The result is saved into the <strong>stdin</strong> file in the object directory.</p>
|
|
<p>Example use of a type: (e.g. in cdist/conf/type/__archlinux_hostname)</p>
|
|
<div class="highlight-sh"><div class="highlight"><pre><span></span>__file /etc/rc.conf --source - <span class="s"><< eof</span>
|
|
<span class="s">...</span>
|
|
<span class="s">HOSTNAME="$__target_host"</span>
|
|
<span class="s">...</span>
|
|
<span class="s">eof</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>If you have not seen this syntax (<< eof) before, it may help you to read
|
|
about “here documents”.</p>
|
|
<p>In the __file type, stdin is used as source for the file, if - is used for source:</p>
|
|
<div class="highlight-sh"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="o">[</span> -f <span class="s2">"</span><span class="nv">$__object</span><span class="s2">/parameter/source"</span> <span class="o">]</span><span class="p">;</span> <span class="k">then</span>
|
|
<span class="nv">source</span><span class="o">=</span><span class="s2">"</span><span class="k">$(</span>cat <span class="s2">"</span><span class="nv">$__object</span><span class="s2">/parameter/source"</span><span class="k">)</span><span class="s2">"</span>
|
|
<span class="k">if</span> <span class="o">[</span> <span class="s2">"</span><span class="nv">$source</span><span class="s2">"</span> <span class="o">=</span> <span class="s2">"-"</span> <span class="o">]</span><span class="p">;</span> <span class="k">then</span>
|
|
<span class="nv">source</span><span class="o">=</span><span class="s2">"</span><span class="nv">$__object</span><span class="s2">/stdin"</span>
|
|
<span class="k">fi</span>
|
|
....
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="writing-the-manifest">
|
|
<h2>14.9. WRITING THE MANIFEST<a class="headerlink" href="#writing-the-manifest" title="Permalink to this headline">¶</a></h2>
|
|
<p>In the manifest of a type you can use other types, so your type extends
|
|
their functionality. A good example is the __package type, which in
|
|
a shortened version looks like this:</p>
|
|
<div class="highlight-sh"><div class="highlight"><pre><span></span><span class="nv">os</span><span class="o">=</span><span class="s2">"</span><span class="k">$(</span>cat <span class="s2">"</span><span class="nv">$__global</span><span class="s2">/explorer/os"</span><span class="k">)</span><span class="s2">"</span>
|
|
<span class="k">case</span> <span class="s2">"</span><span class="nv">$os</span><span class="s2">"</span> in
|
|
archlinux<span class="o">)</span> <span class="nv">type</span><span class="o">=</span><span class="s2">"pacman"</span> <span class="p">;;</span>
|
|
debian<span class="p">|</span>ubuntu<span class="o">)</span> <span class="nv">type</span><span class="o">=</span><span class="s2">"apt"</span> <span class="p">;;</span>
|
|
gentoo<span class="o">)</span> <span class="nv">type</span><span class="o">=</span><span class="s2">"emerge"</span> <span class="p">;;</span>
|
|
*<span class="o">)</span>
|
|
<span class="nb">echo</span> <span class="s2">"Don't know how to manage packages on: </span><span class="nv">$os</span><span class="s2">"</span> ><span class="p">&</span>2
|
|
<span class="nb">exit</span> 1
|
|
<span class="p">;;</span>
|
|
<span class="k">esac</span>
|
|
|
|
__package_<span class="nv">$type</span> <span class="s2">"</span><span class="nv">$@</span><span class="s2">"</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>As you can see, the type can reference different environment variables,
|
|
which are documented in cdist-reference(7).</p>
|
|
<p>Always ensure the manifest is executable, otherwise cdist will not be able
|
|
to execute it. For more information about manifests see cdist-manifest(7).</p>
|
|
</div>
|
|
<div class="section" id="singleton-one-instance-only">
|
|
<h2>14.10. SINGLETON - ONE INSTANCE ONLY<a class="headerlink" href="#singleton-one-instance-only" title="Permalink to this headline">¶</a></h2>
|
|
<p>If you want to ensure that a type can only be used once per target, you can
|
|
mark it as a singleton: Just create the (empty) file “singleton” in your type
|
|
directory:</p>
|
|
<div class="highlight-sh"><div class="highlight"><pre><span></span>touch cdist/conf/type/__NAME/singleton
|
|
</pre></div>
|
|
</div>
|
|
<p>This will also change the way your type must be called:</p>
|
|
<div class="highlight-sh"><div class="highlight"><pre><span></span>__YOURTYPE --parameter value
|
|
</pre></div>
|
|
</div>
|
|
<p>As you can see, the object ID is omitted, because it does not make any sense,
|
|
if your type can be used only once.</p>
|
|
</div>
|
|
<div class="section" id="the-type-explorers">
|
|
<h2>14.11. THE TYPE EXPLORERS<a class="headerlink" href="#the-type-explorers" title="Permalink to this headline">¶</a></h2>
|
|
<p>If a type needs to explore specific details, it can provide type specific
|
|
explorers, which will be executed on the target for every created object.</p>
|
|
<p>The explorers are stored under the “explorer” directory below the type.
|
|
It could for instance contain code to check the md5sum of a file on the
|
|
client, like this (shortened version from the type __file):</p>
|
|
<div class="highlight-sh"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="o">[</span> -f <span class="s2">"</span><span class="nv">$__object</span><span class="s2">/parameter/destination"</span> <span class="o">]</span><span class="p">;</span> <span class="k">then</span>
|
|
<span class="nv">destination</span><span class="o">=</span><span class="s2">"</span><span class="k">$(</span>cat <span class="s2">"</span><span class="nv">$__object</span><span class="s2">/parameter/destination"</span><span class="k">)</span><span class="s2">"</span>
|
|
<span class="k">else</span>
|
|
<span class="nv">destination</span><span class="o">=</span><span class="s2">"/</span><span class="nv">$__object_id</span><span class="s2">"</span>
|
|
<span class="k">fi</span>
|
|
|
|
<span class="k">if</span> <span class="o">[</span> -e <span class="s2">"</span><span class="nv">$destination</span><span class="s2">"</span> <span class="o">]</span><span class="p">;</span> <span class="k">then</span>
|
|
md5sum < <span class="s2">"</span><span class="nv">$destination</span><span class="s2">"</span>
|
|
<span class="k">fi</span>
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="writing-the-gencode-script">
|
|
<h2>14.12. WRITING THE GENCODE SCRIPT<a class="headerlink" href="#writing-the-gencode-script" title="Permalink to this headline">¶</a></h2>
|
|
<p>There are two gencode scripts: <strong>gencode-local</strong> and <strong>gencode-remote</strong>.
|
|
The output of gencode-local is executed locally, whereas
|
|
the output of gencode-remote is executed on the target.
|
|
The gencode scripts can make use of the parameters, the global explorers
|
|
and the type specific explorers.</p>
|
|
<p>If the gencode scripts encounters an error, it should print diagnostic
|
|
messages to stderr and exit non-zero. If you need to debug the gencode
|
|
script, you can write to stderr:</p>
|
|
<div class="highlight-sh"><div class="highlight"><pre><span></span><span class="c1"># Debug output to stderr</span>
|
|
<span class="nb">echo</span> <span class="s2">"My fancy debug line"</span> ><span class="p">&</span>2
|
|
|
|
<span class="c1"># Output to be saved by cdist for execution on the target</span>
|
|
<span class="nb">echo</span> <span class="s2">"touch /etc/cdist-configured"</span>
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="variable-access-from-the-generated-scripts">
|
|
<h2>14.13. VARIABLE ACCESS FROM THE GENERATED SCRIPTS<a class="headerlink" href="#variable-access-from-the-generated-scripts" title="Permalink to this headline">¶</a></h2>
|
|
<p>In the generated scripts, you have access to the following cdist variables</p>
|
|
<ul class="simple">
|
|
<li>__object</li>
|
|
<li>__object_id</li>
|
|
</ul>
|
|
<p>but only for read operations, means there is no back copy of this
|
|
files after the script execution.</p>
|
|
<p>So when you generate a script with the following content, it will work:</p>
|
|
<div class="highlight-sh"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="o">[</span> -f <span class="s2">"</span><span class="nv">$__object</span><span class="s2">/parameter/name"</span> <span class="o">]</span><span class="p">;</span> <span class="k">then</span>
|
|
<span class="nv">name</span><span class="o">=</span><span class="s2">"</span><span class="k">$(</span>cat <span class="s2">"</span><span class="nv">$__object</span><span class="s2">/parameter/name"</span><span class="k">)</span><span class="s2">"</span>
|
|
<span class="k">else</span>
|
|
<span class="nv">name</span><span class="o">=</span><span class="s2">"</span><span class="nv">$__object_id</span><span class="s2">"</span>
|
|
<span class="k">fi</span>
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="hints-for-typewriters">
|
|
<h2>14.14. HINTS FOR TYPEWRITERS<a class="headerlink" href="#hints-for-typewriters" title="Permalink to this headline">¶</a></h2>
|
|
<p>It must be assumed that the target is pretty dumb and thus does not have high
|
|
level tools like ruby installed. If a type requires specific tools to be present
|
|
on the target, there must be another type that provides this tool and the first
|
|
type should create an object of the specific type.</p>
|
|
<p>If your type wants to save temporary data, that may be used by other types
|
|
later on (for instance __file), you can save them in the subdirectory
|
|
“files” below $__object (but you must create it yourself).
|
|
cdist will not touch this directory.</p>
|
|
<p>If your type contains static files, it’s also recommended to place them in
|
|
a folder named “files” within the type (again, because cdist guarantees to
|
|
never ever touch this folder).</p>
|
|
</div>
|
|
<div class="section" id="how-to-include-a-type-into-upstream-cdist">
|
|
<h2>14.15. HOW TO INCLUDE A TYPE INTO UPSTREAM CDIST<a class="headerlink" href="#how-to-include-a-type-into-upstream-cdist" title="Permalink to this headline">¶</a></h2>
|
|
<p>If you think your type may be useful for others, ensure it works with the
|
|
current master branch of cdist and have a look at cdist-hacker(7) on
|
|
how to submit it.</p>
|
|
</div>
|
|
<div class="section" id="see-also">
|
|
<h2>14.16. 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-explorer.html">cdist-explorer(7)</a></li>
|
|
<li><a class="reference external" href="cdist-hacker.html">cdist-hacker(7)</a></li>
|
|
<li><a class="reference external" href="cdist-stages.html">cdist-stages(7)</a></li>
|
|
<li><a class="reference external" href="cdist-tutorial.html">cdist-tutorial(7)</a></li>
|
|
</ul>
|
|
</div>
|
|
<div class="section" id="copying">
|
|
<h2>14.17. COPYING<a class="headerlink" href="#copying" title="Permalink to this headline">¶</a></h2>
|
|
<p>Copyright (C) 2011-2012 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-type__apt_key.html" class="btn btn-neutral float-right" title="15. cdist-type__apt_key(7)" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
|
|
|
|
|
|
<a href="cdist-tutorial.html" class="btn btn-neutral" title="13. cdist-tutorial(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> |