Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
A list of available modules
placerat nibh, non feugiat risus varius vitae. Donec eu libero
:doc:`playbooks`
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
Alternative ways to use ansible
magna porta venenatis. Quisque scelerisque, sem non ultrices bibendum,
dolor diam rutrum lectus, sed luctus neque neque vitae eros. Vivamus
mattis, ipsum ut bibendum gravida, lectus arcu venenatis elit, vitae
Parallelism and Shell Commands
luctus diam leo sit amet ligula. Nunc egestas justo in nulla sagittis
``````````````````````````````
ut suscipit sapien gravida. Morbi id dui nibh. Nullam diam massa,
rhoncus a dignissim non, adipiscing vel arcu. Quisque ultricies
Reboot all web servers in Atlanta, 10 at a time::
tincidunt purus ut sodales. Quisque scelerisque dapibus purus quis
egestas. Maecenas sagittis porttitor adipiscing. Duis eu magna
ssh-agent bash
sem. Donec arcu felis, faucibus et malesuada non, blandit vitae
ssh-add ~/.ssh/id_rsa.pub
metus. Fusce nec sapien dolor.
ansible atlanta -a "/sbin/reboot" -f 10
Examples 2
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.
Aenean ac fermentum nisl. Integer leo sem, rutrum nec dictum at,
pretium quis sapien. Duis felis metus, sodales sit amet gravida in,
pretium ut arcu. Nulla ligula quam, aliquam sit amet sollicitudin
Example 2: Time Limited Background Operations
eget, molestie tincidunt ipsum. Nulla leo nunc, mattis sed auctor at,
`````````````````````````````````````````````
suscipit ut metus. Suspendisse hendrerit, justo sagittis malesuada
molestie, nisi nunc placerat libero, vel vulputate elit tellus et
augue. Phasellus tempor lectus ac nisi aliquam faucibus. Donec feugiat
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.::
egestas nibh id mattis. In hac habitasse platea dictumst. Ut accumsan
lorem eget leo dictum viverra.
ansible all -B 3600 -a "/usr/bin/long_running_operation --do-stuff"
ansible all -n job_status -a jid=123456789
Examples 3
``````````
Any module other than 'copy' or 'template' can be backgrounded.
Quisque egestas lorem sit amet felis tincidunt adipiscing. Aenean
ornare fermentum accumsan. Aenean eu mauris arcu, id pulvinar
Examples 3: File Transfer & Templating
quam. Suspendisse nec massa vel augue laoreet ultricies in convallis
``````````````````````````````````````
dolor. Mauris sodales porta enim, non ultricies dolor luctus
in. Phasellus eu tortor lectus, vel porttitor nulla. Mauris vulputate,
Ansible can SCP lots of files to multiple machines in parallel, and optionally use them as template sources.
erat id scelerisque lobortis, nibh ipsum tristique elit, ac viverra
arcu sem a ante. Praesent nec metus vestibulum augue eleifend
To just transfer a file directly to many different servers::
suscipit. In feugiat, sem nec dignissim consequat, velit tortor
scelerisque metus, sit amet mollis nisl sem eu nibh. Quisque in nibh
ansible atlanta copy -a "/etc/hosts /tmp/hosts"
turpis. Proin ac nisi ligula, a pretium augue.
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.::
Examples 3
``````````
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"
In nibh eros, laoreet id interdum vel, sodales sed tortor. Sed
ansible webservers -m template -a "src=/srv/ntp.j2 dest=/etc/ntp.conf"
ullamcorper, sem vel mattis consectetur, nibh turpis molestie nisl,
eget lobortis mi magna sed metus. Cras justo est, tempus quis
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.
adipiscing ut, hendrerit convallis sem. Mauris ullamcorper, sapien et
luctus iaculis, urna elit egestas ipsum, et tristique enim risus vitae
Examples 3: Deploying From Source Control
nunc. Vivamus aliquet lorem eu urna pulvinar hendrerit malesuada nunc
`````````````````````````````````````````
sollicitudin. Cras in mi rhoncus quam egestas dignissim vel sit amet
lacus. Maecenas interdum viverra laoreet. Quisque elementum
Deploy your webapp straight from git::
sollicitudin ullamcorper.
ansible webservers -m git -a "repo=git://foo dest=/srv/myapp version=HEAD"
Examples 4
``````````
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.
Pellentesque mauris sem, malesuada at lobortis in, porta eget
urna. Duis aliquet quam eget risus elementum quis auctor ligula
gravida. Phasellus et ullamcorper libero. Nam elementum ultricies
tellus, in sagittis magna aliquet quis. Ut sit amet tellus id erat
tristique lobortis. Suspendisse est enim, tristique eu convallis id,
rutrum nec lacus. Fusce iaculis diam non felis rutrum lobortis. Proin
Ansible is a extra-simple tool/API for doing 'parallel remote things'
Ansible is a radically simple deployment, configuration, and command execution framework.
over SSH -- whether executing commands, running "modules", or
Other tools in this space have been too complicated for too long, require too much bootstrapping,
executing larger 'playbooks' that can serve as a configuration
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.
management or deployment system.
While `Func installation <http://fedorahosted.org/func>`_ which I
Ansible isn't just for configuration -- it's also great for Ad-Hoc tasks,
co-wrote, aspired to avoid using SSH and have it's own daemon
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.
infrastructure, Ansible aspires to be quite different and more
minimal, but still able to grow more modularly over time. This is
based on talking to a lot of users of various tools and wishing to
eliminate problems with connectivity and long running daemons, or not
picking tool `X` because they preferred to code in `Y`. Further,
playbooks take things a whole step further, building the config and
deployment system I always wanted to build.
Why use Ansible versus something else? (Fabric, Capistrano,
Ansible does not require programming in any particular language -- you can write modules
as scripts or programs that return simple JSON.
Why use Ansible versus something else? (Puppet, Chef, Fabric, Capistrano,
mCollective, Func, SaltStack, etc?) It will have far less code, it
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
will be 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.
use you'll ever see -- regardless of your favorite language of choice.
Want to only code plugins in bash or clojure? Ansible doesn't care.
Systems management doesn't have to be complicated. Ansible's docs will remain
The docs will fit on one page and the source will be blindingly
short & simple, and the source will be blindingly obvious.
obvious.
Design Principles
Design Goals
`````````````````
````````````
* Dead simple setup
* Dead simple setup
* Super fast & parallel by default
* Super fast & parallel by default
* No server or client daemons; use existing SSHd
* No server or client daemons; use existing SSHd out of the box
* No additional software required on client boxes
* No additional software required on client boxes
* Modules can be written in ANY language
* Modules can be written in ANY language
* Awesome API for creating very powerful distributed scripts
* Awesome API for creating very powerful distributed scripts
* Be usable as non-root
* Be usable as non-root
* Create the easiest config management system to use, ever.
* Create the easiest config management system to use, ever.
About the Author
````````````````
Requirements
Michael DeHaan is a Raleigh, NC based software developer and architect. He created other
````````````
DevOps programs such as Cobbler, the popular Linux install server.
Cobbler is used to deploy mission critical systems all over the planet, in industries
Requirements are extremely minimal.
ranging from massively multiplayer gaming, core internet infrastructure, finance,
chip design, and more. Michael also helped co-author of Func, which is used
If you are running python 2.6 on the **overlord** machine, you will
to orchestrate systems in lots of diverse places.
need:
* ``paramiko``
* ``PyYAML``
* ``python-jinja2`` (for playbooks)
* ``Asciidoc`` (for building documentation)
If you are running less than Python 2.6, you will also need:
* The Python 2.4 or 2.5 backport of the ``multiprocessing`` module
- `Installation and Testing Instructions <http://code.google.com/p/python-multiprocessing/wiki/Install>`_
* ``simplejson``
On the managed nodes, to use templating, you will need:
* ``python-jinja2`` (you can install this with ansible)
Getting Ansible
```````````````
Tagged releases are available as tar.gz files from the Ansible github
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
.. seealso::
placerat nibh, non feugiat risus varius vitae. Donec eu libero
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
:doc:`examples`
magna porta venenatis. Quisque scelerisque, sem non ultrices bibendum,
Examples of using modules in /usr/bin/ansible
dolor diam rutrum lectus, sed luctus neque neque vitae eros. Vivamus
:doc:`playbooks`
mattis, ipsum ut bibendum gravida, lectus arcu venenatis elit, vitae
Examples of using modules with /usr/bin/ansible-playbook
luctus diam leo sit amet ligula. Nunc egestas justo in nulla sagittis
:doc:`api`
ut suscipit sapien gravida. Morbi id dui nibh. Nullam diam massa,
Examples of using modules with the Python API
rhoncus a dignissim non, adipiscing vel arcu. Quisque ultricies
tincidunt purus ut sodales. Quisque scelerisque dapibus purus quis
egestas. Maecenas sagittis porttitor adipiscing. Duis eu magna
About Modules
sem. Donec arcu felis, faucibus et malesuada non, blandit vitae
`````````````
metus. Fusce nec sapien dolor.
Ansible ships with a number of modules that can be executed directly on remote hosts or through
Aenean ac fermentum nisl. Integer leo sem, rutrum nec dictum at,
ansible playbooks.
pretium quis sapien. Duis felis metus, sodales sit amet gravida in,
pretium ut arcu. Nulla ligula quam, aliquam sit amet sollicitudin
eget, molestie tincidunt ipsum. Nulla leo nunc, mattis sed auctor at,
Idempotence
suscipit ut metus. Suspendisse hendrerit, justo sagittis malesuada
```````````
molestie, nisi nunc placerat libero, vel vulputate elit tellus et
augue. Phasellus tempor lectus ac nisi aliquam faucibus. Donec feugiat
Most modules other than command are idempotent, meaning they will seek to avoid changes
egestas nibh id mattis. In hac habitasse platea dictumst. Ut accumsan
unless a change needs to be made. When using ansible playbooks, these modules can
lorem eget leo dictum viverra.
trigger change events. Unless otherwise noted, all modules support change hooks.
Quisque egestas lorem sit amet felis tincidunt adipiscing. Aenean
ornare fermentum accumsan. Aenean eu mauris arcu, id pulvinar
command
quam. Suspendisse nec massa vel augue laoreet ultricies in convallis
```````
dolor. Mauris sodales porta enim, non ultricies dolor luctus
in. Phasellus eu tortor lectus, vel porttitor nulla. Mauris vulputate,
The command module takes the command name followed by a list of arguments, space delimited.
erat id scelerisque lobortis, nibh ipsum tristique elit, ac viverra
This is the only module that does not use key=value style parameters.
arcu sem a ante. Praesent nec metus vestibulum augue eleifend
suscipit. In feugiat, sem nec dignissim consequat, velit tortor
Example usage::
scelerisque metus, sit amet mollis nisl sem eu nibh. Quisque in nibh
turpis. Proin ac nisi ligula, a pretium augue.
/sbin/shutdown -t now
In nibh eros, laoreet id interdum vel, sodales sed tortor. Sed
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.
ullamcorper, sem vel mattis consectetur, nibh turpis molestie nisl,
eget lobortis mi magna sed metus. Cras justo est, tempus quis
adipiscing ut, hendrerit convallis sem. Mauris ullamcorper, sapien et
copy
luctus iaculis, urna elit egestas ipsum, et tristique enim risus vitae
````
nunc. Vivamus aliquet lorem eu urna pulvinar hendrerit malesuada nunc
sollicitudin. Cras in mi rhoncus quam egestas dignissim vel sit amet
The copy module moves a file on the local box to remote locations.
lacus. Maecenas interdum viverra laoreet. Quisque elementum
sollicitudin ullamcorper.
*src*::
Pellentesque mauris sem, malesuada at lobortis in, porta eget
Local absolute path to a file to copy to the remote server
urna. Duis aliquet quam eget risus elementum quis auctor ligula
gravida. Phasellus et ullamcorper libero. Nam elementum ultricies
tellus, in sagittis magna aliquet quis. Ut sit amet tellus id erat
*dest*::
tristique lobortis. Suspendisse est enim, tristique eu convallis id,
rutrum nec lacus. Fusce iaculis diam non felis rutrum lobortis. Proin
Remote absolute path where the file should end up
hendrerit mi tincidunt dui fermentum placerat.
This module also returns md5sum information about the resultant file.
facter
``````
Runs the discovery program 'facter' on the remote system, returning
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.
git
```
Deploys software from git checkouts.
*repo*::
git or http protocol address of the repo to checkout
*dest*::
where to check it out, an absolute directory path
*version*::
what version to check out -- either the git SHA, the literal string 'HEAD', or a tag name
ohai
````
Similar to the facter module, this returns JSON inventory data. Ohai
data is a bit more verbose and nested than facter.
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.
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
support change hooks, nor does it make any changes on the system.
service
```````
Controls services on remote machines.
*state*
Values are 'started', 'stopped', or 'restarted'. Started/stopped
are idempotent actions that will not run commands unless neccessary.
'restarted' will always bounce the service
*name*
The name of the service
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.
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.
*anything*
any other parameters can be named basically anything, and set a key=value
pair in the JSON file for use in templating.
template
````````
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
*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
````
This module is in plan.
yum
```
This module is in plan.
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.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
.. seealso::
placerat nibh, non feugiat risus varius vitae. Donec eu libero
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
:doc:`YAMLScripts`
magna porta venenatis. Quisque scelerisque, sem non ultrices bibendum,
Learn about YAML syntax
dolor diam rutrum lectus, sed luctus neque neque vitae eros. Vivamus
:doc:`modules`
mattis, ipsum ut bibendum gravida, lectus arcu venenatis elit, vitae
Learn about available modules and writing your own
luctus diam leo sit amet ligula. Nunc egestas justo in nulla sagittis
:doc:`patterns`
ut suscipit sapien gravida. Morbi id dui nibh. Nullam diam massa,
Learn about how to select hosts
rhoncus a dignissim non, adipiscing vel arcu. Quisque ultricies
tincidunt purus ut sodales. Quisque scelerisque dapibus purus quis
egestas. Maecenas sagittis porttitor adipiscing. Duis eu magna
Playbooks are a completely different way to use ansible and are particularly awesome.
sem. Donec arcu felis, faucibus et malesuada non, blandit vitae
metus. Fusce nec sapien dolor.
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.
Aenean ac fermentum nisl. Integer leo sem, rutrum nec dictum at,
pretium quis sapien. Duis felis metus, sodales sit amet gravida in,
Playbook Example
pretium ut arcu. Nulla ligula quam, aliquam sit amet sollicitudin
````````````````
eget, molestie tincidunt ipsum. Nulla leo nunc, mattis sed auctor at,
suscipit ut metus. Suspendisse hendrerit, justo sagittis malesuada
Playbooks are expressed in YAML format and have a minimum of syntax. Each playbook is composed
molestie, nisi nunc placerat libero, vel vulputate elit tellus et
of one or more patterns in a list. By composing a playbook of multiple patterns, it is possible
augue. Phasellus tempor lectus ac nisi aliquam faucibus. Donec feugiat
to orchestrate multi-machine deployments, running certain steps on all machines in
egestas nibh id mattis. In hac habitasse platea dictumst. Ut accumsan
the webservers group, then certain steps on the database server group, then more commands
lorem eget leo dictum viverra.
back on the webservers group, etc::
Quisque egestas lorem sit amet felis tincidunt adipiscing. Aenean
---
ornare fermentum accumsan. Aenean eu mauris arcu, id pulvinar
- hosts: all
quam. Suspendisse nec massa vel augue laoreet ultricies in convallis
vars:
dolor. Mauris sodales porta enim, non ultricies dolor luctus
http_port: 80
in. Phasellus eu tortor lectus, vel porttitor nulla. Mauris vulputate,
max_clients: 200
erat id scelerisque lobortis, nibh ipsum tristique elit, ac viverra
user: root
arcu sem a ante. Praesent nec metus vestibulum augue eleifend
tasks:
suscipit. In feugiat, sem nec dignissim consequat, velit tortor
- include: base.yml somevar=3 othervar=4
scelerisque metus, sit amet mollis nisl sem eu nibh. Quisque in nibh
<h1>Communicate<aclass="headerlink"href="#communicate"title="Permalink to this headline">¶</a></h1>
<h1>Communicate and Get Involved<aclass="headerlink"href="#communicate-and-get-involved"title="Permalink to this headline">¶</a></h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
<ulclass="simple">
placerat nibh, non feugiat risus varius vitae. Donec eu libero
<li>Join the <aclass="reference external"href="http://groups.google.com/group/ansible-project">ansible-project mailing list</a> on Google Groups</li>
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
<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>
magna porta venenatis. Quisque scelerisque, sem non ultrices bibendum,
<li>Visit the <aclass="reference external"href="https://github.com/ansible/ansible">project page</a> on Github<ul>
dolor diam rutrum lectus, sed luctus neque neque vitae eros. Vivamus
<li>View the <aclass="reference external"href="https://github.com/ansible/ansible/issues">issue tracker</a></li>
mattis, ipsum ut bibendum gravida, lectus arcu venenatis elit, vitae
</ul>
luctus diam leo sit amet ligula. Nunc egestas justo in nulla sagittis
</li>
ut suscipit sapien gravida. Morbi id dui nibh. Nullam diam massa,
</ul>
rhoncus a dignissim non, adipiscing vel arcu. Quisque ultricies
tincidunt purus ut sodales. Quisque scelerisque dapibus purus quis
egestas. Maecenas sagittis porttitor adipiscing. Duis eu magna
sem. Donec arcu felis, faucibus et malesuada non, blandit vitae
metus. Fusce nec sapien dolor.</p>
<p>Aenean ac fermentum nisl. Integer leo sem, rutrum nec dictum at,
pretium quis sapien. Duis felis metus, sodales sit amet gravida in,
pretium ut arcu. Nulla ligula quam, aliquam sit amet sollicitudin
eget, molestie tincidunt ipsum. Nulla leo nunc, mattis sed auctor at,
suscipit ut metus. Suspendisse hendrerit, justo sagittis malesuada
molestie, nisi nunc placerat libero, vel vulputate elit tellus et
augue. Phasellus tempor lectus ac nisi aliquam faucibus. Donec feugiat
egestas nibh id mattis. In hac habitasse platea dictumst. Ut accumsan
lorem eget leo dictum viverra.</p>
<p>Quisque egestas lorem sit amet felis tincidunt adipiscing. Aenean
ornare fermentum accumsan. Aenean eu mauris arcu, id pulvinar
quam. Suspendisse nec massa vel augue laoreet ultricies in convallis
dolor. Mauris sodales porta enim, non ultricies dolor luctus
in. Phasellus eu tortor lectus, vel porttitor nulla. Mauris vulputate,
erat id scelerisque lobortis, nibh ipsum tristique elit, ac viverra
arcu sem a ante. Praesent nec metus vestibulum augue eleifend
suscipit. In feugiat, sem nec dignissim consequat, velit tortor
scelerisque metus, sit amet mollis nisl sem eu nibh. Quisque in nibh
turpis. Proin ac nisi ligula, a pretium augue.</p>
<p>In nibh eros, laoreet id interdum vel, sodales sed tortor. Sed
ullamcorper, sem vel mattis consectetur, nibh turpis molestie nisl,
eget lobortis mi magna sed metus. Cras justo est, tempus quis
adipiscing ut, hendrerit convallis sem. Mauris ullamcorper, sapien et
luctus iaculis, urna elit egestas ipsum, et tristique enim risus vitae
nunc. Vivamus aliquet lorem eu urna pulvinar hendrerit malesuada nunc
sollicitudin. Cras in mi rhoncus quam egestas dignissim vel sit amet
lacus. Maecenas interdum viverra laoreet. Quisque elementum
sollicitudin ullamcorper.</p>
<p>Pellentesque mauris sem, malesuada at lobortis in, porta eget
urna. Duis aliquet quam eget risus elementum quis auctor ligula
gravida. Phasellus et ullamcorper libero. Nam elementum ultricies
tellus, in sagittis magna aliquet quis. Ut sit amet tellus id erat
tristique lobortis. Suspendisse est enim, tristique eu convallis id,
rutrum nec lacus. Fusce iaculis diam non felis rutrum lobortis. Proin
hendrerit mi tincidunt dui fermentum placerat.</p>
</div>
</div>
...
@@ -120,7 +80,7 @@ hendrerit mi tincidunt dui fermentum placerat.</p>
...
@@ -120,7 +80,7 @@ hendrerit mi tincidunt dui fermentum placerat.</p>
<h2>Examples 2<aclass="headerlink"href="#examples-2"title="Permalink to this headline">¶</a></h2>
<h2>Parallelism and Shell Commands<aclass="headerlink"href="#parallelism-and-shell-commands"title="Permalink to this headline">¶</a></h2>
<p>Aenean ac fermentum nisl. Integer leo sem, rutrum nec dictum at,
<p>Reboot all web servers in Atlanta, 10 at a time:</p>
pretium quis sapien. Duis felis metus, sodales sit amet gravida in,
<divclass="highlight-python"><pre>ssh-agent bash
pretium ut arcu. Nulla ligula quam, aliquam sit amet sollicitudin
ssh-add ~/.ssh/id_rsa.pub
eget, molestie tincidunt ipsum. Nulla leo nunc, mattis sed auctor at,
suscipit ut metus. Suspendisse hendrerit, justo sagittis malesuada
ansible atlanta -a "/sbin/reboot" -f 10</pre>
molestie, nisi nunc placerat libero, vel vulputate elit tellus et
</div>
augue. Phasellus tempor lectus ac nisi aliquam faucibus. Donec feugiat
<p>The -f 10 specifies the usage of 10 simultaneous processes.</p>
egestas nibh id mattis. In hac habitasse platea dictumst. Ut accumsan
<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>
<h2>Example 2: Time Limited Background Operations<aclass="headerlink"href="#example-2-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>
<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>
</div>
<p>Any module other than ‘copy’ or ‘template’ can be backgrounded.</p>
<h2>Examples 3: File Transfer & Templating<aclass="headerlink"href="#examples-3-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>
<divclass="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>
<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/ntp.j2 dest=/etc/ntp.conf"</pre>
</div>
</div>
<divclass="section"id="examples-3">
<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>Examples 3<aclass="headerlink"href="#examples-3"title="Permalink to this headline">¶</a></h2>
<p>Quisque egestas lorem sit amet felis tincidunt adipiscing. Aenean
ornare fermentum accumsan. Aenean eu mauris arcu, id pulvinar
quam. Suspendisse nec massa vel augue laoreet ultricies in convallis
dolor. Mauris sodales porta enim, non ultricies dolor luctus
in. Phasellus eu tortor lectus, vel porttitor nulla. Mauris vulputate,
erat id scelerisque lobortis, nibh ipsum tristique elit, ac viverra
arcu sem a ante. Praesent nec metus vestibulum augue eleifend
suscipit. In feugiat, sem nec dignissim consequat, velit tortor
scelerisque metus, sit amet mollis nisl sem eu nibh. Quisque in nibh
turpis. Proin ac nisi ligula, a pretium augue.</p>
<h2>Examples 3<aclass="headerlink"href="#id1"title="Permalink to this headline">¶</a></h2>
<h2>Examples 3: Deploying From Source Control<aclass="headerlink"href="#examples-3-deploying-from-source-control"title="Permalink to this headline">¶</a></h2>
<p>In nibh eros, laoreet id interdum vel, sodales sed tortor. Sed
<p>Deploy your webapp straight from git:</p>
ullamcorper, sem vel mattis consectetur, nibh turpis molestie nisl,
<divclass="highlight-python"><pre>ansible webservers -m git -a "repo=git://foo dest=/srv/myapp version=HEAD"</pre>
eget lobortis mi magna sed metus. Cras justo est, tempus quis
adipiscing ut, hendrerit convallis sem. Mauris ullamcorper, sapien et
luctus iaculis, urna elit egestas ipsum, et tristique enim risus vitae
nunc. Vivamus aliquet lorem eu urna pulvinar hendrerit malesuada nunc
sollicitudin. Cras in mi rhoncus quam egestas dignissim vel sit amet
lacus. Maecenas interdum viverra laoreet. Quisque elementum
sollicitudin ullamcorper.</p>
</div>
</div>
<divclass="section"id="examples-4">
<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>
<h2>Examples 4<aclass="headerlink"href="#examples-4"title="Permalink to this headline">¶</a></h2>
<p>Pellentesque mauris sem, malesuada at lobortis in, porta eget
urna. Duis aliquet quam eget risus elementum quis auctor ligula
gravida. Phasellus et ullamcorper libero. Nam elementum ultricies
tellus, in sagittis magna aliquet quis. Ut sit amet tellus id erat
tristique lobortis. Suspendisse est enim, tristique eu convallis id,
rutrum nec lacus. Fusce iaculis diam non felis rutrum lobortis. Proin
hendrerit mi tincidunt dui fermentum placerat.</p>
</div>
</div>
</div>
</div>
...
@@ -124,11 +109,10 @@ hendrerit mi tincidunt dui fermentum placerat.</p>
...
@@ -124,11 +109,10 @@ hendrerit mi tincidunt dui fermentum placerat.</p>
<h3><ahref="index.html">Table Of Contents</a></h3>
<h3><ahref="index.html">Table Of Contents</a></h3>
<h1>Ansible<aclass="headerlink"href="#ansible"title="Permalink to this headline">¶</a></h1>
<h1>Ansible<aclass="headerlink"href="#ansible"title="Permalink to this headline">¶</a></h1>
<p>Ansible is a extra-simple tool/API for doing ‘parallel remote things’
<p>Ansible is a radically simple deployment, configuration, and command execution framework.
over SSH – whether executing commands, running “modules”, or
Other tools in this space have been too complicated for too long, require too much bootstrapping,
executing larger ‘playbooks’ that can serve as a configuration
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>
management or deployment system.</p>
<p>Ansible isn’t just for configuration – it’s also great for Ad-Hoc tasks,
<p>While <aclass="reference external"href="http://fedorahosted.org/func">Func installation</a> which I
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.</p>
co-wrote, aspired to avoid using SSH and have it’s own daemon
<p>Ansible does not require programming in any particular language – you can write modules
infrastructure, Ansible aspires to be quite different and more
as scripts or programs that return simple JSON.</p>
minimal, but still able to grow more modularly over time. This is
<p>Why use Ansible versus something else? (Puppet, Chef, Fabric, Capistrano,
based on talking to a lot of users of various tools and wishing to
eliminate problems with connectivity and long running daemons, or not
picking tool <cite>X</cite> because they preferred to code in <cite>Y</cite>. Further,
playbooks take things a whole step further, building the config and
deployment system I always wanted to build.</p>
<p>Why use Ansible versus something else? (Fabric, Capistrano,
mCollective, Func, SaltStack, etc?) It will have far less code, it
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
will be 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.
use you’ll ever see – regardless of your favorite language of choice.
Want to only code plugins in bash or clojure? Ansible doesn’t care.
Systems management doesn’t have to be complicated. Ansible’s docs will remain
The docs will fit on one page and the source will be blindingly
short & simple, and the source will be blindingly obvious.</p>
obvious.</p>
<divclass="section"id="design-goals">
<divclass="section"id="design-principles">
<h2>Design Goals<aclass="headerlink"href="#design-goals"title="Permalink to this headline">¶</a></h2>
<h2>Design Principles<aclass="headerlink"href="#design-principles"title="Permalink to this headline">¶</a></h2>
<ulclass="simple">
<ulclass="simple">
<li>Dead simple setup</li>
<li>Dead simple setup</li>
<li>Super fast & parallel by default</li>
<li>Super fast & parallel by default</li>
<li>No server or client daemons; use existing SSHd</li>
<li>No server or client daemons; use existing SSHd out of the box</li>
<li>No additional software required on client boxes</li>
<li>No additional software required on client boxes</li>
<li>Modules can be written in ANY language</li>
<li>Modules can be written in ANY language</li>
<li>Awesome API for creating very powerful distributed scripts</li>
<li>Awesome API for creating very powerful distributed scripts</li>
...
@@ -79,57 +72,16 @@ obvious.</p>
...
@@ -79,57 +72,16 @@ obvious.</p>
<li>Create the easiest config management system to use, ever.</li>
<li>Create the easiest config management system to use, ever.</li>
</ul>
</ul>
</div>
</div>
<divclass="section"id="requirements">
<divclass="section"id="about-the-author">
<h2>Requirements<aclass="headerlink"href="#requirements"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>Requirements are extremely minimal.</p>
<p>Michael DeHaan is a Raleigh, NC based software developer and architect. He created other
<p>If you are running python 2.6 on the <strong>overlord</strong> machine, you will
DevOps programs such as Cobbler, the popular Linux install server.
need:</p>
Cobbler is used to deploy mission critical systems all over the planet, in industries
<ulclass="simple">
ranging from massively multiplayer gaming, core internet infrastructure, finance,
<liclass="toctree-l2"><aclass="reference internal"href="examples.html#examples-3-file-transfer-templating">Examples 3: File Transfer & Templating</a></li>
<h1>Communicate or Get Involved<aclass="headerlink"href="#communicate-or-get-involved"title="Permalink to this headline">¶</a></h1>
<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 <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>Visit the <aclass="reference external"href="https://github.com/ansible/ansible">project page</a> on Github<ul>
<li>View the <aclass="reference external"href="https://github.com/ansible/ansible/issues">issue tracker</a></li>
<!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="id327073"></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="id326412"></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="id458930"></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="id532031"></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="id355813"></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="id320915"></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
arcu sem a ante. Praesent nec metus vestibulum augue eleifend
</div>
suscipit. In feugiat, sem nec dignissim consequat, velit tortor
<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>
scelerisque metus, sit amet mollis nisl sem eu nibh. Quisque in nibh
</div>
turpis. Proin ac nisi ligula, a pretium augue.</p>
<divclass="section"id="copy">
<p>In nibh eros, laoreet id interdum vel, sodales sed tortor. Sed
<h2>copy<aclass="headerlink"href="#copy"title="Permalink to this headline">¶</a></h2>
ullamcorper, sem vel mattis consectetur, nibh turpis molestie nisl,
<p>The copy module moves a file on the local box to remote locations.</p>
eget lobortis mi magna sed metus. Cras justo est, tempus quis
<p><em>src</em>:</p>
adipiscing ut, hendrerit convallis sem. Mauris ullamcorper, sapien et
<p>Local absolute path to a file to copy to the remote server</p>
luctus iaculis, urna elit egestas ipsum, et tristique enim risus vitae
<p><em>dest</em>:</p>
nunc. Vivamus aliquet lorem eu urna pulvinar hendrerit malesuada nunc
<p>Remote absolute path where the file should end up</p>
sollicitudin. Cras in mi rhoncus quam egestas dignissim vel sit amet
<p>This module also returns md5sum information about the resultant file.</p>
lacus. Maecenas interdum viverra laoreet. Quisque elementum
</div>
sollicitudin ullamcorper.</p>
<divclass="section"id="facter">
<p>Pellentesque mauris sem, malesuada at lobortis in, porta eget
<h2>facter<aclass="headerlink"href="#facter"title="Permalink to this headline">¶</a></h2>
urna. Duis aliquet quam eget risus elementum quis auctor ligula
<p>Runs the discovery program ‘facter’ on the remote system, returning
gravida. Phasellus et ullamcorper libero. Nam elementum ultricies
JSON data that can be useful for inventory purposes.</p>
tellus, in sagittis magna aliquet quis. Ut sit amet tellus id erat
<p>Requires that ‘facter’ and ‘ruby-json’ be installed on the remote end.</p>
tristique lobortis. Suspendisse est enim, tristique eu convallis id,
<p>This module is informative only - it takes no parameters & does not support change hooks,
rutrum nec lacus. Fusce iaculis diam non felis rutrum lobortis. Proin
nor does it make any changes on the system.</p>
hendrerit mi tincidunt dui fermentum placerat.</p>
</div>
<divclass="section"id="git">
<h2>git<aclass="headerlink"href="#git"title="Permalink to this headline">¶</a></h2>
<p>Deploys software 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>
<p>where to check it out, an absolute directory path</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>
</div>
<divclass="section"id="ohai">
<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
data is a bit more verbose and nested than facter.</p>
<p>Requires that ‘ohai’ be installed on the remote end.</p>
<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>
</div>
<divclass="section"id="ping">
<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
successful contact.</p>
<p>This module does not support change hooks.</p>
<p>This module is informative only - it takes no parameters & does not
support change hooks, nor does it make any changes on the system.</p>
</div>
<divclass="section"id="service">
<h2>service<aclass="headerlink"href="#service"title="Permalink to this headline">¶</a></h2>
<p>Controls services on remote machines.</p>
<p><em>state</em></p>
<p>Values are ‘started’, ‘stopped’, or ‘restarted’. Started/stopped
are idempotent actions that will not run commands unless neccessary.
‘restarted’ will always bounce the service</p>
<p><em>name</em></p>
<p>The name of the service</p>
</div>
<divclass="section"id="setup">
<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.
Call this once before using the template modules. Playbooks will
execute this module automatically as the first step in each play.</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 ‘<aclass="reference internal"href="#facter">facter</a>‘ and ‘<aclass="reference internal"href="#ohai">ohai</a>” so it’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>
<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>
</div>
<divclass="section"id="template">
<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><em>src</em></p>
<p>path of a Jinja2 formatted template on the local server</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>
<divclass="section"id="user">
<h2>user<aclass="headerlink"href="#user"title="Permalink to this headline">¶</a></h2>
<p>This module is in plan.</p>
</div>
<divclass="section"id="yum">
<h2>yum<aclass="headerlink"href="#yum"title="Permalink to this headline">¶</a></h2>
<p>This module is in plan.</p>
</div>
<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>
<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 ‘failure’ element with a True value, and a ‘msg’ element
describing the nature of the failure. Other values are up to the module.</p>
</div>
</div>
</div>
...
@@ -106,12 +189,33 @@ hendrerit mi tincidunt dui fermentum placerat.</p>
...
@@ -106,12 +189,33 @@ hendrerit mi tincidunt dui fermentum placerat.</p>
</div>
</div>
<divclass="sphinxsidebar">
<divclass="sphinxsidebar">
<divclass="sphinxsidebarwrapper">
<divclass="sphinxsidebarwrapper">
<h3><ahref="index.html">Table Of Contents</a></h3>
rhoncus a dignissim non, adipiscing vel arcu. Quisque ultricies
<dd>Learn about how to select hosts</dd>
tincidunt purus ut sodales. Quisque scelerisque dapibus purus quis
</dl>
egestas. Maecenas sagittis porttitor adipiscing. Duis eu magna
</div>
sem. Donec arcu felis, faucibus et malesuada non, blandit vitae
<p>Playbooks are a completely different way to use ansible and are particularly awesome.</p>
metus. Fusce nec sapien dolor.</p>
<p>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>Aenean ac fermentum nisl. Integer leo sem, rutrum nec dictum at,
<divclass="section"id="playbook-example">
pretium quis sapien. Duis felis metus, sodales sit amet gravida in,
<h2>Playbook Example<aclass="headerlink"href="#playbook-example"title="Permalink to this headline">¶</a></h2>
pretium ut arcu. Nulla ligula quam, aliquam sit amet sollicitudin
<p>Playbooks are expressed in YAML format and have a minimum of syntax. Each playbook is composed
eget, molestie tincidunt ipsum. Nulla leo nunc, mattis sed auctor at,
of one or more patterns in a list. By composing a playbook of multiple patterns, it is possible
suscipit ut metus. Suspendisse hendrerit, justo sagittis malesuada
to orchestrate multi-machine deployments, running certain steps on all machines in
molestie, nisi nunc placerat libero, vel vulputate elit tellus et
the webservers group, then certain steps on the database server group, then more commands
augue. Phasellus tempor lectus ac nisi aliquam faucibus. Donec feugiat
back on the webservers group, etc:</p>
egestas nibh id mattis. In hac habitasse platea dictumst. Ut accumsan
<divclass="highlight-python"><pre>---
lorem eget leo dictum viverra.</p>
- hosts: all</pre>
<p>Quisque egestas lorem sit amet felis tincidunt adipiscing. Aenean
</div>
ornare fermentum accumsan. Aenean eu mauris arcu, id pulvinar
<blockquote>
quam. Suspendisse nec massa vel augue laoreet ultricies in convallis
<div><dlclass="docutils">
dolor. Mauris sodales porta enim, non ultricies dolor luctus
<dt>vars:</dt>
in. Phasellus eu tortor lectus, vel porttitor nulla. Mauris vulputate,
<dd>http_port: 80
erat id scelerisque lobortis, nibh ipsum tristique elit, ac viverra
max_clients: 200</dd>
arcu sem a ante. Praesent nec metus vestibulum augue eleifend
</dl>
suscipit. In feugiat, sem nec dignissim consequat, velit tortor
<p>user: root
scelerisque metus, sit amet mollis nisl sem eu nibh. Quisque in nibh
tasks:
turpis. Proin ac nisi ligula, a pretium augue.</p>
- include: base.yml somevar=3 othervar=4
<p>In nibh eros, laoreet id interdum vel, sodales sed tortor. Sed
- name: write the apache config file</p>
ullamcorper, sem vel mattis consectetur, nibh turpis molestie nisl,
<blockquote>
eget lobortis mi magna sed metus. Cras justo est, tempus quis
Search.setIndex({objects:{},terms:{all:[0,1,2,4,5,6,8],code:[1,2,8],donec:[],mcollect:1,prefix:[2,4,8],rhoncu:[],lacu:[],follow:[6,2,4],scp:8,nunc:[],bubbl:4,depend:2,fusc:[],program:[1,2,4],certain:4,vel:[],blindingli:1,spec:4,sourc:[1,2,4,8],everi:5,string:2,fals:[5,2],consequat:[],failur:[7,2],veri:[1,7,4],affect:4,risu:[],luctu:[],magic:6,level:[5,2],id_rsa:[0,8],list:[1,2,3,4,5,6,8,9],vivamu:[],item:5,ansible_librari:[],form:[5,4],dotnet:5,saltstack:1,mpdehaan:[],phasellu:[],ornar:[],natur:2,seper:4,chef:1,second:5,design:1,pass:4,eleifend:[],further:4,even:8,what:2,diam:[],favcolor:8,section:[1,4],abl:[],nec:[],abbrevi:5,version:[2,8],directori:2,ever:1,method:7,metadata:2,tar:0,suscipit:[],hash:2,eckersberg:5,here:[],leo:[],address:[6,2],path:2,sinc:8,valu:[5,2,4],aliquam:[],scelerisqu:[],great:1,purpos:[2,4],larger:[],host:[0,1,2,4,6,7,8],adipisc:[],prior:2,venenati:[],permit:5,action:[1,2,4],nulla:[],implement:7,iaculi:[],via:[0,1],regardless:[5,1],dictionari:5,accumsan:[],extra:4,apach:[4,8],modul:[0,1,2,4,7,8],prefer:[],put:[0,8],unix:4,api:[1,7,2],instal:[8,0,2,4,1],select:[6,4],httpd:4,from:[0,1,2,4,5,8],describ:2,would:8,commun:[1,3],visit:3,two:[5,0,6],noarch:0,dehaan:1,call:2,usr:[2,8],taken:4,sagitti:[],basi:4,checkout:2,until:0,more:[0,6,2,4,1],desir:[],idempot:[1,2,4],dbserver:[6,4],sbin:[2,8],agent:[0,8],particular:1,easiest:1,must:[5,2],none:[],join:3,ibm:[],module_arg:7,habitass:[],setup:[1,2,8],work:[6,8],critic:1,remain:1,tag:[0,2],can:[0,1,2,4,5,6,7,8],learn:[0,6,4,1],ero:[],root:[5,1,2,4],pick:5,employe:5,myapp:8,yamllint:5,ultric:[],process:[1,8],rpath:[],sudo:0,share:2,templat:[8,0,2,4,1],othervar:4,knows_oop:5,minimum:4,want:7,occur:4,nullam:[],alwai:2,multipl:[6,4,8],newlin:5,puru:[],sit:[],capistrano:1,ping:[0,7,2,1],write:[5,1,2,4,8],how:[0,1,2,4,5,6,7],etiam:[],yum:[1,2],simpl:[5,1,7,4,8],updat:8,arcu:[],express:[5,1,7,4],referenc:[6,4],clone:0,usabl:1,tristiqu:[],mai:[5,0],end:2,data:[5,7,2,8],parallel:[1,8],man:[1,9],repo:[2,8],github:[0,3],orchestr:[1,4],read:[5,0],bootstrap:1,favorit:1,turpi:[],element:[5,2],issu:3,inform:[2,4],mango:5,combin:5,asynchron:[1,4],order:4,talk:[],oper:[1,4,8],help:1,over:1,move:[2,4],orang:5,becaus:[],elit:5,rpmbuild:0,comma:5,vita:[],still:[],paramet:[2,4],jid:8,overlord:0,group:[1,7,3,4,6],cli:7,fit:[],yaml:[5,0,4,1],pend:[4,8],rapidli:7,infrastructur:[1,6],mail:[6,3],sapien:[],main:4,might:4,easier:[],non:[1,2],"return":[1,7,2],thei:[7,2,4,8],food:5,alist:4,nibh:[],egesta:[],"break":[],framework:[1,7],jinja2:[0,2,8],now:[0,2],nor:2,choic:1,multiprocess:0,name:[5,1,2,4],anyth:2,neccessari:[2,8],config:[1,4],viverra:[],datastructur:7,porta:[],separ:5,each:[5,2,4,8],stock:[],nearli:4,mean:2,metu:[],michael:1,auctor:[],realli:[5,4],contributor:[],backport:0,connect:[],our:5,todo:[],event:2,out:[5,1,2,4],variabl:[2,4,8],"try":0,shown:[],network:3,space:[1,2],reboot:8,content:[0,1],stuff:8,sshd:1,internet:1,correct:[5,1],red:8,state:[2,4,8],hendrerit:[],ntp:8,contain:[2,4],differ:[1,4,8],pub:8,control:[1,2,4,8],base:[1,4],lab:[],tempu:[],qui:[],org:0,molli:[],bash:[0,8],care:[],vestibulum:[],pyyaml:0,indent:5,maecena:[],could:7,fqdn:8,thing:[1,6],place:1,isn:1,principl:[],licens:1,first:[0,2,8,1],origin:[],softwar:[1,2],rang:1,notifi:[1,4,8],obviou:1,onc:2,number:2,yourself:0,hook:2,instruct:0,alreadi:[2,4],puppet:1,fast:1,enim:[],massiv:1,open:1,straight:8,given:8,convent:2,script:[0,1,4,5,7,8],associ:5,top:2,system:[0,1,2,4,6,8],messag:7,grow:[],too:1,statement:[1,4],molesti:[],john:5,banana:5,includ:[1,4],shell:[1,8],option:[5,9,2,4,8],tool:1,copi:[1,2,8],specifi:[5,2,8],quam:[],next:4,"short":1,kept:4,than:[0,2,8],serv:[],liter:2,target:[1,6],provid:5,sollicitudin:[],heavyweight:[],structur:5,charact:5,project:[0,3,8,1],architect:1,were:4,minut:[],uses_cv:5,pre:0,sai:4,runner:7,ani:[1,7,2,4,8],ant:[],download:0,have:[0,2,4,1],need:[5,0,2,8],tellu:[],seek:2,paramiko:0,engin:8,built:0,contact:[0,7,2],note:[2,8],also:[0,1,2,4,5,6,8],client:1,massa:[],build:[0,7],indic:2,environ:[],divers:1,pulvinar:[],begin:5,sure:[],unless:2,distribut:[0,1],deploy:[1,4],track:8,who:2,discov:4,most:[5,2],plai:2,regular:4,plan:2,deploi:[1,2,4,8],pair:2,why:1,porttitor:[],simplic:[],doc:1,later:8,cover:8,doe:[1,2,6],sodal:[],bracket:5,snapshot:2,clojur:[],wildcard:[1,6],dolor:[],someth:[1,8],awesom:[1,4],laoreet:[],blandit:[],verbos:2,syntax:[5,0,4],bring:[],directli:[2,4,8],raleigh:1,particularli:4,playbook:[0,1,2,4,5,6,7,8],permiss:2,hack:1,radic:1,pki:[],trivial:2,varnam:4,involv:[1,3],absolut:2,onli:[2,4],explicitli:4,locat:2,just:[8,0,4,1],pretti:7,configur:[5,0,6,4,1],releas:0,written:[1,2,4,8],should:[5,2],consectetur:[],somevar:4,congratul:0,variu:[],local:2,yml:4,long_running_oper:8,contribut:1,variou:[],get:[5,0,3,8,1],financ:1,stop:2,mission:1,bibendum:[],ssl:[],ssh:[0,8],malesuada:[],requir:[0,2,4,1],uvh:0,nisi:[],bar:6,lame:5,nisl:[],remot:[0,2,4,8],cra:[],orci:[],through:[0,2,1],where:[1,2,4],wrote:[],view:[3,9],set:[2,4],creator:[],elimin:[],see:[0,1,2,4,5,6,8],sed:[],result:[7,2],fail:4,sem:[],extend:1,ntp_server:8,faucibu:[],statu:8,kei:[5,0,2,4],databas:4,modularli:[],discoveri:2,restart:[2,4,8],behind:[],won:8,languag:[5,0,6,2,1],between:5,"import":7,irc:3,altern:8,elementum:[],manpag:[0,9],handful:[],aspir:[],style:2,job:[5,8],aserv:0,magna:[],webapp:8,amet:[],addit:[5,1],delimit:2,plugin:[],goal:1,against:[1,4,6],tempor:[],etc:[0,1,2,4,6,8],befor:[2,4],mani:8,placerat:[],com:[0,7,4,6],proin:[],sha:2,assur:4,simpli:2,author:1,overview:5,format:[2,4,8],inspir:[],colon:4,shutdown:2,linux:[1,4],poll:[1,4,8],rpm:[0,1],matti:[],dui:[],pretium:[],multiplay:1,morbi:[],three:6,been:[1,2],json:[1,7,2],much:1,basic:[5,0,6,2,1],ungroup:6,feugiat:[],quickli:[5,1],box:[1,2],fire:1,rubi:[5,2,8],vulput:[],argument:2,understand:0,pellentesqu:[],func:1,atlanta:8,job_statu:8,those:[5,2],emploi:5,authorized_kei:0,multi:[1,4],tortor:[],look:[6,4,8],nequ:[],hoc:[1,4],servic:[1,2,4],md5sum:2,batch:[],"while":4,overrid:2,ipsum:[],cobbler:1,real:0,motd:8,max_client:4,them:8,erat:[],conf:[4,8],module_nam:7,ship:[0,2],sever:5,http_port:4,develop:[5,0,1],inventori:[6,2],minim:0,make:[0,2,8],platea:[],same:[5,6,2,8],member:5,python:[0,1,2,5,7,8],complex:[1,4],success:2,fedora:[],document:[0,7,4],ansibl:[0,1,2,3,4,5,6,7,8,9],complet:[0,4],finish:[],http:2,webserv:[6,4,8],nest:2,painless:1,effect:4,dai:[],fruit:5,user:[1,2,4],ownership:[],extrem:0,php:8,distutil:[0,1],chang:[2,4,8],squar:5,exceedingli:[],task:[1,4,8],off:1,scenario:2,whole:[],well:[2,4],spent:[],exampl:[0,1,2,4,5,6,7,8],command:[0,1,2,4,6,8,9],thi:[0,1,2,4,5,6,8],choos:2,usual:4,comment:[1,4],protocol:2,execut:[1,2,4],less:[0,1],when:[2,4,8],skill:5,simultan:8,ligula:[],previous:[],web:[7,8],versu:1,easi:2,mix:[1,6],trigger:2,hac:[],except:4,littl:1,add:[0,8],other:[1,2,8],els:1,unlik:4,hat:[],match:4,take:2,bin:[2,8],applic:[7,4],which:[0,1,2,4,5,6],ohai:[1,2,4,8],dest:[2,4,8],tincidunt:[],dark:7,game:1,know:5,background:[1,8],world:0,bit:2,daemon:1,like:[5,6,4,8],specif:[1,7,8,6],signal:4,manual:[],integ:2,server:[1,2,4,8],edit:0,"boolean":5,either:2,velit:[],popular:1,async:[],page:[5,0,9,3,1],deal:[],suppli:2,some:0,back:4,dead:1,tumblr:[],home:[],librari:[],tmp:8,render:2,avoid:2,though:1,ultrici:[],per:7,tracker:3,unit:[],pattern:[1,7,4,6],foo:[6,4,8],complic:1,machin:[0,2,4,8],core:1,run:[0,7,2,4,8],power:[1,7],quit:[],lose:8,usag:[2,8],asciidoc:0,web2:7,step:[2,4],web1:7,repositori:0,"super":1,aenean:[],simpler:8,comparison:1,about:[5,0,2,4,1],gplv3:1,justo:[],libero:[],surround:5,manag:[5,0,6,4,1],srv:[4,8],quisqu:[],industri:1,own:[1,2,4],"final":5,bounc:2,automat:2,compos:4,down:4,ensur:4,perl:8,bserver:0,your:[0,1,2,4,5,6,8],praesent:[],git:[0,2,8,1],type:7,fabric:1,wai:[5,0,4,8],interdum:[],transfer:[1,8],dictum:[],support:[2,8],rotat:4,"long":[1,2,8],avail:[0,9,2,4,8],start:[5,0,2,4,1],appl:5,augu:[],lot:[1,8],suit:4,"var":[1,4],individu:6,fork:7,head:[2,8],doctyp:[],simplejson:0,eget:[],handler:[1,4,8],lint:5,msg:2,loborti:[],ullamcorp:[],line:[5,1,9,4,8],"true":[5,2],freenod:3,info:4,strawberri:5,made:[2,8],possibl:[6,4,8],whether:7,wish:[5,0,6],tell:[2,8],planet:1,record:5,below:8,limit:[1,8],suspendiss:[],otherwis:2,problem:[],similar:2,chip:1,facter:[1,2,4,8],curv:1,featur:[1,4],tasti:5,creat:1,lectu:[],doesn:1,repres:5,ansil:[],deferenc:4,file:[0,1,2,4,5,6,8],mauri:[],exist:[1,4],check:[2,8],urna:[],conval:[],googl:3,excel:1,nam:[],"default":[1,2,6],likes_emac:5,futur:0,dignissim:[],test:[0,2],you:[0,1,4,5,6,8],node:[0,1],dapibu:[],journei:[],gravida:[],sequenc:1,devop:1,push:4,est:[],feli:[],aliquet:[],src:[2,4,8],lorem:[],"60k":1,dictumst:[],sphinx:0,rutrum:[],anywher:[],descript:[],portion:6,time:[0,1,2,4,6,8],far:1,serious:[],fermentum:[]},objtypes:{},titles:["Getting Started","Ansible","Ansible Modules","Communicate and Get Involved","Playbooks","YAML Scripts","Patterns","API","Examples","Man Pages"],objnames:{},filenames:["gettingstarted","index","modules","communicate","playbooks","YAMLScripts","patterns","api","examples","man"]})
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
A list of available modules
placerat nibh, non feugiat risus varius vitae. Donec eu libero
:doc:`playbooks`
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
Alternative ways to use ansible
magna porta venenatis. Quisque scelerisque, sem non ultrices bibendum,
dolor diam rutrum lectus, sed luctus neque neque vitae eros. Vivamus
mattis, ipsum ut bibendum gravida, lectus arcu venenatis elit, vitae
Parallelism and Shell Commands
luctus diam leo sit amet ligula. Nunc egestas justo in nulla sagittis
``````````````````````````````
ut suscipit sapien gravida. Morbi id dui nibh. Nullam diam massa,
rhoncus a dignissim non, adipiscing vel arcu. Quisque ultricies
Reboot all web servers in Atlanta, 10 at a time::
tincidunt purus ut sodales. Quisque scelerisque dapibus purus quis
egestas. Maecenas sagittis porttitor adipiscing. Duis eu magna
ssh-agent bash
sem. Donec arcu felis, faucibus et malesuada non, blandit vitae
ssh-add ~/.ssh/id_rsa.pub
metus. Fusce nec sapien dolor.
ansible atlanta -a "/sbin/reboot" -f 10
Examples 2
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.
Aenean ac fermentum nisl. Integer leo sem, rutrum nec dictum at,
pretium quis sapien. Duis felis metus, sodales sit amet gravida in,
pretium ut arcu. Nulla ligula quam, aliquam sit amet sollicitudin
Example 2: Time Limited Background Operations
eget, molestie tincidunt ipsum. Nulla leo nunc, mattis sed auctor at,
`````````````````````````````````````````````
suscipit ut metus. Suspendisse hendrerit, justo sagittis malesuada
molestie, nisi nunc placerat libero, vel vulputate elit tellus et
augue. Phasellus tempor lectus ac nisi aliquam faucibus. Donec feugiat
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.::
egestas nibh id mattis. In hac habitasse platea dictumst. Ut accumsan
lorem eget leo dictum viverra.
ansible all -B 3600 -a "/usr/bin/long_running_operation --do-stuff"
ansible all -n job_status -a jid=123456789
Examples 3
``````````
Any module other than 'copy' or 'template' can be backgrounded.
Quisque egestas lorem sit amet felis tincidunt adipiscing. Aenean
ornare fermentum accumsan. Aenean eu mauris arcu, id pulvinar
Examples 3: File Transfer & Templating
quam. Suspendisse nec massa vel augue laoreet ultricies in convallis
``````````````````````````````````````
dolor. Mauris sodales porta enim, non ultricies dolor luctus
in. Phasellus eu tortor lectus, vel porttitor nulla. Mauris vulputate,
Ansible can SCP lots of files to multiple machines in parallel, and optionally use them as template sources.
erat id scelerisque lobortis, nibh ipsum tristique elit, ac viverra
arcu sem a ante. Praesent nec metus vestibulum augue eleifend
To just transfer a file directly to many different servers::
suscipit. In feugiat, sem nec dignissim consequat, velit tortor
scelerisque metus, sit amet mollis nisl sem eu nibh. Quisque in nibh
ansible atlanta copy -a "/etc/hosts /tmp/hosts"
turpis. Proin ac nisi ligula, a pretium augue.
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.::
Examples 3
``````````
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"
In nibh eros, laoreet id interdum vel, sodales sed tortor. Sed
ansible webservers -m template -a "src=/srv/ntp.j2 dest=/etc/ntp.conf"
ullamcorper, sem vel mattis consectetur, nibh turpis molestie nisl,
eget lobortis mi magna sed metus. Cras justo est, tempus quis
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.
adipiscing ut, hendrerit convallis sem. Mauris ullamcorper, sapien et
luctus iaculis, urna elit egestas ipsum, et tristique enim risus vitae
Examples 3: Deploying From Source Control
nunc. Vivamus aliquet lorem eu urna pulvinar hendrerit malesuada nunc
`````````````````````````````````````````
sollicitudin. Cras in mi rhoncus quam egestas dignissim vel sit amet
lacus. Maecenas interdum viverra laoreet. Quisque elementum
Deploy your webapp straight from git::
sollicitudin ullamcorper.
ansible webservers -m git -a "repo=git://foo dest=/srv/myapp version=HEAD"
Examples 4
``````````
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.
Pellentesque mauris sem, malesuada at lobortis in, porta eget
urna. Duis aliquet quam eget risus elementum quis auctor ligula
gravida. Phasellus et ullamcorper libero. Nam elementum ultricies
tellus, in sagittis magna aliquet quis. Ut sit amet tellus id erat
tristique lobortis. Suspendisse est enim, tristique eu convallis id,
rutrum nec lacus. Fusce iaculis diam non felis rutrum lobortis. Proin
Ansible is a extra-simple tool/API for doing 'parallel remote things'
Ansible is a radically simple deployment, configuration, and command execution framework.
over SSH -- whether executing commands, running "modules", or
Other tools in this space have been too complicated for too long, require too much bootstrapping,
executing larger 'playbooks' that can serve as a configuration
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.
management or deployment system.
While `Func installation <http://fedorahosted.org/func>`_ which I
Ansible isn't just for configuration -- it's also great for Ad-Hoc tasks,
co-wrote, aspired to avoid using SSH and have it's own daemon
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.
infrastructure, Ansible aspires to be quite different and more
minimal, but still able to grow more modularly over time. This is
based on talking to a lot of users of various tools and wishing to
eliminate problems with connectivity and long running daemons, or not
picking tool `X` because they preferred to code in `Y`. Further,
playbooks take things a whole step further, building the config and
deployment system I always wanted to build.
Why use Ansible versus something else? (Fabric, Capistrano,
Ansible does not require programming in any particular language -- you can write modules
as scripts or programs that return simple JSON.
Why use Ansible versus something else? (Puppet, Chef, Fabric, Capistrano,
mCollective, Func, SaltStack, etc?) It will have far less code, it
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
will be 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.
use you'll ever see -- regardless of your favorite language of choice.
Want to only code plugins in bash or clojure? Ansible doesn't care.
Systems management doesn't have to be complicated. Ansible's docs will remain
The docs will fit on one page and the source will be blindingly
short & simple, and the source will be blindingly obvious.
obvious.
Design Principles
Design Goals
`````````````````
````````````
* Dead simple setup
* Dead simple setup
* Super fast & parallel by default
* Super fast & parallel by default
* No server or client daemons; use existing SSHd
* No server or client daemons; use existing SSHd out of the box
* No additional software required on client boxes
* No additional software required on client boxes
* Modules can be written in ANY language
* Modules can be written in ANY language
* Awesome API for creating very powerful distributed scripts
* Awesome API for creating very powerful distributed scripts
* Be usable as non-root
* Be usable as non-root
* Create the easiest config management system to use, ever.
* Create the easiest config management system to use, ever.
About the Author
````````````````
Requirements
Michael DeHaan is a Raleigh, NC based software developer and architect. He created other
````````````
DevOps programs such as Cobbler, the popular Linux install server.
Cobbler is used to deploy mission critical systems all over the planet, in industries
Requirements are extremely minimal.
ranging from massively multiplayer gaming, core internet infrastructure, finance,
chip design, and more. Michael also helped co-author of Func, which is used
If you are running python 2.6 on the **overlord** machine, you will
to orchestrate systems in lots of diverse places.
need:
* ``paramiko``
* ``PyYAML``
* ``python-jinja2`` (for playbooks)
* ``Asciidoc`` (for building documentation)
If you are running less than Python 2.6, you will also need:
* The Python 2.4 or 2.5 backport of the ``multiprocessing`` module
- `Installation and Testing Instructions <http://code.google.com/p/python-multiprocessing/wiki/Install>`_
* ``simplejson``
On the managed nodes, to use templating, you will need:
* ``python-jinja2`` (you can install this with ansible)
Getting Ansible
```````````````
Tagged releases are available as tar.gz files from the Ansible github
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
.. seealso::
placerat nibh, non feugiat risus varius vitae. Donec eu libero
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
:doc:`examples`
magna porta venenatis. Quisque scelerisque, sem non ultrices bibendum,
Examples of using modules in /usr/bin/ansible
dolor diam rutrum lectus, sed luctus neque neque vitae eros. Vivamus
:doc:`playbooks`
mattis, ipsum ut bibendum gravida, lectus arcu venenatis elit, vitae
Examples of using modules with /usr/bin/ansible-playbook
luctus diam leo sit amet ligula. Nunc egestas justo in nulla sagittis
:doc:`api`
ut suscipit sapien gravida. Morbi id dui nibh. Nullam diam massa,
Examples of using modules with the Python API
rhoncus a dignissim non, adipiscing vel arcu. Quisque ultricies
tincidunt purus ut sodales. Quisque scelerisque dapibus purus quis
egestas. Maecenas sagittis porttitor adipiscing. Duis eu magna
About Modules
sem. Donec arcu felis, faucibus et malesuada non, blandit vitae
`````````````
metus. Fusce nec sapien dolor.
Ansible ships with a number of modules that can be executed directly on remote hosts or through
Aenean ac fermentum nisl. Integer leo sem, rutrum nec dictum at,
ansible playbooks.
pretium quis sapien. Duis felis metus, sodales sit amet gravida in,
pretium ut arcu. Nulla ligula quam, aliquam sit amet sollicitudin
eget, molestie tincidunt ipsum. Nulla leo nunc, mattis sed auctor at,
Idempotence
suscipit ut metus. Suspendisse hendrerit, justo sagittis malesuada
```````````
molestie, nisi nunc placerat libero, vel vulputate elit tellus et
augue. Phasellus tempor lectus ac nisi aliquam faucibus. Donec feugiat
Most modules other than command are idempotent, meaning they will seek to avoid changes
egestas nibh id mattis. In hac habitasse platea dictumst. Ut accumsan
unless a change needs to be made. When using ansible playbooks, these modules can
lorem eget leo dictum viverra.
trigger change events. Unless otherwise noted, all modules support change hooks.
Quisque egestas lorem sit amet felis tincidunt adipiscing. Aenean
ornare fermentum accumsan. Aenean eu mauris arcu, id pulvinar
command
quam. Suspendisse nec massa vel augue laoreet ultricies in convallis
```````
dolor. Mauris sodales porta enim, non ultricies dolor luctus
in. Phasellus eu tortor lectus, vel porttitor nulla. Mauris vulputate,
The command module takes the command name followed by a list of arguments, space delimited.
erat id scelerisque lobortis, nibh ipsum tristique elit, ac viverra
This is the only module that does not use key=value style parameters.
arcu sem a ante. Praesent nec metus vestibulum augue eleifend
suscipit. In feugiat, sem nec dignissim consequat, velit tortor
Example usage::
scelerisque metus, sit amet mollis nisl sem eu nibh. Quisque in nibh
turpis. Proin ac nisi ligula, a pretium augue.
/sbin/shutdown -t now
In nibh eros, laoreet id interdum vel, sodales sed tortor. Sed
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.
ullamcorper, sem vel mattis consectetur, nibh turpis molestie nisl,
eget lobortis mi magna sed metus. Cras justo est, tempus quis
adipiscing ut, hendrerit convallis sem. Mauris ullamcorper, sapien et
copy
luctus iaculis, urna elit egestas ipsum, et tristique enim risus vitae
````
nunc. Vivamus aliquet lorem eu urna pulvinar hendrerit malesuada nunc
sollicitudin. Cras in mi rhoncus quam egestas dignissim vel sit amet
The copy module moves a file on the local box to remote locations.
lacus. Maecenas interdum viverra laoreet. Quisque elementum
sollicitudin ullamcorper.
*src*::
Pellentesque mauris sem, malesuada at lobortis in, porta eget
Local absolute path to a file to copy to the remote server
urna. Duis aliquet quam eget risus elementum quis auctor ligula
gravida. Phasellus et ullamcorper libero. Nam elementum ultricies
tellus, in sagittis magna aliquet quis. Ut sit amet tellus id erat
*dest*::
tristique lobortis. Suspendisse est enim, tristique eu convallis id,
rutrum nec lacus. Fusce iaculis diam non felis rutrum lobortis. Proin
Remote absolute path where the file should end up
hendrerit mi tincidunt dui fermentum placerat.
This module also returns md5sum information about the resultant file.
facter
``````
Runs the discovery program 'facter' on the remote system, returning
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.
git
```
Deploys software from git checkouts.
*repo*::
git or http protocol address of the repo to checkout
*dest*::
where to check it out, an absolute directory path
*version*::
what version to check out -- either the git SHA, the literal string 'HEAD', or a tag name
ohai
````
Similar to the facter module, this returns JSON inventory data. Ohai
data is a bit more verbose and nested than facter.
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.
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
support change hooks, nor does it make any changes on the system.
service
```````
Controls services on remote machines.
*state*
Values are 'started', 'stopped', or 'restarted'. Started/stopped
are idempotent actions that will not run commands unless neccessary.
'restarted' will always bounce the service
*name*
The name of the service
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.
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.
*anything*
any other parameters can be named basically anything, and set a key=value
pair in the JSON file for use in templating.
template
````````
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
*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
````
This module is in plan.
yum
```
This module is in plan.
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.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
.. seealso::
placerat nibh, non feugiat risus varius vitae. Donec eu libero
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
:doc:`YAMLScripts`
magna porta venenatis. Quisque scelerisque, sem non ultrices bibendum,
Learn about YAML syntax
dolor diam rutrum lectus, sed luctus neque neque vitae eros. Vivamus
:doc:`modules`
mattis, ipsum ut bibendum gravida, lectus arcu venenatis elit, vitae
Learn about available modules and writing your own
luctus diam leo sit amet ligula. Nunc egestas justo in nulla sagittis
:doc:`patterns`
ut suscipit sapien gravida. Morbi id dui nibh. Nullam diam massa,
Learn about how to select hosts
rhoncus a dignissim non, adipiscing vel arcu. Quisque ultricies
tincidunt purus ut sodales. Quisque scelerisque dapibus purus quis
egestas. Maecenas sagittis porttitor adipiscing. Duis eu magna
Playbooks are a completely different way to use ansible and are particularly awesome.
sem. Donec arcu felis, faucibus et malesuada non, blandit vitae
metus. Fusce nec sapien dolor.
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.
Aenean ac fermentum nisl. Integer leo sem, rutrum nec dictum at,
pretium quis sapien. Duis felis metus, sodales sit amet gravida in,
Playbook Example
pretium ut arcu. Nulla ligula quam, aliquam sit amet sollicitudin
````````````````
eget, molestie tincidunt ipsum. Nulla leo nunc, mattis sed auctor at,
suscipit ut metus. Suspendisse hendrerit, justo sagittis malesuada
Playbooks are expressed in YAML format and have a minimum of syntax. Each playbook is composed
molestie, nisi nunc placerat libero, vel vulputate elit tellus et
of one or more patterns in a list. By composing a playbook of multiple patterns, it is possible
augue. Phasellus tempor lectus ac nisi aliquam faucibus. Donec feugiat
to orchestrate multi-machine deployments, running certain steps on all machines in
egestas nibh id mattis. In hac habitasse platea dictumst. Ut accumsan
the webservers group, then certain steps on the database server group, then more commands
lorem eget leo dictum viverra.
back on the webservers group, etc::
Quisque egestas lorem sit amet felis tincidunt adipiscing. Aenean
---
ornare fermentum accumsan. Aenean eu mauris arcu, id pulvinar
- hosts: all
quam. Suspendisse nec massa vel augue laoreet ultricies in convallis
vars:
dolor. Mauris sodales porta enim, non ultricies dolor luctus
http_port: 80
in. Phasellus eu tortor lectus, vel porttitor nulla. Mauris vulputate,
max_clients: 200
erat id scelerisque lobortis, nibh ipsum tristique elit, ac viverra
user: root
arcu sem a ante. Praesent nec metus vestibulum augue eleifend
tasks:
suscipit. In feugiat, sem nec dignissim consequat, velit tortor
- include: base.yml somevar=3 othervar=4
scelerisque metus, sit amet mollis nisl sem eu nibh. Quisque in nibh