Sophie

Sophie

distrib > Fedora > 17 > i386 > media > updates > by-pkgid > b50d8ee6d7871fcc13c0677a9364ed59 > files > 462

bcfg2-doc-1.3.0-1.fc17.noarch.rpm



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Hostbase &mdash; Bcfg2 1.3.0 documentation</title>
    
    <link rel="stylesheet" href="../../../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../../../',
        VERSION:     '1.3.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/sidebar.js"></script>
    <link rel="shortcut icon" href="../../../_static/favicon.ico"/>
    <link rel="top" title="Bcfg2 1.3.0 documentation" href="../../../index.html" />
    <link rel="up" title="Plugins" href="../index.html" />
    <link rel="next" title="NagiosGen" href="nagiosgen.html" />
    <link rel="prev" title="Decisions" href="decisions.html" />
 
<link rel="stylesheet" href="../../../_static/bcfg2.css" type=""/>

  </head>
  <body>

<div style="text-align: left; padding: 10px 10px 15px 15px">
<a href="../../../index.html"><img src="../../../_static/bcfg2_logo.png" border="0" alt="sampledoc"/></a>
</div>

    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="nagiosgen.html" title="NagiosGen"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="decisions.html" title="Decisions"
             accesskey="P">previous</a> |</li>
	<li><a href="../../../index.html">home</a> |&nbsp;</li>
	<!--<li><a href="../../../search.html">search</a> |&nbsp;</li>-->
	<li><a href="../../../help/index.html">help</a> |&nbsp;</li>
	<li><a href="../../../contents.html">documentation </a> &raquo;</li>

          <li><a href="../../../contents.html" >Bcfg2 documentation 1.3.0</a> &raquo;</li>
          <li><a href="../../index.html" >The Bcfg2 Server</a> &raquo;</li>
          <li><a href="../index.html" accesskey="U">Plugins</a> &raquo;</li> 
      </ul>
    </div>
  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="hostbase">
<span id="server-plugins-generators-hostbase"></span><h1>Hostbase<a class="headerlink" href="#hostbase" title="Permalink to this headline">¶</a></h1>
<p>IP management system built on top of Bcfg2. It has four main parts: a
django data model, a web frontend, command-line utilities, and a Bcfg2
plugin that generates dhcp, dns, and yp configuration files.</p>
<div class="section" id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline">¶</a></h2>
<p>Installation of Hostbase requires installation of a python module,
configuration of database (mysql or postgres), and configuration of an
Apache webserver with mod_python. Hostbase was developed using MySQL,
so this document is aimed at MySQL users.</p>
<div class="section" id="prerequisites">
<h3>Prerequisites<a class="headerlink" href="#prerequisites" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li><a class="reference external" href="http://www.mysql.com/">mysql</a></li>
<li><a class="reference external" href="http://mysql-python.sourceforge.net/MySQLdb.html">python-mysqldb</a></li>
<li><a class="reference external" href="http://www.djangoproject.com">Django</a></li>
</ul>
</div>
<div class="section" id="configure-the-database">
<h3>Configure the database<a class="headerlink" href="#configure-the-database" title="Permalink to this headline">¶</a></h3>
<p>Create the hostbase database and a user.  For MySQL users:</p>
<div class="highlight-python"><pre>mysql&gt; CREATE DATABASE hostbase
mysql&gt; quit

systemprompt#:  mysql -u root hostbase
mysql&gt; GRANT ALL PRIVILEGES ON *.* TO hostbaseuser@mycomputer.private.net IDENTIFIED
       BY 'password' WITH GRANT OPTION;
mysql&gt; quit</pre>
</div>
<p>As of Bcfg2 v0.8.7 configuration options for Hostbase have moved to
<tt class="docutils literal"><span class="pre">/etc/bcfg2.conf</span></tt>.  There is an example bcfg2.conf with Hostbase
options located at <tt class="docutils literal"><span class="pre">bcfg2-tarball/examples/bcfg2.confHostbase</span></tt>.
Edit the hostbase options to correspond to the database you&#8217;ve
initialized and copy the configuration to <tt class="docutils literal"><span class="pre">/etc/bcfg2.conf</span></tt>.  To
finish creating the database, from your <tt class="docutils literal"><span class="pre">path</span> <span class="pre">to</span>
<span class="pre">python/Bcfg2/Server/Hostbase</span></tt> directory, run <tt class="docutils literal"><span class="pre">python</span> <span class="pre">manage.py</span>
<span class="pre">syncdb</span></tt> to do all table creation.</p>
</div>
<div class="section" id="configure-the-web-interface">
<h3>Configure the web interface<a class="headerlink" href="#configure-the-web-interface" title="Permalink to this headline">¶</a></h3>
<p>Now it&#8217;s possible to explore the Hostbase web interface.  For
curiosity, you can run Django&#8217;s built-in development server to take a
peek.  Do this by running <tt class="docutils literal"><span class="pre">python</span> <span class="pre">manage.py</span> <span class="pre">runserver</span>
<span class="pre">[servername:port]</span></tt> from your Hostbase directory.  Django will
default to <tt class="docutils literal"><span class="pre">localhost:8000</span></tt> if no server or port is entered.  Now
you can explore the web interface.  Try adding a host and a zone.
You&#8217;ll see that a &#8221;.rev&#8221; zone already exists.  This is where
information for reverse files will go.</p>
<p>For production, you&#8217;ll want to have this configured for Apache with
mod_python. Here is an example of how to configure Hostbase as a
virtual host.</p>
<div class="highlight-html"><pre>&lt;VirtualHost hostbase.mcs.anl.gov:80&gt;
        ServerAdmin systems@mcs.anl.gov

        DocumentRoot /var/www/hostbase/
        &lt;Directory /&gt;
                AllowOverride None
        &lt;/Directory&gt;

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        ServerSignature Off

        # Stop TRACE/TRACK vulnerability
        &lt;IfModule mod_rewrite.c&gt;
                RewriteEngine on
                RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
                RewriteRule .* - [F]
        &lt;/IfModule&gt;

        Redirect / https://hostbase.mcs.anl.gov/
&lt;/VirtualHost&gt;

&lt;VirtualHost hostbase.mcs.anl.gov:443&gt;
        ServerAdmin systems@mcs.anl.gov

        DocumentRoot /var/www/hostbase/
        &lt;Directory /&gt;
                AllowOverride None
        &lt;/Directory&gt;

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        ServerSignature Off

        # Stop TRACE/TRACK vulnerability
        &lt;IfModule mod_rewrite.c&gt;
                RewriteEngine on
                RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
                RewriteRule .* - [F]
        &lt;/IfModule&gt;

        SSLEngine On
        SSLCertificateFile /etc/apache2/ssl/hostbase_server.crt
        SSLCertificateKeyfile /etc/apache2/ssl/hostbase_server.key

&lt;Location "/"&gt;
        SetHandler python-program
        PythonHandler django.core.handlers.modpython
        SetEnv DJANGO_SETTINGS_MODULE Bcfg2.Server.Hostbase.settings
        PythonDebug On
&lt;/Location&gt;
&lt;Location "/site_media/"&gt;
        SetHandler None
&lt;/Location&gt;
&lt;/VirtualHost&gt;</pre>
</div>
<p>You&#8217;ll need to copy the contents of <tt class="docutils literal"><span class="pre">Hostbase/media</span></tt> into
<tt class="docutils literal"><span class="pre">/var/www/hostbase/site_media</span></tt> in this configuration to serve the
correct css files.</p>
</div>
<div class="section" id="enable-the-hostbase-plugin">
<h3>Enable the Hostbase plugin<a class="headerlink" href="#enable-the-hostbase-plugin" title="Permalink to this headline">¶</a></h3>
<p>Now that the database is accessible and there is some data in it, you can
enable the Hostbase plugin on your Bcfg2 server to start generating some
configuration files.  All that needs to be done is to add <tt class="docutils literal"><span class="pre">Hostbase</span></tt>
to the end of the list of generators in your bcfg2.conf file.  To see
what&#8217;s being generated by Hostbase, fire up a Bcfg2 development server:
<tt class="docutils literal"><span class="pre">bcfg2-info</span></tt>.  For more information on how to use the Bcfg2 development
server, type help at the prompt.  For our purposes, type <tt class="docutils literal"><span class="pre">debug</span></tt>.
This will bring you to an interactive python prompt where you can access
bcfg&#8217;s core data.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">for</span> <span class="n">each</span> <span class="ow">in</span> <span class="n">bcore</span><span class="o">.</span><span class="n">plugins</span><span class="p">[</span><span class="s">&#39;Hostbase&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">filedata</span><span class="p">:</span>
    <span class="k">print</span> <span class="n">each</span>
</pre></div>
</div>
<p>The above loop will print out the name of each file that was generated
by Hostbase.  You can see the contents of any of these by typing <tt class="docutils literal"><span class="pre">print</span>
<span class="pre">bcore.plugins['Hostbase'].filedata[filename]</span></tt>.</p>
</div>
<div class="section" id="create-a-bundle">
<h3>Create a bundle<a class="headerlink" href="#create-a-bundle" title="Permalink to this headline">¶</a></h3>
<p>Bcfg2 needs a way to distribute the files generated by Hostbase.
We&#8217;ll do this with a bundle.  In bcfg&#8217;s <tt class="docutils literal"><span class="pre">Bundler</span></tt> directory, touch
<tt class="docutils literal"><span class="pre">hostbase.xml</span></tt>.</p>
<div class="highlight-xml"><div class="highlight"><pre><span class="nt">&lt;Bundle</span> <span class="na">name=</span><span class="s">&#39;hostbase&#39;</span> <span class="na">version=</span><span class="s">&#39;0.1&#39;</span><span class="nt">&gt;</span>
   <span class="nt">&lt;Package</span> <span class="na">name=</span><span class="s">&#39;dhcp3-server&#39;</span><span class="nt">/&gt;</span>
   <span class="nt">&lt;Package</span> <span class="na">name=</span><span class="s">&#39;bind9&#39;</span><span class="nt">/&gt;</span>
   <span class="nt">&lt;Service</span> <span class="na">name=</span><span class="s">&#39;dhcp3-server&#39;</span><span class="nt">/&gt;</span>
   <span class="nt">&lt;Service</span> <span class="na">name=</span><span class="s">&#39;bind9&#39;</span><span class="nt">/&gt;</span>
   <span class="nt">&lt;Path</span> <span class="na">name=</span><span class="s">&#39;/etc/dhcp3/dhcpd.conf&#39;</span><span class="nt">/&gt;</span>
   <span class="nt">&lt;Path</span> <span class="na">name=</span><span class="s">&#39;/etc/bind/[your domain]&#39;</span><span class="nt">/&gt;</span>
   <span class="nt">&lt;Path</span> <span class="na">name=</span><span class="s">&#39;/etc/bind/xxx.xxx.xxx.rev&#39;</span><span class="nt">/&gt;</span>
<span class="nt">&lt;/Bundle&gt;</span>
</pre></div>
</div>
<p>The above example is a bundle that will deliver both dhcp and dns files.
This can be trivially split into separate bundles.  It is planned that
Hostbase will eventually be able to generate the list of <tt class="docutils literal"><span class="pre">Paths</span></tt>
in its bundles automatically.</p>
</div>
<div class="section" id="do-a-hostbase-push">
<h3>Do a Hostbase push<a class="headerlink" href="#do-a-hostbase-push" title="Permalink to this headline">¶</a></h3>
<p>You&#8217;ll want to be able to trigger the Hostbase plugin to rebuild
it&#8217;s config files and push them out when data has been modified
in the database.  This can be done through and XMLRPC function
available from the Bcfg2 server.  From a client that is configured
to receive one or more hostbase bundles, you&#8217;ll need to first
edit your <tt class="docutils literal"><span class="pre">python/site-packages/Bcfg2/Client/Proxy.py</span></tt> file.
Add <tt class="docutils literal"><span class="pre">'Hostbase.rebuildState'</span></tt> to the list of methods in the Bcfg2
client proxy object.  The modified list is shown below:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">class</span> <span class="nc">bcfg2</span><span class="p">(</span><span class="n">ComponentProxy</span><span class="p">):</span>
    <span class="sd">&#39;&#39;&#39;bcfg2 client code&#39;&#39;&#39;</span>
    <span class="n">name</span> <span class="o">=</span> <span class="s">&#39;bcfg2&#39;</span>
    <span class="n">methods</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;AssertProfile&#39;</span><span class="p">,</span> <span class="s">&#39;GetConfig&#39;</span><span class="p">,</span> <span class="s">&#39;GetProbes&#39;</span><span class="p">,</span> <span class="s">&#39;RecvProbeData&#39;</span><span class="p">,</span> <span class="s">&#39;RecvStats&#39;</span><span class="p">,</span> <span class="s">&#39;Hostbase.rebuildState&#39;</span><span class="p">]</span>
</pre></div>
</div>
<p>Now copy the file <tt class="docutils literal"><span class="pre">hostbasepush.py</span></tt> from <tt class="docutils literal"><span class="pre">bcfg2/tools</span></tt> in the Bcfg2
source to your machine.  When this command is run as root, it triggers
the Hostbase to rebuild it&#8217;s files, then runs the Bcfg2 client on your
local machine to grab the new configs.</p>
</div>
</div>
<div class="section" id="nis-authentication">
<h2>NIS Authentication<a class="headerlink" href="#nis-authentication" title="Permalink to this headline">¶</a></h2>
<p>Django allows for custom authentication backends to its login procedure.
Hostbase has an NIS authentication backend that verifies a user to be
in the unix group allowed to modify Hostbase.</p>
<p>To enable this feature:</p>
<ul class="simple">
<li>first edit your <tt class="docutils literal"><span class="pre">Hostbase/settings.py</span></tt> file and uncomment
the line <strong>Hostbase.backends.NISBackend</strong> in the list of
<em>AUTHENTICATION_BACKENDS</em></li>
<li>enter the name of the unix group you want to give access to Hostbase
in the <em>AUTHORIZED_GROUP</em> variable</li>
<li>in your <tt class="docutils literal"><span class="pre">Hostbase/hostbase/views.py</span></tt> file at the very bottom,
uncomment the block(s) of lines that give you the desired level
of access</li>
</ul>
<p>Hostbase will now direct the user to a login page if he or she is not
authorized to view a certain page.  Users should log in with their
regular Unix username and password.</p>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../../../index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Hostbase</a><ul>
<li><a class="reference internal" href="#installation">Installation</a><ul>
<li><a class="reference internal" href="#prerequisites">Prerequisites</a></li>
<li><a class="reference internal" href="#configure-the-database">Configure the database</a></li>
<li><a class="reference internal" href="#configure-the-web-interface">Configure the web interface</a></li>
<li><a class="reference internal" href="#enable-the-hostbase-plugin">Enable the Hostbase plugin</a></li>
<li><a class="reference internal" href="#create-a-bundle">Create a bundle</a></li>
<li><a class="reference internal" href="#do-a-hostbase-push">Do a Hostbase push</a></li>
</ul>
</li>
<li><a class="reference internal" href="#nis-authentication">NIS Authentication</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="decisions.html"
                        title="previous chapter">Decisions</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="nagiosgen.html"
                        title="next chapter">NagiosGen</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../../../_sources/server/plugins/generators/hostbase.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../../../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="nagiosgen.html" title="NagiosGen"
             >next</a> |</li>
        <li class="right" >
          <a href="decisions.html" title="Decisions"
             >previous</a> |</li>
	<li><a href="../../../index.html">home</a> |&nbsp;</li>
	<!--<li><a href="../../../search.html">search</a> |&nbsp;</li>-->
	<li><a href="../../../help/index.html">help</a> |&nbsp;</li>
	<li><a href="../../../contents.html">documentation </a> &raquo;</li>

          <li><a href="../../../contents.html" >Bcfg2 documentation 1.3.0</a> &raquo;</li>
          <li><a href="../../index.html" >The Bcfg2 Server</a> &raquo;</li>
          <li><a href="../index.html" >Plugins</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2009-2013, Narayan Desai.
      Last updated on Mar 20, 2013.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
    </div>
  </body>
</html>