Commit e030d085 by Michael DeHaan

Docs rebuild

parent 449725a2
...@@ -165,7 +165,7 @@ s.parentNode.insertBefore(ga, s); ...@@ -165,7 +165,7 @@ s.parentNode.insertBefore(ga, s);
<div class="section" id="api-integrations"> <div class="section" id="api-integrations">
<h1>API &amp; Integrations<a class="headerlink" href="#api-integrations" title="Permalink to this headline"></a></h1> <h1>API &amp; Integrations<a class="headerlink" href="#api-integrations" title="Permalink to this headline"></a></h1>
<p>There are two major ways to use Ansible from an API perspective. The primary way <p>There are two major ways to use Ansible from an API perspective. The primary way
is to use the Ansible python API to control nodes. Ansible is written in it&#8217;s own is to use the Ansible python API to control nodes. Ansible is written in its own
API so you have a considerable amount of power there.</p> API so you have a considerable amount of power there.</p>
<p>Also covered here, Ansible&#8217;s <p>Also covered here, Ansible&#8217;s
list of hosts, groups, and variables assigned to each host can be driven from list of hosts, groups, and variables assigned to each host can be driven from
...@@ -244,8 +244,7 @@ command line tools <tt class="docutils literal"><span class="pre">ansible</span> ...@@ -244,8 +244,7 @@ command line tools <tt class="docutils literal"><span class="pre">ansible</span>
in a different system. Frequent examples include LDAP, <a class="reference external" href="http://cobbler.github.com">Cobbler</a>, in a different system. Frequent examples include LDAP, <a class="reference external" href="http://cobbler.github.com">Cobbler</a>,
or a piece of expensive enterprisey CMDB software. Ansible easily supports all or a piece of expensive enterprisey CMDB software. Ansible easily supports all
of these options via an external interventory system.</p> of these options via an external interventory system.</p>
<p>If you have a data store system where an Ansible external inventory script doesn&#8217;t already exist, this may require a little coding,J <p>If you have a data store system where an Ansible external inventory script doesn&#8217;t already exist, this may require a little coding, but we have a <a class="reference external" href="https://github.com/ansible/ansible/blob/master/examples/scripts/cobbler_external_inventory.py">Cobbler example</a> in the main source tree &#8211; but it&#8217;s pretty simple, as we&#8217;ll explain below &#8211; that would provide a good starting point. Like with modules, it&#8217;s possible to build an external inventory script in any language, as long as it returns JSON.</p>
but we have a <a class="reference external" href="https://github.com/ansible/ansible/blob/master/examples/scripts/cobbler_external_inventory.py">Cobbler example</a> in the main source tree &#8211; but it&#8217;s pretty simple, as we&#8217;ll explain below &#8211; that would provide a good starting point. Like with modules, it&#8217;s possible to build an external inventory script in any language, as long as it returns JSON.</p>
<p>If you are familiar with Puppet terminology, this concept is basically the same as &#8216;external nodes&#8217;, with the slight difference that it also defines which hosts are managed.</p> <p>If you are familiar with Puppet terminology, this concept is basically the same as &#8216;external nodes&#8217;, with the slight difference that it also defines which hosts are managed.</p>
<div class="section" id="script-conventions"> <div class="section" id="script-conventions">
<h3>Script Conventions<a class="headerlink" href="#script-conventions" title="Permalink to this headline"></a></h3> <h3>Script Conventions<a class="headerlink" href="#script-conventions" title="Permalink to this headline"></a></h3>
......
...@@ -234,7 +234,7 @@ even bash ... just return some output in JSON format. You don&#8217;t need to k ...@@ -234,7 +234,7 @@ even bash ... just return some output in JSON format. You don&#8217;t need to k
as it can. A system shouldn&#8217;t be half correct, especially if we&#8217;re planning on configuring as it can. A system shouldn&#8217;t be half correct, especially if we&#8217;re planning on configuring
other systems that depend on that system.</p> other systems that depend on that system.</p>
<p>Ansible also has a VERY short learning curve &#8211; but it also has less language constructs and <p>Ansible also has a VERY short learning curve &#8211; but it also has less language constructs and
does not create it&#8217;s own programming language. What constructs Ansible does have should be enough to cover 80% or so of the cases of most Puppet users, and it should scale equally well (not having a server is does not create its own programming language. What constructs Ansible does have should be enough to cover 80% or so of the cases of most Puppet users, and it should scale equally well (not having a server is
almost like cheating).</p> almost like cheating).</p>
<p>I also suspect some Ansible users will actually use Ansible to trigger Puppet &#8211; using the git <p>I also suspect some Ansible users will actually use Ansible to trigger Puppet &#8211; using the git
module to checkout a Puppet module hierachy from source, and the command module to run module to checkout a Puppet module hierachy from source, and the command module to run
...@@ -284,7 +284,7 @@ run multiple commands in seperate forks, thanks to the magic behind ...@@ -284,7 +284,7 @@ run multiple commands in seperate forks, thanks to the magic behind
Python&#8217;s multiprocessing module.</p> Python&#8217;s multiprocessing module.</p>
<p>If you need to address 500 machines you can decide if you want to try <p>If you need to address 500 machines you can decide if you want to try
to contact 5 at a time, or 50 at a time. to contact 5 at a time, or 50 at a time.
It&#8217;s up to you and how much power you can throw at it, but it&#8217;s heritage It&#8217;s up to you and how much power you can throw at it, but its heritage
is about handling those kinds of use cases.</p> is about handling those kinds of use cases.</p>
<p>There are no daemons so it&#8217;s entirely up to you. When you are aren&#8217;t using <p>There are no daemons so it&#8217;s entirely up to you. When you are aren&#8217;t using
Ansible, it is not consuming any resources.</p> Ansible, it is not consuming any resources.</p>
......
...@@ -220,6 +220,7 @@ you with questions about Ansible.</p> ...@@ -220,6 +220,7 @@ you with questions about Ansible.</p>
<li>See the presentation on <a class="reference external" href="http://speakerdeck.com/u/mpdehaan/p/ansible">Speakerdeck</a></li> <li>See the presentation on <a class="reference external" href="http://speakerdeck.com/u/mpdehaan/p/ansible">Speakerdeck</a></li>
<li>Visit the <a class="reference external" href="http://groups.google.com/group/ansible-project">Google Group</a></li> <li>Visit the <a class="reference external" href="http://groups.google.com/group/ansible-project">Google Group</a></li>
<li>Chat on <a class="reference external" href="http://webchat.freenode.net/?channels=ansible">FreeNode</a></li> <li>Chat on <a class="reference external" href="http://webchat.freenode.net/?channels=ansible">FreeNode</a></li>
<li>View or add to the the <a class="reference external" href="https://github.com/ansible/ansible-contrib">Contrib Repo</a> on Github</li>
</ul> </ul>
<img src="http://groups.google.com/intl/en/images/logos/groups_logo_sm.gif" height=30 width=140 alt="Google Groups"> <img src="http://groups.google.com/intl/en/images/logos/groups_logo_sm.gif" height=30 width=140 alt="Google Groups">
<br/> <br/>
...@@ -269,6 +270,7 @@ Email: <input type=text name=email>&nbsp;&nbsp;<input type=submit name="sub" val ...@@ -269,6 +270,7 @@ Email: <input type=text name=email>&nbsp;&nbsp;<input type=submit name="sub" val
<li class="toctree-l2"><a class="reference internal" href="modules.html#command">command</a></li> <li class="toctree-l2"><a class="reference internal" href="modules.html#command">command</a></li>
<li class="toctree-l2"><a class="reference internal" href="modules.html#copy">copy</a></li> <li class="toctree-l2"><a class="reference internal" href="modules.html#copy">copy</a></li>
<li class="toctree-l2"><a class="reference internal" href="modules.html#facter">facter</a></li> <li class="toctree-l2"><a class="reference internal" href="modules.html#facter">facter</a></li>
<li class="toctree-l2"><a class="reference internal" href="modules.html#fetch">fetch</a></li>
<li class="toctree-l2"><a class="reference internal" href="modules.html#file">file</a></li> <li class="toctree-l2"><a class="reference internal" href="modules.html#file">file</a></li>
<li class="toctree-l2"><a class="reference internal" href="modules.html#git">git</a></li> <li class="toctree-l2"><a class="reference internal" href="modules.html#git">git</a></li>
<li class="toctree-l2"><a class="reference internal" href="modules.html#group">group</a></li> <li class="toctree-l2"><a class="reference internal" href="modules.html#group">group</a></li>
...@@ -298,6 +300,7 @@ Email: <input type=text name=email>&nbsp;&nbsp;<input type=submit name="sub" val ...@@ -298,6 +300,7 @@ Email: <input type=text name=email>&nbsp;&nbsp;<input type=submit name="sub" val
</li> </li>
<li class="toctree-l2"><a class="reference internal" href="playbooks.html#running-operations-on-change">Running Operations On Change</a></li> <li class="toctree-l2"><a class="reference internal" href="playbooks.html#running-operations-on-change">Running Operations On Change</a></li>
<li class="toctree-l2"><a class="reference internal" href="playbooks.html#power-tricks">Power Tricks</a><ul> <li class="toctree-l2"><a class="reference internal" href="playbooks.html#power-tricks">Power Tricks</a><ul>
<li class="toctree-l3"><a class="reference internal" href="playbooks.html#local-playbooks">Local Playbooks</a></li>
<li class="toctree-l3"><a class="reference internal" href="playbooks.html#external-variables-and-prompted-or-sensitive-data">External Variables And Prompted or Sensitive Data</a></li> <li class="toctree-l3"><a class="reference internal" href="playbooks.html#external-variables-and-prompted-or-sensitive-data">External Variables And Prompted or Sensitive Data</a></li>
<li class="toctree-l3"><a class="reference internal" href="playbooks.html#conditional-execution">Conditional Execution</a></li> <li class="toctree-l3"><a class="reference internal" href="playbooks.html#conditional-execution">Conditional Execution</a></li>
<li class="toctree-l3"><a class="reference internal" href="playbooks.html#conditional-imports">Conditional Imports</a></li> <li class="toctree-l3"><a class="reference internal" href="playbooks.html#conditional-imports">Conditional Imports</a></li>
......
...@@ -212,7 +212,7 @@ chmod +x ansible/hacking/test-module</pre> ...@@ -212,7 +212,7 @@ chmod +x ansible/hacking/test-module</pre>
<h2>Reading Input<a class="headerlink" href="#reading-input" title="Permalink to this headline"></a></h2> <h2>Reading Input<a class="headerlink" href="#reading-input" title="Permalink to this headline"></a></h2>
<p>Let&#8217;s modify the module to allow setting the current time. We&#8217;ll do this by seeing <p>Let&#8217;s modify the module to allow setting the current time. We&#8217;ll do this by seeing
if a key value pair in the form <cite>time=&lt;string&gt;</cite> is passed in to the module.</p> if a key value pair in the form <cite>time=&lt;string&gt;</cite> is passed in to the module.</p>
<p>Ansible internally saves arguments to a arguments file. So we must read the file <p>Ansible internally saves arguments to an arguments file. So we must read the file
and parse it. The arguments file is just a string, so any form of arguments are legal. and parse it. The arguments file is just a string, so any form of arguments are legal.
Here we&#8217;ll do some basic parsing to treat the input as key=value.</p> Here we&#8217;ll do some basic parsing to treat the input as key=value.</p>
<p>The example usage we are trying to achieve to set the time is:</p> <p>The example usage we are trying to achieve to set the time is:</p>
......
...@@ -138,6 +138,7 @@ s.parentNode.insertBefore(ga, s); ...@@ -138,6 +138,7 @@ s.parentNode.insertBefore(ga, s);
</li> </li>
<li><a class="reference internal" href="#running-operations-on-change">Running Operations On Change</a></li> <li><a class="reference internal" href="#running-operations-on-change">Running Operations On Change</a></li>
<li><a class="reference internal" href="#power-tricks">Power Tricks</a><ul> <li><a class="reference internal" href="#power-tricks">Power Tricks</a><ul>
<li><a class="reference internal" href="#local-playbooks">Local Playbooks</a></li>
<li><a class="reference internal" href="#external-variables-and-prompted-or-sensitive-data">External Variables And Prompted or Sensitive Data</a></li> <li><a class="reference internal" href="#external-variables-and-prompted-or-sensitive-data">External Variables And Prompted or Sensitive Data</a></li>
<li><a class="reference internal" href="#conditional-execution">Conditional Execution</a></li> <li><a class="reference internal" href="#conditional-execution">Conditional Execution</a></li>
<li><a class="reference internal" href="#conditional-imports">Conditional Imports</a></li> <li><a class="reference internal" href="#conditional-imports">Conditional Imports</a></li>
...@@ -197,7 +198,7 @@ Each playbook is composed of one or more &#8216;plays&#8217; in a list.</p> ...@@ -197,7 +198,7 @@ Each playbook is composed of one or more &#8216;plays&#8217; in a list.</p>
orchestrate multi-machine deployments, running certain steps on all orchestrate multi-machine deployments, running certain steps on all
machines in the webservers group, then certain steps on the database machines in the webservers group, then certain steps on the database
server group, then more commands back on the webservers group, etc.</p> server group, then more commands back on the webservers group, etc.</p>
<p>For starters, here&#8217;s a playbook that contains just one play.:</p> <p>For starters, here&#8217;s a playbook that contains just one play:</p>
<div class="highlight-python"><pre>--- <div class="highlight-python"><pre>---
- hosts: webservers - hosts: webservers
vars: vars:
...@@ -355,6 +356,20 @@ won&#8217;t need them for much else.</p> ...@@ -355,6 +356,20 @@ won&#8217;t need them for much else.</p>
<h2>Power Tricks<a class="headerlink" href="#power-tricks" title="Permalink to this headline"></a></h2> <h2>Power Tricks<a class="headerlink" href="#power-tricks" title="Permalink to this headline"></a></h2>
<p>Now that you have the basics down, let&#8217;s learn some more advanced <p>Now that you have the basics down, let&#8217;s learn some more advanced
things you can do with playbooks.</p> things you can do with playbooks.</p>
<div class="section" id="local-playbooks">
<h3>Local Playbooks<a class="headerlink" href="#local-playbooks" title="Permalink to this headline"></a></h3>
<p>It may be useful to use a playbook locally, rather than by connecting over SSH. This can be useful
for assuring the configuration of a system by putting a playbook on a crontab. This may also be used
to run a playbook inside a OS installer, such as an Anaconda kickstart.</p>
<p>To run an entire playbook locally, just set the &#8220;hosts:&#8221; line to &#8220;hosts:127.0.0.1&#8221; and then run the playbook like so:</p>
<div class="highlight-python"><pre>playbook playbook.yml --connection=local</pre>
</div>
<p>Alternatively, a local connection can be used in a single playbook play, even if other plays in the playbook
use the default remote connection type:</p>
<div class="highlight-python"><pre>hosts: 127.0.0.1
connection: local</pre>
</div>
</div>
<div class="section" id="external-variables-and-prompted-or-sensitive-data"> <div class="section" id="external-variables-and-prompted-or-sensitive-data">
<h3>External Variables And Prompted or Sensitive Data<a class="headerlink" href="#external-variables-and-prompted-or-sensitive-data" title="Permalink to this headline"></a></h3> <h3>External Variables And Prompted or Sensitive Data<a class="headerlink" href="#external-variables-and-prompted-or-sensitive-data" title="Permalink to this headline"></a></h3>
<p>It&#8217;s a great idea to keep your playbooks under source control, but <p>It&#8217;s a great idea to keep your playbooks under source control, but
...@@ -411,7 +426,7 @@ or it could be something like performing some cleanup steps if a filesystem is g ...@@ -411,7 +426,7 @@ or it could be something like performing some cleanup steps if a filesystem is g
<p>This is easy to do in Ansible, with the <cite>only_if</cite> clause. This clause can be applied to any task, <p>This is easy to do in Ansible, with the <cite>only_if</cite> clause. This clause can be applied to any task,
and allows usage of variables from anywhere in ansible, either denoted with <cite>$dollar_sign_syntax</cite> or and allows usage of variables from anywhere in ansible, either denoted with <cite>$dollar_sign_syntax</cite> or
<cite>{{ braces_syntax }}</cite> and then evaluates them with a Python expression. Don&#8217;t panic &#8211; it&#8217;s actually <cite>{{ braces_syntax }}</cite> and then evaluates them with a Python expression. Don&#8217;t panic &#8211; it&#8217;s actually
pretty simple.:</p> pretty simple:</p>
<div class="highlight-python"><pre>vars: <div class="highlight-python"><pre>vars:
favcolor: blue favcolor: blue
is_favcolor_blue: "'$favcolor' == 'blue'" is_favcolor_blue: "'$favcolor' == 'blue'"
...@@ -569,7 +584,7 @@ running operations can go faster. The easiest way to do this is ...@@ -569,7 +584,7 @@ running operations can go faster. The easiest way to do this is
to kick them off all at once and then poll until they are done.</p> to kick them off all at once and then poll until they are done.</p>
<p>You will also want to use asynchronous mode on very long running <p>You will also want to use asynchronous mode on very long running
operations that might be subject to timeout.</p> operations that might be subject to timeout.</p>
<p>To launch a task asynchronously, specify it&#8217;s maximum runtime <p>To launch a task asynchronously, specify its maximum runtime
and how frequently you would like to poll for status. The default and how frequently you would like to poll for status. The default
poll value is 10 seconds if you do not specify a value for <cite>poll</cite>:</p> poll value is 10 seconds if you do not specify a value for <cite>poll</cite>:</p>
<div class="highlight-python"><pre>--- <div class="highlight-python"><pre>---
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment