<h1>API & Integrations<aclass="headerlink"href="#api-integrations"title="Permalink to this headline">¶</a></h1>
<h1><aclass="toc-backref"href="#table-of-contents">API & Integrations</a><aclass="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 its 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’s
<p>Also covered here, Ansible’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
external sources. We’ll start with the Python API.</p>
external sources. We’ll start with the Python API.</p>
<divclass="contents topic"id="table-of-contents">
<pclass="topic-title first"><cite>Table of contents</cite></p>
<ulclass="simple">
<li><aclass="reference internal"href="#api-integrations"id="id2">API & Integrations</a><ul>
<h2>External Inventory<aclass="headerlink"href="#external-inventory"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#table-of-contents">External Inventory</a><aclass="headerlink"href="#external-inventory"title="Permalink to this headline">¶</a></h2>
<p>Often a user of a configuration management system will want to keep inventory
<p>Often a user of a configuration management system will want to keep inventory
in a different system. Frequent examples include LDAP, <aclass="reference external"href="http://cobbler.github.com">Cobbler</a>,
in a different system. Frequent examples include LDAP, <aclass="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
...
@@ -422,9 +432,9 @@ e.g.
...
@@ -422,9 +432,9 @@ e.g.
</ul>
</ul>
<p>Both <ttclass="docutils literal"><spanclass="pre">ec2_security_group_ids</span></tt> and <ttclass="docutils literal"><spanclass="pre">ec2_security_group_names</span></tt> are comma-separated lists of all security groups. Each EC2 tag is a variable in the format <ttclass="docutils literal"><spanclass="pre">ec2_tag_KEY</span></tt>.</p>
<p>Both <ttclass="docutils literal"><spanclass="pre">ec2_security_group_ids</span></tt> and <ttclass="docutils literal"><spanclass="pre">ec2_security_group_names</span></tt> are comma-separated lists of all security groups. Each EC2 tag is a variable in the format <ttclass="docutils literal"><spanclass="pre">ec2_tag_KEY</span></tt>.</p>
<p>To see the complete list of variables available for an instance, run the script by itself:</p>
<p>To see the complete list of variables available for an instance, run the script by itself:</p>
<h2>Always Mention State<aclass="headerlink"href="#always-mention-state"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#contents">Always Mention State</a><aclass="headerlink"href="#always-mention-state"title="Permalink to this headline">¶</a></h2>
<p>The ‘state’ parameter is optional to a lot of modules. Whether
<p>The ‘state’ parameter is optional to a lot of modules. Whether
‘state=present’ or ‘state=absent’, it’s always best to leave that
‘state=present’ or ‘state=absent’, it’s always best to leave that
parameter in your playbooks to make it clear, especially as some
parameter in your playbooks to make it clear, especially as some
modules support additional states.</p>
modules support additional states.</p>
</div>
</div>
<divclass="section"id="group-by-roles">
<divclass="section"id="group-by-roles">
<h2>Group By Roles<aclass="headerlink"href="#group-by-roles"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#contents">Group By Roles</a><aclass="headerlink"href="#group-by-roles"title="Permalink to this headline">¶</a></h2>
<p>A system can be in multiple groups. See <aclass="reference internal"href="patterns.html"><em>Inventory & Patterns</em></a>. Having groups named after things like
<p>A system can be in multiple groups. See <aclass="reference internal"href="patterns.html"><em>Inventory & Patterns</em></a>. Having groups named after things like
<em>webservers</em> and <em>dbservers</em> is repeated in the examples because it’s a very powerful concept.</p>
<em>webservers</em> and <em>dbservers</em> is repeated in the examples because it’s a very powerful concept.</p>
<p>This allows playbooks to target machines based on role, as well as to assign role specific variables
<p>This allows playbooks to target machines based on role, as well as to assign role specific variables
using the group variable system.</p>
using the group variable system.</p>
</div>
</div>
<divclass="section"id="directory-organization">
<divclass="section"id="directory-organization">
<h2>Directory Organization<aclass="headerlink"href="#directory-organization"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#contents">Directory Organization</a><aclass="headerlink"href="#directory-organization"title="Permalink to this headline">¶</a></h2>
<p>Playbooks should be organized like this:</p>
<p>Playbooks should be organized like this:</p>
<divclass="highlight-python"><pre># root of source control repository
<divclass="highlight-python"><pre># root of source control repository
├── acme/
├── acme/
...
@@ -240,14 +253,9 @@ these sections do, see <a class="reference internal" href="playbooks.html"><em>P
...
@@ -240,14 +253,9 @@ these sections do, see <a class="reference internal" href="playbooks.html"><em>P
are contained in ‘acme/handlers/main.yml’. As a reminder, handlers are mostly just used to notify services to restart
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 <aclass="reference internal"href="playbooks.html"><em>Playbooks</em></a>.</p>
when things change, and these are described in <aclass="reference internal"href="playbooks.html"><em>Playbooks</em></a>.</p>
<p>Including more than one setup file or more than one handlers file is of course legal.</p>
<p>Including more than one setup file or more than one handlers file is of course legal.</p>
<p>Having playbooks be able to include other playbooks is coming in a
future release. See <aclass="reference external"href="https://github.com/ansible/ansible/issues/538">Issue 538</a>.</p>
<p>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.</p>
<h2>Bundling Ansible Modules With Playbooks<aclass="headerlink"href="#bundling-ansible-modules-with-playbooks"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#contents">Bundling Ansible Modules With Playbooks</a><aclass="headerlink"href="#bundling-ansible-modules-with-playbooks"title="Permalink to this headline">¶</a></h2>
<pclass="versionadded">
<pclass="versionadded">
<spanclass="versionmodified">New in version 0.5.</span></p>
<spanclass="versionmodified">New in version 0.5.</span></p>
<p>If a playbook has a ”./library” directory relative to it’s YAML file,
<p>If a playbook has a ”./library” directory relative to it’s YAML file,
...
@@ -256,7 +264,7 @@ automatically be in the ansible module path. This is a great way to
...
@@ -256,7 +264,7 @@ automatically be in the ansible module path. This is a great way to
keep modules that go with a playbook together.</p>
keep modules that go with a playbook together.</p>
</div>
</div>
<divclass="section"id="miscellaneous-tips">
<divclass="section"id="miscellaneous-tips">
<h2>Miscellaneous Tips<aclass="headerlink"href="#miscellaneous-tips"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#contents">Miscellaneous Tips</a><aclass="headerlink"href="#miscellaneous-tips"title="Permalink to this headline">¶</a></h2>
<p>When you can do something simply, do something simply. Do not reach
<p>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
to use every feature of Ansible together, all at once. Use what works
for you. For example, you should probably not need ‘vars’,
for you. For example, you should probably not need ‘vars’,
<h1>Command Line Examples And Next Steps<aclass="headerlink"href="#command-line-examples-and-next-steps"title="Permalink to this headline">¶</a></h1>
<h1><aclass="toc-backref"href="#contents">Command Line Examples And Next Steps</a><aclass="headerlink"href="#command-line-examples-and-next-steps"title="Permalink to this headline">¶</a></h1>
<p>The following examples show how to use <cite>/usr/bin/ansible</cite> for running
<p>The following examples show how to use <cite>/usr/bin/ansible</cite> for running
ad hoc tasks. Start here.</p>
ad hoc tasks. Start here.</p>
<p>For configuration management and deployments, you’ll want to pick up on
<p>For configuration management and deployments, you’ll want to pick up on
using <cite>/usr/bin/ansible-playbook</cite>– the concepts port over directly.
using <cite>/usr/bin/ansible-playbook</cite>– the concepts port over directly.
(See <aclass="reference internal"href="playbooks.html"><em>Playbooks</em></a> for more information about those)</p>
(See <aclass="reference internal"href="playbooks.html"><em>Playbooks</em></a> for more information about those)</p>
<divclass="contents topic"id="contents">
<pclass="topic-title first">Contents</p>
<ulclass="simple">
<li><aclass="reference internal"href="#command-line-examples-and-next-steps"id="id1">Command Line Examples And Next Steps</a><ul>
<li><aclass="reference internal"href="#parallelism-and-shell-commands"id="id2">Parallelism and Shell Commands</a></li>
<h2>Parallelism and Shell Commands<aclass="headerlink"href="#parallelism-and-shell-commands"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#contents">Parallelism and Shell Commands</a><aclass="headerlink"href="#parallelism-and-shell-commands"title="Permalink to this headline">¶</a></h2>
<p>Let’s use ansible’s command line tool to reboot all web servers in Atlanta, 10 at a time. First, let’s
<p>Let’s use ansible’s command line tool to reboot all web servers in Atlanta, 10 at a time. First, let’s
set up SSH-agent so it can remember our credentials:</p>
set up SSH-agent so it can remember our credentials:</p>
@@ -257,7 +274,7 @@ get it there. This is commonly referred to as ‘idempotence’, and is
...
@@ -257,7 +274,7 @@ get it there. This is commonly referred to as ‘idempotence’, and is
However, we also recognize that running <em>ad hoc</em> commands is equally important, so Ansible easily supports both.</p>
However, we also recognize that running <em>ad hoc</em> commands is equally important, so Ansible easily supports both.</p>
</div>
</div>
<divclass="section"id="file-transfer">
<divclass="section"id="file-transfer">
<h2>File Transfer<aclass="headerlink"href="#file-transfer"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#contents">File Transfer</a><aclass="headerlink"href="#file-transfer"title="Permalink to this headline">¶</a></h2>
<p>Here’s another use case for the <cite>/usr/bin/ansible</cite> command line. Ansible can SCP lots of files to multiple machines in parallel.</p>
<p>Here’s another use case for the <cite>/usr/bin/ansible</cite> command line. Ansible can SCP lots of files to multiple machines in parallel.</p>
<p>To transfer a file directly to many different servers:</p>
<p>To transfer a file directly to many different servers:</p>
<divclass="highlight-bash"><divclass="highlight"><pre><spanclass="nv">$ </span>ansible atlanta -m copy -a <spanclass="s2">"src=/etc/hosts dest=/tmp/hosts"</span>
<divclass="highlight-bash"><divclass="highlight"><pre><spanclass="nv">$ </span>ansible atlanta -m copy -a <spanclass="s2">"src=/etc/hosts dest=/tmp/hosts"</span>
...
@@ -281,7 +298,7 @@ same options can be passed directly to the <tt class="docutils literal"><span cl
...
@@ -281,7 +298,7 @@ same options can be passed directly to the <tt class="docutils literal"><span cl
</div>
</div>
</div>
</div>
<divclass="section"id="managing-packages">
<divclass="section"id="managing-packages">
<h2>Managing Packages<aclass="headerlink"href="#managing-packages"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#contents">Managing Packages</a><aclass="headerlink"href="#managing-packages"title="Permalink to this headline">¶</a></h2>
<p>There are modules available for yum and apt. Here are some examples
<p>There are modules available for yum and apt. Here are some examples
with <aclass="reference internal"href="modules.html#yum"><em>yum</em></a>.</p>
with <aclass="reference internal"href="modules.html#yum"><em>yum</em></a>.</p>
<p>Ensure a package is installed, but don’t update it:</p>
<p>Ensure a package is installed, but don’t update it:</p>
...
@@ -305,7 +322,7 @@ for other packages for now using the command module or (better!) contribute a mo
...
@@ -305,7 +322,7 @@ for other packages for now using the command module or (better!) contribute a mo
for other package managers. Stop by the mailing list for info/details.</p>
for other package managers. Stop by the mailing list for info/details.</p>
</div>
</div>
<divclass="section"id="users-and-groups">
<divclass="section"id="users-and-groups">
<h2>Users and Groups<aclass="headerlink"href="#users-and-groups"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#contents">Users and Groups</a><aclass="headerlink"href="#users-and-groups"title="Permalink to this headline">¶</a></h2>
<p>The <aclass="reference internal"href="modules.html#user"><em>user</em></a> module allows easy creation and manipulation of
<p>The <aclass="reference internal"href="modules.html#user"><em>user</em></a> module allows easy creation and manipulation of
existing user accounts, as well as removal of user accounts that may
existing user accounts, as well as removal of user accounts that may
exist:</p>
exist:</p>
...
@@ -318,7 +335,7 @@ exist:</p>
...
@@ -318,7 +335,7 @@ exist:</p>
how to manipulate groups and group membership.</p>
how to manipulate groups and group membership.</p>
<h2>Deploying From Source Control<aclass="headerlink"href="#deploying-from-source-control"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#contents">Deploying From Source Control</a><aclass="headerlink"href="#deploying-from-source-control"title="Permalink to this headline">¶</a></h2>
<p>Deploy your webapp straight from git:</p>
<p>Deploy your webapp straight from git:</p>
<divclass="highlight-bash"><divclass="highlight"><pre><spanclass="nv">$ </span>ansible webservers -m git -a <spanclass="s2">"repo=git://foo.example.org/repo.git dest=/srv/myapp version=HEAD"</span>
<divclass="highlight-bash"><divclass="highlight"><pre><spanclass="nv">$ </span>ansible webservers -m git -a <spanclass="s2">"repo=git://foo.example.org/repo.git dest=/srv/myapp version=HEAD"</span>
</pre></div>
</pre></div>
...
@@ -329,7 +346,7 @@ deploying Perl/Python/PHP/Ruby directly from git and then restarting
...
@@ -329,7 +346,7 @@ deploying Perl/Python/PHP/Ruby directly from git and then restarting
apache.</p>
apache.</p>
</div>
</div>
<divclass="section"id="managing-services">
<divclass="section"id="managing-services">
<h2>Managing Services<aclass="headerlink"href="#managing-services"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#contents">Managing Services</a><aclass="headerlink"href="#managing-services"title="Permalink to this headline">¶</a></h2>
<p>Ensure a service is started on all webservers:</p>
<p>Ensure a service is started on all webservers:</p>
<divclass="highlight-bash"><divclass="highlight"><pre><spanclass="nv">$ </span>ansible webservers -m service -a <spanclass="s2">"name=httpd state=started"</span>
<divclass="highlight-bash"><divclass="highlight"><pre><spanclass="nv">$ </span>ansible webservers -m service -a <spanclass="s2">"name=httpd state=started"</span>
<h2>Time Limited Background Operations<aclass="headerlink"href="#time-limited-background-operations"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#contents">Time Limited Background Operations</a><aclass="headerlink"href="#time-limited-background-operations"title="Permalink to this headline">¶</a></h2>
<p>Long running operations can be backgrounded, and their status can be
<p>Long running operations can be backgrounded, and their status can be
checked on later. The same job ID is given to the same task on all
checked on later. The same job ID is given to the same task on all
hosts, so you won’t lose track. If you kick hosts and don’t want
hosts, so you won’t lose track. If you kick hosts and don’t want
...
@@ -370,7 +387,7 @@ the remote nodes will be terminated.</p>
...
@@ -370,7 +387,7 @@ the remote nodes will be terminated.</p>
shell commands or software upgrades only. Backgrounding the copy module does not do a background file transfer. <aclass="reference internal"href="playbooks.html"><em>Playbooks</em></a> also support polling, and have a simplified syntax for this.</p>
shell commands or software upgrades only. Backgrounding the copy module does not do a background file transfer. <aclass="reference internal"href="playbooks.html"><em>Playbooks</em></a> also support polling, and have a simplified syntax for this.</p>
</div>
</div>
<divclass="section"id="limiting-selected-hosts">
<divclass="section"id="limiting-selected-hosts">
<h2>Limiting Selected Hosts<aclass="headerlink"href="#limiting-selected-hosts"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#contents">Limiting Selected Hosts</a><aclass="headerlink"href="#limiting-selected-hosts"title="Permalink to this headline">¶</a></h2>
<pclass="versionadded">
<pclass="versionadded">
<spanclass="versionmodified">New in version 0.7.</span></p>
<spanclass="versionmodified">New in version 0.7.</span></p>
<p>What hosts you select to manage can be additionally constrained by using the ‘–limit’ parameter or
<p>What hosts you select to manage can be additionally constrained by using the ‘–limit’ parameter or
...
@@ -394,7 +411,7 @@ what their names or IP addresses are).</p>
...
@@ -394,7 +411,7 @@ what their names or IP addresses are).</p>
<p>Both of these methods can be used at the same time, and ranges can also be passed to the –limit parameter.</p>
<p>Both of these methods can be used at the same time, and ranges can also be passed to the –limit parameter.</p>
</div>
</div>
<divclass="section"id="configuration-defaults">
<divclass="section"id="configuration-defaults">
<h2>Configuration & Defaults<aclass="headerlink"href="#configuration-defaults"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#contents">Configuration & Defaults</a><aclass="headerlink"href="#configuration-defaults"title="Permalink to this headline">¶</a></h2>
<pclass="versionadded">
<pclass="versionadded">
<spanclass="versionmodified">New in version 0.7.</span></p>
<spanclass="versionmodified">New in version 0.7.</span></p>
<p>Ansible has an optional configuration file that can be used to tune settings and also eliminate the need to pass various command line flags. The config file location is controlled by the ANSIBLE_CONFIG environment variable, if set, otherwise ~/.ansible.cfg or /etc/ansible/ansible.cfg will be loaded, whichever comes first. For those running from source, a sample configuration file lives in the examples/ directory. The RPM will install configuration into /etc/ansible/ansible.cfg automatically.</p>
<p>Ansible has an optional configuration file that can be used to tune settings and also eliminate the need to pass various command line flags. The config file location is controlled by the ANSIBLE_CONFIG environment variable, if set, otherwise ~/.ansible.cfg or /etc/ansible/ansible.cfg will be loaded, whichever comes first. For those running from source, a sample configuration file lives in the examples/ directory. The RPM will install configuration into /etc/ansible/ansible.cfg automatically.</p>
<li><aclass="reference internal"href="#what-is-ansible-s-approach-to-security"id="id10">What is Ansible’s approach to security?</a></li>
<li><aclass="reference internal"href="#how-does-ansible-scale"id="id11">How does Ansible scale?</a></li>
<li><aclass="reference internal"href="#are-transports-other-than-ssh-supported"id="id12">Are transports other than SSH supported?</a></li>
<li><aclass="reference internal"href="#what-are-some-ideal-uses-for-ansible"id="id13">What are some ideal uses for Ansible?</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<divclass="section"id="why-is-it-called-ansible">
<divclass="section"id="why-is-it-called-ansible">
<h2>Why Is It Called Ansible?<aclass="headerlink"href="#why-is-it-called-ansible"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#contents">Why Is It Called Ansible?</a><aclass="headerlink"href="#why-is-it-called-ansible"title="Permalink to this headline">¶</a></h2>
<p>One of my favorite books is Orson Scott Card’s “Ender’s Game”. In the book, the Ansible is a method of instantaneous
<p>One of my favorite books is Orson Scott Card’s “Ender’s Game”. In the book, the Ansible is a method of instantaneous
long distance “hyperspace” communication with a large number of space ships. You should read it!</p>
long distance “hyperspace” communication with a large number of space ships. You should read it!</p>
</div>
</div>
<divclass="section"id="what-inspired-ansible">
<divclass="section"id="what-inspired-ansible">
<h2>What inspired Ansible?<aclass="headerlink"href="#what-inspired-ansible"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#contents">What inspired Ansible?</a><aclass="headerlink"href="#what-inspired-ansible"title="Permalink to this headline">¶</a></h2>
<p>Back when I worked for Red Hat and working on <aclass="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 <aclass="reference external"href="http://cobbler.github.com/">Cobbler</a>, several of us identified a gap between
provisioning (Cobbler) and configuration management solutions (cfengine, Puppet, etc).
provisioning (Cobbler) and configuration management solutions (cfengine, Puppet, etc).
There was a need for a way to do ad-hoc tasks efficiently, and various parallel
There was a need for a way to do ad-hoc tasks efficiently, and various parallel
...
@@ -232,9 +256,9 @@ best’, and distills all of the ideas behind all of these other tools to th
...
@@ -232,9 +256,9 @@ best’, and distills all of the ideas behind all of these other tools to th
<p>I’d like to know what you think of it. Hop by the mailing list and say hi.</p>
<p>I’d like to know what you think of it. Hop by the mailing list and say hi.</p>
</div>
</div>
<divclass="section"id="comparisons">
<divclass="section"id="comparisons">
<h2>Comparisons<aclass="headerlink"href="#comparisons"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#contents">Comparisons</a><aclass="headerlink"href="#comparisons"title="Permalink to this headline">¶</a></h2>
<divclass="section"id="vs-func">
<divclass="section"id="vs-func">
<h3>vs Func?<aclass="headerlink"href="#vs-func"title="Permalink to this headline">¶</a></h3>
<h3><aclass="toc-backref"href="#contents">vs Func?</a><aclass="headerlink"href="#vs-func"title="Permalink to this headline">¶</a></h3>
<p>Ansible uses SSH by default instead of SSL and custom daemons, and requires
<p>Ansible uses SSH by default instead of SSL and custom daemons, and requires
no extra software to run on managed machines. You can also write modules
no extra software to run on managed machines. You can also write modules
in any language as long as they return JSON. Ansible’s API, of course, is
in any language as long as they return JSON. Ansible’s API, of course, is
...
@@ -243,7 +267,7 @@ a configuration management and multinode orchestration layer (<a class="referenc
...
@@ -243,7 +267,7 @@ a configuration management and multinode orchestration layer (<a class="referenc
that Func didn’t have.</p>
that Func didn’t have.</p>
</div>
</div>
<divclass="section"id="vs-puppet">
<divclass="section"id="vs-puppet">
<h3>vs Puppet?<aclass="headerlink"href="#vs-puppet"title="Permalink to this headline">¶</a></h3>
<h3><aclass="toc-backref"href="#contents">vs Puppet?</a><aclass="headerlink"href="#vs-puppet"title="Permalink to this headline">¶</a></h3>
<p>First off, Ansible wouldn’t have happened without Puppet. Puppet took configuration
<p>First off, Ansible wouldn’t have happened without Puppet. Puppet took configuration
management ideas from cfengine and made them sane. However, I still think they can
management ideas from cfengine and made them sane. However, I still think they can
be much simpler.</p>
be much simpler.</p>
...
@@ -271,7 +295,7 @@ in jinja2 in a way just like Puppet does with erb. Ansible also has it’s
...
@@ -271,7 +295,7 @@ in jinja2 in a way just like Puppet does with erb. Ansible also has it’s
so usage of facter is not required to get variables about the system.</p>
so usage of facter is not required to get variables about the system.</p>
</div>
</div>
<divclass="section"id="vs-chef">
<divclass="section"id="vs-chef">
<h3>vs Chef?<aclass="headerlink"href="#vs-chef"title="Permalink to this headline">¶</a></h3>
<h3><aclass="toc-backref"href="#contents">vs Chef?</a><aclass="headerlink"href="#vs-chef"title="Permalink to this headline">¶</a></h3>
<p>Much in the ways Ansible is different from Puppet. Chef is notoriously hard
<p>Much in the ways Ansible is different from Puppet. Chef is notoriously hard
to set up on the server, and requires that you know how to program in Ruby to
to set up on the server, and requires that you know how to program in Ruby to
use the language. As such, it seems to have a pretty good following mainly
use the language. As such, it seems to have a pretty good following mainly
...
@@ -292,7 +316,7 @@ submit a patch or module.</p>
...
@@ -292,7 +316,7 @@ submit a patch or module.</p>
has it’s own facts so you do not need to use ohai unless you want to.</p>
has it’s own facts so you do not need to use ohai unless you want to.</p>
</div>
</div>
<divclass="section"id="vs-capistrano-fabric">
<divclass="section"id="vs-capistrano-fabric">
<h3>vs Capistrano/Fabric?<aclass="headerlink"href="#vs-capistrano-fabric"title="Permalink to this headline">¶</a></h3>
<h3><aclass="toc-backref"href="#contents">vs Capistrano/Fabric?</a><aclass="headerlink"href="#vs-capistrano-fabric"title="Permalink to this headline">¶</a></h3>
<p>These tools aren’t really well suited to doing idempotent configuration and are
<p>These tools aren’t really well suited to doing idempotent configuration and are
typically about pushing software out for web deployment and automating steps.</p>
typically about pushing software out for web deployment and automating steps.</p>
<p>Meanwhile Ansible is designed for other types of configuration management, and contains some
<p>Meanwhile Ansible is designed for other types of configuration management, and contains some
...
@@ -303,9 +327,9 @@ useful for sysadmins (not just web developers), and can also be used for firing
...
@@ -303,9 +327,9 @@ useful for sysadmins (not just web developers), and can also be used for firing
</div>
</div>
</div>
</div>
<divclass="section"id="other-questions">
<divclass="section"id="other-questions">
<h2>Other Questions<aclass="headerlink"href="#other-questions"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#contents">Other Questions</a><aclass="headerlink"href="#other-questions"title="Permalink to this headline">¶</a></h2>
<h3>What is Ansible’s approach to security?<aclass="headerlink"href="#what-is-ansible-s-approach-to-security"title="Permalink to this headline">¶</a></h3>
<h3><aclass="toc-backref"href="#contents">What is Ansible’s approach to security?</a><aclass="headerlink"href="#what-is-ansible-s-approach-to-security"title="Permalink to this headline">¶</a></h3>
<p>Ansible aims to not develop custom daemon or PKI code but rely heavily on OpenSSH, which is extremely well
<p>Ansible aims to not develop custom daemon or PKI code but rely heavily on OpenSSH, which is extremely well
peer reviewed and the most widely used security subsystem in the industry. As a result, Ansible
peer reviewed and the most widely used security subsystem in the industry. As a result, Ansible
has a lower attack surface than any configuration management tool featuring daemons that run
has a lower attack surface than any configuration management tool featuring daemons that run
...
@@ -320,7 +344,7 @@ free RAM and compute resources, which should be relevant to users wanting to max
...
@@ -320,7 +344,7 @@ free RAM and compute resources, which should be relevant to users wanting to max
computing investments.</p>
computing investments.</p>
</div>
</div>
<divclass="section"id="how-does-ansible-scale">
<divclass="section"id="how-does-ansible-scale">
<h3>How does Ansible scale?<aclass="headerlink"href="#how-does-ansible-scale"title="Permalink to this headline">¶</a></h3>
<h3><aclass="toc-backref"href="#contents">How does Ansible scale?</a><aclass="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 parallel forks, thanks to the magic behind
run multiple commands in seperate parallel forks, thanks to the magic behind
Python’s multiprocessing module.</p>
Python’s multiprocessing module.</p>
...
@@ -345,7 +369,7 @@ model.</p>
...
@@ -345,7 +369,7 @@ model.</p>
<p>If you’d like to discuss scaling strategies further, please hop on the mailing list.</p>
<p>If you’d like to discuss scaling strategies further, please hop on the mailing list.</p>
<h3>Are transports other than SSH supported?<aclass="headerlink"href="#are-transports-other-than-ssh-supported"title="Permalink to this headline">¶</a></h3>
<h3><aclass="toc-backref"href="#contents">Are transports other than SSH supported?</a><aclass="headerlink"href="#are-transports-other-than-ssh-supported"title="Permalink to this headline">¶</a></h3>
<p>Currently SSH (you can choose between paramiko or the openssh binaries)
<p>Currently SSH (you can choose between paramiko or the openssh binaries)
and local connections are supported. The interface is actually pluggable so a
and local connections are supported. The interface is actually pluggable so a
small patch could bring transport over message bus or XMPP as an option.</p>
small patch could bring transport over message bus or XMPP as an option.</p>
...
@@ -353,7 +377,7 @@ small patch could bring transport over message bus or XMPP as an option.</p>
...
@@ -353,7 +377,7 @@ small patch could bring transport over message bus or XMPP as an option.</p>
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>
<h3>What are some ideal uses for Ansible?<aclass="headerlink"href="#what-are-some-ideal-uses-for-ansible"title="Permalink to this headline">¶</a></h3>
<h3><aclass="toc-backref"href="#contents">What are some ideal uses for Ansible?</a><aclass="headerlink"href="#what-are-some-ideal-uses-for-ansible"title="Permalink to this headline">¶</a></h3>
<p>One of the best use cases? Complex multi-node cloud deployments using playbooks. Another good
<p>One of the best use cases? Complex multi-node cloud deployments using playbooks. Another good
example is for configuration management where you
example is for configuration management where you
are starting from a clean OS with no extra software installed, adopting systems
are starting from a clean OS with no extra software installed, adopting systems
<li><aclass="reference internal"href="#python-2-6-epel-instructions-for-rhel-and-centos-5"id="id3">Python 2.6 EPEL instructions for RHEL and CentOS 5</a></li>
<h2>Python 2.6 EPEL instructions for RHEL and CentOS 5<aclass="headerlink"href="#python-2-6-epel-instructions-for-rhel-and-centos-5"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#contents">Python 2.6 EPEL instructions for RHEL and CentOS 5</a><aclass="headerlink"href="#python-2-6-epel-instructions-for-rhel-and-centos-5"title="Permalink to this headline">¶</a></h2>
<p>These distributions don’t have Python 2.6 by default, but it is easily
<p>These distributions don’t have Python 2.6 by default, but it is easily
installable. If you have not already done so, <aclass="reference external"href="http://fedoraproject.org/wiki/EPEL">configure EPEL</a></p>
installable. If you have not already done so, <aclass="reference external"href="http://fedoraproject.org/wiki/EPEL">configure EPEL</a></p>
<h2>Choosing Between Paramiko and Native SSH<aclass="headerlink"href="#choosing-between-paramiko-and-native-ssh"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#contents">Choosing Between Paramiko and Native SSH</a><aclass="headerlink"href="#choosing-between-paramiko-and-native-ssh"title="Permalink to this headline">¶</a></h2>
<p>By default, ansible uses paramiko to talk to managed nodes over SSH. Paramiko is fast, works
<p>By default, ansible uses paramiko to talk to managed nodes over SSH. Paramiko is fast, works
very transparently, requires no configuration, and is a good choice for most users.
very transparently, requires no configuration, and is a good choice for most users.
However, it does not support some advanced SSH features that folks will want to use.</p>
However, it does not support some advanced SSH features that folks will want to use.</p>
...
@@ -327,7 +340,7 @@ are roughly the same speed. Without CM, the binary ssh transport is signficantl
...
@@ -327,7 +340,7 @@ are roughly the same speed. Without CM, the binary ssh transport is signficantl
<p>If none of this makes sense to you, the default paramiko option is probably fine.</p>
<p>If none of this makes sense to you, the default paramiko option is probably fine.</p>
</div>
</div>
<divclass="section"id="your-first-commands">
<divclass="section"id="your-first-commands">
<h2>Your first commands<aclass="headerlink"href="#your-first-commands"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#contents">Your first commands</a><aclass="headerlink"href="#your-first-commands"title="Permalink to this headline">¶</a></h2>
<p>Now that you’ve installed Ansible, it’s time to test it.</p>
<p>Now that you’ve installed Ansible, it’s time to test it.</p>
<p>Edit (or create) /etc/ansible/hosts and put one or more remote systems in it, for
<p>Edit (or create) /etc/ansible/hosts and put one or more remote systems in it, for
which you have your SSH key in <ttclass="docutils literal"><spanclass="pre">authorized_keys</span></tt>:</p>
which you have your SSH key in <ttclass="docutils literal"><spanclass="pre">authorized_keys</span></tt>:</p>
<h1>Module Development<aclass="headerlink"href="#module-development"title="Permalink to this headline">¶</a></h1>
<h1><aclass="toc-backref"href="#contents">Module Development</a><aclass="headerlink"href="#module-development"title="Permalink to this headline">¶</a></h1>
<p>Ansible modules are reusable units of magic that can be used by the Ansible API,
<p>Ansible modules are reusable units of magic that can be used by the Ansible API,
or by the <cite>ansible</cite> or <cite>ansible-playbook</cite> programs.</p>
or by the <cite>ansible</cite> or <cite>ansible-playbook</cite> programs.</p>
<p>Modules can be written in any language and are found in the path specified
<p>Modules can be written in any language and are found in the path specified
by <cite>ANSIBLE_LIBRARY_PATH</cite> or the <ttclass="docutils literal"><spanclass="pre">--module-path</span></tt> command line option.</p>
by <cite>ANSIBLE_LIBRARY_PATH</cite> or the <ttclass="docutils literal"><spanclass="pre">--module-path</span></tt> command line option.</p>
<p>If you did not, you might have a typo in your module, so recheck it and try again.</p>
<p>If you did not, you might have a typo in your module, so recheck it and try again.</p>
</div>
</div>
<divclass="section"id="reading-input">
<divclass="section"id="reading-input">
<h2>Reading Input<aclass="headerlink"href="#reading-input"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#contents">Reading Input</a><aclass="headerlink"href="#reading-input"title="Permalink to this headline">¶</a></h2>
<p>Let’s modify the module to allow setting the current time. We’ll do this by seeing
<p>Let’s modify the module to allow setting the current time. We’ll do this by seeing
if a key value pair in the form <cite>time=<string></cite> is passed in to the module.</p>
if a key value pair in the form <cite>time=<string></cite> is passed in to the module.</p>
<p>Ansible internally saves arguments to an arguments file. So we must read the file
<p>Ansible internally saves arguments to an arguments file. So we must read the file
...
@@ -342,7 +360,7 @@ a lot shorter than this:</p>
...
@@ -342,7 +360,7 @@ a lot shorter than this:</p>
</div>
</div>
</div>
</div>
<divclass="section"id="module-provided-facts">
<divclass="section"id="module-provided-facts">
<h2>Module Provided ‘Facts’<aclass="headerlink"href="#module-provided-facts"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#contents">Module Provided ‘Facts’</a><aclass="headerlink"href="#module-provided-facts"title="Permalink to this headline">¶</a></h2>
<p>The ‘setup’ module that ships with Ansible provides many variables about a system that can be used in playbooks
<p>The ‘setup’ module that ships with Ansible provides many variables about a system that can be used in playbooks
and templates. However, it’s possible to also add your own facts without modifying the system module. To do
and templates. However, it’s possible to also add your own facts without modifying the system module. To do
this, just have the module return a <cite>ansible_facts</cite> key, like so, along with other return data:</p>
this, just have the module return a <cite>ansible_facts</cite> key, like so, along with other return data:</p>
...
@@ -363,7 +381,7 @@ A good idea might be make a module called ‘site_facts’ and always ca
...
@@ -363,7 +381,7 @@ A good idea might be make a module called ‘site_facts’ and always ca
we’re always open to improving the selection of core facts in Ansible as well.</p>
we’re always open to improving the selection of core facts in Ansible as well.</p>
<h2>Common Module Boilerplate<aclass="headerlink"href="#common-module-boilerplate"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#contents">Common Module Boilerplate</a><aclass="headerlink"href="#common-module-boilerplate"title="Permalink to this headline">¶</a></h2>
<p>As mentioned, if you are writing a module in Python, there are some very powerful shortcuts you can use.
<p>As mentioned, if you are writing a module in Python, there are some very powerful shortcuts you can use.
Modules are still transferred as one file, but an arguments file is no longer needed, so these are not
Modules are still transferred as one file, but an arguments file is no longer needed, so these are not
only shorter in terms of code, they are actually FASTER in terms of execution time.</p>
only shorter in terms of code, they are actually FASTER in terms of execution time.</p>
...
@@ -405,7 +423,7 @@ can function outside of Ansible.</p>
...
@@ -405,7 +423,7 @@ can function outside of Ansible.</p>
class is required.</p>
class is required.</p>
</div>
</div>
<divclass="section"id="common-pitfalls">
<divclass="section"id="common-pitfalls">
<h2>Common Pitfalls<aclass="headerlink"href="#common-pitfalls"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#contents">Common Pitfalls</a><aclass="headerlink"href="#common-pitfalls"title="Permalink to this headline">¶</a></h2>
<p>You should also never do this in a module:</p>
<p>You should also never do this in a module:</p>
<divclass="highlight-python"><divclass="highlight"><pre><spanclass="k">print</span><spanclass="s">"some status message"</span>
<divclass="highlight-python"><divclass="highlight"><pre><spanclass="k">print</span><spanclass="s">"some status message"</span>
</pre></div>
</pre></div>
...
@@ -422,7 +440,7 @@ will still be shown in Ansible, but the command will not succeed.</p>
...
@@ -422,7 +440,7 @@ will still be shown in Ansible, but the command will not succeed.</p>
<h2>Conventions/Recomendations<aclass="headerlink"href="#conventions-recomendations"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#contents">Conventions/Recomendations</a><aclass="headerlink"href="#conventions-recomendations"title="Permalink to this headline">¶</a></h2>
<p>As a reminder from the example code above, here are some basic conventions
<p>As a reminder from the example code above, here are some basic conventions
and guidelines:</p>
and guidelines:</p>
<ulclass="simple">
<ulclass="simple">
...
@@ -439,7 +457,7 @@ and guidelines:</p>
...
@@ -439,7 +457,7 @@ and guidelines:</p>
</ul>
</ul>
</div>
</div>
<divclass="section"id="shorthand-vs-json">
<divclass="section"id="shorthand-vs-json">
<h2>Shorthand Vs JSON<aclass="headerlink"href="#shorthand-vs-json"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#contents">Shorthand Vs JSON</a><aclass="headerlink"href="#shorthand-vs-json"title="Permalink to this headline">¶</a></h2>
<p>To make it easier to write modules in bash and in cases where a JSON
<p>To make it easier to write modules in bash and in cases where a JSON
module might not be available, it is acceptable for a module to return
module might not be available, it is acceptable for a module to return
key=value output all on one line, like this. The Ansible parser
key=value output all on one line, like this. The Ansible parser
...
@@ -450,7 +468,7 @@ will know what to do:</p>
...
@@ -450,7 +468,7 @@ will know what to do:</p>
JSON is probably the simplest way to go.</p>
JSON is probably the simplest way to go.</p>
</div>
</div>
<divclass="section"id="sharing-your-module">
<divclass="section"id="sharing-your-module">
<h2>Sharing Your Module<aclass="headerlink"href="#sharing-your-module"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#contents">Sharing Your Module</a><aclass="headerlink"href="#sharing-your-module"title="Permalink to this headline">¶</a></h2>
<p>If you think your module is generally useful to others, a good place to share it
<p>If you think your module is generally useful to others, a good place to share it
is in <aclass="reference external"href="https://github.com/ansible/ansible-resources">Ansible Resources</a>. This is maintained
is in <aclass="reference external"href="https://github.com/ansible/ansible-resources">Ansible Resources</a>. This is maintained
as a simple repo with pointers to other github projects.</p>
as a simple repo with pointers to other github projects.</p>
...
@@ -459,7 +477,7 @@ We would like to build up as many of these as possible in as many languages as p
...
@@ -459,7 +477,7 @@ We would like to build up as many of these as possible in as many languages as p
<h2>Getting Your Module Into Core<aclass="headerlink"href="#getting-your-module-into-core"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#contents">Getting Your Module Into Core</a><aclass="headerlink"href="#getting-your-module-into-core"title="Permalink to this headline">¶</a></h2>
<p>High-quality modules with minimal dependencies
<p>High-quality modules with minimal dependencies
can be included in the core, but core modules (just due to the programming
can be included in the core, but core modules (just due to the programming
preferences of the developers) will need to be implemented in Python and use
preferences of the developers) will need to be implemented in Python and use
<spanid="patterns"></span><h1>Inventory & Patterns<aclass="headerlink"href="#inventory-patterns"title="Permalink to this headline">¶</a></h1>
<spanid="patterns"></span><h1><aclass="toc-backref"href="#table-of-contents">Inventory & Patterns</a><aclass="headerlink"href="#inventory-patterns"title="Permalink to this headline">¶</a></h1>
<p>Ansible works against multiple systems in your infrastructure at the
<p>Ansible works against multiple systems in your infrastructure at the
same time. It does this by selecting portions of systems listed in
same time. It does this by selecting portions of systems listed in
Ansible’s inventory file, which defaults to /etc/ansible/hosts.</p>
Ansible’s inventory file, which defaults to /etc/ansible/hosts.</p>
<divclass="contents topic"id="table-of-contents">
<pclass="topic-title first"><cite>Table of contents</cite></p>
<ulclass="simple">
<li><aclass="reference internal"href="#inventory-patterns"id="id1">Inventory & Patterns</a><ul>
<li><aclass="reference internal"href="#hosts-and-groups"id="id2">Hosts and Groups</a></li>
<spanid="inventoryformat"></span><h2>Hosts and Groups<aclass="headerlink"href="#hosts-and-groups"title="Permalink to this headline">¶</a></h2>
<spanid="inventoryformat"></span><h2><aclass="toc-backref"href="#table-of-contents">Hosts and Groups</a><aclass="headerlink"href="#hosts-and-groups"title="Permalink to this headline">¶</a></h2>
<p>The format for /etc/ansible/hosts is an INI format and looks like this:</p>
<p>The format for /etc/ansible/hosts is an INI format and looks like this:</p>
@@ -217,7 +232,7 @@ after the hostname with a colon.</p>
...
@@ -217,7 +232,7 @@ after the hostname with a colon.</p>
<p>Leading zeros can be included or removed, as desired, and the ranges are inclusive.</p>
<p>Leading zeros can be included or removed, as desired, and the ranges are inclusive.</p>
</div>
</div>
<divclass="section"id="selecting-targets">
<divclass="section"id="selecting-targets">
<h2>Selecting Targets<aclass="headerlink"href="#selecting-targets"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#table-of-contents">Selecting Targets</a><aclass="headerlink"href="#selecting-targets"title="Permalink to this headline">¶</a></h2>
<p>We’ll go over how to use the command line in <aclass="reference internal"href="examples.html"><em>Command Line Examples And Next Steps</em></a> section, however, basically it looks like this:</p>
<p>We’ll go over how to use the command line in <aclass="reference internal"href="examples.html"><em>Command Line Examples And Next Steps</em></a> section, however, basically it looks like this:</p>
<divclass="highlight-python"><pre>ansible <pattern_goes_here> -m <module_name> -a <arguments></pre>
<divclass="highlight-python"><pre>ansible <pattern_goes_here> -m <module_name> -a <arguments></pre>
</div>
</div>
...
@@ -256,7 +271,7 @@ wildcards:</p>
...
@@ -256,7 +271,7 @@ wildcards:</p>
<p>Easy enough. See <aclass="reference internal"href="examples.html"><em>Command Line Examples And Next Steps</em></a> and then <aclass="reference internal"href="playbooks.html"><em>Playbooks</em></a> for how to do things to selected hosts.</p>
<p>Easy enough. See <aclass="reference internal"href="examples.html"><em>Command Line Examples And Next Steps</em></a> and then <aclass="reference internal"href="playbooks.html"><em>Playbooks</em></a> for how to do things to selected hosts.</p>
</div>
</div>
<divclass="section"id="host-variables">
<divclass="section"id="host-variables">
<h2>Host Variables<aclass="headerlink"href="#host-variables"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#table-of-contents">Host Variables</a><aclass="headerlink"href="#host-variables"title="Permalink to this headline">¶</a></h2>
<p>It is easy to assign variables to hosts that will be used later in playbooks:</p>
<p>It is easy to assign variables to hosts that will be used later in playbooks:</p>
<h2>Group Variables<aclass="headerlink"href="#group-variables"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#table-of-contents">Group Variables</a><aclass="headerlink"href="#group-variables"title="Permalink to this headline">¶</a></h2>
<p>Variables can also be applied to an entire group at once:</p>
<p>Variables can also be applied to an entire group at once:</p>
<h2>Groups of Groups, and Group Variables<aclass="headerlink"href="#groups-of-groups-and-group-variables"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#table-of-contents">Groups of Groups, and Group Variables</a><aclass="headerlink"href="#groups-of-groups-and-group-variables"title="Permalink to this headline">¶</a></h2>
<p>It is also possible to make groups of groups and assign
<p>It is also possible to make groups of groups and assign
variables to groups. These variables can be used by /usr/bin/ansible-playbook, but not
variables to groups. These variables can be used by /usr/bin/ansible-playbook, but not
/usr/bin/ansible:</p>
/usr/bin/ansible:</p>
...
@@ -308,7 +323,7 @@ southeast</pre>
...
@@ -308,7 +323,7 @@ southeast</pre>
seperate from the inventory file, see the next section.</p>
seperate from the inventory file, see the next section.</p>
<h2>Splitting Out Host and Group Specific Data<aclass="headerlink"href="#splitting-out-host-and-group-specific-data"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#table-of-contents">Splitting Out Host and Group Specific Data</a><aclass="headerlink"href="#splitting-out-host-and-group-specific-data"title="Permalink to this headline">¶</a></h2>
<pclass="versionadded">
<pclass="versionadded">
<spanclass="versionmodified">New in version 0.6.</span></p>
<spanclass="versionmodified">New in version 0.6.</span></p>
<p>In addition to the storing variables directly in the INI file, host
<p>In addition to the storing variables directly in the INI file, host
...
@@ -339,7 +354,7 @@ variable called ‘ansible_python_interpreter’ to the Python
...
@@ -339,7 +354,7 @@ variable called ‘ansible_python_interpreter’ to the Python
interpreter path you would like to use.</p>
interpreter path you would like to use.</p>
</div>
</div>
<divclass="section"id="yaml-inventory">
<divclass="section"id="yaml-inventory">
<h2>YAML Inventory<aclass="headerlink"href="#yaml-inventory"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#table-of-contents">YAML Inventory</a><aclass="headerlink"href="#yaml-inventory"title="Permalink to this headline">¶</a></h2>
<pclass="deprecated">
<pclass="deprecated">
<spanclass="versionmodified">Deprecated since version 0.7.</span></p>
<spanclass="versionmodified">Deprecated since version 0.7.</span></p>
<p>Ansible’s YAML inventory format is deprecated and will be removed in
<p>Ansible’s YAML inventory format is deprecated and will be removed in
<h2>Playbook Language Example<aclass="headerlink"href="#playbook-language-example"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#contents">Playbook Language Example</a><aclass="headerlink"href="#playbook-language-example"title="Permalink to this headline">¶</a></h2>
<p>Playbooks are expressed in YAML format and have a minimum of syntax.
<p>Playbooks are expressed in YAML format and have a minimum of syntax.
Each playbook is composed of one or more ‘plays’ in a list.</p>
Each playbook is composed of one or more ‘plays’ in a list.</p>
<p>The goal of a play is map a group of hosts to some well defined roles, represented by
<p>The goal of a play is map a group of hosts to some well defined roles, represented by
...
@@ -238,7 +257,7 @@ server group, then more commands back on the webservers group, etc.</p>
...
@@ -238,7 +257,7 @@ server group, then more commands back on the webservers group, etc.</p>
<p>Below, we’ll break down what the various features of the playbook language are.</p>
<p>Below, we’ll break down what the various features of the playbook language are.</p>
</div>
</div>
<divclass="section"id="basics">
<divclass="section"id="basics">
<h2>Basics<aclass="headerlink"href="#basics"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#contents">Basics</a><aclass="headerlink"href="#basics"title="Permalink to this headline">¶</a></h2>
<divclass="section"id="hosts-and-users">
<divclass="section"id="hosts-and-users">
<h3>Hosts and Users<aclass="headerlink"href="#hosts-and-users"title="Permalink to this headline">¶</a></h3>
<h3>Hosts and Users<aclass="headerlink"href="#hosts-and-users"title="Permalink to this headline">¶</a></h3>
<p>For each play in a playbook, you get to choose which machines in your infrastructure
<p>For each play in a playbook, you get to choose which machines in your infrastructure
...
@@ -378,7 +397,7 @@ make more sense to break up tasks using the ‘include:’ directive. W
...
@@ -378,7 +397,7 @@ make more sense to break up tasks using the ‘include:’ directive. W
<h2>Running Operations On Change<aclass="headerlink"href="#running-operations-on-change"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#contents">Running Operations On Change</a><aclass="headerlink"href="#running-operations-on-change"title="Permalink to this headline">¶</a></h2>
<p>As we’ve mentioned, modules are written to be ‘idempotent’ and can relay when
<p>As we’ve mentioned, modules are written to be ‘idempotent’ and can relay when
they have made a change on the remote system. Playbooks recognize this and
they have made a change on the remote system. Playbooks recognize this and
have a basic event system that can be used to respond to change.</p>
have a basic event system that can be used to respond to change.</p>
...
@@ -415,7 +434,7 @@ won’t need them for much else.</p>
...
@@ -415,7 +434,7 @@ won’t need them for much else.</p>
<h2>Include Files And Encouraging Reuse<aclass="headerlink"href="#include-files-and-encouraging-reuse"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#contents">Include Files And Encouraging Reuse</a><aclass="headerlink"href="#include-files-and-encouraging-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. Use of included task lists is a great way to define a role
include files to do this. Use of included task lists is a great way to define a role
that system is going to fulfill. Remember, the goal of a play in a playbook is to map
that system is going to fulfill. Remember, the goal of a play in a playbook is to map
...
@@ -477,14 +496,14 @@ ability for hosts to conditionally skip tasks).</p>
...
@@ -477,14 +496,14 @@ ability for hosts to conditionally skip tasks).</p>
</div>
</div>
</div>
</div>
<divclass="section"id="executing-a-playbook">
<divclass="section"id="executing-a-playbook">
<h2>Executing A Playbook<aclass="headerlink"href="#executing-a-playbook"title="Permalink to this headline">¶</a></h2>
<h2><aclass="toc-backref"href="#contents">Executing A Playbook</a><aclass="headerlink"href="#executing-a-playbook"title="Permalink to this headline">¶</a></h2>
<p>Now that you’ve learned playbook syntax, how do you run a playbook? It’s simple.
<p>Now that you’ve learned playbook syntax, how do you run a playbook? It’s simple.
Let’s run a playbook using a parallelism level of 10:</p>
Let’s run a playbook using a parallelism level of 10:</p>