<p>The -f 10 specifies the usage of 10 simultaneous processes.</p>
<p>The -f 10 specifies the usage of 10 simultaneous processes.</p>
<p>Note that other than the command module, ansible modules do not work like simple scripts. They make the remote system look like you state, and run the commands neccessary to get it there. This is commonly refered to
<divclass="admonition note">
as ‘idempotency’.</p>
<pclass="first admonition-title">Note</p>
<pclass="last">Note that other than the <aclass="reference internal"href="modules.html#command"><em>command</em></a> module, ansible modules do
not work like simple scripts. They make the remote system look like
you state, and run the commands necessary to get it there. This
is commonly referred to as ‘idempotent’.</p>
</div>
</div>
</div>
<divclass="section"id="file-transfer-templating">
<divclass="section"id="file-transfer-templating">
<h2>File Transfer & Templating<aclass="headerlink"href="#file-transfer-templating"title="Permalink to this headline">¶</a></h2>
<h2>File Transfer & Templating<aclass="headerlink"href="#file-transfer-templating"title="Permalink to this headline">¶</a></h2>
<p>Ansible can SCP lots of files to multiple machines in parallel, and optionally use them as template sources.</p>
<p>Ansible can SCP lots of files to multiple machines in parallel, and
optionally use them as template sources.</p>
<p>To just transfer a file directly to many different servers:</p>
<p>To just transfer a file directly to many different servers:</p>
<divclass="highlight-python"><pre>ansible atlanta copy -a "/etc/hosts /tmp/hosts"</pre>
<divclass="highlight-python"><pre>ansible atlanta copy -a "/etc/hosts /tmp/hosts"</pre>
</div>
</div>
<p>To use templating, first run the setup module to put the template variables you would like to use on the remote host. Then use the template module to write the files using the templates. Templates are written in Jinja2 format. Playbooks (covered elsewhere in the documentation) will run the setup module for you, making this even simpler.:</p>
<p>To use templating, first run the setup module to put the template
variables you would like to use on the remote host. Then use the
template module to write the files using the templates. Templates are
written in Jinja2 format. Playbooks (covered elsewhere in the
documentation) will run the setup module for you, making this even
simpler.:</p>
<divclass="highlight-python"><pre>ansible webservers -m setup -a "favcolor=red ntp_server=192.168.1.1"
<divclass="highlight-python"><pre>ansible webservers -m setup -a "favcolor=red ntp_server=192.168.1.1"
ansible webservers -m template -a "src=/srv/motd.j2 dest=/etc/motd"
ansible webservers -m template -a "src=/srv/motd.j2 dest=/etc/motd"
ansible webservers -m template -a "src=/srv/ntp.j2 dest=/etc/ntp.conf"</pre>
ansible webservers -m template -a "src=/srv/ntp.j2 dest=/etc/ntp.conf"</pre>
</div>
</div>
<p>Need something like the fqdn in a template? If facter or ohai are installed, data from these projects will also be made available to the template engine, using ‘facter’ and ‘ohai’ prefixes for each.</p>
<p>Need something like the fqdn in a template? If facter or ohai are
installed, data from these projects will also be made available to the
template engine, using ‘facter’ and ‘ohai’ prefixes for each.</p>
<h2>Deploying From Source Control<aclass="headerlink"href="#deploying-from-source-control"title="Permalink to this headline">¶</a></h2>
<h2>Deploying From Source Control<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-python"><pre>ansible webservers -m git -a "repo=git://foo dest=/srv/myapp version=HEAD"</pre>
<divclass="highlight-python"><pre>ansible webservers -m git -a "repo=git://foo dest=/srv/myapp version=HEAD"</pre>
</div>
</div>
<p>Since ansible modules can notify change handlers (see ‘Playbooks’) it is possible to tell ansible to run specific tasks when the code is updated, such as deploying Perl/Python/PHP/Ruby directly from git and then restarting apache.</p>
<p>Since ansible modules can notify change handlers (see
<aclass="reference internal"href="playbooks.html"><em>Playbooks</em></a>) it is possible to tell ansible to run specific tasks
when the code is updated, such as deploying Perl/Python/PHP/Ruby
directly from git and then restarting 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>Managing Services<aclass="headerlink"href="#managing-services"title="Permalink to this headline">¶</a></h2>
<h2>Time Limited Background Operations<aclass="headerlink"href="#time-limited-background-operations"title="Permalink to this headline">¶</a></h2>
<h2>Time Limited Background Operations<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 checked on later. The same job ID is given to the same task on all hosts, so you won’t lose track. Polling support is pending in the command line.:</p>
<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
hosts, so you won’t lose track. Polling support is pending in the
command line.:</p>
<divclass="highlight-python"><pre>ansible all -B 3600 -a "/usr/bin/long_running_operation --do-stuff"
<divclass="highlight-python"><pre>ansible all -B 3600 -a "/usr/bin/long_running_operation --do-stuff"
ansible all -n job_status -a jid=123456789</pre>
ansible all -n job_status -a jid=123456789</pre>
</div>
</div>
<p>Any module other than ‘copy’ or ‘template’ can be backgrounded. Typically you’ll be backgrounding shell
<p>Any module other than <aclass="reference internal"href="modules.html#copy"><em>copy</em></a> or <aclass="reference internal"href="modules.html#template"><em>template</em></a> can be
commands or software upgrades only.</p>
backgrounded. Typically you’ll be backgrounding shell commands or
<p>After the time limit (in seconds) runs out (-B), the process on the remote nodes will be killed.</p>
software upgrades only.</p>
<p>After the time limit (in seconds) runs out (<ttclass="docutils literal"><spanclass="pre">-B</span></tt>), the process on
the remote nodes will be killed.</p>
</div>
</div>
</div>
</div>
@ -224,7 +245,7 @@ commands or software upgrades only.</p>
title="next chapter">The Inventory File, Patterns, and Groups »</a></li>
title="next chapter">The Inventory File, Patterns, and Groups »</a></li>
@ -167,7 +167,8 @@
<divclass="section"id="requirements">
<divclass="section"id="requirements">
<h2>Requirements<aclass="headerlink"href="#requirements"title="Permalink to this headline">¶</a></h2>
<h2>Requirements<aclass="headerlink"href="#requirements"title="Permalink to this headline">¶</a></h2>
<p>Requirements for Ansible are extremely minimal.</p>
<p>Requirements for Ansible are extremely minimal.</p>
<p>If you are running python 2.6 on the <strong>overlord</strong> machine (the machine that you’ll be talking to the other machines from), you will need:</p>
<p>If you are running python 2.6 on the <strong>overlord</strong> machine (the machine
that you’ll be talking to the other machines from), you will need:</p>
<h1>Ansible<aclass="headerlink"href="#ansible"title="Permalink to this headline">¶</a></h1>
<divclass="section"id="introducing-ansible">
<p>Ansible is a radically simple deployment, configuration, and command execution framework.
<h1>Introducing Ansible<aclass="headerlink"href="#introducing-ansible"title="Permalink to this headline">¶</a></h1>
Other tools in this space have been too complicated for too long, require too much bootstrapping,
<p>Ansible is a radically simple deployment, configuration, and command
and have too much learning curve. Ansible is dead simple and painless to extend. For comparison, Puppet and Chef have about 60k lines of code. Ansible’s core is a little over 1000 lines.</p>
execution framework. Other tools in this space have been too
<p>Ansible isn’t just for configuration – it’s also great for Ad-Hoc tasks,
complicated for too long, require too much bootstrapping, and have too
quickly firing off commands against nodes. Where Ansible excels though, is expressing complex multi-node deployment processes, executing complex sequences of commands on different hosts through “playbooks”.</p>
much learning curve. Ansible is dead simple and painless to extend.
<p>Extending ansible does not require programming in any particular language – you can write modules
For comparison, Puppet and Chef have about 60k lines of code.
as scripts or programs that return simple JSON. It’s also trivially easy to just execute
Ansible’s core is a little over 1000 lines.</p>
useful shell commands.</p>
<p>Ansible isn’t just for configuration – it’s also great for Ad-Hoc
<p>Why use Ansible versus something else? (Puppet, Chef, Fabric, Capistrano,
tasks, quickly firing off commands against nodes. Where Ansible
mCollective, Func, SaltStack, etc?) Ansible will have far less code, it
excels though, is expressing complex multi-node deployment processes,
will be (by extension) more correct, and it will be the easiest thing to hack on and
executing complex sequences of commands on different hosts through
use you’ll ever see – regardless of your favorite language of choice.</p>
<h2>Communicate and Get Involved<aclass="headerlink"href="#communicate-and-get-involved"title="Permalink to this headline">¶</a></h2>
<h2>Communicate and Get Involved<aclass="headerlink"href="#communicate-and-get-involved"title="Permalink to this headline">¶</a></h2>
<p>Your ideas and contributions are welcome. We’re also happy to help you with questions about Ansible.</p>
<p>Your ideas and contributions are welcome. We’re also happy to help
you with questions about Ansible.</p>
<ulclass="simple">
<ulclass="simple">
<li>Join the <aclass="reference external"href="http://groups.google.com/group/ansible-project">ansible-project mailing list</a> on Google Groups</li>
<li>Join the <aclass="reference external"href="http://groups.google.com/group/ansible-project">ansible-project mailing list</a> on Google Groups</li>
<li>Join <aclass="reference external"href="irc://irc.freenode.net/#ansible">#ansible</a> on the <aclass="reference external"href="http://freenode.net/">freenode IRC network</a></li>
<li>Join <aclass="reference external"href="irc://irc.freenode.net/#ansible">#ansible</a> on the <aclass="reference external"href="http://freenode.net/">freenode IRC network</a></li>
@ -260,13 +270,16 @@ short & simple, and the source will be blindingly obvious.</p>
</div>
</div>
<divclass="section"id="about-the-author">
<divclass="section"id="about-the-author">
<h2>About the Author<aclass="headerlink"href="#about-the-author"title="Permalink to this headline">¶</a></h2>
<h2>About the Author<aclass="headerlink"href="#about-the-author"title="Permalink to this headline">¶</a></h2>
<p>Ansible was originally developed by Michael DeHaan, a Raleigh, NC based software developer and architect.
<p>Ansible was originally developed by Michael DeHaan, a Raleigh, NC
He created other popular DevOps programs such as Cobbler, the popular Linux install server.
based software developer and architect. He created other popular
Cobbler is used to deploy mission critical systems all over the planet, in industries
DevOps programs such as Cobbler, the popular Linux install server.
ranging from massively multiplayer gaming, core internet infrastructure, finance,
Cobbler is used to deploy mission critical systems all over the
chip design, and more. Michael also helped co-author of Func, a precursor to Ansible, which is used
planet, in industries ranging from massively multiplayer gaming, core
to orchestrate systems in lots of diverse places. He’s worked on systems software for
internet infrastructure, finance, chip design, and more. Michael also
IBM, Motorola, Red Hat’s Emerging Technologies Group, Puppet Labs, and rPath.</p>
helped co-author of Func, a precursor to Ansible, which is used to
orchestrate systems in lots of diverse places. He’s worked on systems
software for IBM, Motorola, Red Hat’s Emerging Technologies Group,
Puppet Labs, and rPath.</p>
</div>
</div>
</div>
</div>
@ -278,7 +291,7 @@ IBM, Motorola, Red Hat’s Emerging Technologies Group, Puppet Labs, and rPa
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml"><head><metahttp-equiv="Content-Type"content="text/html; charset=UTF-8"/><title>ansible-modules</title><linkrel="stylesheet"type="text/css"href="./docbook-xsl.css" /><metaname="generator"content="DocBook XSL Stylesheets V1.76.1" /></head><body><divxml:lang="en"class="refentry"title="ansible-modules"lang="en"><aid="id475130"></a><divclass="titlepage"></div><divclass="refnamediv"><h2>Name</h2><p>ansible-modules — stock modules shipped with ansible</p></div><divclass="refsect1"title="DESCRIPTION"><aid="_description"></a><h2>DESCRIPTION</h2><p>Ansible ships with a number of modules that can be executed directly on remote hosts or through
<htmlxmlns="http://www.w3.org/1999/xhtml"><head><metahttp-equiv="Content-Type"content="text/html; charset=UTF-8"/><title>ansible-modules</title><linkrel="stylesheet" href="./docbook-xsl.css" type="text/css" /><metaname="generator"content="DocBook XSL Stylesheets V1.75.2" /></head><body><divxml:lang="en"class="refentry"title="ansible-modules"lang="en"><aid="id510561"></a><divclass="titlepage"></div><divclass="refnamediv"><h2>Name</h2><p>ansible-modules — stock modules shipped with ansible</p></div><divclass="refsect1"title="DESCRIPTION"><aid="_description"></a><h2>DESCRIPTION</h2><p>Ansible ships with a number of modules that can be executed directly on remote hosts or through
ansible playbooks.</p></div><divclass="refsect1"title="IDEMPOTENCE"><aid="_idempotence"></a><h2>IDEMPOTENCE</h2><p>Most modules other than command are idempotent, meaning they will seek to avoid changes
ansible playbooks.</p></div><divclass="refsect1"title="IDEMPOTENCE"><aid="_idempotence"></a><h2>IDEMPOTENCE</h2><p>Most modules other than command are idempotent, meaning they will seek to avoid changes
unless a change needs to be made. When using ansible playbooks, these modules can
unless a change needs to be made. When using ansible playbooks, these modules can
trigger change events, as described in <spanclass="strong"><strong>ansible-playbooks</strong></span>(5).</p><p>Unless otherwise noted, all modules support change hooks.</p></div><divclass="refsect1"title="command"><aid="_command"></a><h2>command</h2><p>The command module takes the command name followed by a list of arguments, space delimited.
trigger change events, as described in <spanclass="strong"><strong>ansible-playbooks</strong></span>(5).</p><p>Unless otherwise noted, all modules support change hooks.</p></div><divclass="refsect1"title="command"><aid="_command"></a><h2>command</h2><p>The command module takes the command name followed by a list of arguments, space delimited.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml"><head><metahttp-equiv="Content-Type"content="text/html; charset=UTF-8"/><title>ansible-modules</title><linkrel="stylesheet"type="text/css"href="./docbook-xsl.css" /><metaname="generator"content="DocBook XSL Stylesheets V1.76.1" /></head><body><divxml:lang="en"class="refentry"title="ansible-modules"lang="en"><aid="id507830"></a><divclass="titlepage"></div><divclass="refnamediv"><h2>Name</h2><p>ansible-playbook — format and function of an ansible playbook file</p></div><divclass="refsect1"title="DESCRIPTION"><aid="_description"></a><h2>DESCRIPTION</h2><p>Ansible ships with <spanclass="emphasis"><em>ansible-playbook</em></span>, a tool for running playbooks.
<htmlxmlns="http://www.w3.org/1999/xhtml"><head><metahttp-equiv="Content-Type"content="text/html; charset=UTF-8"/><title>ansible-modules</title><linkrel="stylesheet" href="./docbook-xsl.css" type="text/css" /><metaname="generator"content="DocBook XSL Stylesheets V1.75.2" /></head><body><divxml:lang="en"class="refentry"title="ansible-modules"lang="en"><aid="id395532"></a><divclass="titlepage"></div><divclass="refnamediv"><h2>Name</h2><p>ansible-playbook — format and function of an ansible playbook file</p></div><divclass="refsect1"title="DESCRIPTION"><aid="_description"></a><h2>DESCRIPTION</h2><p>Ansible ships with <spanclass="emphasis"><em>ansible-playbook</em></span>, a tool for running playbooks.
Playbooks can represent frequent tasks, desired system configurations,
Playbooks can represent frequent tasks, desired system configurations,
or deployment processes.</p></div><divclass="refsect1"title="FORMAT"><aid="_format"></a><h2>FORMAT</h2><p>Playbooks are written in YAML.</p></div><divclass="refsect1"title="EXAMPLE"><aid="_example"></a><h2>EXAMPLE</h2><p>See:</p><divclass="itemizedlist"><ulclass="itemizedlist"type="disc"><liclass="listitem">
or deployment processes.</p></div><divclass="refsect1"title="FORMAT"><aid="_format"></a><h2>FORMAT</h2><p>Playbooks are written in YAML.</p></div><divclass="refsect1"title="EXAMPLE"><aid="_example"></a><h2>EXAMPLE</h2><p>See:</p><divclass="itemizedlist"><ulclass="itemizedlist"type="disc"><liclass="listitem">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml"><head><metahttp-equiv="Content-Type"content="text/html; charset=UTF-8"/><title>ansible</title><linkrel="stylesheet"type="text/css"href="./docbook-xsl.css" /><metaname="generator"content="DocBook XSL Stylesheets V1.76.1" /></head><body><divxml:lang="en"class="refentry"title="ansible"lang="en"><aid="id547391"></a><divclass="titlepage"></div><divclass="refnamediv"><h2>Name</h2><p>ansible — run a command somewhere else</p></div><divclass="refsynopsisdiv"title="Synopsis"><aid="_synopsis"></a><h2>Synopsis</h2><p>ansible <host-pattern> [-f forks] [-m module_name] [-a args]</p></div><divclass="refsect1"title="DESCRIPTION"><aid="_description"></a><h2>DESCRIPTION</h2><p><spanclass="strong"><strong>Ansible</strong></span> is an extra-simple tool/framework/API for doing 'remote things' over
<htmlxmlns="http://www.w3.org/1999/xhtml"><head><metahttp-equiv="Content-Type"content="text/html; charset=UTF-8"/><title>ansible</title><linkrel="stylesheet" href="./docbook-xsl.css" type="text/css" /><metaname="generator"content="DocBook XSL Stylesheets V1.75.2" /></head><body><divxml:lang="en"class="refentry"title="ansible"lang="en"><aid="id421198"></a><divclass="titlepage"></div><divclass="refnamediv"><h2>Name</h2><p>ansible — run a command somewhere else</p></div><divclass="refsynopsisdiv"title="Synopsis"><aid="_synopsis"></a><h2>Synopsis</h2><p>ansible <host-pattern> [-f forks] [-m module_name] [-a args]</p></div><divclass="refsect1"title="DESCRIPTION"><aid="_description"></a><h2>DESCRIPTION</h2><p><spanclass="strong"><strong>Ansible</strong></span> is an extra-simple tool/framework/API for doing 'remote things' over
<p>The given shell command will be executed on all selected nodes.</p>
<p>The given shell command will be executed on all selected nodes.</p>
<p>This module does not support change hooks and returns the return code from the program as well as timing information about how long the command was running for.</p>
<p>This module does not support change hooks and returns the return code
from the program as well as timing information about how long the
command was running for.</p>
</div>
</div>
<divclass="section"id="copy">
<divclass="section"id="copy">
<h2>copy<aclass="headerlink"href="#copy"title="Permalink to this headline">¶</a></h2>
<spanid="id2"></span><h2>copy<aclass="headerlink"href="#copy"title="Permalink to this headline">¶</a></h2>
<p>The copy module moves a file on the local box to remote locations.</p>
<p>The copy module moves a file on the local box to remote locations.</p>
<p><em>src</em>:</p>
<p><em>src</em>:</p>
<p>Local path to a file to copy to the remote server. This can be an absolute or relative path.</p>
<ulclass="simple">
<li>Local path to a file to copy to the remote server. This can be an
absolute or relative path.</li>
</ul>
<p><em>dest</em>:</p>
<p><em>dest</em>:</p>
<p>Remote absolute path where the file should end up.</p>
<ulclass="simple">
<li>Remote absolute path where the file should end up.</li>
</ul>
<p>This module also returns md5sum information about the resultant file.</p>
<p>This module also returns md5sum information about the resultant file.</p>
</div>
</div>
<divclass="section"id="facter">
<divclass="section"id="facter">
<h2>facter<aclass="headerlink"href="#facter"title="Permalink to this headline">¶</a></h2>
<spanid="id3"></span><h2>facter<aclass="headerlink"href="#facter"title="Permalink to this headline">¶</a></h2>
<p>Runs the discovery program ‘facter’ on the remote system, returning
<p>Runs the discovery program ‘facter’ on the remote system, returning
JSON data that can be useful for inventory purposes.</p>
JSON data that can be useful for inventory purposes.</p>
<p>Requires that ‘facter’ and ‘ruby-json’ be installed on the remote end.</p>
<p>Requires that ‘facter’ and ‘ruby-json’ be installed on the remote end.</p>
<p>This module is informative only - it takes no parameters & does not support change hooks,
<p>This module is informative only - it takes no parameters & does not
nor does it make any changes on the system. Playbooks do not actually use
support change hooks, nor does it make any changes on the system.
this module, they use the ‘setup’ module behind the scenes.</p>
Playbooks do not actually use this module, they use the <aclass="reference internal"href="#setup"><em>setup</em></a>
module behind the scenes.</p>
</div>
</div>
<divclass="section"id="git">
<divclass="section"id="git">
<h2>git<aclass="headerlink"href="#git"title="Permalink to this headline">¶</a></h2>
<h2>git<aclass="headerlink"href="#git"title="Permalink to this headline">¶</a></h2>
<p>Deploys software (or files) from git checkouts.</p>
<p>Deploys software (or files) from git checkouts.</p>
<p><em>repo</em>:</p>
<p><em>repo</em>:</p>
<p>git or http protocol address of the repo to checkout</p>
<ulclass="simple">
<li>git or http protocol address of the repo to checkout.</li>
</ul>
<p><em>dest</em>:</p>
<p><em>dest</em>:</p>
<p>where to check it out, an absolute directory path</p>
<ulclass="simple">
<li>Where to check it out, an absolute directory path.</li>
</ul>
<p><em>version</em>:</p>
<p><em>version</em>:</p>
<p>what version to check out – either the git SHA, the literal string ‘HEAD’, or a tag name</p>
<ulclass="simple">
<li>What version to check out – either the git SHA, the literal string
<ttclass="docutils literal"><spanclass="pre">HEAD</span></tt>, or a tag name.</li>
</ul>
</div>
</div>
<divclass="section"id="ohai">
<divclass="section"id="ohai">
<h2>ohai<aclass="headerlink"href="#ohai"title="Permalink to this headline">¶</a></h2>
<h2>ohai<aclass="headerlink"href="#ohai"title="Permalink to this headline">¶</a></h2>
<p>Similar to the facter module, this returns JSON inventory data. Ohai
<p>Similar to the <aclass="reference internal"href="#facter"><em>facter</em></a> module, this returns JSON inventory data.
data is a bit more verbose and nested than facter.</p>
Ohai data is a bit more verbose and nested than facter.</p>
<p>Requires that ‘ohai’ be installed on the remote end.</p>
<p>Requires that ‘ohai’ be installed on the remote end.</p>
<p>This module is information only - it takes no parameters & does not
<p>This module is information only - it takes no parameters & does not
support change hooks, nor does it make any changes on the system.</p>
support change hooks, nor does it make any changes on the system.</p>
<p>Playbooks should not call the ohai module, playbooks call the‘setup’
<p>Playbooks should not call the ohai module, playbooks call the
module behind the scenes instead.</p>
<aclass="reference internal"href="#setup"><em>setup</em></a>module behind the scenes instead.</p>
</div>
</div>
<divclass="section"id="ping">
<divclass="section"id="ping">
<h2>ping<aclass="headerlink"href="#ping"title="Permalink to this headline">¶</a></h2>
<h2>ping<aclass="headerlink"href="#ping"title="Permalink to this headline">¶</a></h2>
<p>A trivial test module, this module always returns the integer ‘1’ on
<p>A trivial test module, this module always returns the integer <ttclass="docutils literal"><spanclass="pre">1</span></tt> on
successful contact.</p>
successful contact.</p>
<p>This module does not support change hooks and is informative only - it takes no parameters & does not
<p>This module does not support change hooks and is informative only - it
support change hooks, nor does it make any changes on the system.</p>
takes no parameters & does not support change hooks, nor does it make
any changes on the system.</p>
</div>
</div>
<divclass="section"id="service">
<divclass="section"id="service">
<h2>service<aclass="headerlink"href="#service"title="Permalink to this headline">¶</a></h2>
<h2>service<aclass="headerlink"href="#service"title="Permalink to this headline">¶</a></h2>
<p>Controls services on remote machines.</p>
<p>Controls services on remote machines.</p>
<p><em>state</em></p>
<p><em>state</em>:</p>
<p>Values are ‘started’, ‘stopped’, or ‘restarted’. Started/stopped
<ulclass="simple">
are idempotent actions that will not run commands unless neccessary.
<li>Values are <ttclass="docutils literal"><spanclass="pre">started</span></tt>, <ttclass="docutils literal"><spanclass="pre">stopped</span></tt>, or <ttclass="docutils literal"><spanclass="pre">restarted</span></tt>.
‘restarted’ will always bounce the service</p>
Started/stopped are idempotent actions that will not run commands
<p><em>name</em></p>
unless necessary. <ttclass="docutils literal"><spanclass="pre">restarted</span></tt> will always bounce the service.</li>
<p>The name of the service</p>
</ul>
<p><em>name</em>:</p>
<ulclass="simple">
<li>The name of the service.</li>
</ul>
</div>
</div>
<divclass="section"id="setup">
<divclass="section"id="setup">
<h2>setup<aclass="headerlink"href="#setup"title="Permalink to this headline">¶</a></h2>
<spanid="id4"></span><h2>setup<aclass="headerlink"href="#setup"title="Permalink to this headline">¶</a></h2>
<p>Writes a JSON file containing key/value data, for use in templating.
<p>Writes a JSON file containing key/value data, for use in templating.
Call this once before using the template modules. Playbooks will
Call this once before using the <aclass="reference internal"href="#template"><em>template</em></a> module. Playbooks
execute this module automatically as the first step in each play using
will execute this module automatically as the first step in each play
the variables section, so it is unneccessary to make explicit calls to
using the variables section, so it is unnecessary to make explicit
setup within a playbook.</p>
calls to setup within a playbook.</p>
<p>If facter or ohai are installed, variables from these programs will also
<p>If facter or ohai are installed, variables from these programs will
be snapshotted into the JSON file for usage in templating. These variables
also be snapshotted into the JSON file for usage in templating. These
are prefixed with ‘<aclass="reference internal"href="#facter">facter</a>‘ and ‘<aclass="reference internal"href="#ohai">ohai</a>” so it’s easy to tell their source.
variables are prefixed with <ttclass="docutils literal"><spanclass="pre">facter_</span></tt> and <ttclass="docutils literal"><spanclass="pre">ohai_</span></tt> so it’s easy to
All variables are then bubbled up to the caller.</p>
tell their source. All variables are then bubbled up to the caller.</p>
<p><em>anything</em></p>
<p><em>anything</em>:</p>
<p>any other parameters can be named basically anything, and set a key=value
<blockquote>
pair in the JSON file for use in templating.</p>
<div><ulclass="simple">
<li>Any other parameters can be named basically anything, and set a
<ttclass="docutils literal"><spanclass="pre">key=value</span></tt> pair in the JSON file for use in templating.</li>
</ul>
</div></blockquote>
</div>
</div>
<divclass="section"id="template">
<divclass="section"id="template">
<h2>template<aclass="headerlink"href="#template"title="Permalink to this headline">¶</a></h2>
<spanid="id5"></span><h2>template<aclass="headerlink"href="#template"title="Permalink to this headline">¶</a></h2>
<p>Templates a file out to a remote server. Call the setup module prior to usage.</p>
<p>Templates a file out to a remote server. Call the <aclass="reference internal"href="#setup"><em>setup</em></a> module
<p><em>src</em></p>
prior to usage.</p>
<p>path of a Jinja2 formatted template on the local server. This can be a relative
<p><em>src</em>:</p>
or absolute path.</p>
<ulclass="simple">
<p><em>dest</em></p>
<li>Path of a Jinja2 formatted template on the local server. This can
<p>location to render the template on the remote server</p>
be a relative or absolute path.</li>
</ul>
<p><em>dest</em>:</p>
<ulclass="simple">
<li>Location to render the template on the remote server.</li>
</ul>
<p>This module also returns md5sum information about the resultant file.</p>
<p>This module also returns md5sum information about the resultant file.</p>
</div>
</div>
<divclass="section"id="writing-your-own-modules">
<divclass="section"id="writing-your-own-modules">
<h2>Writing your own modules<aclass="headerlink"href="#writing-your-own-modules"title="Permalink to this headline">¶</a></h2>
<h2>Writing your own modules<aclass="headerlink"href="#writing-your-own-modules"title="Permalink to this headline">¶</a></h2>
<p>To write your own modules, simply follow the convention of those already available in
<p>To write your own modules, simply follow the convention of those
/usr/share/ansible. Modules must return JSON but can be written in any language.
already available in /usr/share/ansible. Modules must return JSON but
Modules should return hashes, but hashes can be nested.</p>
can be written in any language. Modules should return hashes, but
<p>To support change hooks, modules should return hashes with a changed: True/False
hashes can be nested.</p>
element at the top level:</p>
<p>To support change hooks, modules should return hashes with a changed:
<p>Modules can also choose to indicate a failure scenario by returning a top level ‘failure’
<p>Modules can also choose to indicate a failure scenario by returning a
element with a True value, and a ‘msg’ element describing the nature of the failure.
top level <ttclass="docutils literal"><spanclass="pre">failure</span></tt> element with a True value, and a <ttclass="docutils literal"><spanclass="pre">msg</span></tt> element
Other return values are up to the module.</p>
describing the nature of the failure. Other return values are up to
<h2>Inventory File Format<aclass="headerlink"href="#inventory-file-format"title="Permalink to this headline">¶</a></h2>
<spanid="inventoryformat"></span><h2>Inventory File Format<aclass="headerlink"href="#inventory-file-format"title="Permalink to this headline">¶</a></h2>
<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 Ansible’s inventory file,
same time. It does this by selecting portions of systems listed in
which defaults to /etc/ansible/hosts, and looks like this:</p>
Ansible’s inventory file, which defaults to /etc/ansible/hosts, and
@ -206,7 +206,7 @@ server group, then more commands back on the webservers group, etc:</p>
<divclass="section"id="hosts-line">
<divclass="section"id="hosts-line">
<h2>Hosts line<aclass="headerlink"href="#hosts-line"title="Permalink to this headline">¶</a></h2>
<h2>Hosts line<aclass="headerlink"href="#hosts-line"title="Permalink to this headline">¶</a></h2>
<p>The hosts line is a list of one or more groups or host patterns,
<p>The hosts line is a list of one or more groups or host patterns,
seperated by colons, as described in the <aclass="reference internal"href="patterns.html#patterns"><em>The Inventory File, Patterns, and Groups</em></a>
separated by colons, as described in the <aclass="reference internal"href="patterns.html#patterns"><em>The Inventory File, Patterns, and Groups</em></a>
documentation. This is just like the first parameter to
documentation. This is just like the first parameter to
<cite>/usr/bin/ansible</cite>.</p>
<cite>/usr/bin/ansible</cite>.</p>
</div>
</div>
@ -215,8 +215,7 @@ documentation. This is just like the first parameter to
<p>A list of variables and values that can be used in the plays. These
<p>A list of variables and values that can be used in the plays. These
can be used in templates or ‘action’ lines and are dereferenced using
can be used in templates or ‘action’ lines and are dereferenced using
<h2>Using Includes To Assign Classes of Systems<aclass="headerlink"href="#using-includes-to-assign-classes-of-systems"title="Permalink to this headline">¶</a></h2>
<h2>Using Includes To Assign Classes of Systems<aclass="headerlink"href="#using-includes-to-assign-classes-of-systems"title="Permalink to this headline">¶</a></h2>
@ -367,7 +369,7 @@ from the configuration file to generate machine specific variables.</p>