docs rebuild

pull/1256/head
Michael DeHaan 13 years ago
parent 1952bd0aa3
commit 2c6dd03229

@ -12,7 +12,7 @@ Examples
Parallelism and Shell Commands
``````````````````````````````
Reboot all web servers in Atlanta, 10 at a time::
Let's use ansible's command line tool to reboot all web servers in Atlanta, 10 at a time::
ssh-agent bash
ssh-add ~/.ssh/id_rsa.pub
@ -21,23 +21,24 @@ Reboot all web servers in Atlanta, 10 at a time::
The -f 10 specifies the usage of 10 simultaneous processes.
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.
Example 2: Time Limited Background Operations
`````````````````````````````````````````````
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
as 'idempotency'.
Time Limited Background Operations
``````````````````````````````````
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.::
ansible all -B 3600 -a "/usr/bin/long_running_operation --do-stuff"
ansible all -n job_status -a jid=123456789
Any module other than 'copy' or 'template' can be backgrounded.
Any module other than 'copy' or 'template' can be backgrounded. Typically you'll be backgrounding shell
commands or software upgrades only.
After the time limit (in seconds) runs out (-B), the process on the remote nodes will be killed.
Examples 3: File Transfer & Templating
``````````````````````````````````````
File Transfer & Templating
``````````````````````````
Ansible can SCP lots of files to multiple machines in parallel, and optionally use them as template sources.
@ -45,7 +46,7 @@ To just transfer a file directly to many different servers::
ansible atlanta copy -a "/etc/hosts /tmp/hosts"
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 below) will run the setup module for you, making this even simpler.::
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.::
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"
@ -53,8 +54,8 @@ To use templating, first run the setup module to put the template variables you
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.
Examples 3: Deploying From Source Control
`````````````````````````````````````````
Deploying From Source Control
`````````````````````````````
Deploy your webapp straight from git::
@ -62,4 +63,15 @@ Deploy your webapp straight from git::
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.
Managing Services
`````````````````
Ensure a service is started on all webservers::
ansible webservers -m service name=httpd state=started
Alternatively, restart a service on all webservers::
ansible webservers -m service name=httpd state=restarted

@ -7,20 +7,15 @@ How to download ansible and get started using it
:doc:`examples`
Examples of basic commands
:doc:`YAMLScripts`
Complete documentation of the YAML syntax `ansible` understands for playbooks.
:doc:`playbooks`
Learning ansible's configuration management language
:doc:`modules`
Learn about modules that ship with ansible
Requirements
````````````
Requirements are extremely minimal.
Requirements for Ansible are extremely minimal.
If you are running python 2.6 on the **overlord** machine, you will
need:
If you are running python 2.6 on the **overlord** machine (the machine that you'll be talking to the other machines from), you will need:
* ``paramiko``
* ``PyYAML``
@ -44,7 +39,7 @@ Developer Requirements
For developers, you may wish to have:
* ``asciidoc`` (for building manpage documentation)
* ``python-sphinx`` (for building content for ansible.github.com)
* ``python-sphinx`` (for building content for the ansible.github.com project only)
Getting Ansible
@ -96,5 +91,6 @@ Now try this:
ansible all -m ping
Congratulations. You've just contacted your nodes with Ansible. It's now time to read some
of the more real-world examples.
of the more real-world examples, and explore what you can do with different modules, as well
as the Ansible playbooks language.

@ -10,15 +10,17 @@ Other tools in this space have been too complicated for too long, require too mu
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.
Ansible isn't just for configuration -- it's also great for Ad-Hoc tasks,
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 the "playbooks" feature.
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".
Ansible does not require programming in any particular language -- you can write modules
as scripts or programs that return simple JSON.
Extending ansible does not require programming in any particular language -- you can write modules
as scripts or programs that return simple JSON. It's also trivially easy to just execute
useful shell commands.
Why use Ansible versus something else? (Puppet, Chef, Fabric, Capistrano,
mCollective, Func, SaltStack, etc?) It will have far less code, it
will be more correct, and it will be the easiest thing to hack on and
mCollective, Func, SaltStack, etc?) Ansible will have far less code, it
will be (by extension) more correct, and it will be the easiest thing to hack on and
use you'll ever see -- regardless of your favorite language of choice.
Systems management doesn't have to be complicated. Ansible's docs will remain
short & simple, and the source will be blindingly obvious.
@ -32,7 +34,7 @@ Design Goals
* No additional software required on client boxes
* Modules can be written in ANY language
* Awesome API for creating very powerful distributed scripts
* Be usable as non-root
* Be very usable as non-root
* Create the easiest config management system to use, ever.
Communicate and Get Involved
@ -55,10 +57,10 @@ Contents
gettingstarted
patterns
examples
modules
YAMLScripts
playbooks
examples
api
man
@ -69,7 +71,7 @@ Ansible was originally developed by Michael DeHaan, a Raleigh, NC based software
He created other popular DevOps programs such as Cobbler, the popular Linux install server.
Cobbler is used to deploy mission critical systems all over the planet, in industries
ranging from massively multiplayer gaming, core internet infrastructure, finance,
chip design, and more. Michael also helped co-author of Func, which is used
chip design, and more. Michael also 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, and rPath.
IBM, Motorola, Red Hat's Emerging Technologies Group, Puppet Labs, and rPath.

@ -13,13 +13,17 @@ ansible playbooks.
:doc:`api`
Examples of using modules with the Python API
Module Idempotence
```````````````````
Nearly all modules take key=value parameters. Some modules take no parameters, and the command
module just takes arguments for the command you want to run.
All modules return JSON format data, thoug if you are using the command line or playbooks, you
don't really need to know much about that.
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
trigger change events. Unless otherwise noted, all modules support change hooks.
Stock modules:
command
```````
@ -31,6 +35,8 @@ Example usage::
/sbin/shutdown -t now
The given shell command will be executed on all selected nodes.
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.
@ -41,12 +47,12 @@ The copy module moves a file on the local box to remote locations.
*src*::
Local absolute path to a file to copy to the remote server
Local path to a file to copy to the remote server. This can be an absolute or relative path.
*dest*::
Remote absolute path where the file should end up
Remote absolute path where the file should end up.
This module also returns md5sum information about the resultant file.
@ -56,18 +62,19 @@ facter
``````
Runs the discovery program 'facter' on the remote system, returning
JSON data that can be useful for inventory purposes.
JSON data that can be useful for inventory purposes.
Requires that 'facter' and 'ruby-json' be installed on the remote end.
This module is informative only - it takes no parameters & does not support change hooks,
nor does it make any changes on the system.
nor does it make any changes on the system. Playbooks do not actually use
this module, they use the 'setup' module behind the scenes.
git
```
Deploys software from git checkouts.
Deploys software (or files) from git checkouts.
*repo*::
@ -93,6 +100,8 @@ Requires that 'ohai' be installed on the remote end.
This module is information only - it takes no parameters & does not
support change hooks, nor does it make any changes on the system.
Playbooks should not call the ohai module, playbooks call the 'setup'
module behind the scenes instead.
ping
````
@ -100,9 +109,7 @@ ping
A trivial test module, this module always returns the integer '1' on
successful contact.
This module does not support change hooks.
This module is informative only - it takes no parameters & does not
This module does not support change hooks and is informative only - it takes no parameters & does not
support change hooks, nor does it make any changes on the system.
@ -128,18 +135,14 @@ setup
Writes a JSON file containing key/value data, for use in templating.
Call this once before using the template modules. Playbooks will
execute this module automatically as the first step in each play.
execute this module automatically as the first step in each play using
the variables section, so it is unneccessary to make explicit calls to
setup within a playbook.
If facter or ohai are installed, variables from these programs will also
be snapshotted into the JSON file for usage in templating. These variables
are prefixed with 'facter_' and 'ohai_" so it's easy to tell their source.
*metadata*
Optionally overrides the default JSON file location of /etc/ansible/setup or ~/ansible/setup
depending on what remote user has been specified.
If used, also supply the metadata parameter to the template module.
All variables are then bubbled up to the caller.
*anything*
@ -154,43 +157,43 @@ Templates a file out to a remote server. Call the setup module prior to usage.
*src*
path of a Jinja2 formatted template on the local server
path of a Jinja2 formatted template on the local server. This can be a relative
or absolute path.
*dest*
location to render the template on the remote server
*metadata*
location of a JSON file to use to supply template data. Default is /etc/ansible/setup
which is the same as the default for the setup module. Change if running as a non-root
remote user who does not have permissions on /etc/ansible.
This module also returns md5sum information about the resultant file.
user
````
Writing your own modules
````````````````````````
This module is in plan.
To write your own modules, simply follow the convention of those already available in
/usr/share/ansible. Modules must return JSON but can be written in any language.
Modules should return hashes, but hashes can be nested.
To support change hooks, modules should return hashes with a changed: True/False
element at the top level::
yum
```
{
'changed' : True,
'something' : 42
}
This module is in plan.
Modules can also choose to indicate a failure scenario by returning a top level 'failure'
element with a True value, and a 'msg' element describing the nature of the failure.
Other return values are up to the module.
{
'failure' : True,
'msg' : "here is what happened..."
}
When shipping modules, drop them in /usr/share/ansible, or specify the module path to the
command line tool or API. It is easy to test modules by running them directly on
the command line, passing them arguments just like they would be passed with ansible.
writing your own modules
````````````````````````
To write your own modules, simply follow the convention of those already available in
/usr/share/ansible. Modules must return JSON but can be written in any language.
Modules should return hashes, but hashes can be nested.
To support change hooks, modules should return hashes with a changed: True/False
element at the top level. Modules can also choose to indicate a failure scenario
by returning a top level 'failure' element with a True value, and a 'msg' element
describing the nature of the failure. Other values are up to the module.

@ -11,7 +11,11 @@ Playbooks: Ansible for Deployment, Configuration Management, and Orchestration
Learn about how to select hosts
Playbooks are a completely different way to use ansible and are particularly awesome. They are the basis for a really simple configuration management and deployment system, unlike any that already exist, and one that is very well suited to deploying complex multi-machine applications. While you might run the main ansible program for ad-hoc tasks, playbooks are more likely to be kept in source control and used to push out your configuration or assure the configurations of your remote systems are in spec.
Playbooks are a completely different way to use ansible and are particularly awesome.
They are the basis for a really simple configuration management and multi-machine deployment system, unlike any that already exist, and one that is very well suited to deploying complex applications.
While you might run the main /usr/bin/ansible program for ad-hoc tasks, playbooks are more likely to be kept in source control and used to push out your configuration or assure the configurations of your remote systems are in spec.
Playbook Example
@ -43,34 +47,43 @@ back on the webservers group, etc::
Hosts line
``````````
The hosts line is alist of one or more groups or host patterns, seperated by colons, as
described in the 'patterns' documentation.
The hosts line is a list of one or more groups or host patterns, seperated by colons, as
described in the 'patterns' documentation. This is just like the first parameter to /usr/bin/ansible.
Vars section
````````````
A list of variables that can be used in the templates, action lines, or included files.
Variables are deferenced using ``jinja2`` syntax like this::
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 ```jinja2``` syntax like this:
{{ varname }}
These variables will be pushed down to the managed systems for use in templating operations, where
the way to dereference them in templates is exactly the same.
Further, if there are discovered variables about the system (say, if facter or ohai were
installed) these variables bubble up back into the playbook, and can be used on each
system just like explicitly set variables. Facter variables are prefixed with 'facter_'
and Ohai variables are prefixed with 'ohai_'.
and Ohai variables are prefixed with 'ohai_'. So for instance, if I wanted to write the
hostname into the /etc/motd file, I could say:
- name: write the motd
- action: template src=/srv/templates/motd.j2 dest=/etc/motd
And in /srv/templates/motd.j2:::
You are logged into {{ facter_hostname }}
But we're getting ahead of ourselves. Let's talk about tasks.
Tasks list
``````````
Each play contains a list of tasks. Tasks are executed in order, one at a time, against
all machines matched by the play's host pattern, before moving on to the next task.
Hosts with failed tasks are taken out of the rotation for the entire playbook. If things fail,
correct the problem and rerun. Modules other than command are idempotent, meaning if you
run them again, they will make the changes they are told to make to bring the system to
the desired state.
simply correct the playbook file and rerun.
Modules other than command are idempotent, meaning if you run them again, they will make the
changes they are told to make to bring the system to the desired state.
Task name and action
`````````````````````
@ -81,27 +94,51 @@ The action line is the name of an ansible module followed by parameters. Usuall
are expressed in key=value form, except for the command module, which looks just like a Linux/Unix
command line. See the module documentation for more info.
Variables, as mentioned above, can be used in action lines. So if, hypothetically, you wanted
to make a directory on each system named after the hostname ... yeah, that's I know silly ... you could
do it like so:
- name: make a directory
- action: mkdir /tmp/{{ facter_hostname }}
Notify statements
`````````````````
Nearly all modules are written to be 'idempotent' and can signal when they have affected a change
on the remote system. If a notify statement is used, the named handler will be run against
each system where a change was effected, but NOT on systems where no change occurred.
each system where a change was effected, but NOT on systems where no change occurred. This happens
after all of the tasks are run. For example, if notifying Apache and potentially replacing lots of
configuration files, you could have Apache restart just once, at the end of a run. If you need
Apache restarted in the middle of a run, you could just make a task for it, no harm done. Notifiers
are optional.
Handlers
````````
Handlers are lists of tasks, not really any different from regular tasks, that are referenced
by name.
by name. Handlers are what notifiers notify. If nothing notifies a handler, it will not run.
Regardless of how many things notify a handler, it will run only once, after all of the tasks
complete in a particular play.
Includes
````````
Not all tasks have to be listed directly in the main file. An include file can contain
a list of tasks (in YAML) as well, optionally passing extra variables into the file.
Variables passed in can be deferenced like this:
Variables passed in can be deferenced like this (assume a variable named 'user')
{{ user }}
For instance, if deploying multiple wordpress instances, I could contain all of my tasks
in a wordpress.yml file, and use it like so:
- tasks:
- include: wordpress.yml user=timmy
- include: wordpress.yml user=alice
- include: wordpress.yml user=bob
{{ variable }}
In addition to the explicitly passed in parameters, all variables from the vars section
are also available.
Asynchronous Actions and Polling
````````````````````````````````

@ -24,7 +24,7 @@
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="Ansible v0.0.1 documentation" href="index.html" />
<link rel="next" title="Man Pages" href="man.html" />
<link rel="prev" title="Examples" href="examples.html" />
<link rel="prev" title="Playbooks: Ansible for Deployment, Configuration Management, and Orchestration" href="playbooks.html" />
</head>
<body>
<div class="related">
@ -37,7 +37,7 @@
<a href="man.html" title="Man Pages"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="examples.html" title="Examples"
<a href="playbooks.html" title="Playbooks: Ansible for Deployment, Configuration Management, and Orchestration"
accesskey="P">previous</a> |</li>
<li><a href="index.html">Ansible v0.0.1 documentation</a> &raquo;</li>
</ul>
@ -87,8 +87,8 @@ be used as a framework to rapidly build powerful applications and scripts.</p>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h4>Previous topic</h4>
<p class="topless"><a href="examples.html"
title="previous chapter">Examples</a></p>
<p class="topless"><a href="playbooks.html"
title="previous chapter">Playbooks: Ansible for Deployment, Configuration Management, and Orchestration</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="man.html"
title="next chapter">Man Pages</a></p>
@ -124,7 +124,7 @@ be used as a framework to rapidly build powerful applications and scripts.</p>
<a href="man.html" title="Man Pages"
>next</a> |</li>
<li class="right" >
<a href="examples.html" title="Examples"
<a href="playbooks.html" title="Playbooks: Ansible for Deployment, Configuration Management, and Orchestration"
>previous</a> |</li>
<li><a href="index.html">Ansible v0.0.1 documentation</a> &raquo;</li>
</ul>

@ -23,8 +23,8 @@
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="Ansible v0.0.1 documentation" href="index.html" />
<link rel="next" title="API" href="api.html" />
<link rel="prev" title="Playbooks: Ansible for Deployment, Configuration Management, and Orchestration" href="playbooks.html" />
<link rel="next" title="Ansible Modules" href="modules.html" />
<link rel="prev" title="The Inventory File, Patterns, and Groups" href="patterns.html" />
</head>
<body>
<div class="related">
@ -34,10 +34,10 @@
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="api.html" title="API"
<a href="modules.html" title="Ansible Modules"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="playbooks.html" title="Playbooks: Ansible for Deployment, Configuration Management, and Orchestration"
<a href="patterns.html" title="The Inventory File, Patterns, and Groups"
accesskey="P">previous</a> |</li>
<li><a href="index.html">Ansible v0.0.1 documentation</a> &raquo;</li>
</ul>
@ -61,43 +61,55 @@
</div>
<div class="section" id="parallelism-and-shell-commands">
<h2>Parallelism and Shell Commands<a class="headerlink" href="#parallelism-and-shell-commands" title="Permalink to this headline"></a></h2>
<p>Reboot all web servers in Atlanta, 10 at a time:</p>
<p>Let&#8217;s use ansible&#8217;s command line tool to reboot all web servers in Atlanta, 10 at a time:</p>
<div class="highlight-python"><pre>ssh-agent bash
ssh-add ~/.ssh/id_rsa.pub
ansible atlanta -a "/sbin/reboot" -f 10</pre>
</div>
<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.</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
as &#8216;idempotency&#8217;.</p>
</div>
<div class="section" id="example-2-time-limited-background-operations">
<h2>Example 2: Time Limited Background Operations<a class="headerlink" href="#example-2-time-limited-background-operations" title="Permalink to this headline"></a></h2>
<div class="section" id="time-limited-background-operations">
<h2>Time Limited Background Operations<a class="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&#8217;t lose track. Polling support is pending in the command line.:</p>
<div class="highlight-python"><pre>ansible all -B 3600 -a "/usr/bin/long_running_operation --do-stuff"
ansible all -n job_status -a jid=123456789</pre>
</div>
<p>Any module other than &#8216;copy&#8217; or &#8216;template&#8217; can be backgrounded.</p>
<p>Any module other than &#8216;copy&#8217; or &#8216;template&#8217; can be backgrounded. Typically you&#8217;ll be backgrounding shell
commands or software upgrades only.</p>
<p>After the time limit (in seconds) runs out (-B), the process on the remote nodes will be killed.</p>
</div>
<div class="section" id="examples-3-file-transfer-templating">
<h2>Examples 3: File Transfer &amp; Templating<a class="headerlink" href="#examples-3-file-transfer-templating" title="Permalink to this headline"></a></h2>
<div class="section" id="file-transfer-templating">
<h2>File Transfer &amp; Templating<a class="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>To just transfer a file directly to many different servers:</p>
<div class="highlight-python"><pre>ansible atlanta copy -a "/etc/hosts /tmp/hosts"</pre>
</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 below) 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>
<div class="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/ntp.j2 dest=/etc/ntp.conf"</pre>
</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 &#8216;facter&#8217; and &#8216;ohai&#8217; prefixes for each.</p>
</div>
<div class="section" id="examples-3-deploying-from-source-control">
<h2>Examples 3: Deploying From Source Control<a class="headerlink" href="#examples-3-deploying-from-source-control" title="Permalink to this headline"></a></h2>
<div class="section" id="deploying-from-source-control">
<h2>Deploying From Source Control<a class="headerlink" href="#deploying-from-source-control" title="Permalink to this headline"></a></h2>
<p>Deploy your webapp straight from git:</p>
<div class="highlight-python"><pre>ansible webservers -m git -a "repo=git://foo dest=/srv/myapp version=HEAD"</pre>
</div>
<p>Since ansible modules can notify change handlers (see &#8216;Playbooks&#8217;) 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 class="section" id="managing-services">
<h2>Managing Services<a class="headerlink" href="#managing-services" title="Permalink to this headline"></a></h2>
<p>Ensure a service is started on all webservers:</p>
<div class="highlight-python"><pre>ansible webservers -m service name=httpd state=started</pre>
</div>
<p>Alternatively, restart a service on all webservers:</p>
<div class="highlight-python"><pre>ansible webservers -m service name=httpd state=restarted</pre>
</div>
</div>
</div>
@ -110,19 +122,20 @@ ansible webservers -m template -a "src=/srv/ntp.j2 dest=/etc/ntp.conf"</pre>
<ul>
<li><a class="reference internal" href="#">Examples</a><ul>
<li><a class="reference internal" href="#parallelism-and-shell-commands">Parallelism and Shell Commands</a></li>
<li><a class="reference internal" href="#example-2-time-limited-background-operations">Example 2: Time Limited Background Operations</a></li>
<li><a class="reference internal" href="#examples-3-file-transfer-templating">Examples 3: File Transfer &amp; Templating</a></li>
<li><a class="reference internal" href="#examples-3-deploying-from-source-control">Examples 3: Deploying From Source Control</a></li>
<li><a class="reference internal" href="#time-limited-background-operations">Time Limited Background Operations</a></li>
<li><a class="reference internal" href="#file-transfer-templating">File Transfer &amp; Templating</a></li>
<li><a class="reference internal" href="#deploying-from-source-control">Deploying From Source Control</a></li>
<li><a class="reference internal" href="#managing-services">Managing Services</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="playbooks.html"
title="previous chapter">Playbooks: Ansible for Deployment, Configuration Management, and Orchestration</a></p>
<p class="topless"><a href="patterns.html"
title="previous chapter">The Inventory File, Patterns, and Groups</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="api.html"
title="next chapter">API</a></p>
<p class="topless"><a href="modules.html"
title="next chapter">Ansible Modules</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/examples.txt"
@ -152,10 +165,10 @@ ansible webservers -m template -a "src=/srv/ntp.j2 dest=/etc/ntp.conf"</pre>
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="api.html" title="API"
<a href="modules.html" title="Ansible Modules"
>next</a> |</li>
<li class="right" >
<a href="playbooks.html" title="Playbooks: Ansible for Deployment, Configuration Management, and Orchestration"
<a href="patterns.html" title="The Inventory File, Patterns, and Groups"
>previous</a> |</li>
<li><a href="index.html">Ansible v0.0.1 documentation</a> &raquo;</li>
</ul>

@ -56,19 +56,14 @@
<dl class="last docutils">
<dt><a class="reference internal" href="examples.html"><em>Examples</em></a></dt>
<dd>Examples of basic commands</dd>
<dt><a class="reference internal" href="YAMLScripts.html"><em>YAML Scripts</em></a></dt>
<dd>Complete documentation of the YAML syntax <cite>ansible</cite> understands for playbooks.</dd>
<dt><a class="reference internal" href="playbooks.html"><em>Playbooks: Ansible for Deployment, Configuration Management, and Orchestration</em></a></dt>
<dd>Learning ansible&#8217;s configuration management language</dd>
<dt><a class="reference internal" href="modules.html"><em>Ansible Modules</em></a></dt>
<dd>Learn about modules that ship with ansible</dd>
</dl>
</div>
<div class="section" id="requirements">
<h2>Requirements<a class="headerlink" href="#requirements" title="Permalink to this headline"></a></h2>
<p>Requirements are extremely minimal.</p>
<p>If you are running python 2.6 on the <strong>overlord</strong> machine, you will
need:</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&#8217;ll be talking to the other machines from), you will need:</p>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">paramiko</span></tt></li>
<li><tt class="docutils literal"><span class="pre">PyYAML</span></tt></li>
@ -92,7 +87,7 @@ need:</p>
<p>For developers, you may wish to have:</p>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">asciidoc</span></tt> (for building manpage documentation)</li>
<li><tt class="docutils literal"><span class="pre">python-sphinx</span></tt> (for building content for ansible.github.com)</li>
<li><tt class="docutils literal"><span class="pre">python-sphinx</span></tt> (for building content for the ansible.github.com project only)</li>
</ul>
</div>
<div class="section" id="getting-ansible">
@ -137,7 +132,8 @@ bserver.example.org</pre>
ssh-add ~/.ssh/id_rsa
ansible all -m ping</div></blockquote>
<p>Congratulations. You&#8217;ve just contacted your nodes with Ansible. It&#8217;s now time to read some
of the more real-world examples.</p>
of the more real-world examples, and explore what you can do with different modules, as well
as the Ansible playbooks language.</p>
</div>
</div>

@ -50,14 +50,15 @@
Other tools in this space have been too complicated for too long, require too much bootstrapping,
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&#8217;s core is a little over 1000 lines.</p>
<p>Ansible isn&#8217;t just for configuration &#8211; it&#8217;s also great for Ad-Hoc tasks,
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 the &#8220;playbooks&#8221; feature.</p>
<p>Ansible does not require programming in any particular language &#8211; you can write modules
as scripts or programs that return simple JSON.</p>
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 &#8220;playbooks&#8221;.</p>
<p>Extending ansible does not require programming in any particular language &#8211; you can write modules
as scripts or programs that return simple JSON. It&#8217;s also trivially easy to just execute
useful shell commands.</p>
<p>Why use Ansible versus something else? (Puppet, Chef, Fabric, Capistrano,
mCollective, Func, SaltStack, etc?) It will have far less code, it
will be more correct, and it will be the easiest thing to hack on and
use you&#8217;ll ever see &#8211; regardless of your favorite language of choice.
Systems management doesn&#8217;t have to be complicated. Ansible&#8217;s docs will remain
mCollective, Func, SaltStack, etc?) Ansible will have far less code, it
will be (by extension) more correct, and it will be the easiest thing to hack on and
use you&#8217;ll ever see &#8211; regardless of your favorite language of choice.</p>
<p>Systems management doesn&#8217;t have to be complicated. Ansible&#8217;s docs will remain
short &amp; simple, and the source will be blindingly obvious.</p>
<div class="section" id="design-goals">
<h2>Design Goals<a class="headerlink" href="#design-goals" title="Permalink to this headline"></a></h2>
@ -68,7 +69,7 @@ short &amp; simple, and the source will be blindingly obvious.</p>
<li>No additional software required on client boxes</li>
<li>Modules can be written in ANY language</li>
<li>Awesome API for creating very powerful distributed scripts</li>
<li>Be usable as non-root</li>
<li>Be very usable as non-root</li>
<li>Create the easiest config management system to use, ever.</li>
</ul>
</div>
@ -105,8 +106,15 @@ short &amp; simple, and the source will be blindingly obvious.</p>
<li class="toctree-l2"><a class="reference internal" href="patterns.html#selecting-targets">Selecting Targets</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="examples.html">Examples</a><ul>
<li class="toctree-l2"><a class="reference internal" href="examples.html#parallelism-and-shell-commands">Parallelism and Shell Commands</a></li>
<li class="toctree-l2"><a class="reference internal" href="examples.html#time-limited-background-operations">Time Limited Background Operations</a></li>
<li class="toctree-l2"><a class="reference internal" href="examples.html#file-transfer-templating">File Transfer &amp; Templating</a></li>
<li class="toctree-l2"><a class="reference internal" href="examples.html#deploying-from-source-control">Deploying From Source Control</a></li>
<li class="toctree-l2"><a class="reference internal" href="examples.html#managing-services">Managing Services</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="modules.html">Ansible Modules</a><ul>
<li class="toctree-l2"><a class="reference internal" href="modules.html#module-idempotence">Module Idempotence</a></li>
<li class="toctree-l2"><a class="reference internal" href="modules.html#command">command</a></li>
<li class="toctree-l2"><a class="reference internal" href="modules.html#copy">copy</a></li>
<li class="toctree-l2"><a class="reference internal" href="modules.html#facter">facter</a></li>
@ -116,9 +124,7 @@ short &amp; simple, and the source will be blindingly obvious.</p>
<li class="toctree-l2"><a class="reference internal" href="modules.html#service">service</a></li>
<li class="toctree-l2"><a class="reference internal" href="modules.html#setup">setup</a></li>
<li class="toctree-l2"><a class="reference internal" href="modules.html#template">template</a></li>
<li class="toctree-l2"><a class="reference internal" href="modules.html#user">user</a></li>
<li class="toctree-l2"><a class="reference internal" href="modules.html#yum">yum</a></li>
<li class="toctree-l2"><a class="reference internal" href="modules.html#writing-your-own-modules">writing your own modules</a></li>
<li class="toctree-l2"><a class="reference internal" href="modules.html#writing-your-own-modules">Writing your own modules</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="YAMLScripts.html">YAML Scripts</a><ul>
@ -138,13 +144,6 @@ short &amp; simple, and the source will be blindingly obvious.</p>
<li class="toctree-l2"><a class="reference internal" href="playbooks.html#executing-a-playbook">Executing A Playbook</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="examples.html">Examples</a><ul>
<li class="toctree-l2"><a class="reference internal" href="examples.html#parallelism-and-shell-commands">Parallelism and Shell Commands</a></li>
<li class="toctree-l2"><a class="reference internal" href="examples.html#example-2-time-limited-background-operations">Example 2: Time Limited Background Operations</a></li>
<li class="toctree-l2"><a class="reference internal" href="examples.html#examples-3-file-transfer-templating">Examples 3: File Transfer &amp; Templating</a></li>
<li class="toctree-l2"><a class="reference internal" href="examples.html#examples-3-deploying-from-source-control">Examples 3: Deploying From Source Control</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="api.html">API</a></li>
<li class="toctree-l1"><a class="reference internal" href="man.html">Man Pages</a><ul>
<li class="toctree-l2"><a class="reference internal" href="man.html#ansible-1">ansible(1)</a></li>
@ -158,9 +157,9 @@ short &amp; simple, and the source will be blindingly obvious.</p>
He created other popular DevOps programs such as Cobbler, the popular Linux install server.
Cobbler is used to deploy mission critical systems all over the planet, in industries
ranging from massively multiplayer gaming, core internet infrastructure, finance,
chip design, and more. Michael also helped co-author of Func, which is used
chip design, and more. Michael also helped co-author of Func, a precursor to Ansible, which is used
to orchestrate systems in lots of diverse places. He&#8217;s worked on systems software for
IBM, Motorola, Red Hat&#8217;s Emerging Technologies Group, and rPath.</p>
IBM, Motorola, Red Hat&#8217;s Emerging Technologies Group, Puppet Labs, and rPath.</p>
</div>
</div>

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>ansible-modules</title><link rel="stylesheet" href="./docbook-xsl.css" type="text/css" /><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /></head><body><div xml:lang="en" class="refentry" title="ansible-modules" lang="en"><a id="id329245"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ansible-modules — stock modules shipped with ansible</p></div><div class="refsect1" title="DESCRIPTION"><a id="_description"></a><h2>DESCRIPTION</h2><p>Ansible ships with a number of modules that can be executed directly on remote hosts or through
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>ansible-modules</title><link rel="stylesheet" href="./docbook-xsl.css" type="text/css" /><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /></head><body><div xml:lang="en" class="refentry" title="ansible-modules" lang="en"><a id="id353684"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ansible-modules — stock modules shipped with ansible</p></div><div class="refsect1" title="DESCRIPTION"><a id="_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><div class="refsect1" title="IDEMPOTENCE"><a id="_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
trigger change events, as described in <span class="strong"><strong>ansible-playbooks</strong></span>(5).</p><p>Unless otherwise noted, all modules support change hooks.</p></div><div class="refsect1" title="command"><a id="_command"></a><h2>command</h2><p>The command module takes the command name followed by a list of arguments, space delimited.

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>ansible-modules</title><link rel="stylesheet" href="./docbook-xsl.css" type="text/css" /><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /></head><body><div xml:lang="en" class="refentry" title="ansible-modules" lang="en"><a id="id511858"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ansible-playbook — format and function of an ansible playbook file</p></div><div class="refsect1" title="DESCRIPTION"><a id="_description"></a><h2>DESCRIPTION</h2><p>Ansible ships with <span class="emphasis"><em>ansible-playbook</em></span>, a tool for running playbooks.
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>ansible-modules</title><link rel="stylesheet" href="./docbook-xsl.css" type="text/css" /><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /></head><body><div xml:lang="en" class="refentry" title="ansible-modules" lang="en"><a id="id308833"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ansible-playbook — format and function of an ansible playbook file</p></div><div class="refsect1" title="DESCRIPTION"><a id="_description"></a><h2>DESCRIPTION</h2><p>Ansible ships with <span class="emphasis"><em>ansible-playbook</em></span>, a tool for running playbooks.
Playbooks can represent frequent tasks, desired system configurations,
or deployment processes.</p></div><div class="refsect1" title="FORMAT"><a id="_format"></a><h2>FORMAT</h2><p>Playbooks are written in YAML.</p></div><div class="refsect1" title="EXAMPLE"><a id="_example"></a><h2>EXAMPLE</h2><p>See:</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
<a class="ulink" href="https://github.com/mpdehaan/ansible/blob/master/examples/playbook.yml" target="_top">https://github.com/mpdehaan/ansible/blob/master/examples/playbook.yml</a>

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>ansible</title><link rel="stylesheet" href="./docbook-xsl.css" type="text/css" /><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /></head><body><div xml:lang="en" class="refentry" title="ansible" lang="en"><a id="id539812"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ansible — run a command somewhere else</p></div><div class="refsynopsisdiv" title="Synopsis"><a id="_synopsis"></a><h2>Synopsis</h2><p>ansible &lt;host-pattern&gt; [-f forks] [-m module_name] [-a args]</p></div><div class="refsect1" title="DESCRIPTION"><a id="_description"></a><h2>DESCRIPTION</h2><p><span class="strong"><strong>Ansible</strong></span> is an extra-simple tool/framework/API for doing 'remote things' over
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>ansible</title><link rel="stylesheet" href="./docbook-xsl.css" type="text/css" /><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /></head><body><div xml:lang="en" class="refentry" title="ansible" lang="en"><a id="id502026"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ansible — run a command somewhere else</p></div><div class="refsynopsisdiv" title="Synopsis"><a id="_synopsis"></a><h2>Synopsis</h2><p>ansible &lt;host-pattern&gt; [-f forks] [-m module_name] [-a args]</p></div><div class="refsect1" title="DESCRIPTION"><a id="_description"></a><h2>DESCRIPTION</h2><p><span class="strong"><strong>Ansible</strong></span> is an extra-simple tool/framework/API for doing 'remote things' over
SSH.</p></div><div class="refsect1" title="ARGUMENTS"><a id="_arguments"></a><h2>ARGUMENTS</h2><div class="variablelist"><dl><dt><span class="term">
<span class="strong"><strong>host-pattern</strong></span>
</span></dt><dd>

@ -24,7 +24,7 @@
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="Ansible v0.0.1 documentation" href="index.html" />
<link rel="next" title="YAML Scripts" href="YAMLScripts.html" />
<link rel="prev" title="The Inventory File, Patterns, and Groups" href="patterns.html" />
<link rel="prev" title="Examples" href="examples.html" />
</head>
<body>
<div class="related">
@ -37,7 +37,7 @@
<a href="YAMLScripts.html" title="YAML Scripts"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="patterns.html" title="The Inventory File, Patterns, and Groups"
<a href="examples.html" title="Examples"
accesskey="P">previous</a> |</li>
<li><a href="index.html">Ansible v0.0.1 documentation</a> &raquo;</li>
</ul>
@ -63,12 +63,14 @@ ansible playbooks.</p>
<dd>Examples of using modules with the Python API</dd>
</dl>
</div>
<div class="section" id="module-idempotence">
<h2>Module Idempotence<a class="headerlink" href="#module-idempotence" title="Permalink to this headline"></a></h2>
<p>Nearly all modules take key=value parameters. Some modules take no parameters, and the command
module just takes arguments for the command you want to run.</p>
<p>All modules return JSON format data, thoug if you are using the command line or playbooks, you
don&#8217;t really need to know much about that.</p>
<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
trigger change events. Unless otherwise noted, all modules support change hooks.</p>
</div>
<p>Stock modules:</p>
<div class="section" id="command">
<h2>command<a class="headerlink" href="#command" title="Permalink to this headline"></a></h2>
<p>The command module takes the command name followed by a list of arguments, space delimited.
@ -76,15 +78,16 @@ This is the only module that does not use key=value style parameters.</p>
<p>Example usage:</p>
<div class="highlight-python"><pre>/sbin/shutdown -t now</pre>
</div>
<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>
</div>
<div class="section" id="copy">
<h2>copy<a class="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><em>src</em>:</p>
<p>Local absolute path to a file to copy to the remote server</p>
<p>Local path to a file to copy to the remote server. This can be an absolute or relative path.</p>
<p><em>dest</em>:</p>
<p>Remote absolute path where the file should end up</p>
<p>Remote absolute path where the file should end up.</p>
<p>This module also returns md5sum information about the resultant file.</p>
</div>
<div class="section" id="facter">
@ -93,11 +96,12 @@ This is the only module that does not use key=value style parameters.</p>
JSON data that can be useful for inventory purposes.</p>
<p>Requires that &#8216;facter&#8217; and &#8216;ruby-json&#8217; be installed on the remote end.</p>
<p>This module is informative only - it takes no parameters &amp; does not support change hooks,
nor does it make any changes on the system.</p>
nor does it make any changes on the system. Playbooks do not actually use
this module, they use the &#8216;setup&#8217; module behind the scenes.</p>
</div>
<div class="section" id="git">
<h2>git<a class="headerlink" href="#git" title="Permalink to this headline"></a></h2>
<p>Deploys software from git checkouts.</p>
<p>Deploys software (or files) from git checkouts.</p>
<p><em>repo</em>:</p>
<p>git or http protocol address of the repo to checkout</p>
<p><em>dest</em>:</p>
@ -112,13 +116,14 @@ data is a bit more verbose and nested than facter.</p>
<p>Requires that &#8216;ohai&#8217; be installed on the remote end.</p>
<p>This module is information only - it takes no parameters &amp; does not
support change hooks, nor does it make any changes on the system.</p>
<p>Playbooks should not call the ohai module, playbooks call the &#8216;setup&#8217;
module behind the scenes instead.</p>
</div>
<div class="section" id="ping">
<h2>ping<a class="headerlink" href="#ping" title="Permalink to this headline"></a></h2>
<p>A trivial test module, this module always returns the integer &#8216;1&#8217; on
successful contact.</p>
<p>This module does not support change hooks.</p>
<p>This module is informative only - it takes no parameters &amp; does not
<p>This module does not support change hooks and is informative only - it takes no parameters &amp; does not
support change hooks, nor does it make any changes on the system.</p>
</div>
<div class="section" id="service">
@ -135,14 +140,13 @@ are idempotent actions that will not run commands unless neccessary.
<h2>setup<a class="headerlink" href="#setup" title="Permalink to this headline"></a></h2>
<p>Writes a JSON file containing key/value data, for use in templating.
Call this once before using the template modules. Playbooks will
execute this module automatically as the first step in each play.</p>
execute this module automatically as the first step in each play using
the variables section, so it is unneccessary to make explicit calls to
setup within a playbook.</p>
<p>If facter or ohai are installed, variables from these programs will also
be snapshotted into the JSON file for usage in templating. These variables
are prefixed with &#8216;<a class="reference internal" href="#facter">facter</a>&#8216; and &#8216;<a class="reference internal" href="#ohai">ohai</a>&#8221; so it&#8217;s easy to tell their source.</p>
<p><em>metadata</em></p>
<p>Optionally overrides the default JSON file location of /etc/ansible/setup or ~/ansible/setup
depending on what remote user has been specified.</p>
<p>If used, also supply the metadata parameter to the template module.</p>
are prefixed with &#8216;<a class="reference internal" href="#facter">facter</a>&#8216; and &#8216;<a class="reference internal" href="#ohai">ohai</a>&#8221; so it&#8217;s easy to tell their source.
All variables are then bubbled up to the caller.</p>
<p><em>anything</em></p>
<p>any other parameters can be named basically anything, and set a key=value
pair in the JSON file for use in templating.</p>
@ -151,32 +155,39 @@ pair in the JSON file for use in templating.</p>
<h2>template<a class="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><em>src</em></p>
<p>path of a Jinja2 formatted template on the local server</p>
<p>path of a Jinja2 formatted template on the local server. This can be a relative
or absolute path.</p>
<p><em>dest</em></p>
<p>location to render the template on the remote server</p>
<p><em>metadata</em></p>
<p>location of a JSON file to use to supply template data. Default is /etc/ansible/setup
which is the same as the default for the setup module. Change if running as a non-root
remote user who does not have permissions on /etc/ansible.</p>
<p>This module also returns md5sum information about the resultant file.</p>
</div>
<div class="section" id="user">
<h2>user<a class="headerlink" href="#user" title="Permalink to this headline"></a></h2>
<p>This module is in plan.</p>
</div>
<div class="section" id="yum">
<h2>yum<a class="headerlink" href="#yum" title="Permalink to this headline"></a></h2>
<p>This module is in plan.</p>
</div>
<div class="section" id="writing-your-own-modules">
<h2>writing your own modules<a class="headerlink" href="#writing-your-own-modules" title="Permalink to this headline"></a></h2>
<h2>Writing your own modules<a class="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
/usr/share/ansible. Modules must return JSON but can be written in any language.
Modules should return hashes, but hashes can be nested.
To support change hooks, modules should return hashes with a changed: True/False
element at the top level. Modules can also choose to indicate a failure scenario
by returning a top level &#8216;failure&#8217; element with a True value, and a &#8216;msg&#8217; element
describing the nature of the failure. Other values are up to the module.</p>
Modules should return hashes, but hashes can be nested.</p>
<p>To support change hooks, modules should return hashes with a changed: True/False
element at the top level:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="p">{</span>
<span class="s">&#39;changed&#39;</span> <span class="p">:</span> <span class="bp">True</span><span class="p">,</span>
<span class="s">&#39;something&#39;</span> <span class="p">:</span> <span class="mi">42</span>
<span class="p">}</span>
</pre></div>
</div>
<p>Modules can also choose to indicate a failure scenario by returning a top level &#8216;failure&#8217;
element with a True value, and a &#8216;msg&#8217; element describing the nature of the failure.
Other return values are up to the module.</p>
<blockquote>
<div><dl class="docutils">
<dt>{</dt>
<dd>&#8216;failure&#8217; : True,
&#8216;msg&#8217; : &#8220;here is what happened...&#8221;</dd>
</dl>
<p>}</p>
</div></blockquote>
<p>When shipping modules, drop them in /usr/share/ansible, or specify the module path to the
command line tool or API. It is easy to test modules by running them directly on
the command line, passing them arguments just like they would be passed with ansible.</p>
</div>
</div>
@ -189,7 +200,6 @@ describing the nature of the failure. Other values are up to the module.</p>
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Ansible Modules</a><ul>
<li><a class="reference internal" href="#module-idempotence">Module Idempotence</a></li>
<li><a class="reference internal" href="#command">command</a></li>
<li><a class="reference internal" href="#copy">copy</a></li>
<li><a class="reference internal" href="#facter">facter</a></li>
@ -199,16 +209,14 @@ describing the nature of the failure. Other values are up to the module.</p>
<li><a class="reference internal" href="#service">service</a></li>
<li><a class="reference internal" href="#setup">setup</a></li>
<li><a class="reference internal" href="#template">template</a></li>
<li><a class="reference internal" href="#user">user</a></li>
<li><a class="reference internal" href="#yum">yum</a></li>
<li><a class="reference internal" href="#writing-your-own-modules">writing your own modules</a></li>
<li><a class="reference internal" href="#writing-your-own-modules">Writing your own modules</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="patterns.html"
title="previous chapter">The Inventory File, Patterns, and Groups</a></p>
<p class="topless"><a href="examples.html"
title="previous chapter">Examples</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="YAMLScripts.html"
title="next chapter">YAML Scripts</a></p>
@ -244,7 +252,7 @@ describing the nature of the failure. Other values are up to the module.</p>
<a href="YAMLScripts.html" title="YAML Scripts"
>next</a> |</li>
<li class="right" >
<a href="patterns.html" title="The Inventory File, Patterns, and Groups"
<a href="examples.html" title="Examples"
>previous</a> |</li>
<li><a href="index.html">Ansible v0.0.1 documentation</a> &raquo;</li>
</ul>

@ -23,7 +23,7 @@
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="Ansible v0.0.1 documentation" href="index.html" />
<link rel="next" title="Ansible Modules" href="modules.html" />
<link rel="next" title="Examples" href="examples.html" />
<link rel="prev" title="Getting Started" href="gettingstarted.html" />
</head>
<body>
@ -34,7 +34,7 @@
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="modules.html" title="Ansible Modules"
<a href="examples.html" title="Examples"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="gettingstarted.html" title="Getting Started"
@ -123,8 +123,8 @@ webservers:dbservers</pre>
<p class="topless"><a href="gettingstarted.html"
title="previous chapter">Getting Started</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="modules.html"
title="next chapter">Ansible Modules</a></p>
<p class="topless"><a href="examples.html"
title="next chapter">Examples</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/patterns.txt"
@ -154,7 +154,7 @@ webservers:dbservers</pre>
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="modules.html" title="Ansible Modules"
<a href="examples.html" title="Examples"
>next</a> |</li>
<li class="right" >
<a href="gettingstarted.html" title="Getting Started"

@ -23,7 +23,7 @@
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="Ansible v0.0.1 documentation" href="index.html" />
<link rel="next" title="Examples" href="examples.html" />
<link rel="next" title="API" href="api.html" />
<link rel="prev" title="YAML Scripts" href="YAMLScripts.html" />
</head>
<body>
@ -34,7 +34,7 @@
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="examples.html" title="Examples"
<a href="api.html" title="API"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="YAMLScripts.html" title="YAML Scripts"
@ -61,7 +61,9 @@
<dd>Learn about how to select hosts</dd>
</dl>
</div>
<p>Playbooks are a completely different way to use ansible and are particularly awesome. They are the basis for a really simple configuration management and deployment system, unlike any that already exist, and one that is very well suited to deploying complex multi-machine applications. While you might run the main ansible program for ad-hoc tasks, playbooks are more likely to be kept in source control and used to push out your configuration or assure the configurations of your remote systems are in spec.</p>
<p>Playbooks are a completely different way to use ansible and are particularly awesome.</p>
<p>They are the basis for a really simple configuration management and multi-machine deployment system, unlike any that already exist, and one that is very well suited to deploying complex applications.</p>
<p>While you might run the main /usr/bin/ansible program for ad-hoc tasks, playbooks are more likely to be kept in source control and used to push out your configuration or assure the configurations of your remote systems are in spec.</p>
<div class="section" id="playbook-example">
<h2>Playbook Example<a class="headerlink" href="#playbook-example" title="Permalink to this headline"></a></h2>
<p>Playbooks are expressed in YAML format and have a minimum of syntax. Each playbook is composed
@ -89,30 +91,39 @@ back on the webservers group, etc:</p>
</div>
<div class="section" id="hosts-line">
<h2>Hosts line<a class="headerlink" href="#hosts-line" title="Permalink to this headline"></a></h2>
<p>The hosts line is alist of one or more groups or host patterns, seperated by colons, as
described in the &#8216;patterns&#8217; documentation.</p>
<p>The hosts line is a list of one or more groups or host patterns, seperated by colons, as
described in the &#8216;patterns&#8217; documentation. This is just like the first parameter to /usr/bin/ansible.</p>
</div>
<div class="section" id="vars-section">
<h2>Vars section<a class="headerlink" href="#vars-section" title="Permalink to this headline"></a></h2>
<p>A list of variables that can be used in the templates, action lines, or included files.
Variables are deferenced using <tt class="docutils literal"><span class="pre">jinja2</span></tt> syntax like this:</p>
<div class="highlight-python"><pre>{{ varname }}</pre>
</div>
<p>These variables will be pushed down to the managed systems for use in templating operations, where
the way to dereference them in templates is exactly the same.</p>
<p>A list of variables and values that can be used in the plays. These can be used in templates
or &#8216;action&#8217; lines and are dereferenced using <tt class="docutils literal"><span class="pre">`jinja2`</span></tt> syntax like this:</p>
<blockquote>
<div>{{ varname }}</div></blockquote>
<p>Further, if there are discovered variables about the system (say, if facter or ohai were
installed) these variables bubble up back into the playbook, and can be used on each
system just like explicitly set variables. Facter variables are prefixed with &#8216;<a href="#id1"><span class="problematic" id="id2">facter_</span></a>&#8216;
and Ohai variables are prefixed with &#8216;<a href="#id3"><span class="problematic" id="id4">ohai_</span></a>&#8216;.</p>
and Ohai variables are prefixed with &#8216;<a href="#id3"><span class="problematic" id="id4">ohai_</span></a>&#8216;. So for instance, if I wanted to write the
hostname into the /etc/motd file, I could say:</p>
<blockquote>
<div><ul class="simple">
<li>name: write the motd</li>
<li>action: template src=/srv/templates/motd.j2 dest=/etc/motd</li>
</ul>
</div></blockquote>
<p>And in /srv/templates/motd.j2::</p>
<div class="highlight-python"><pre>You are logged into {{ facter_hostname }}</pre>
</div>
<p>But we&#8217;re getting ahead of ourselves. Let&#8217;s talk about tasks.</p>
</div>
<div class="section" id="tasks-list">
<h2>Tasks list<a class="headerlink" href="#tasks-list" title="Permalink to this headline"></a></h2>
<p>Each play contains a list of tasks. Tasks are executed in order, one at a time, against
all machines matched by the play&#8217;s host pattern, before moving on to the next task.
Hosts with failed tasks are taken out of the rotation for the entire playbook. If things fail,
correct the problem and rerun. Modules other than command are idempotent, meaning if you
run them again, they will make the changes they are told to make to bring the system to
the desired state.</p>
all machines matched by the play&#8217;s host pattern, before moving on to the next task.</p>
<p>Hosts with failed tasks are taken out of the rotation for the entire playbook. If things fail,
simply correct the playbook file and rerun.</p>
<p>Modules other than command are idempotent, meaning if you run them again, they will make the
changes they are told to make to bring the system to the desired state.</p>
</div>
<div class="section" id="task-name-and-action">
<h2>Task name and action<a class="headerlink" href="#task-name-and-action" title="Permalink to this headline"></a></h2>
@ -120,25 +131,58 @@ the desired state.</p>
<p>The action line is the name of an ansible module followed by parameters. Usually these
are expressed in key=value form, except for the command module, which looks just like a Linux/Unix
command line. See the module documentation for more info.</p>
<p>Variables, as mentioned above, can be used in action lines. So if, hypothetically, you wanted
to make a directory on each system named after the hostname ... yeah, that&#8217;s I know silly ... you could
do it like so:</p>
<blockquote>
<div><ul class="simple">
<li>name: make a directory</li>
<li>action: mkdir /tmp/{{ facter_hostname }}</li>
</ul>
</div></blockquote>
</div>
<div class="section" id="notify-statements">
<h2>Notify statements<a class="headerlink" href="#notify-statements" title="Permalink to this headline"></a></h2>
<p>Nearly all modules are written to be &#8216;idempotent&#8217; and can signal when they have affected a change
on the remote system. If a notify statement is used, the named handler will be run against
each system where a change was effected, but NOT on systems where no change occurred.</p>
each system where a change was effected, but NOT on systems where no change occurred. This happens
after all of the tasks are run. For example, if notifying Apache and potentially replacing lots of
configuration files, you could have Apache restart just once, at the end of a run. If you need
Apache restarted in the middle of a run, you could just make a task for it, no harm done. Notifiers
are optional.</p>
</div>
<div class="section" id="handlers">
<h2>Handlers<a class="headerlink" href="#handlers" title="Permalink to this headline"></a></h2>
<p>Handlers are lists of tasks, not really any different from regular tasks, that are referenced
by name.</p>
by name. Handlers are what notifiers notify. If nothing notifies a handler, it will not run.
Regardless of how many things notify a handler, it will run only once, after all of the tasks
complete in a particular play.</p>
</div>
<div class="section" id="includes">
<h2>Includes<a class="headerlink" href="#includes" title="Permalink to this headline"></a></h2>
<p>Not all tasks have to be listed directly in the main file. An include file can contain
a list of tasks (in YAML) as well, optionally passing extra variables into the file.
Variables passed in can be deferenced like this:</p>
Variables passed in can be deferenced like this (assume a variable named &#8216;user&#8217;)</p>
<blockquote>
<div>{{ user }}</div></blockquote>
<p>For instance, if deploying multiple wordpress instances, I could contain all of my tasks
in a wordpress.yml file, and use it like so:</p>
<blockquote>
<div>{{ variable }}</div></blockquote>
<div><ul>
<li><dl class="first docutils">
<dt>tasks:</dt>
<dd><ul class="first last simple">
<li>include: wordpress.yml user=timmy</li>
<li>include: wordpress.yml user=alice</li>
<li>include: wordpress.yml user=bob</li>
</ul>
</dd>
</dl>
</li>
</ul>
</div></blockquote>
<p>In addition to the explicitly passed in parameters, all variables from the vars section
are also available.</p>
</div>
<div class="section" id="asynchronous-actions-and-polling">
<h2>Asynchronous Actions and Polling<a class="headerlink" href="#asynchronous-actions-and-polling" title="Permalink to this headline"></a></h2>
@ -179,8 +223,8 @@ Variables passed in can be deferenced like this:</p>
<p class="topless"><a href="YAMLScripts.html"
title="previous chapter">YAML Scripts</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="examples.html"
title="next chapter">Examples</a></p>
<p class="topless"><a href="api.html"
title="next chapter">API</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/playbooks.txt"
@ -210,7 +254,7 @@ Variables passed in can be deferenced like this:</p>
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="examples.html" title="Examples"
<a href="api.html" title="API"
>next</a> |</li>
<li class="right" >
<a href="YAMLScripts.html" title="YAML Scripts"

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save