1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

new playbooks best practices page + docs rebuild

This commit is contained in:
Michael DeHaan 2012-05-13 11:56:09 -04:00
parent 4994566124
commit 0127df97b5
17 changed files with 270 additions and 153 deletions

View file

@ -136,9 +136,10 @@ s.parentNode.insertBefore(ga, s);
<li class="toctree-l1 current"><a class="current reference internal" href="">YAML Syntax</a></li> <li class="toctree-l1 current"><a class="current reference internal" href="">YAML Syntax</a></li>
<li class="toctree-l1"><a class="reference internal" href="playbooks.html">Playbooks</a></li> <li class="toctree-l1"><a class="reference internal" href="playbooks.html">Playbooks</a></li>
<li class="toctree-l1"><a class="reference internal" href="playbooks2.html">Advanced Playbooks</a></li> <li class="toctree-l1"><a class="reference internal" href="playbooks2.html">Advanced Playbooks</a></li>
<li class="toctree-l1"><a class="reference internal" href="bestpractices.html">Best Practices</a></li>
<li class="toctree-l1"><a class="reference internal" href="api.html">API &amp; Integrations</a></li> <li class="toctree-l1"><a class="reference internal" href="api.html">API &amp; Integrations</a></li>
<li class="toctree-l1"><a class="reference internal" href="moduledev.html">Module Development</a></li> <li class="toctree-l1"><a class="reference internal" href="moduledev.html">Module Development</a></li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">Frequently Asked Questions</a></li> <li class="toctree-l1"><a class="reference internal" href="faq.html">FAQ</a></li>
</ul> </ul>
</span> </span>
</li> </li>
@ -274,7 +275,7 @@ languages:
</p> </p>
<p> <p>
&copy; Copyright 2012 Michael DeHaan.<br/> &copy; Copyright 2012 Michael DeHaan.<br/>
Last updated on May 10, 2012.<br/> Last updated on May 13, 2012.<br/>
</p> </p>
</div> </div>
</footer> </footer>

View file

@ -28,7 +28,7 @@
<link rel="shortcut icon" href="_static/favicon.ico"/> <link rel="shortcut icon" href="_static/favicon.ico"/>
<link rel="top" title="Ansible - SSH-Based Configuration Management &amp; Deployment" href="index.html" /> <link rel="top" title="Ansible - SSH-Based Configuration Management &amp; Deployment" href="index.html" />
<link rel="next" title="Module Development" href="moduledev.html" /> <link rel="next" title="Module Development" href="moduledev.html" />
<link rel="prev" title="Advanced Playbooks" href="playbooks2.html" /> <link rel="prev" title="Best Practices" href="bestpractices.html" />
<script type="text/javascript"> <script type="text/javascript">
(function () { (function () {
/** /**
@ -136,9 +136,10 @@ s.parentNode.insertBefore(ga, s);
<li class="toctree-l1"><a class="reference internal" href="YAMLSyntax.html">YAML Syntax</a></li> <li class="toctree-l1"><a class="reference internal" href="YAMLSyntax.html">YAML Syntax</a></li>
<li class="toctree-l1"><a class="reference internal" href="playbooks.html">Playbooks</a></li> <li class="toctree-l1"><a class="reference internal" href="playbooks.html">Playbooks</a></li>
<li class="toctree-l1"><a class="reference internal" href="playbooks2.html">Advanced Playbooks</a></li> <li class="toctree-l1"><a class="reference internal" href="playbooks2.html">Advanced Playbooks</a></li>
<li class="toctree-l1"><a class="reference internal" href="bestpractices.html">Best Practices</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="">API &amp; Integrations</a></li> <li class="toctree-l1 current"><a class="current reference internal" href="">API &amp; Integrations</a></li>
<li class="toctree-l1"><a class="reference internal" href="moduledev.html">Module Development</a></li> <li class="toctree-l1"><a class="reference internal" href="moduledev.html">Module Development</a></li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">Frequently Asked Questions</a></li> <li class="toctree-l1"><a class="reference internal" href="faq.html">FAQ</a></li>
</ul> </ul>
</span> </span>
</li> </li>
@ -358,7 +359,7 @@ a conf.d file appropriately or something similar. Who knows?</p>
</p> </p>
<p> <p>
&copy; Copyright 2012 Michael DeHaan.<br/> &copy; Copyright 2012 Michael DeHaan.<br/>
Last updated on May 10, 2012.<br/> Last updated on May 13, 2012.<br/>
</p> </p>
</div> </div>
</footer> </footer>

View file

@ -136,9 +136,10 @@ s.parentNode.insertBefore(ga, s);
<li class="toctree-l1"><a class="reference internal" href="YAMLSyntax.html">YAML Syntax</a></li> <li class="toctree-l1"><a class="reference internal" href="YAMLSyntax.html">YAML Syntax</a></li>
<li class="toctree-l1"><a class="reference internal" href="playbooks.html">Playbooks</a></li> <li class="toctree-l1"><a class="reference internal" href="playbooks.html">Playbooks</a></li>
<li class="toctree-l1"><a class="reference internal" href="playbooks2.html">Advanced Playbooks</a></li> <li class="toctree-l1"><a class="reference internal" href="playbooks2.html">Advanced Playbooks</a></li>
<li class="toctree-l1"><a class="reference internal" href="bestpractices.html">Best Practices</a></li>
<li class="toctree-l1"><a class="reference internal" href="api.html">API &amp; Integrations</a></li> <li class="toctree-l1"><a class="reference internal" href="api.html">API &amp; Integrations</a></li>
<li class="toctree-l1"><a class="reference internal" href="moduledev.html">Module Development</a></li> <li class="toctree-l1"><a class="reference internal" href="moduledev.html">Module Development</a></li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">Frequently Asked Questions</a></li> <li class="toctree-l1"><a class="reference internal" href="faq.html">FAQ</a></li>
</ul> </ul>
</span> </span>
</li> </li>
@ -381,7 +382,7 @@ a simplified syntax for this.</p>
</p> </p>
<p> <p>
&copy; Copyright 2012 Michael DeHaan.<br/> &copy; Copyright 2012 Michael DeHaan.<br/>
Last updated on May 10, 2012.<br/> Last updated on May 13, 2012.<br/>
</p> </p>
</div> </div>
</footer> </footer>

View file

@ -6,7 +6,7 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Frequently Asked Questions &mdash; Ansible - SSH-Based Configuration Management &amp; Deployment</title> <title>FAQ &mdash; Ansible - SSH-Based Configuration Management &amp; Deployment</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" /> <link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/bootstrap.css" type="text/css" /> <link rel="stylesheet" href="_static/bootstrap.css" type="text/css" />
@ -135,9 +135,10 @@ s.parentNode.insertBefore(ga, s);
<li class="toctree-l1"><a class="reference internal" href="YAMLSyntax.html">YAML Syntax</a></li> <li class="toctree-l1"><a class="reference internal" href="YAMLSyntax.html">YAML Syntax</a></li>
<li class="toctree-l1"><a class="reference internal" href="playbooks.html">Playbooks</a></li> <li class="toctree-l1"><a class="reference internal" href="playbooks.html">Playbooks</a></li>
<li class="toctree-l1"><a class="reference internal" href="playbooks2.html">Advanced Playbooks</a></li> <li class="toctree-l1"><a class="reference internal" href="playbooks2.html">Advanced Playbooks</a></li>
<li class="toctree-l1"><a class="reference internal" href="bestpractices.html">Best Practices</a></li>
<li class="toctree-l1"><a class="reference internal" href="api.html">API &amp; Integrations</a></li> <li class="toctree-l1"><a class="reference internal" href="api.html">API &amp; Integrations</a></li>
<li class="toctree-l1"><a class="reference internal" href="moduledev.html">Module Development</a></li> <li class="toctree-l1"><a class="reference internal" href="moduledev.html">Module Development</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="">Frequently Asked Questions</a></li> <li class="toctree-l1 current"><a class="current reference internal" href="">FAQ</a></li>
</ul> </ul>
</span> </span>
</li> </li>
@ -145,7 +146,7 @@ s.parentNode.insertBefore(ga, s);
<a href="#" <a href="#"
class="dropdown-toggle">Page</a> class="dropdown-toggle">Page</a>
<span class="localtoc"><ul> <span class="localtoc"><ul>
<li><a class="reference internal" href="#">Frequently Asked Questions</a><ul> <li><a class="reference internal" href="#">FAQ</a><ul>
<li><a class="reference internal" href="#what-inspired-ansible">What inspired Ansible?</a></li> <li><a class="reference internal" href="#what-inspired-ansible">What inspired Ansible?</a></li>
<li><a class="reference internal" href="#comparisons">Comparisons</a><ul> <li><a class="reference internal" href="#comparisons">Comparisons</a><ul>
<li><a class="reference internal" href="#vs-func">vs Func?</a></li> <li><a class="reference internal" href="#vs-func">vs Func?</a></li>
@ -188,8 +189,8 @@ s.parentNode.insertBefore(ga, s);
<a href="http://ansible.github.com"><img src="http://ansible.github.com/ansible-logo.png" alt="Ansible"/></a><br/> <a href="http://ansible.github.com"><img src="http://ansible.github.com/ansible-logo.png" alt="Ansible"/></a><br/>
<br/> <br/>
<div class="section" id="frequently-asked-questions"> <div class="section" id="faq">
<h1>Frequently Asked Questions<a class="headerlink" href="#frequently-asked-questions" title="Permalink to this headline"></a></h1> <h1>FAQ<a class="headerlink" href="#faq" title="Permalink to this headline"></a></h1>
<div class="section" id="what-inspired-ansible"> <div class="section" id="what-inspired-ansible">
<h2>What inspired Ansible?<a class="headerlink" href="#what-inspired-ansible" title="Permalink to this headline"></a></h2> <h2>What inspired Ansible?<a class="headerlink" href="#what-inspired-ansible" title="Permalink to this headline"></a></h2>
<p>Back when I worked for Red Hat and working on <a class="reference external" href="http://cobbler.github.com/">Cobbler</a>, several of us identified a gap between <p>Back when I worked for Red Hat and working on <a class="reference external" href="http://cobbler.github.com/">Cobbler</a>, several of us identified a gap between
@ -314,26 +315,31 @@ computing investments.</p>
<div class="section" id="how-does-ansible-scale"> <div class="section" id="how-does-ansible-scale">
<h3>How does Ansible scale?<a class="headerlink" href="#how-does-ansible-scale" title="Permalink to this headline"></a></h3> <h3>How does Ansible scale?<a class="headerlink" href="#how-does-ansible-scale" title="Permalink to this headline"></a></h3>
<p>Whether in single-execution mode or using ansible playbooks, ansible can <p>Whether in single-execution mode or using ansible playbooks, ansible can
run multiple commands in seperate forks, thanks to the magic behind run multiple commands in seperate parallel 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>You can decide if you want to try to manage 5 hosts 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 and how fast you want
It&#8217;s up to you and how much power you can throw at it, but its heritage to go.</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, and you don&#8217;t have to contend
with a herd of machines all knocking at the door of your management server
all at once.</p>
<p>If you have 10,000 systems, running a single ansible playbook against all of <p>If you have 10,000 systems, running a single ansible playbook against all of
them probably isn&#8217;t always appropriate, but most users shouldn&#8217;t have any problems. them probably isn&#8217;t appropriate, which is why ansible-pull exists.</p>
If you want to kick off an async task/module, it&#8217;s probably fine. We also <p>This tool is designed for running out of git and cron, and can scale to any
support a local connection mode (&#8211;connection=local) that will enable pull number of hosts. Ansible-pull uses local connections versus SSH, but can be
based usage for those that want that. Look for future features in this area.</p> easily bootstrapped or reconfigured just using SSH. There is more information
<p>If you&#8217;d like to discuss scaling, please hop on the mailing list.</p> available about this in the ref:<cite>playbooks2</cite> section. The self-bootstrapping
and ease of use are ansible are still retained, even when switching to the pull
model.</p>
<p>If you&#8217;d like to discuss scaling strategies further, please hop on the mailing list.</p>
</div> </div>
<div class="section" id="are-transports-other-than-ssh-supported"> <div class="section" id="are-transports-other-than-ssh-supported">
<h3>Are transports other than SSH supported?<a class="headerlink" href="#are-transports-other-than-ssh-supported" title="Permalink to this headline"></a></h3> <h3>Are transports other than SSH supported?<a class="headerlink" href="#are-transports-other-than-ssh-supported" title="Permalink to this headline"></a></h3>
<p>Currently SSH is the only remote transport, though the interface is pluggable so a <p>Currently SSH and local connections are supported. In 0.5, we&#8217;ll also be including
small patch could bring transport over message bus or XMPP as an option. a faster SSH transport. The interface is actually pluggable so a
Stop by the mailing list if you have ideas. The connection-specific parts of Ansible small patch could bring transport over message bus or XMPP as an option.</p>
<p>Stop by the mailing list if you have ideas. The connection-specific parts of Ansible
are all abstracted away from the core implementation so it is very easy to extend.</p> are all abstracted away from the core implementation so it is very easy to extend.</p>
</div> </div>
<div class="section" id="what-are-some-ideal-uses-for-ansible"> <div class="section" id="what-are-some-ideal-uses-for-ansible">
@ -380,7 +386,7 @@ tasks &#8211; whether for a QA sytem, build system, or anything you can think of
</p> </p>
<p> <p>
&copy; Copyright 2012 Michael DeHaan.<br/> &copy; Copyright 2012 Michael DeHaan.<br/>
Last updated on May 10, 2012.<br/> Last updated on May 13, 2012.<br/>
</p> </p>
</div> </div>
</footer> </footer>

View file

@ -134,9 +134,10 @@ s.parentNode.insertBefore(ga, s);
<li class="toctree-l1"><a class="reference internal" href="YAMLSyntax.html">YAML Syntax</a></li> <li class="toctree-l1"><a class="reference internal" href="YAMLSyntax.html">YAML Syntax</a></li>
<li class="toctree-l1"><a class="reference internal" href="playbooks.html">Playbooks</a></li> <li class="toctree-l1"><a class="reference internal" href="playbooks.html">Playbooks</a></li>
<li class="toctree-l1"><a class="reference internal" href="playbooks2.html">Advanced Playbooks</a></li> <li class="toctree-l1"><a class="reference internal" href="playbooks2.html">Advanced Playbooks</a></li>
<li class="toctree-l1"><a class="reference internal" href="bestpractices.html">Best Practices</a></li>
<li class="toctree-l1"><a class="reference internal" href="api.html">API &amp; Integrations</a></li> <li class="toctree-l1"><a class="reference internal" href="api.html">API &amp; Integrations</a></li>
<li class="toctree-l1"><a class="reference internal" href="moduledev.html">Module Development</a></li> <li class="toctree-l1"><a class="reference internal" href="moduledev.html">Module Development</a></li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">Frequently Asked Questions</a></li> <li class="toctree-l1"><a class="reference internal" href="faq.html">FAQ</a></li>
</ul> </ul>
</span> </span>
</li> </li>
@ -189,7 +190,7 @@ s.parentNode.insertBefore(ga, s);
</p> </p>
<p> <p>
&copy; Copyright 2012 Michael DeHaan.<br/> &copy; Copyright 2012 Michael DeHaan.<br/>
Last updated on May 10, 2012.<br/> Last updated on May 13, 2012.<br/>
</p> </p>
</div> </div>
</footer> </footer>

View file

@ -136,9 +136,10 @@ s.parentNode.insertBefore(ga, s);
<li class="toctree-l1"><a class="reference internal" href="YAMLSyntax.html">YAML Syntax</a></li> <li class="toctree-l1"><a class="reference internal" href="YAMLSyntax.html">YAML Syntax</a></li>
<li class="toctree-l1"><a class="reference internal" href="playbooks.html">Playbooks</a></li> <li class="toctree-l1"><a class="reference internal" href="playbooks.html">Playbooks</a></li>
<li class="toctree-l1"><a class="reference internal" href="playbooks2.html">Advanced Playbooks</a></li> <li class="toctree-l1"><a class="reference internal" href="playbooks2.html">Advanced Playbooks</a></li>
<li class="toctree-l1"><a class="reference internal" href="bestpractices.html">Best Practices</a></li>
<li class="toctree-l1"><a class="reference internal" href="api.html">API &amp; Integrations</a></li> <li class="toctree-l1"><a class="reference internal" href="api.html">API &amp; Integrations</a></li>
<li class="toctree-l1"><a class="reference internal" href="moduledev.html">Module Development</a></li> <li class="toctree-l1"><a class="reference internal" href="moduledev.html">Module Development</a></li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">Frequently Asked Questions</a></li> <li class="toctree-l1"><a class="reference internal" href="faq.html">FAQ</a></li>
</ul> </ul>
</span> </span>
</li> </li>
@ -350,7 +351,7 @@ explore, but you already have a fully working infrastructure!</p>
</p> </p>
<p> <p>
&copy; Copyright 2012 Michael DeHaan.<br/> &copy; Copyright 2012 Michael DeHaan.<br/>
Last updated on May 10, 2012.<br/> Last updated on May 13, 2012.<br/>
</p> </p>
</div> </div>
</footer> </footer>

View file

@ -135,9 +135,10 @@ s.parentNode.insertBefore(ga, s);
<li class="toctree-l1"><a class="reference internal" href="YAMLSyntax.html">YAML Syntax</a></li> <li class="toctree-l1"><a class="reference internal" href="YAMLSyntax.html">YAML Syntax</a></li>
<li class="toctree-l1"><a class="reference internal" href="playbooks.html">Playbooks</a></li> <li class="toctree-l1"><a class="reference internal" href="playbooks.html">Playbooks</a></li>
<li class="toctree-l1"><a class="reference internal" href="playbooks2.html">Advanced Playbooks</a></li> <li class="toctree-l1"><a class="reference internal" href="playbooks2.html">Advanced Playbooks</a></li>
<li class="toctree-l1"><a class="reference internal" href="bestpractices.html">Best Practices</a></li>
<li class="toctree-l1"><a class="reference internal" href="api.html">API &amp; Integrations</a></li> <li class="toctree-l1"><a class="reference internal" href="api.html">API &amp; Integrations</a></li>
<li class="toctree-l1"><a class="reference internal" href="moduledev.html">Module Development</a></li> <li class="toctree-l1"><a class="reference internal" href="moduledev.html">Module Development</a></li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">Frequently Asked Questions</a></li> <li class="toctree-l1"><a class="reference internal" href="faq.html">FAQ</a></li>
</ul> </ul>
</span> </span>
</li> </li>
@ -346,23 +347,30 @@ Email: <input type=text name=email>&nbsp;&nbsp;<input type=submit name="sub" val
</ul> </ul>
</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#include-files-and-reuse">Include Files And Reuse</a></li>
<li class="toctree-l3"><a class="reference internal" href="playbooks.html#include-files-and-reuse">Include Files And Reuse</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="playbooks.html#executing-a-playbook">Executing A Playbook</a></li> <li class="toctree-l2"><a class="reference internal" href="playbooks.html#executing-a-playbook">Executing A Playbook</a></li>
</ul> </ul>
</li> </li>
<li class="toctree-l1"><a class="reference internal" href="playbooks2.html">Advanced Playbooks</a><ul> <li class="toctree-l1"><a class="reference internal" href="playbooks2.html">Advanced Playbooks</a><ul>
<li class="toctree-l2"><a class="reference internal" href="playbooks2.html#local-playbooks">Local Playbooks</a></li> <li class="toctree-l2"><a class="reference internal" href="playbooks2.html#accessing-complex-variable-data">Accessing Complex Variable Data</a></li>
<li class="toctree-l2"><a class="reference internal" href="playbooks2.html#pull-mode-playbooks">Pull-Mode Playbooks</a></li> <li class="toctree-l2"><a class="reference internal" href="playbooks2.html#accessing-information-about-other-hosts">Accessing Information About Other Hosts</a></li>
<li class="toctree-l2"><a class="reference internal" href="playbooks2.html#variables-from-other-hosts">Variables From Other Hosts</a></li> <li class="toctree-l2"><a class="reference internal" href="playbooks2.html#magic-variables">Magic Variables</a></li>
<li class="toctree-l2"><a class="reference internal" href="playbooks2.html#external-variables-and-prompted-or-sensitive-data">External Variables and Prompted or Sensitive Data</a></li> <li class="toctree-l2"><a class="reference internal" href="playbooks2.html#variable-file-seperation">Variable File Seperation</a></li>
<li class="toctree-l2"><a class="reference internal" href="playbooks2.html#prompting-for-sensitive-data">Prompting For Sensitive Data</a></li>
<li class="toctree-l2"><a class="reference internal" href="playbooks2.html#passing-variables-on-the-command-line">Passing Variables On The Command Line</a></li>
<li class="toctree-l2"><a class="reference internal" href="playbooks2.html#conditional-execution">Conditional Execution</a></li> <li class="toctree-l2"><a class="reference internal" href="playbooks2.html#conditional-execution">Conditional Execution</a></li>
<li class="toctree-l2"><a class="reference internal" href="playbooks2.html#conditional-imports">Conditional Imports</a></li> <li class="toctree-l2"><a class="reference internal" href="playbooks2.html#conditional-imports">Conditional Imports</a></li>
<li class="toctree-l2"><a class="reference internal" href="playbooks2.html#using-includes-to-assign-classes-of-systems">Using Includes To Assign Classes of Systems</a></li>
<li class="toctree-l2"><a class="reference internal" href="playbooks2.html#loop-shorthand">Loop Shorthand</a></li> <li class="toctree-l2"><a class="reference internal" href="playbooks2.html#loop-shorthand">Loop Shorthand</a></li>
<li class="toctree-l2"><a class="reference internal" href="playbooks2.html#selecting-files-and-templates-based-on-variables">Selecting Files And Templates Based On Variables</a></li>
<li class="toctree-l2"><a class="reference internal" href="playbooks2.html#asynchronous-actions-and-polling">Asynchronous Actions and Polling</a></li> <li class="toctree-l2"><a class="reference internal" href="playbooks2.html#asynchronous-actions-and-polling">Asynchronous Actions and Polling</a></li>
<li class="toctree-l2"><a class="reference internal" href="playbooks2.html#local-playbooks">Local Playbooks</a></li>
<li class="toctree-l2"><a class="reference internal" href="playbooks2.html#pull-mode-playbooks">Pull-Mode Playbooks</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="bestpractices.html">Best Practices</a><ul>
<li class="toctree-l2"><a class="reference internal" href="bestpractices.html#group-by-roles">Group By Roles</a></li>
<li class="toctree-l2"><a class="reference internal" href="bestpractices.html#directory-organization">Directory Organization</a></li>
<li class="toctree-l2"><a class="reference internal" href="bestpractices.html#miscellaneous-tips">Miscellaneous Tips</a></li>
</ul> </ul>
</li> </li>
<li class="toctree-l1"><a class="reference internal" href="api.html">API &amp; Integrations</a><ul> <li class="toctree-l1"><a class="reference internal" href="api.html">API &amp; Integrations</a><ul>
@ -389,7 +397,7 @@ Email: <input type=text name=email>&nbsp;&nbsp;<input type=submit name="sub" val
<li class="toctree-l2"><a class="reference internal" href="moduledev.html#getting-your-module-into-core">Getting Your Module Into Core</a></li> <li class="toctree-l2"><a class="reference internal" href="moduledev.html#getting-your-module-into-core">Getting Your Module Into Core</a></li>
</ul> </ul>
</li> </li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">Frequently Asked Questions</a><ul> <li class="toctree-l1"><a class="reference internal" href="faq.html">FAQ</a><ul>
<li class="toctree-l2"><a class="reference internal" href="faq.html#what-inspired-ansible">What inspired Ansible?</a></li> <li class="toctree-l2"><a class="reference internal" href="faq.html#what-inspired-ansible">What inspired Ansible?</a></li>
<li class="toctree-l2"><a class="reference internal" href="faq.html#comparisons">Comparisons</a><ul> <li class="toctree-l2"><a class="reference internal" href="faq.html#comparisons">Comparisons</a><ul>
<li class="toctree-l3"><a class="reference internal" href="faq.html#vs-func">vs Func?</a></li> <li class="toctree-l3"><a class="reference internal" href="faq.html#vs-func">vs Func?</a></li>
@ -439,7 +447,7 @@ Puppet Labs, and is now with <a class="reference external" href="http://rpath.co
</p> </p>
<p> <p>
&copy; Copyright 2012 Michael DeHaan.<br/> &copy; Copyright 2012 Michael DeHaan.<br/>
Last updated on May 10, 2012.<br/> Last updated on May 13, 2012.<br/>
</p> </p>
</div> </div>
</footer> </footer>

View file

@ -27,7 +27,7 @@
<script type="text/javascript" src="_static/bootstrap-scrollspy.js"></script> <script type="text/javascript" src="_static/bootstrap-scrollspy.js"></script>
<link rel="shortcut icon" href="_static/favicon.ico"/> <link rel="shortcut icon" href="_static/favicon.ico"/>
<link rel="top" title="Ansible - SSH-Based Configuration Management &amp; Deployment" href="index.html" /> <link rel="top" title="Ansible - SSH-Based Configuration Management &amp; Deployment" href="index.html" />
<link rel="next" title="Frequently Asked Questions" href="faq.html" /> <link rel="next" title="FAQ" href="faq.html" />
<link rel="prev" title="API &amp; Integrations" href="api.html" /> <link rel="prev" title="API &amp; Integrations" href="api.html" />
<script type="text/javascript"> <script type="text/javascript">
(function () { (function () {
@ -136,9 +136,10 @@ s.parentNode.insertBefore(ga, s);
<li class="toctree-l1"><a class="reference internal" href="YAMLSyntax.html">YAML Syntax</a></li> <li class="toctree-l1"><a class="reference internal" href="YAMLSyntax.html">YAML Syntax</a></li>
<li class="toctree-l1"><a class="reference internal" href="playbooks.html">Playbooks</a></li> <li class="toctree-l1"><a class="reference internal" href="playbooks.html">Playbooks</a></li>
<li class="toctree-l1"><a class="reference internal" href="playbooks2.html">Advanced Playbooks</a></li> <li class="toctree-l1"><a class="reference internal" href="playbooks2.html">Advanced Playbooks</a></li>
<li class="toctree-l1"><a class="reference internal" href="bestpractices.html">Best Practices</a></li>
<li class="toctree-l1"><a class="reference internal" href="api.html">API &amp; Integrations</a></li> <li class="toctree-l1"><a class="reference internal" href="api.html">API &amp; Integrations</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="">Module Development</a></li> <li class="toctree-l1 current"><a class="current reference internal" href="">Module Development</a></li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">Frequently Asked Questions</a></li> <li class="toctree-l1"><a class="reference internal" href="faq.html">FAQ</a></li>
</ul> </ul>
</span> </span>
</li> </li>
@ -454,7 +455,7 @@ Stop by the mailing list to inquire about requirements.</p>
</p> </p>
<p> <p>
&copy; Copyright 2012 Michael DeHaan.<br/> &copy; Copyright 2012 Michael DeHaan.<br/>
Last updated on May 10, 2012.<br/> Last updated on May 13, 2012.<br/>
</p> </p>
</div> </div>
</footer> </footer>

View file

@ -136,9 +136,10 @@ s.parentNode.insertBefore(ga, s);
<li class="toctree-l1"><a class="reference internal" href="YAMLSyntax.html">YAML Syntax</a></li> <li class="toctree-l1"><a class="reference internal" href="YAMLSyntax.html">YAML Syntax</a></li>
<li class="toctree-l1"><a class="reference internal" href="playbooks.html">Playbooks</a></li> <li class="toctree-l1"><a class="reference internal" href="playbooks.html">Playbooks</a></li>
<li class="toctree-l1"><a class="reference internal" href="playbooks2.html">Advanced Playbooks</a></li> <li class="toctree-l1"><a class="reference internal" href="playbooks2.html">Advanced Playbooks</a></li>
<li class="toctree-l1"><a class="reference internal" href="bestpractices.html">Best Practices</a></li>
<li class="toctree-l1"><a class="reference internal" href="api.html">API &amp; Integrations</a></li> <li class="toctree-l1"><a class="reference internal" href="api.html">API &amp; Integrations</a></li>
<li class="toctree-l1"><a class="reference internal" href="moduledev.html">Module Development</a></li> <li class="toctree-l1"><a class="reference internal" href="moduledev.html">Module Development</a></li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">Frequently Asked Questions</a></li> <li class="toctree-l1"><a class="reference internal" href="faq.html">FAQ</a></li>
</ul> </ul>
</span> </span>
</li> </li>
@ -786,7 +787,7 @@ yum pkg=httpd state=installed</pre>
</p> </p>
<p> <p>
&copy; Copyright 2012 Michael DeHaan.<br/> &copy; Copyright 2012 Michael DeHaan.<br/>
Last updated on May 10, 2012.<br/> Last updated on May 13, 2012.<br/>
</p> </p>
</div> </div>
</footer> </footer>

View file

@ -136,9 +136,10 @@ s.parentNode.insertBefore(ga, s);
<li class="toctree-l1"><a class="reference internal" href="YAMLSyntax.html">YAML Syntax</a></li> <li class="toctree-l1"><a class="reference internal" href="YAMLSyntax.html">YAML Syntax</a></li>
<li class="toctree-l1"><a class="reference internal" href="playbooks.html">Playbooks</a></li> <li class="toctree-l1"><a class="reference internal" href="playbooks.html">Playbooks</a></li>
<li class="toctree-l1"><a class="reference internal" href="playbooks2.html">Advanced Playbooks</a></li> <li class="toctree-l1"><a class="reference internal" href="playbooks2.html">Advanced Playbooks</a></li>
<li class="toctree-l1"><a class="reference internal" href="bestpractices.html">Best Practices</a></li>
<li class="toctree-l1"><a class="reference internal" href="api.html">API &amp; Integrations</a></li> <li class="toctree-l1"><a class="reference internal" href="api.html">API &amp; Integrations</a></li>
<li class="toctree-l1"><a class="reference internal" href="moduledev.html">Module Development</a></li> <li class="toctree-l1"><a class="reference internal" href="moduledev.html">Module Development</a></li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">Frequently Asked Questions</a></li> <li class="toctree-l1"><a class="reference internal" href="faq.html">FAQ</a></li>
</ul> </ul>
</span> </span>
</li> </li>
@ -362,7 +363,7 @@ YAML:</p>
</p> </p>
<p> <p>
&copy; Copyright 2012 Michael DeHaan.<br/> &copy; Copyright 2012 Michael DeHaan.<br/>
Last updated on May 10, 2012.<br/> Last updated on May 13, 2012.<br/>
</p> </p>
</div> </div>
</footer> </footer>

View file

@ -136,9 +136,10 @@ s.parentNode.insertBefore(ga, s);
<li class="toctree-l1"><a class="reference internal" href="YAMLSyntax.html">YAML Syntax</a></li> <li class="toctree-l1"><a class="reference internal" href="YAMLSyntax.html">YAML Syntax</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="">Playbooks</a></li> <li class="toctree-l1 current"><a class="current reference internal" href="">Playbooks</a></li>
<li class="toctree-l1"><a class="reference internal" href="playbooks2.html">Advanced Playbooks</a></li> <li class="toctree-l1"><a class="reference internal" href="playbooks2.html">Advanced Playbooks</a></li>
<li class="toctree-l1"><a class="reference internal" href="bestpractices.html">Best Practices</a></li>
<li class="toctree-l1"><a class="reference internal" href="api.html">API &amp; Integrations</a></li> <li class="toctree-l1"><a class="reference internal" href="api.html">API &amp; Integrations</a></li>
<li class="toctree-l1"><a class="reference internal" href="moduledev.html">Module Development</a></li> <li class="toctree-l1"><a class="reference internal" href="moduledev.html">Module Development</a></li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">Frequently Asked Questions</a></li> <li class="toctree-l1"><a class="reference internal" href="faq.html">FAQ</a></li>
</ul> </ul>
</span> </span>
</li> </li>
@ -155,10 +156,7 @@ s.parentNode.insertBefore(ga, s);
</ul> </ul>
</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="#include-files-and-reuse">Include Files And Reuse</a></li> <li><a class="reference internal" href="#include-files-and-reuse">Include Files And Reuse</a></li>
</ul>
</li>
<li><a class="reference internal" href="#executing-a-playbook">Executing A Playbook</a></li> <li><a class="reference internal" href="#executing-a-playbook">Executing A Playbook</a></li>
</ul> </ul>
</li> </li>
@ -373,12 +371,8 @@ won&#8217;t need them for much else.</p>
<p class="last">Notify handlers are always run in the order written.</p> <p class="last">Notify handlers are always run in the order written.</p>
</div> </div>
</div> </div>
<div class="section" id="power-tricks">
<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
things you can do with playbooks.</p>
<div class="section" id="include-files-and-reuse"> <div class="section" id="include-files-and-reuse">
<h3>Include Files And Reuse<a class="headerlink" href="#include-files-and-reuse" title="Permalink to this headline"></a></h3> <h2>Include Files And Reuse<a class="headerlink" href="#include-files-and-reuse" title="Permalink to this headline"></a></h2>
<p>Suppose you want to reuse lists of tasks between plays or playbooks. You can use <p>Suppose you want to reuse lists of tasks between plays or playbooks. You can use
include files to do this.</p> include files to do this.</p>
<p>An include file simply contains a flat list of tasks, like so:</p> <p>An include file simply contains a flat list of tasks, like so:</p>
@ -430,7 +424,6 @@ of a play:</p>
with &#8216;vars_files&#8217;. If you find yourself needing to do this, consider how you can with &#8216;vars_files&#8217;. If you find yourself needing to do this, consider how you can
restructure your playbook to be more class/role oriented.</p> restructure your playbook to be more class/role oriented.</p>
</div> </div>
</div>
<div class="section" id="executing-a-playbook"> <div class="section" id="executing-a-playbook">
<h2>Executing A Playbook<a class="headerlink" href="#executing-a-playbook" title="Permalink to this headline"></a></h2> <h2>Executing A Playbook<a class="headerlink" href="#executing-a-playbook" title="Permalink to this headline"></a></h2>
<p>Now that you&#8217;ve learned playbook syntax, how do you run a playbook? It&#8217;s simple. <p>Now that you&#8217;ve learned playbook syntax, how do you run a playbook? It&#8217;s simple.
@ -442,8 +435,12 @@ Let&#8217;s run a playbook using a parallelism level of 10:</p>
<dl class="last docutils"> <dl class="last docutils">
<dt><a class="reference internal" href="YAMLSyntax.html"><em>YAML Syntax</em></a></dt> <dt><a class="reference internal" href="YAMLSyntax.html"><em>YAML Syntax</em></a></dt>
<dd>Learn about YAML syntax</dd> <dd>Learn about YAML syntax</dd>
<dt><a class="reference internal" href=""><em>Playbooks</em></a></dt>
<dd>Review the basic Playbook language features</dd>
<dt><a class="reference internal" href="playbooks2.html"><em>Advanced Playbooks</em></a></dt> <dt><a class="reference internal" href="playbooks2.html"><em>Advanced Playbooks</em></a></dt>
<dd>Learn about Advanced Playbook Features</dd> <dd>Learn about Advanced Playbook Features</dd>
<dt><a class="reference internal" href="bestpractices.html"><em>Best Practices</em></a></dt>
<dd>Various tips about managing playbooks in the real world</dd>
<dt><a class="reference internal" href="modules.html"><em>Ansible Modules</em></a></dt> <dt><a class="reference internal" href="modules.html"><em>Ansible Modules</em></a></dt>
<dd>Learn about available modules</dd> <dd>Learn about available modules</dd>
<dt><a class="reference internal" href="moduledev.html"><em>Module Development</em></a></dt> <dt><a class="reference internal" href="moduledev.html"><em>Module Development</em></a></dt>
@ -474,7 +471,7 @@ Let&#8217;s run a playbook using a parallelism level of 10:</p>
</p> </p>
<p> <p>
&copy; Copyright 2012 Michael DeHaan.<br/> &copy; Copyright 2012 Michael DeHaan.<br/>
Last updated on May 10, 2012.<br/> Last updated on May 13, 2012.<br/>
</p> </p>
</div> </div>
</footer> </footer>

111
rst/bestpractices.rst Normal file
View file

@ -0,0 +1,111 @@
Best Practices
==============
Here are some tips for making the most of Ansible.
Group By Roles
++++++++++++++
A system can be in multiple groups. See ref:`patterns`. Having groups named after things like
'webservers' and 'dbservers' is repeated in the examples because it's a very powerful concept.
This allows playbooks to target machines based on role, as well as to assign role specific variables
using the group variable system.
Directory Organization
++++++++++++++++++++++
Playbooks should be organized like this::
(root of source control repository)
acme/ # each playbook has a directory
setup.yml # playbook to manage the service
stop.yml # playbook to halt the service (optional)
files/
some_file_path_foo.conf
templates/
etc_acme_conf_acme.conf
etc_other_conf_other.conf
vars/
main.yml
handlers/
main.yml
tasks/
setup.yml
stop.yml
Any directories or files not needed can be omitted. Not all modules may require `vars` or `files` sections, though most
will require `handlers`, `tasks`, and `templates`. To review what each of these sections do, see ref:`playbooks` and ref:`playbooks2`.
The acme/setup.yml playbook would be as simple as::
----
- hosts: webservers
user: root
vars_files
- include: vars/main.yml
tasks:
- include: tasks/setup.yml
handlers:
- include: handlers/main.yml
The tasks are individually broken out in 'acme/tasks/setup.yml', and handlers, which are common to all task files,
are contained in 'acme/handlers/main.yml'. As a reminder, handlers are mostly just used to notify services to restart
when things change, and these are described in ref:`playbooks`.
Including more than one setup file or more than one handlers file is of course legal.
Having playbooks be able to include other playbooks is coming in release 0.5.
Until then, to manage your entire site, simply execute all of your playbooks together, in the order desired.
You don't have to do this though, it's fine to select sections of your infrastructure to manage at a single time.
You may wish to construct simple shell scripts to wrap calls to ansible-playbook.
Miscellaneous Tips
++++++++++++++++++
When you can do something simply, do something simply. Do not reach to use every feature of Ansible together, all
at once. Use what works for you. For example, you should probably not need 'vars', 'vars_files', 'vars_prompt' and '--extra-vars' all at once, while also using an external inventory file.
Optimize for readability. Whitespace between sections of YAML documents and in between tasks is strongly encouraged,
as is usage of YAML comments, which start with "#". It is also useful to comment at the top of each file the purpose of the individual file and the author, including email address.
It is possible to leave off the "name" for a given task, though it is recommended to provide
a descriptive comment about why something is being done instead.
Use version control. Keep your playbooks and inventory file in git (or another version control system), and commit when you make changes to them.
This way you have an audit trail describing when and why you changed the rules automating your infrastructure.
Resist the urge to write the same playbooks and configuration files for heterogeneous distributions. While lots of software packages claim to make this easy on you, the configuration files are often quite different, to the point where it would be easier to treat them as different playbooks. This is why, for example, Ansible has a seperate 'yum' and 'apt' module. Yum and apt have different capabilities, and we don't want to code for the least common denominator.
Use variables for user tunable settings versus having constants in the tasks file or templates, so that it is easy to reconfigure a playbook. Think about this as exposing the knobs to things you would like to tweak.
Since a system can be in more than one group, if you have multiple datacenters or sites, consider putting systems into groups by role, but also different groups by geography. This allows you to assign different variables to different geographies.
.. seealso::
:doc:`YAMLSyntax`
Learn about YAML syntax
:doc:`playbooks`
Review the basic playbook features
:doc:`modules`
Learn about available modules
:doc:`moduledev`
Learn how to extend Ansible by writing your own modules
:doc:`patterns`
Learn about how to select hosts
`Github examples directory <https://github.com/ansible/ansible/tree/master/examples/playbooks>`_
Complete playbook files from the github project source
`Mailing List <http://groups.google.com/group/ansible-project>`_
Questions? Help? Ideas? Stop by the list on Google Groups

View file

@ -127,6 +127,7 @@ Contents
YAMLSyntax YAMLSyntax
playbooks playbooks
playbooks2 playbooks2
bestpractices
api api
moduledev moduledev
faq faq

View file

@ -224,14 +224,8 @@ won't need them for much else.
Notify handlers are always run in the order written. Notify handlers are always run in the order written.
Power Tricks
````````````
Now that you have the basics down, let's learn some more advanced
things you can do with playbooks.
Include Files And Reuse Include Files And Reuse
+++++++++++++++++++++++ ```````````````````````
Suppose you want to reuse lists of tasks between plays or playbooks. You can use Suppose you want to reuse lists of tasks between plays or playbooks. You can use
include files to do this. include files to do this.
@ -306,8 +300,12 @@ Let's run a playbook using a parallelism level of 10::
:doc:`YAMLSyntax` :doc:`YAMLSyntax`
Learn about YAML syntax Learn about YAML syntax
:doc:`playbooks`
Review the basic Playbook language features
:doc:`playbooks2` :doc:`playbooks2`
Learn about Advanced Playbook Features Learn about Advanced Playbook Features
:doc:`bestpractices`
Various tips about managing playbooks in the real world
:doc:`modules` :doc:`modules`
Learn about available modules Learn about available modules
:doc:`moduledev` :doc:`moduledev`

View file

@ -2,39 +2,12 @@ Advanced Playbooks
================== ==================
Here are some advanced features of the playbooks language. Using all of these features Here are some advanced features of the playbooks language. Using all of these features
are not neccessary, but many of them will prove useful. are not neccessary, but many of them will prove useful. If a feature doesn't seem immediately
relevant, feel free to skip it. For many people, the features documented in `playbooks` will
be 90% or more of what they use in Ansible.
Local Playbooks Accessing Complex Variable Data
+++++++++++++++ +++++++++++++++++++++++++++++++
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.
To run an entire playbook locally, just set the "hosts:" line to "hosts:127.0.0.1" and then run the playbook like so::
ansible-playbook playbook.yml --connection=local
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::
hosts: 127.0.0.1
connection: local
Pull-Mode Playbooks
+++++++++++++++++++
The use of playbooks in local mode (above) is made extremely powerful with the addition of `ansible-pull` in the
0.4 release. A script for setting up ansible-pull is provided in the examples/playbooks directory of the source
checkout.
The basic idea is to use Ansible to set up a remote copy of ansible on each managed node, each set to run via
cron and update playbook source via git. This interverts the default push architecture of ansible into a pull
architecture, which has near-limitless scaling potential. The setup playbook can be tuned to change
the cron frequency, logging locations, and parameters to ansible-pull.
Accessing Hash and Array Variable Data
++++++++++++++++++++++++++++++++++++++
Some provided facts, like networking information, are made available as nested datastructures. To access Some provided facts, like networking information, are made available as nested datastructures. To access
them a simple '$foo' is not sufficient, but it is still easy to do. Here's how we get an IP address using them a simple '$foo' is not sufficient, but it is still easy to do. Here's how we get an IP address using
@ -44,12 +17,17 @@ Ansible 0.4 and later::
It is also possible to access variables whose elements are arrays:: It is also possible to access variables whose elements are arrays::
${somelist[1]} ${somelist[0]}
And the array and hash reference syntaxes can be mixed. And the array and hash reference syntaxes can be mixed.
Accessing Variables From Other Hosts In templates, the simple access form still holds, but they can also be accessed from Jinja2 in more Python-native ways if
++++++++++++++++++++++++++++++++++++ that is preferred::
{{ ansible_eth0["ipv4"]["address"] }}
Accessing Information About Other Hosts
+++++++++++++++++++++++++++++++++++++++
If your database server wants to check the value of a 'fact' from another node, or an inventory variable If your database server wants to check the value of a 'fact' from another node, or an inventory variable
assigned to another node, it's easy to do so within a template or even an action line (note: this uses syntax available in 0.4 and later):: assigned to another node, it's easy to do so within a template or even an action line (note: this uses syntax available in 0.4 and later)::
@ -59,8 +37,24 @@ assigned to another node, it's easy to do so within a template or even an action
NOTE: No database or other complex system is required to exchange data between hosts. The hosts that you NOTE: No database or other complex system is required to exchange data between hosts. The hosts that you
want to reference data from must be included in either the current play or any previous play. want to reference data from must be included in either the current play or any previous play.
External Variables and Prompted or Sensitive Data Magic Variables
+++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++
Some variables made available to hosts don't come from definitions in a playbook, the inventory file, or discovery from the system. There are only two of these, and are used in special cases that many users won't need.
`groups` is a list (array) of all the groups the current host is in. This can be used in templates using Jinja2
syntax to make template source files that vary based on the group membership (or role) of the host::
{% if 'webserver' in groups %}
# some part of a configuration file that only applies to webservers
{% endif %}
`inventory_hostname` is the name of the hostname as configured in Ansible's inventory host file. This can
be useful for when you don't want to rely on the discovered hostname `ansible_hostname` or for other mysterious
reasons. Don't worry about it unless you think you need it.
Variable File Seperation
++++++++++++++++++++++++
It's a great idea to keep your playbooks under source control, but It's a great idea to keep your playbooks under source control, but
you may wish to make the playbook source public while keeping certain you may wish to make the playbook source public while keeping certain
@ -200,48 +194,6 @@ from turning into arbitrary code with ugly nested ifs, conditionals, and so on -
in more streamlined & auditable configuration rules -- especially because there are a in more streamlined & auditable configuration rules -- especially because there are a
minimum of decision points to track. minimum of decision points to track.
Using Includes To Assign Classes of Systems
+++++++++++++++++++++++++++++++++++++++++++
Include files are really powerful when used to reuse logic between playbooks. You
could imagine a playbook describing your entire infrastructure like
this, in a list of just a few plays::
---
- hosts: atlanta-webservers
vars:
datacenter: atlanta
database: db.atlanta.com
tasks:
- include: tasks/base.yml
- include: tasks/webservers.yml
handlers:
- include: handlers/common.yml
- hosts: atlanta-dbservers
vars:
datacenter: atlanta
tasks:
- include: tasks/base.yml
- include: tasks/dbservers.yml
handlers:
- include: handlers/common.yml
There is one (or more) play defined for each group of systems, and
each play maps each group to several includes. These includes represent
'class definitions', telling the systems what they are supposed to do or be.
In the above example, all hosts get the base configuration first and further
customize it depending on what class or nature of machines they are.
Loop Shorthand Loop Shorthand
++++++++++++++ ++++++++++++++
@ -272,7 +224,7 @@ The following construct (new in 0.4) selects the first available file appropriat
which is often much cleaner than putting a lot of if conditionals in a template. which is often much cleaner than putting a lot of if conditionals in a template.
The following example shows how to template out a configuration file that was very different between, say, The following example shows how to template out a configuration file that was very different between, say,
CentOS and Debian. CentOS and Debian::
- name: template a file - name: template a file
action: template src=$item dest=/etc/myapp/foo.conf action: template src=$item dest=/etc/myapp/foo.conf
@ -332,12 +284,47 @@ Alternatively, if you do not need to wait on the task to complete, you may
Using a higher value for ``--forks`` will result in kicking off asynchronous Using a higher value for ``--forks`` will result in kicking off asynchronous
tasks even faster. This also increases the efficiency of polling. tasks even faster. This also increases the efficiency of polling.
Local Playbooks
+++++++++++++++
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.
To run an entire playbook locally, just set the "hosts:" line to "hosts:127.0.0.1" and then run the playbook like so::
ansible-playbook playbook.yml --connection=local
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::
hosts: 127.0.0.1
connection: local
Pull-Mode Playbooks
+++++++++++++++++++
The use of playbooks in local mode (above) is made extremely powerful with the addition of `ansible-pull` in the
0.4 release. A script for setting up ansible-pull is provided in the examples/playbooks directory of the source
checkout.
The basic idea is to use Ansible to set up a remote copy of ansible on each managed node, each set to run via
cron and update playbook source via git. This interverts the default push architecture of ansible into a pull
architecture, which has near-limitless scaling potential. The setup playbook can be tuned to change
the cron frequency, logging locations, and parameters to ansible-pull.
This is useful both for extreme scale-out as well as periodic remediation. Usage of the 'fetch' module to retrieve
logs from ansible-pull runs would be an excellent way to gather and analyze remote logs from ansible-pull.
.. seealso:: .. seealso::
:doc:`YAMLSyntax` :doc:`YAMLSyntax`
Learn about YAML syntax Learn about YAML syntax
:doc:`playbooks` :doc:`playbooks`
Review the basic playbook features Review the basic playbook features
:doc:`bestpractices`
Various tips about playbooks in the real world
:doc:`modules` :doc:`modules`
Learn about available modules Learn about available modules
:doc:`moduledev` :doc:`moduledev`

View file

@ -140,9 +140,10 @@ s.parentNode.insertBefore(ga, s);
<li class="toctree-l1"><a class="reference internal" href="YAMLSyntax.html">YAML Syntax</a></li> <li class="toctree-l1"><a class="reference internal" href="YAMLSyntax.html">YAML Syntax</a></li>
<li class="toctree-l1"><a class="reference internal" href="playbooks.html">Playbooks</a></li> <li class="toctree-l1"><a class="reference internal" href="playbooks.html">Playbooks</a></li>
<li class="toctree-l1"><a class="reference internal" href="playbooks2.html">Advanced Playbooks</a></li> <li class="toctree-l1"><a class="reference internal" href="playbooks2.html">Advanced Playbooks</a></li>
<li class="toctree-l1"><a class="reference internal" href="bestpractices.html">Best Practices</a></li>
<li class="toctree-l1"><a class="reference internal" href="api.html">API &amp; Integrations</a></li> <li class="toctree-l1"><a class="reference internal" href="api.html">API &amp; Integrations</a></li>
<li class="toctree-l1"><a class="reference internal" href="moduledev.html">Module Development</a></li> <li class="toctree-l1"><a class="reference internal" href="moduledev.html">Module Development</a></li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">Frequently Asked Questions</a></li> <li class="toctree-l1"><a class="reference internal" href="faq.html">FAQ</a></li>
</ul> </ul>
</span> </span>
</li> </li>
@ -206,7 +207,7 @@ s.parentNode.insertBefore(ga, s);
</p> </p>
<p> <p>
&copy; Copyright 2012 Michael DeHaan.<br/> &copy; Copyright 2012 Michael DeHaan.<br/>
Last updated on May 10, 2012.<br/> Last updated on May 13, 2012.<br/>
</p> </p>
</div> </div>
</footer> </footer>

File diff suppressed because one or more lines are too long