419 lines
No EOL
20 KiB
HTML
419 lines
No EOL
20 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>21. PreOS — cdist 4.10.7 documentation</title>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
|
|
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
|
<link rel="index" title="Index" href="genindex.html" />
|
|
<link rel="search" title="Search" href="search.html" />
|
|
<link rel="next" title="22. cdist integration / using cdist as library" href="cdist-integration.html" />
|
|
<link rel="prev" title="20. Trigger" href="cdist-trigger.html" />
|
|
|
|
|
|
<script src="_static/js/modernizr.min.js"></script>
|
|
|
|
</head>
|
|
|
|
<body class="wy-body-for-nav">
|
|
|
|
|
|
<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.10.7
|
|
</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="cdist-intro.html">1. cdist - usable configuration management</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-why.html">2. Why should I use cdist?</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-os.html">3. Supported Operating Systems</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-install.html">4. How to install cdist</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-update.html">5. How to update cdist</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-support.html">6. Support</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-features.html">7. Features</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-quickstart.html">8. Quickstart</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-real-world.html">9. Dive into real world cdist</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="man1/cdist.html">10. cdist(1)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-bootstrap.html">11. Bootstrap</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-configuration.html">12. Configuration</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-manifest.html">13. Manifest</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-type.html">14. cdist type</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-types.html">15. cdist types</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-explorer.html">16. Explorer</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-messaging.html">17. Messaging</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-parallelization.html">18. Parallelization</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-inventory.html">19. Inventory</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-trigger.html">20. Trigger</a></li>
|
|
<li class="toctree-l1 current"><a class="current reference internal" href="#">21. PreOS</a><ul>
|
|
<li class="toctree-l2"><a class="reference internal" href="#description">21.1. Description</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="#preos-creation">21.2. PreOS creation</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="#implementing-new-preos-sub-command">21.3. Implementing new PreOS sub-command</a><ul>
|
|
<li class="toctree-l3"><a class="reference internal" href="#example-writing-new-dummy-preos-sub-command">21.3.1. Example writing new dummy preos sub-command</a><ul>
|
|
<li class="toctree-l4"><a class="reference internal" href="#module-based-preos">21.3.1.1. Module based preos:</a></li>
|
|
<li class="toctree-l4"><a class="reference internal" href="#class-based-preos">21.3.1.2. Class based preos:</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
<li class="toctree-l2"><a class="reference internal" href="#simple-tipical-use-case-for-using-preos-and-trigger">21.4. Simple tipical use case for using PreOS and trigger</a></li>
|
|
</ul>
|
|
</li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-integration.html">22. cdist integration / using cdist as library</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-reference.html">23. Reference</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-best-practice.html">24. Best practice</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-stages.html">25. Execution stages</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-cache.html">26. Local cache overview</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-saving-output-streams.html">27. Saving output streams</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-remote-exec-copy.html">28. Remote exec and copy commands</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-hacker.html">29. Hacking</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdist-troubleshooting.html">30. Troubleshooting</a></li>
|
|
</ul>
|
|
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
|
|
|
|
|
<nav class="wy-nav-top" 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>21. PreOS</li>
|
|
|
|
|
|
<li class="wy-breadcrumbs-aside">
|
|
|
|
|
|
<a href="_sources/cdist-preos.rst.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="preos">
|
|
<h1>21. PreOS<a class="headerlink" href="#preos" title="Permalink to this headline">¶</a></h1>
|
|
<div class="section" id="description">
|
|
<h2>21.1. Description<a class="headerlink" href="#description" title="Permalink to this headline">¶</a></h2>
|
|
<p>With cdist you can install and configure new machines. You can use cdist to
|
|
create PreOS, minimal OS which purpose is to boot new machine.
|
|
After PreOS is booted machine is ready for installing desired OS and
|
|
then it is ready for configuration.</p>
|
|
</div>
|
|
<div class="section" id="preos-creation">
|
|
<h2>21.2. PreOS creation<a class="headerlink" href="#preos-creation" title="Permalink to this headline">¶</a></h2>
|
|
<p>With cdist you can create PreOS.
|
|
Currently supported PreOS-es include:</p>
|
|
<ul class="simple">
|
|
<li>debian</li>
|
|
<li>ubuntu</li>
|
|
<li>devuan.</li>
|
|
</ul>
|
|
<p>PreOS is created using cdist preos command. preos command has subcommands that
|
|
create the desired PreOS.</p>
|
|
<p>For example, to create ubuntu PreOS:</p>
|
|
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ cdist preos ubuntu /preos/preos-ubuntu -b -C <span class="se">\</span>
|
|
-k ~/.ssh/id_rsa.pub -p /preos/pxe-ubuntu <span class="se">\</span>
|
|
-t <span class="s2">"/usr/bin/curl 192.168.111.5:3000/cdist/install/"</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>For more info about available options see cdist manual page.</p>
|
|
<p>This will bootstrap (<code class="docutils literal notranslate"><span class="pre">-b</span></code>) ubuntu PreOS in <code class="docutils literal notranslate"><span class="pre">/preos/preos-ubuntu</span></code> directory, it
|
|
will be configured (<code class="docutils literal notranslate"><span class="pre">-C</span></code>) using default built-in initial manifest and with
|
|
specified ssh authorized key (<code class="docutils literal notranslate"><span class="pre">-k</span></code>) and with specified trigger command (<code class="docutils literal notranslate"><span class="pre">-t</span></code>).
|
|
After bootstrapping and configuration PXE
|
|
boot directory will be created (<code class="docutils literal notranslate"><span class="pre">-p</span></code>) in <code class="docutils literal notranslate"><span class="pre">/preos/pxe-ubuntu</span></code>.</p>
|
|
<p>After PreOS is created new machines can be booted using created PXE (after
|
|
proper dhcp, tftp setting).</p>
|
|
<p>Since PreOS is configured with ssh authorized key it can be accessed throguh
|
|
ssh, i.e. it can be further installed and configured with cdist.</p>
|
|
<p>When installing and configuring new machines using cdist's PreOS concept
|
|
cdist can use triggering for host installation/configuration, which is described
|
|
in the previous chapter.</p>
|
|
<p>When new machine is booted with PreOS then trigger command is executed.
|
|
Machine will connect to cdist trigger server. If the request is, for example,
|
|
for installation then cdist trigger server will start install command for the
|
|
client host using parameters specified at trigger server startup.</p>
|
|
</div>
|
|
<div class="section" id="implementing-new-preos-sub-command">
|
|
<h2>21.3. Implementing new PreOS sub-command<a class="headerlink" href="#implementing-new-preos-sub-command" title="Permalink to this headline">¶</a></h2>
|
|
<p>preos command is implemented as a plugin system. This plugin system scans for
|
|
preos subcommands in <code class="docutils literal notranslate"><span class="pre">cdist/preos/</span></code> distribution directory and also in
|
|
<code class="docutils literal notranslate"><span class="pre">~/.cdist/preos/</span></code> directory if it exists.</p>
|
|
<p>preos subcommand is a module or a class that satisfies the following:</p>
|
|
<ul class="simple">
|
|
<li>it has attribute <code class="docutils literal notranslate"><span class="pre">_cdist_preos</span></code> set to <code class="docutils literal notranslate"><span class="pre">True</span></code></li>
|
|
<li>it has function/method <code class="docutils literal notranslate"><span class="pre">commandline</span></code>.</li>
|
|
</ul>
|
|
<p>For a module based preos subcommand <code class="docutils literal notranslate"><span class="pre">commandline</span></code> function accepts a module
|
|
object as its first argument and the list of command line
|
|
arguments (<code class="docutils literal notranslate"><span class="pre">sys.argv[2:]</span></code>).</p>
|
|
<p>For a class preos subcommand <code class="docutils literal notranslate"><span class="pre">commandline</span></code> method should be staticmethod and
|
|
it accepts a class object as its first argument and the list of command line
|
|
arguments(<code class="docutils literal notranslate"><span class="pre">sys.argv[2:]</span></code>).</p>
|
|
<p>If preos scanning finds a module/class that has <code class="docutils literal notranslate"><span class="pre">_cdist_preos</span></code> set
|
|
to <code class="docutils literal notranslate"><span class="pre">True</span></code> and it has function/method <code class="docutils literal notranslate"><span class="pre">commandline</span></code> then this module/class is
|
|
registered to preos subcommands. The name of the command is set to <code class="docutils literal notranslate"><span class="pre">_preos_name</span></code>
|
|
attribute if it exists, otherwise it is set to the module/class name, lowercase.
|
|
When registered preos subcommand is specified as preos command then <code class="docutils literal notranslate"><span class="pre">commandline</span></code>
|
|
will be called with first argument set to module/class object and second argument
|
|
set to <code class="docutils literal notranslate"><span class="pre">sys.argv[2:]</span></code>.</p>
|
|
<div class="section" id="example-writing-new-dummy-preos-sub-command">
|
|
<h3>21.3.1. Example writing new dummy preos sub-command<a class="headerlink" href="#example-writing-new-dummy-preos-sub-command" title="Permalink to this headline">¶</a></h3>
|
|
<div class="section" id="module-based-preos">
|
|
<h4>21.3.1.1. Module based preos:<a class="headerlink" href="#module-based-preos" title="Permalink to this headline">¶</a></h4>
|
|
<ol class="arabic simple">
|
|
<li>Create directory <code class="docutils literal notranslate"><span class="pre">~/.cdist/preos/</span></code> if it does not exist</li>
|
|
<li>Create <code class="docutils literal notranslate"><span class="pre">~/.cdist/preos/netbsd.py</span></code> with the following contents:</li>
|
|
</ol>
|
|
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">_preos_name</span> <span class="o">=</span> <span class="s1">'netbsd'</span>
|
|
<span class="n">_cdist_preos</span> <span class="o">=</span> <span class="bp">True</span>
|
|
|
|
<span class="k">def</span> <span class="nf">commandline</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">args</span><span class="p">):</span>
|
|
<span class="k">print</span><span class="p">(</span><span class="s2">"NetBSD PreOS: {}"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">args</span><span class="p">))</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>When you try to run this new preos you will get:</p>
|
|
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ cdist preos -h
|
|
usage: cdist preos <span class="o">[</span>-h<span class="o">]</span> preos
|
|
|
|
Create PreOS
|
|
|
|
positional arguments:
|
|
preos PreOS to create, one of: <span class="o">{</span><span class="s1">'netbsd'</span>, <span class="s1">'debian'</span>, <span class="s1">'ubuntu'</span><span class="o">}</span>
|
|
|
|
optional arguments:
|
|
-h, --help show this <span class="nb">help</span> message and <span class="nb">exit</span>
|
|
$ cdist preos netbsd
|
|
NetBSD PreOS: <span class="o">[]</span>
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="class-based-preos">
|
|
<h4>21.3.1.2. Class based preos:<a class="headerlink" href="#class-based-preos" title="Permalink to this headline">¶</a></h4>
|
|
<ol class="arabic simple">
|
|
<li>Create directory <code class="docutils literal notranslate"><span class="pre">~/.cdist/preos/</span></code> if it does not exist</li>
|
|
<li>Create <code class="docutils literal notranslate"><span class="pre">~/.cdist/preos/freebsd.py</span></code> with the following contents:</li>
|
|
</ol>
|
|
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">FreeBSD</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
|
|
<span class="n">_cdist_preos</span> <span class="o">=</span> <span class="bp">True</span>
|
|
|
|
<span class="nd">@classmethod</span>
|
|
<span class="k">def</span> <span class="nf">commandline</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">args</span><span class="p">):</span>
|
|
<span class="k">print</span><span class="p">(</span><span class="s2">"FreeBSD dummy preos: {}"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">args</span><span class="p">))</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>When you try to run this new preos you will get:</p>
|
|
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ cdist preos -h
|
|
usage: cdist preos <span class="o">[</span>-h<span class="o">]</span> preos
|
|
|
|
Create PreOS
|
|
|
|
positional arguments:
|
|
preos PreOS to create, one of: <span class="o">{</span><span class="s1">'freebsd'</span>, <span class="s1">'debian'</span>, <span class="s1">'ubuntu'</span><span class="o">}</span>
|
|
|
|
optional arguments:
|
|
-h, --help show this <span class="nb">help</span> message and <span class="nb">exit</span>
|
|
$ cdist preos freebsd
|
|
FreeBSD dummy preos: <span class="o">[]</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>In the <code class="docutils literal notranslate"><span class="pre">commandline</span></code> function/method you have all the freedom to actually create
|
|
PreOS.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="simple-tipical-use-case-for-using-preos-and-trigger">
|
|
<h2>21.4. Simple tipical use case for using PreOS and trigger<a class="headerlink" href="#simple-tipical-use-case-for-using-preos-and-trigger" title="Permalink to this headline">¶</a></h2>
|
|
<p>Tipical use case for using PreOS and trigger command include the following steps.</p>
|
|
<ol class="arabic">
|
|
<li><p class="first">Create PreOS PXE with ssh key and trigger command for installation.</p>
|
|
<blockquote>
|
|
<div><div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ cdist preos ubuntu /preos/ubuntu -b -C <span class="se">\</span>
|
|
-k ~/.ssh/id_rsa.pub -p /preos/pxe <span class="se">\</span>
|
|
-t <span class="s2">"/usr/bin/curl 192.168.111.5:3000/cdist/install/"</span>
|
|
</pre></div>
|
|
</div>
|
|
</div></blockquote>
|
|
</li>
|
|
<li><p class="first">Configure dhcp server and tftp server.</p>
|
|
</li>
|
|
<li><p class="first">On cdist host (192.168.111.5 from above) start trigger command (it will use
|
|
default init manifest for installation).</p>
|
|
<blockquote>
|
|
<div><div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ cdist trigger -b -v
|
|
</pre></div>
|
|
</div>
|
|
</div></blockquote>
|
|
</li>
|
|
<li><p class="first">After all is set up start new machines (PXE boot).</p>
|
|
</li>
|
|
<li><p class="first">New machine boots and executes trigger command, i.e. triggers installation.</p>
|
|
</li>
|
|
<li><p class="first">Cdist trigger server starts installing host that has triggered it.</p>
|
|
</li>
|
|
<li><p class="first">After cdist install is finished new host is installed.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
<footer>
|
|
|
|
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
|
|
|
|
<a href="cdist-integration.html" class="btn btn-neutral float-right" title="22. cdist integration / using cdist as library" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
|
|
|
|
|
|
<a href="cdist-trigger.html" class="btn btn-neutral" title="20. Trigger" accesskey="p" rel="prev"><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/rtfd/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" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></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 async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript" src="_static/js/theme.js"></script>
|
|
|
|
<script type="text/javascript">
|
|
jQuery(function () {
|
|
SphinxRtdTheme.Navigation.enable(true);
|
|
});
|
|
</script>
|
|
|
|
</body>
|
|
</html> |