Merge branch 'master' of https://github.com/ansible/ansible.github.com
This commit is contained in:
commit
26800d5db8
39 changed files with 2358 additions and 1697 deletions
|
@ -20,6 +20,7 @@ __docformat__ = 'restructuredtext'
|
|||
|
||||
import os
|
||||
import sys
|
||||
import traceback
|
||||
from sphinx.application import Sphinx
|
||||
from os import path
|
||||
|
||||
|
@ -68,12 +69,7 @@ class SphinxBuilder(object):
|
|||
# print "Run 'make htmlman' to recreate the problem."
|
||||
#print "Your docs are now in %s" % outdir
|
||||
except ImportError, ie:
|
||||
print >> sys.stderr, "You don't seem to have the following which"
|
||||
print >> sys.stderr, "are required to make documentation:"
|
||||
print >> sys.stderr, "\tsphinx.application.Sphinx"
|
||||
print >> sys.stderr, "This is usually available from the python-sphinx package"
|
||||
print >> sys.stderr, "=== Error message received while attempting to build==="
|
||||
print >> sys.stderr, ie
|
||||
traceback.print_exc()
|
||||
except Exception, ex:
|
||||
print >> sys.stderr, "FAIL! exiting ... (%s)" % ex
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
|
||||
<title>YAML Scripts — Ansible v0.0.1 documentation</title>
|
||||
<title>YAML Format — Ansible v0.0.1 documentation</title>
|
||||
<link rel="stylesheet" href="_static/default.css" type="text/css" />
|
||||
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
||||
<script type="text/javascript">
|
||||
|
@ -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="Patterns" href="patterns.html" />
|
||||
<link rel="prev" title="Getting Started" href="gettingstarted.html" />
|
||||
<link rel="next" title="Playbooks: Ansible for Deployment, Configuration Management, and Orchestration" href="playbooks.html" />
|
||||
<link rel="prev" title="Ansible Modules" href="modules.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="patterns.html" title="Patterns"
|
||||
<a href="playbooks.html" title="Playbooks: Ansible for Deployment, Configuration Management, and Orchestration"
|
||||
accesskey="N">next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="gettingstarted.html" title="Getting Started"
|
||||
<a href="modules.html" title="Ansible Modules"
|
||||
accesskey="P">previous</a> |</li>
|
||||
<li><a href="index.html">Ansible v0.0.1 documentation</a> »</li>
|
||||
</ul>
|
||||
|
@ -48,18 +48,20 @@
|
|||
<div class="bodywrapper">
|
||||
<div class="body">
|
||||
|
||||
<div class="section" id="yaml-scripts">
|
||||
<h1>YAML Scripts<a class="headerlink" href="#yaml-scripts" title="Permalink to this headline">¶</a></h1>
|
||||
<p>This page provides a basic overview of correct YAML syntax.</p>
|
||||
<div class="section" id="yaml-format">
|
||||
<h1>YAML Format<a class="headerlink" href="#yaml-format" title="Permalink to this headline">¶</a></h1>
|
||||
<p>This page provides a basic overview of correct YAML syntax, which is how Ansible
|
||||
playbooks (our configuration management language) are expressed.
|
||||
You may also wish to read playbook examples and will quickly pick this up from those.</p>
|
||||
<div class="section" id="yaml-basics">
|
||||
<h2>YAML Basics<a class="headerlink" href="#yaml-basics" title="Permalink to this headline">¶</a></h2>
|
||||
<p>For <cite>ansible</cite>, every YAML script must be a list at it’s root-most
|
||||
<p>For <cite>ansible</cite>, every YAML file must be a list at it’s root-most
|
||||
element. Each item in the list is a dictionary. These dictionaries
|
||||
represent all the options you can use to write a <cite>ansible</cite> script. In
|
||||
represent all the options you can use to write an <cite>ansible</cite> file. In
|
||||
addition, all YAML files (regardless of their association with
|
||||
<cite>ansible</cite> or not) should start with <tt class="docutils literal"><span class="pre">---</span></tt>.</p>
|
||||
<p>In YAML a list can be represented in two ways. In one way all members
|
||||
of a list are lines beginning at the same indentation level starting
|
||||
of a list are lines beginning at the same indenta`tion level starting
|
||||
with a <tt class="docutils literal"><span class="pre">-</span></tt> character:</p>
|
||||
<div class="highlight-python"><pre>---
|
||||
# A list of tasty fruits
|
||||
|
@ -111,7 +113,7 @@ languages:
|
|||
dotnet: Lame</pre>
|
||||
</div>
|
||||
<p>That’s all you really need to know about YAML to get started writing
|
||||
<cite>Ansible</cite> scripts.</p>
|
||||
<cite>Ansible</cite> playbooks.</p>
|
||||
<div class="admonition-see-also admonition seealso">
|
||||
<p class="first admonition-title">See also</p>
|
||||
<dl class="last docutils">
|
||||
|
@ -130,18 +132,18 @@ languages:
|
|||
<div class="sphinxsidebarwrapper">
|
||||
<h3><a href="index.html">Table Of Contents</a></h3>
|
||||
<ul>
|
||||
<li><a class="reference internal" href="#">YAML Scripts</a><ul>
|
||||
<li><a class="reference internal" href="#">YAML Format</a><ul>
|
||||
<li><a class="reference internal" href="#yaml-basics">YAML Basics</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4>Previous topic</h4>
|
||||
<p class="topless"><a href="gettingstarted.html"
|
||||
title="previous chapter">Getting Started</a></p>
|
||||
<p class="topless"><a href="modules.html"
|
||||
title="previous chapter">Ansible Modules</a></p>
|
||||
<h4>Next topic</h4>
|
||||
<p class="topless"><a href="patterns.html"
|
||||
title="next chapter">Patterns</a></p>
|
||||
<p class="topless"><a href="playbooks.html"
|
||||
title="next chapter">Playbooks: Ansible for Deployment, Configuration Management, and Orchestration</a></p>
|
||||
<h3>This Page</h3>
|
||||
<ul class="this-page-menu">
|
||||
<li><a href="_sources/YAMLScripts.txt"
|
||||
|
@ -150,7 +152,7 @@ languages:
|
|||
<div id="searchbox" style="display: none">
|
||||
<h3>Quick search</h3>
|
||||
<form class="search" action="search.html" method="get">
|
||||
<input type="text" name="q" size="18" />
|
||||
<input type="text" name="q" />
|
||||
<input type="submit" value="Go" />
|
||||
<input type="hidden" name="check_keywords" value="yes" />
|
||||
<input type="hidden" name="area" value="default" />
|
||||
|
@ -171,18 +173,18 @@ languages:
|
|||
<a href="genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="patterns.html" title="Patterns"
|
||||
<a href="playbooks.html" title="Playbooks: Ansible for Deployment, Configuration Management, and Orchestration"
|
||||
>next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="gettingstarted.html" title="Getting Started"
|
||||
<a href="modules.html" title="Ansible Modules"
|
||||
>previous</a> |</li>
|
||||
<li><a href="index.html">Ansible v0.0.1 documentation</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer">
|
||||
© Copyright 2012 Michael DeHaan.
|
||||
Last updated on Mar 07, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
|
||||
Last updated on Mar 09, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.8.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,20 +1,21 @@
|
|||
YAML Scripts
|
||||
============
|
||||
|
||||
This page provides a basic overview of correct YAML syntax.
|
||||
YAML Format
|
||||
===========
|
||||
|
||||
This page provides a basic overview of correct YAML syntax, which is how Ansible
|
||||
playbooks (our configuration management language) are expressed.
|
||||
You may also wish to read playbook examples and will quickly pick this up from those.
|
||||
|
||||
YAML Basics
|
||||
-----------
|
||||
|
||||
For `ansible`, every YAML script must be a list at it's root-most
|
||||
For `ansible`, every YAML file must be a list at it's root-most
|
||||
element. Each item in the list is a dictionary. These dictionaries
|
||||
represent all the options you can use to write a `ansible` script. In
|
||||
represent all the options you can use to write an `ansible` file. In
|
||||
addition, all YAML files (regardless of their association with
|
||||
`ansible` or not) should start with ``---``.
|
||||
|
||||
In YAML a list can be represented in two ways. In one way all members
|
||||
of a list are lines beginning at the same indentation level starting
|
||||
of a list are lines beginning at the same indenta`tion level starting
|
||||
with a ``-`` character::
|
||||
|
||||
---
|
||||
|
@ -74,7 +75,7 @@ Finally, you can combine these data structures::
|
|||
dotnet: Lame
|
||||
|
||||
That's all you really need to know about YAML to get started writing
|
||||
`Ansible` scripts.
|
||||
`Ansible` playbooks.
|
||||
|
||||
.. seealso::
|
||||
|
||||
|
|
|
@ -1,55 +1,73 @@
|
|||
API
|
||||
===
|
||||
Using the Python API
|
||||
====================
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
|
||||
placerat nibh, non feugiat risus varius vitae. Donec eu libero
|
||||
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
|
||||
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
|
||||
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
|
||||
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.
|
||||
The Python API is very powerful, and is how the ansible CLI and ansible-playbook
|
||||
are implemented.
|
||||
|
||||
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.
|
||||
It's pretty simple::
|
||||
|
||||
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.
|
||||
import ansible.runner
|
||||
|
||||
runner = ansible.runner.Runner(
|
||||
module_name='ping',
|
||||
module_args='',
|
||||
pattern='web*',
|
||||
forks=10
|
||||
)
|
||||
datastructure = runner.run()
|
||||
|
||||
The run method returns results per host, grouped by whether they
|
||||
could be contacted or not. Return types are module specific, as
|
||||
expressed in the 'ansible-modules' documentation.::
|
||||
|
||||
{
|
||||
"dark" : {
|
||||
"web1.example.com" : "failure message"
|
||||
}
|
||||
"contacted" : {
|
||||
"web2.example.com" : 1
|
||||
}
|
||||
}
|
||||
|
||||
A module can return any type of JSON data it wants, so Ansible can
|
||||
be used as a framework to rapidly build powerful applications and scripts.
|
||||
|
||||
Detailed API Example
|
||||
````````````````````
|
||||
|
||||
The following script prints out the uptime information for all hosts::
|
||||
|
||||
#!/usr/bin/python
|
||||
|
||||
import ansible.runner
|
||||
import sys
|
||||
|
||||
# construct the ansible runner and execute on all hosts
|
||||
results = ansible.runner.Runner(
|
||||
pattern='*', forks=10,
|
||||
module_name='command', module_args=['/usr/bin/uptime'],
|
||||
).run()
|
||||
|
||||
if results is None:
|
||||
print "No hosts found"
|
||||
sys.exit(1)
|
||||
|
||||
print "UP ***********"
|
||||
for (hostname, result) in results['contacted'].items():
|
||||
if not 'failed' in result:
|
||||
print "%s >>> %s" % (hostname, result['stdout'])
|
||||
|
||||
print "FAILED *******"
|
||||
for (hostname, result) in results['contacted'].items():
|
||||
if 'failed' in result:
|
||||
print "%s >>> %s" % (hostname, result['msg'])
|
||||
|
||||
print "DOWN *********"
|
||||
for (hostname, result) in results['dark'].items():
|
||||
print "%s >>> %s" % (hostname, result)
|
||||
|
||||
Advanced programmers may also wish to read the source to ansible itself, for
|
||||
it uses the Runner() API (with all available options) to implement the
|
||||
command line tools ``ansible`` and ``ansible-playbook``.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
|
|
@ -1,55 +1,9 @@
|
|||
Communicate
|
||||
===========
|
||||
Communicate and Get Involved
|
||||
===========================
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
|
||||
placerat nibh, non feugiat risus varius vitae. Donec eu libero
|
||||
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
|
||||
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
|
||||
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
|
||||
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.
|
||||
* Join the `ansible-project mailing list <http://groups.google.com/group/ansible-project>`_ on Google Groups
|
||||
* Join `#ansible <irc://irc.freenode.net/#ansible>`_ on the `freenode IRC network <http://freenode.net/>`_
|
||||
* Visit the `project page <https://github.com/ansible/ansible>`_ on Github
|
||||
|
||||
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.
|
||||
- View the `issue tracker <https://github.com/ansible/ansible/issues>`_
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
|
|
@ -1,71 +1,81 @@
|
|||
Examples
|
||||
========
|
||||
Command Line Examples
|
||||
=====================
|
||||
|
||||
Examples 1
|
||||
``````````
|
||||
The following examples show how to use `/usr/bin/ansible` for running ad-hoc tasks.
|
||||
Start here. For configuration management and deployments, you'll want to pick up on
|
||||
using `/usr/bin/ansible-playbook` -- the concepts port over directly.
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
|
||||
placerat nibh, non feugiat risus varius vitae. Donec eu libero
|
||||
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
|
||||
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
|
||||
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
|
||||
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.
|
||||
.. seealso::
|
||||
|
||||
:doc:`modules`
|
||||
A list of available modules
|
||||
:doc:`playbooks`
|
||||
Alternative ways to use ansible
|
||||
|
||||
|
||||
Examples 2
|
||||
``````````
|
||||
Parallelism and Shell Commands
|
||||
``````````````````````````````
|
||||
|
||||
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.
|
||||
Let's use ansible's command line tool to reboot all web servers in Atlanta, 10 at a time::
|
||||
|
||||
Examples 3
|
||||
``````````
|
||||
ssh-agent bash
|
||||
ssh-add ~/.ssh/id_rsa.pub
|
||||
|
||||
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.
|
||||
ansible atlanta -a "/sbin/reboot" -f 10
|
||||
|
||||
Examples 3
|
||||
``````````
|
||||
The -f 10 specifies the usage of 10 simultaneous processes.
|
||||
|
||||
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.
|
||||
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'.
|
||||
|
||||
File Transfer & Templating
|
||||
``````````````````````````
|
||||
|
||||
Ansible can SCP lots of files to multiple machines in parallel, and optionally use them as template sources.
|
||||
|
||||
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 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"
|
||||
ansible webservers -m template -a "src=/srv/ntp.j2 dest=/etc/ntp.conf"
|
||||
|
||||
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.
|
||||
|
||||
Deploying From Source Control
|
||||
`````````````````````````````
|
||||
|
||||
Deploy your webapp straight from git::
|
||||
|
||||
ansible webservers -m git -a "repo=git://foo dest=/srv/myapp version=HEAD"
|
||||
|
||||
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
|
||||
|
||||
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. 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 4
|
||||
``````````
|
||||
|
||||
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.
|
||||
|
|
|
@ -1,67 +1,104 @@
|
|||
Getting Started
|
||||
===============
|
||||
|
||||
How to ansible
|
||||
|
||||
How to download ansible and get started using it
|
||||
|
||||
.. seealso::
|
||||
|
||||
:doc:`YAMLScripts`
|
||||
Complete documentation of the YAML syntax `ansible` understands.
|
||||
:doc:`examples`
|
||||
Examples of basic commands
|
||||
:doc:`playbooks`
|
||||
Learning ansible's configuration management language
|
||||
|
||||
Requirements
|
||||
````````````
|
||||
|
||||
Requirements for Ansible are extremely minimal.
|
||||
|
||||
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``
|
||||
* ``python-jinja2`` (for playbooks)
|
||||
|
||||
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)
|
||||
|
||||
Developer Requirements
|
||||
``````````````````````
|
||||
|
||||
For developers, you may wish to have:
|
||||
|
||||
* ``asciidoc`` (for building manpage documentation)
|
||||
* ``python-sphinx`` (for building content for the ansible.github.com project only)
|
||||
|
||||
|
||||
What you need
|
||||
-------------
|
||||
Getting Ansible
|
||||
```````````````
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
|
||||
placerat nibh, non feugiat risus varius vitae. Donec eu libero
|
||||
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
|
||||
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
|
||||
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
|
||||
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.
|
||||
Tagged releases are available as tar.gz files from the Ansible github
|
||||
project page:
|
||||
|
||||
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.
|
||||
* `Ansible/downloads <https://github.com/ansible/ansible/downloads>`_
|
||||
|
||||
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.
|
||||
You can also clone the git repository yourself and install Ansible in
|
||||
one of two ways:
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
Python Distutils
|
||||
++++++++++++++++
|
||||
|
||||
You can also install Ansible using Python Distutils::
|
||||
|
||||
$ git clone git://github.com/ansible/ansible.git
|
||||
$ cd ./ansible
|
||||
$ sudo make install
|
||||
|
||||
Via RPM
|
||||
+++++++
|
||||
|
||||
In the near future, pre-built RPMs will be available through your distribution. Until that time you
|
||||
can use the ``make rpm`` command::
|
||||
|
||||
$ git clone git://github.com/ansible/ansible.git
|
||||
$ cd ./ansible
|
||||
$ make rpm
|
||||
$ sudo rpm -Uvh ~/rpmbuild/RPMS/noarch/ansible-1.0-1.noarch.rpm
|
||||
|
||||
Your first commands
|
||||
```````````````````
|
||||
|
||||
Edit /etc/ansible/hosts and put one or more remote systems in it, for which you have your SSH
|
||||
key in ``authorized_keys``::
|
||||
|
||||
192.168.1.50
|
||||
aserver.example.org
|
||||
bserver.example.org
|
||||
|
||||
Set up SSH agent to avoid retyping passwords::
|
||||
|
||||
ssh-agent bash
|
||||
ssh-add ~/.ssh/id_rsa
|
||||
|
||||
Now ping all your nodes::
|
||||
|
||||
ansible all -m ping
|
||||
|
||||
Now run a live command on all of your nodes::
|
||||
|
||||
ansible all /bin/echo hello
|
||||
|
||||
Congratulations. You've just contacted your nodes with Ansible. It's now time to read some
|
||||
of the more real-world examples, and explore what you can do with different modules, as well
|
||||
as the Ansible playbooks language. Ansible is not just about running commands, but you already
|
||||
have a working infrastructure!
|
||||
|
||||
|
|
|
@ -5,102 +5,49 @@
|
|||
Ansible
|
||||
=======
|
||||
|
||||
Ansible is a extra-simple tool/API for doing 'parallel remote things'
|
||||
over SSH -- whether executing commands, running "modules", or
|
||||
executing larger 'playbooks' that can serve as a configuration
|
||||
management or deployment system.
|
||||
Ansible is a radically simple deployment, configuration, and command execution framework.
|
||||
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's core is a little over 1000 lines.
|
||||
|
||||
While `Func installation <http://fedorahosted.org/func>`_ which I
|
||||
co-wrote, aspired to avoid using SSH and have it's own daemon
|
||||
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.
|
||||
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 "playbooks".
|
||||
|
||||
Why use Ansible versus something else? (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
|
||||
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?) 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.
|
||||
Want to only code plugins in bash or clojure? Ansible doesn't care.
|
||||
The docs will fit on one page and the source will be blindingly
|
||||
obvious.
|
||||
|
||||
Systems management doesn't have to be complicated. Ansible's docs will remain
|
||||
short & simple, and the source will be blindingly obvious.
|
||||
|
||||
|
||||
Design Principles
|
||||
`````````````````
|
||||
Design Goals
|
||||
````````````
|
||||
|
||||
* Dead simple setup
|
||||
* 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
|
||||
* 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
|
||||
````````````````````````````
|
||||
|
||||
Requirements
|
||||
````````````
|
||||
Your ideas and contributions are welcome. We're also happy to help you with questions about Ansible.
|
||||
|
||||
Requirements are extremely minimal.
|
||||
* Join the `ansible-project mailing list <http://groups.google.com/group/ansible-project>`_ on Google Groups
|
||||
* Join `#ansible <irc://irc.freenode.net/#ansible>`_ on the `freenode IRC network <http://freenode.net/>`_
|
||||
* Visit the `project page <https://github.com/ansible/ansible>`_ on Github
|
||||
|
||||
If you are running python 2.6 on the **overlord** machine, you will
|
||||
need:
|
||||
- View the `issue tracker <https://github.com/ansible/ansible/issues>`_
|
||||
|
||||
* ``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
|
||||
project page:
|
||||
|
||||
* `Ansible/downloads <https://github.com/ansible/ansible/downloads>`_
|
||||
|
||||
You can also clone the git repository yourself and install Ansible in
|
||||
one of two ways:
|
||||
|
||||
|
||||
Python Distutils
|
||||
++++++++++++++++
|
||||
|
||||
You can install Ansible using Python Distutils::
|
||||
|
||||
$ git clone git://github.com/ansible/ansible.git
|
||||
$ cd ./ansible
|
||||
$ sudo make install
|
||||
|
||||
|
||||
Via RPM
|
||||
+++++++
|
||||
|
||||
In the future, pre-built RPMs may be available. Until that time you
|
||||
can use the ``make rpm`` command::
|
||||
|
||||
$ git clone git://github.com/ansible/ansible.git
|
||||
$ cd ./ansible
|
||||
$ make rpm
|
||||
$ sudo rpm -Uvh ~/rpmbuild/RPMS/noarch/ansible-1.0-1.noarch.rpm
|
||||
|
||||
|
||||
Contents
|
||||
========
|
||||
|
@ -109,21 +56,22 @@ Contents
|
|||
:maxdepth: 3
|
||||
|
||||
gettingstarted
|
||||
YAMLScripts
|
||||
patterns
|
||||
modules
|
||||
playbooks
|
||||
examples
|
||||
modules
|
||||
YAMLScripts
|
||||
playbooks
|
||||
api
|
||||
communicate
|
||||
man
|
||||
|
||||
About the Author
|
||||
````````````````
|
||||
|
||||
Communicate or Get Involved
|
||||
===========================
|
||||
Ansible was originally developed by Michael DeHaan, a Raleigh, NC based software developer and architect.
|
||||
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, a precursor to Ansible, which is used
|
||||
to orchestrate systems in lots of diverse places. He's worked on systems software for
|
||||
IBM, Motorola, Red Hat's Emerging Technologies Group, Puppet Labs, and rPath.
|
||||
|
||||
* Join the `ansible-project mailing list <http://groups.google.com/group/ansible-project>`_ on Google Groups
|
||||
* Join `#ansible <irc://irc.freenode.net/#ansible>`_ on the `freenode IRC network <http://freenode.net/>`_
|
||||
* Visit the `project page <https://github.com/ansible/ansible>`_ on Github
|
||||
|
||||
- View the `issue tracker <https://github.com/ansible/ansible/issues>`_
|
||||
|
|
|
@ -3,19 +3,10 @@
|
|||
Man Pages
|
||||
=========
|
||||
|
||||
Ansile ships with a handfull of manpages to help you on your journey.
|
||||
Ansible's manpage lists available command line options.
|
||||
|
||||
ansible(1)
|
||||
----------
|
||||
|
||||
* `View ansible.1 <man/ansible.1.html>`_
|
||||
|
||||
ansible-modules(5)
|
||||
------------------
|
||||
|
||||
* `View ansible-modules.5 <man/ansible-modules.5.html>`_
|
||||
|
||||
ansible-playbook(5)
|
||||
-------------------
|
||||
|
||||
* `View ansible-playbook.5 <man/ansible-playbook.5.html>`_
|
||||
|
|
|
@ -1,55 +1,199 @@
|
|||
Modules
|
||||
=======
|
||||
Ansible Modules
|
||||
===============
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
|
||||
placerat nibh, non feugiat risus varius vitae. Donec eu libero
|
||||
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
|
||||
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
|
||||
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
|
||||
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.
|
||||
Ansible ships with a number of modules that can be executed directly on remote hosts or through
|
||||
ansible playbooks.
|
||||
|
||||
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.
|
||||
.. seealso::
|
||||
|
||||
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.
|
||||
:doc:`examples`
|
||||
Examples of using modules in /usr/bin/ansible
|
||||
:doc:`playbooks`
|
||||
Examples of using modules with /usr/bin/ansible-playbook
|
||||
:doc:`api`
|
||||
Examples of using modules with the Python API
|
||||
|
||||
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
|
||||
```````
|
||||
|
||||
The command module takes the command name followed by a list of arguments, space delimited.
|
||||
This is the only module that does not use key=value style parameters.
|
||||
|
||||
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.
|
||||
|
||||
|
||||
copy
|
||||
````
|
||||
|
||||
The copy module moves a file on the local box to remote locations.
|
||||
|
||||
*src*::
|
||||
|
||||
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.
|
||||
|
||||
|
||||
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. Playbooks do not actually use
|
||||
this module, they use the 'setup' module behind the scenes.
|
||||
|
||||
|
||||
git
|
||||
```
|
||||
|
||||
Deploys software (or files) 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.
|
||||
|
||||
Playbooks should not call the ohai module, playbooks call the 'setup'
|
||||
module behind the scenes instead.
|
||||
|
||||
ping
|
||||
````
|
||||
|
||||
A trivial test module, this module always returns the integer '1' on
|
||||
successful contact.
|
||||
|
||||
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.
|
||||
|
||||
|
||||
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 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.
|
||||
All variables are then bubbled up to the caller.
|
||||
|
||||
*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. This can be a relative
|
||||
or absolute path.
|
||||
|
||||
*dest*
|
||||
|
||||
location to render the template on the remote server
|
||||
|
||||
|
||||
This module also returns md5sum information about the resultant file.
|
||||
|
||||
|
||||
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::
|
||||
|
||||
{
|
||||
'changed' : True,
|
||||
'something' : 42
|
||||
}
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
|
|
@ -1,55 +1,63 @@
|
|||
Patterns
|
||||
========
|
||||
The Inventory File, Patterns, and Groups
|
||||
========================================
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
|
||||
placerat nibh, non feugiat risus varius vitae. Donec eu libero
|
||||
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
|
||||
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
|
||||
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
|
||||
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.
|
||||
How to select hosts you wish to manage
|
||||
|
||||
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.
|
||||
.. seealso::
|
||||
|
||||
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.
|
||||
:doc:`examples`
|
||||
Examples of basic commands
|
||||
:doc:`playbooks`
|
||||
Learning ansible's configuration management language
|
||||
|
||||
Inventory File Format
|
||||
+++++++++++++++++++++
|
||||
|
||||
Ansible works against multiple systems in your infrastructure at the
|
||||
same time. It does this by selecting portions of systems listed in Ansible's inventory file,
|
||||
which defaults to /etc/ansible/hosts, and looks like this::
|
||||
|
||||
mail.example.com
|
||||
|
||||
[webservers]
|
||||
foo.example.com
|
||||
bar.example.com
|
||||
|
||||
[dbservers]
|
||||
one.example.com
|
||||
two.example.com
|
||||
three.example.com
|
||||
|
||||
|
||||
Selecting Targets
|
||||
+++++++++++++++++
|
||||
|
||||
These patterns target all hosts in the inventory file::
|
||||
|
||||
all
|
||||
*
|
||||
|
||||
It is also possible to address specific hosts::
|
||||
|
||||
one.example.com
|
||||
one.example.com:two.example.com
|
||||
|
||||
|
||||
The following patterns address one or more groups, which are denoted with the bracket
|
||||
headers in the inventory file::
|
||||
|
||||
webservers
|
||||
webservers:dbservers
|
||||
|
||||
Individual hosts, but not groups, can also be referenced using wildcards:
|
||||
|
||||
*.example.com
|
||||
*.com
|
||||
|
||||
It's also ok to mix wildcard patterns and groups at the same time::
|
||||
|
||||
one*.com:dbservers
|
||||
|
||||
NOTE: It is not possible to target a host not in the inventory file.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
|
|
@ -1,55 +1,205 @@
|
|||
Playbooks
|
||||
=========
|
||||
Playbooks: Ansible for Deployment, Configuration Management, and Orchestration
|
||||
==============================================================================
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
|
||||
placerat nibh, non feugiat risus varius vitae. Donec eu libero
|
||||
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
|
||||
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
|
||||
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
|
||||
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.
|
||||
.. seealso::
|
||||
|
||||
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.
|
||||
:doc:`YAMLScripts`
|
||||
Learn about YAML syntax
|
||||
:doc:`modules`
|
||||
Learn about available modules and writing your own
|
||||
:doc:`patterns`
|
||||
Learn about how to select hosts
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
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
|
||||
````````````````
|
||||
|
||||
Playbooks are expressed in YAML format and have a minimum of syntax. Each playbook is composed
|
||||
of one or more 'plays' in a list. By composing a playbook of multiple 'plays', it is possible
|
||||
to orchestrate multi-machine deployments, running certain steps on all machines in
|
||||
the webservers group, then certain steps on the database server group, then more commands
|
||||
back on the webservers group, etc::
|
||||
|
||||
---
|
||||
- hosts: webservers
|
||||
vars:
|
||||
http_port: 80
|
||||
max_clients: 200
|
||||
user: root
|
||||
tasks:
|
||||
- include: base.yml somevar=3 othervar=4
|
||||
- name: write the apache config file
|
||||
action: template src=/srv/httpd.j2 dest=/etc/httpd.conf
|
||||
notify:
|
||||
- restart apache
|
||||
- name: ensure apache is running
|
||||
action: service name=httpd state=started
|
||||
handlers:
|
||||
- include: handlers.yml
|
||||
|
||||
Hosts line
|
||||
``````````
|
||||
|
||||
The hosts line is a list of one or more groups or host patterns, seperated by colons, asdescribed in the 'patterns' documentation. This is just like the first parameter to /usr/bin/ansible.
|
||||
|
||||
Vars section
|
||||
````````````
|
||||
|
||||
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 }}
|
||||
|
||||
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_'. 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,
|
||||
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
|
||||
`````````````````````
|
||||
|
||||
Every task must have a name, which is included in the output from running the playbook.
|
||||
|
||||
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.
|
||||
|
||||
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. 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. 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 (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
|
||||
|
||||
In addition to the explicitly passed in parameters, all variables from the vars section
|
||||
are also available.
|
||||
|
||||
The format of an included list of tasks or handlers looks just like a flat list of tasks. Here
|
||||
is an example of what base.yml might look like::
|
||||
|
||||
---
|
||||
- name: no selinux
|
||||
action: command /usr/sbin/setenforce 0
|
||||
- name: no iptables
|
||||
action: service name=iptables state=stopped
|
||||
- name: this is just to show variables work here, favcolor={{ favcolor }}
|
||||
action: command /bin/true
|
||||
|
||||
As you can see above, variables in include files work just like they do in the main file.
|
||||
Including a variable in the name of a task is a contrived example, you could also
|
||||
pass them to the action command line or use them inside a template file.
|
||||
|
||||
Note that include statements are only usable from the top level playbook file.
|
||||
At this time, includes can not include other includes.
|
||||
|
||||
Using Includes To Assign Classes of Systems
|
||||
```````````````````````````````````````````
|
||||
|
||||
Include files are best used to reuse logic between playbooks. You could imagine
|
||||
a playbook describing your entire infrastructure like this::
|
||||
|
||||
---
|
||||
- hosts: atlanta-webservers
|
||||
vars:
|
||||
datacenter: atlanta
|
||||
tasks:
|
||||
- include: base.yml
|
||||
- include: webservers.yml database=db.atlanta.com
|
||||
handlers:
|
||||
- include: generic-handlers.yml
|
||||
- hosts: atlanta-dbservers
|
||||
vars:
|
||||
datacenter: atlanta
|
||||
tasks:
|
||||
- include: base.yml
|
||||
- include: dbservers.yml
|
||||
handlers:
|
||||
- include: generic-handlers.yml
|
||||
|
||||
There is one (or more) play defined for each group of systems, and each play maps
|
||||
each group includes one or more 'class definitions' telling the systems what they
|
||||
are supposed to do or be.
|
||||
|
||||
Using a common handlers file could allow one task in 'webservers' to define 'restart apache',
|
||||
and it could be reused between multiple plays.
|
||||
|
||||
Variables like 'database' above can be used in templates referenced from the
|
||||
configuration file to generate machine specific variables.
|
||||
|
||||
Asynchronous Actions and Polling
|
||||
````````````````````````````````
|
||||
|
||||
(Information on this feature is pending)
|
||||
|
||||
Executing A Playbook
|
||||
````````````````````
|
||||
|
||||
To run a playbook::
|
||||
|
||||
ansible-playbook playbook.yml
|
||||
|
||||
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.
|
||||
|
|
|
@ -79,6 +79,14 @@ div.sphinxsidebar input {
|
|||
font-size: 1em;
|
||||
}
|
||||
|
||||
div.sphinxsidebar input[type="text"] {
|
||||
width: 170px;
|
||||
}
|
||||
|
||||
div.sphinxsidebar input[type="submit"] {
|
||||
width: 30px;
|
||||
}
|
||||
|
||||
img {
|
||||
border: 0;
|
||||
}
|
||||
|
@ -236,7 +244,6 @@ img.align-center, .figure.align-center, object.align-center {
|
|||
}
|
||||
|
||||
.align-center {
|
||||
clear: both;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
|
|
@ -363,10 +363,13 @@ var Search = {
|
|||
var fullname = (prefix ? prefix + '.' : '') + name;
|
||||
if (fullname.toLowerCase().indexOf(object) > -1) {
|
||||
match = objects[prefix][name];
|
||||
descr = objnames[match[1]] + _(', in ') + titles[match[0]];
|
||||
// XXX the generated anchors are not generally correct
|
||||
// XXX there may be custom prefixes
|
||||
result = [filenames[match[0]], fullname, '#'+fullname, descr];
|
||||
descr = objnames[match[1]][2] + _(', in ') + titles[match[0]];
|
||||
anchor = match[3];
|
||||
if (anchor == '')
|
||||
anchor = fullname;
|
||||
else if (anchor == '-')
|
||||
anchor = objnames[match[1]][1] + '-' + fullname;
|
||||
result = [filenames[match[0]], fullname, '#'+anchor, descr];
|
||||
switch (match[2]) {
|
||||
case 1: objectResults.push(result); break;
|
||||
case 0: importantResults.push(result); break;
|
||||
|
@ -489,7 +492,7 @@ var Search = {
|
|||
listItem.slideDown(5, function() {
|
||||
displayNextItem();
|
||||
});
|
||||
});
|
||||
}, "text");
|
||||
} else {
|
||||
// no source available, just display title
|
||||
Search.output.append(listItem);
|
||||
|
|
153
html/api.html
153
html/api.html
|
@ -7,7 +7,7 @@
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
|
||||
<title>API — Ansible v0.0.1 documentation</title>
|
||||
<title>Using the Python API — Ansible v0.0.1 documentation</title>
|
||||
<link rel="stylesheet" href="_static/default.css" type="text/css" />
|
||||
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
||||
<script type="text/javascript">
|
||||
|
@ -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="Communicate" href="communicate.html" />
|
||||
<link rel="prev" title="Examples" href="examples.html" />
|
||||
<link rel="next" title="Man Pages" href="man.html" />
|
||||
<link rel="prev" title="Playbooks: Ansible for Deployment, Configuration Management, and Orchestration" href="playbooks.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="communicate.html" title="Communicate"
|
||||
<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> »</li>
|
||||
</ul>
|
||||
|
@ -48,56 +48,73 @@
|
|||
<div class="bodywrapper">
|
||||
<div class="body">
|
||||
|
||||
<div class="section" id="api">
|
||||
<h1>API<a class="headerlink" href="#api" title="Permalink to this headline">¶</a></h1>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
|
||||
placerat nibh, non feugiat risus varius vitae. Donec eu libero
|
||||
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
|
||||
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
|
||||
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
|
||||
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 class="section" id="using-the-python-api">
|
||||
<h1>Using the Python API<a class="headerlink" href="#using-the-python-api" title="Permalink to this headline">¶</a></h1>
|
||||
<p>The Python API is very powerful, and is how the ansible CLI and ansible-playbook
|
||||
are implemented.</p>
|
||||
<p>It’s pretty simple:</p>
|
||||
<div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">ansible.runner</span>
|
||||
|
||||
<span class="n">runner</span> <span class="o">=</span> <span class="n">ansible</span><span class="o">.</span><span class="n">runner</span><span class="o">.</span><span class="n">Runner</span><span class="p">(</span>
|
||||
<span class="n">module_name</span><span class="o">=</span><span class="s">'ping'</span><span class="p">,</span>
|
||||
<span class="n">module_args</span><span class="o">=</span><span class="s">''</span><span class="p">,</span>
|
||||
<span class="n">pattern</span><span class="o">=</span><span class="s">'web*'</span><span class="p">,</span>
|
||||
<span class="n">forks</span><span class="o">=</span><span class="mi">10</span>
|
||||
<span class="p">)</span>
|
||||
<span class="n">datastructure</span> <span class="o">=</span> <span class="n">runner</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>The run method returns results per host, grouped by whether they
|
||||
could be contacted or not. Return types are module specific, as
|
||||
expressed in the ‘ansible-modules’ documentation.:</p>
|
||||
<div class="highlight-python"><pre>{
|
||||
"dark" : {
|
||||
"web1.example.com" : "failure message"
|
||||
}
|
||||
"contacted" : {
|
||||
"web2.example.com" : 1
|
||||
}
|
||||
}</pre>
|
||||
</div>
|
||||
<p>A module can return any type of JSON data it wants, so Ansible can
|
||||
be used as a framework to rapidly build powerful applications and scripts.</p>
|
||||
<div class="section" id="detailed-api-example">
|
||||
<h2>Detailed API Example<a class="headerlink" href="#detailed-api-example" title="Permalink to this headline">¶</a></h2>
|
||||
<p>The following script prints out the uptime information for all hosts:</p>
|
||||
<div class="highlight-python"><div class="highlight"><pre><span class="c">#!/usr/bin/python</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">ansible.runner</span>
|
||||
<span class="kn">import</span> <span class="nn">sys</span>
|
||||
|
||||
<span class="c"># construct the ansible runner and execute on all hosts</span>
|
||||
<span class="n">results</span> <span class="o">=</span> <span class="n">ansible</span><span class="o">.</span><span class="n">runner</span><span class="o">.</span><span class="n">Runner</span><span class="p">(</span>
|
||||
<span class="n">pattern</span><span class="o">=</span><span class="s">'*'</span><span class="p">,</span> <span class="n">forks</span><span class="o">=</span><span class="mi">10</span><span class="p">,</span>
|
||||
<span class="n">module_name</span><span class="o">=</span><span class="s">'command'</span><span class="p">,</span> <span class="n">module_args</span><span class="o">=</span><span class="p">[</span><span class="s">'/usr/bin/uptime'</span><span class="p">],</span>
|
||||
<span class="p">)</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">results</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
|
||||
<span class="k">print</span> <span class="s">"No hosts found"</span>
|
||||
<span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
|
||||
|
||||
<span class="k">print</span> <span class="s">"UP ***********"</span>
|
||||
<span class="k">for</span> <span class="p">(</span><span class="n">hostname</span><span class="p">,</span> <span class="n">result</span><span class="p">)</span> <span class="ow">in</span> <span class="n">results</span><span class="p">[</span><span class="s">'contacted'</span><span class="p">]</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="s">'failed'</span> <span class="ow">in</span> <span class="n">result</span><span class="p">:</span>
|
||||
<span class="k">print</span> <span class="s">"</span><span class="si">%s</span><span class="s"> >>> </span><span class="si">%s</span><span class="s">"</span> <span class="o">%</span> <span class="p">(</span><span class="n">hostname</span><span class="p">,</span> <span class="n">result</span><span class="p">[</span><span class="s">'stdout'</span><span class="p">])</span>
|
||||
|
||||
<span class="k">print</span> <span class="s">"FAILED *******"</span>
|
||||
<span class="k">for</span> <span class="p">(</span><span class="n">hostname</span><span class="p">,</span> <span class="n">result</span><span class="p">)</span> <span class="ow">in</span> <span class="n">results</span><span class="p">[</span><span class="s">'contacted'</span><span class="p">]</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
|
||||
<span class="k">if</span> <span class="s">'failed'</span> <span class="ow">in</span> <span class="n">result</span><span class="p">:</span>
|
||||
<span class="k">print</span> <span class="s">"</span><span class="si">%s</span><span class="s"> >>> </span><span class="si">%s</span><span class="s">"</span> <span class="o">%</span> <span class="p">(</span><span class="n">hostname</span><span class="p">,</span> <span class="n">result</span><span class="p">[</span><span class="s">'msg'</span><span class="p">])</span>
|
||||
|
||||
<span class="k">print</span> <span class="s">"DOWN *********"</span>
|
||||
<span class="k">for</span> <span class="p">(</span><span class="n">hostname</span><span class="p">,</span> <span class="n">result</span><span class="p">)</span> <span class="ow">in</span> <span class="n">results</span><span class="p">[</span><span class="s">'dark'</span><span class="p">]</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
|
||||
<span class="k">print</span> <span class="s">"</span><span class="si">%s</span><span class="s"> >>> </span><span class="si">%s</span><span class="s">"</span> <span class="o">%</span> <span class="p">(</span><span class="n">hostname</span><span class="p">,</span> <span class="n">result</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Advanced programmers may also wish to read the source to ansible itself, for
|
||||
it uses the Runner() API (with all available options) to implement the
|
||||
command line tools <tt class="docutils literal"><span class="pre">ansible</span></tt> and <tt class="docutils literal"><span class="pre">ansible-playbook</span></tt>.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -106,12 +123,20 @@ hendrerit mi tincidunt dui fermentum placerat.</p>
|
|||
</div>
|
||||
<div class="sphinxsidebar">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<h3><a href="index.html">Table Of Contents</a></h3>
|
||||
<ul>
|
||||
<li><a class="reference internal" href="#">Using the Python API</a><ul>
|
||||
<li><a class="reference internal" href="#detailed-api-example">Detailed API Example</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<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="communicate.html"
|
||||
title="next chapter">Communicate</a></p>
|
||||
<p class="topless"><a href="man.html"
|
||||
title="next chapter">Man Pages</a></p>
|
||||
<h3>This Page</h3>
|
||||
<ul class="this-page-menu">
|
||||
<li><a href="_sources/api.txt"
|
||||
|
@ -120,7 +145,7 @@ hendrerit mi tincidunt dui fermentum placerat.</p>
|
|||
<div id="searchbox" style="display: none">
|
||||
<h3>Quick search</h3>
|
||||
<form class="search" action="search.html" method="get">
|
||||
<input type="text" name="q" size="18" />
|
||||
<input type="text" name="q" />
|
||||
<input type="submit" value="Go" />
|
||||
<input type="hidden" name="check_keywords" value="yes" />
|
||||
<input type="hidden" name="area" value="default" />
|
||||
|
@ -141,18 +166,18 @@ hendrerit mi tincidunt dui fermentum placerat.</p>
|
|||
<a href="genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="communicate.html" title="Communicate"
|
||||
<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> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer">
|
||||
© Copyright 2012 Michael DeHaan.
|
||||
Last updated on Mar 07, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
|
||||
Last updated on Mar 09, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.8.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,158 +0,0 @@
|
|||
|
||||
|
||||
<!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>Communicate — Ansible v0.0.1 documentation</title>
|
||||
<link rel="stylesheet" href="_static/default.css" type="text/css" />
|
||||
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
||||
<script type="text/javascript">
|
||||
var DOCUMENTATION_OPTIONS = {
|
||||
URL_ROOT: '',
|
||||
VERSION: '0.0.1',
|
||||
COLLAPSE_INDEX: false,
|
||||
FILE_SUFFIX: '.html',
|
||||
HAS_SOURCE: true
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" src="_static/jquery.js"></script>
|
||||
<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="Man Pages" href="man.html" />
|
||||
<link rel="prev" title="API" href="api.html" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="related">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="man.html" title="Man Pages"
|
||||
accesskey="N">next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="api.html" title="API"
|
||||
accesskey="P">previous</a> |</li>
|
||||
<li><a href="index.html">Ansible v0.0.1 documentation</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body">
|
||||
|
||||
<div class="section" id="communicate">
|
||||
<h1>Communicate<a class="headerlink" href="#communicate" title="Permalink to this headline">¶</a></h1>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
|
||||
placerat nibh, non feugiat risus varius vitae. Donec eu libero
|
||||
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
|
||||
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
|
||||
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
|
||||
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>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<h4>Previous topic</h4>
|
||||
<p class="topless"><a href="api.html"
|
||||
title="previous chapter">API</a></p>
|
||||
<h4>Next topic</h4>
|
||||
<p class="topless"><a href="man.html"
|
||||
title="next chapter">Man Pages</a></p>
|
||||
<h3>This Page</h3>
|
||||
<ul class="this-page-menu">
|
||||
<li><a href="_sources/communicate.txt"
|
||||
rel="nofollow">Show Source</a></li>
|
||||
</ul>
|
||||
<div id="searchbox" style="display: none">
|
||||
<h3>Quick search</h3>
|
||||
<form class="search" action="search.html" method="get">
|
||||
<input type="text" name="q" size="18" />
|
||||
<input type="submit" value="Go" />
|
||||
<input type="hidden" name="check_keywords" value="yes" />
|
||||
<input type="hidden" name="area" value="default" />
|
||||
</form>
|
||||
<p class="searchtip" style="font-size: 90%">
|
||||
Enter search terms or a module, class or function name.
|
||||
</p>
|
||||
</div>
|
||||
<script type="text/javascript">$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="man.html" title="Man Pages"
|
||||
>next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="api.html" title="API"
|
||||
>previous</a> |</li>
|
||||
<li><a href="index.html">Ansible v0.0.1 documentation</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer">
|
||||
© Copyright 2012 Michael DeHaan.
|
||||
Last updated on Mar 07, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -7,7 +7,7 @@
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
|
||||
<title>Examples — Ansible v0.0.1 documentation</title>
|
||||
<title>Command Line Examples — Ansible v0.0.1 documentation</title>
|
||||
<link rel="stylesheet" href="_static/default.css" type="text/css" />
|
||||
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
||||
<script type="text/javascript">
|
||||
|
@ -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" 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"
|
||||
<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> »</li>
|
||||
</ul>
|
||||
|
@ -48,70 +48,70 @@
|
|||
<div class="bodywrapper">
|
||||
<div class="body">
|
||||
|
||||
<div class="section" id="examples">
|
||||
<h1>Examples<a class="headerlink" href="#examples" title="Permalink to this headline">¶</a></h1>
|
||||
<div class="section" id="examples-1">
|
||||
<h2>Examples 1<a class="headerlink" href="#examples-1" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
|
||||
placerat nibh, non feugiat risus varius vitae. Donec eu libero
|
||||
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
|
||||
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
|
||||
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
|
||||
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>
|
||||
<div class="section" id="command-line-examples">
|
||||
<h1>Command Line Examples<a class="headerlink" href="#command-line-examples" title="Permalink to this headline">¶</a></h1>
|
||||
<p>The following examples show how to use <cite>/usr/bin/ansible</cite> for running ad-hoc tasks.
|
||||
Start here. For configuration management and deployments, you’ll want to pick up on
|
||||
using <cite>/usr/bin/ansible-playbook</cite> – the concepts port over directly.</p>
|
||||
<div class="admonition-see-also admonition seealso">
|
||||
<p class="first admonition-title">See also</p>
|
||||
<dl class="last docutils">
|
||||
<dt><a class="reference internal" href="modules.html"><em>Ansible Modules</em></a></dt>
|
||||
<dd>A list of available modules</dd>
|
||||
<dt><a class="reference internal" href="playbooks.html"><em>Playbooks: Ansible for Deployment, Configuration Management, and Orchestration</em></a></dt>
|
||||
<dd>Alternative ways to use ansible</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="examples-2">
|
||||
<h2>Examples 2<a class="headerlink" href="#examples-2" title="Permalink to this headline">¶</a></h2>
|
||||
<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>
|
||||
<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>Let’s use ansible’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>
|
||||
<div class="section" id="examples-3">
|
||||
<h2>Examples 3<a class="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>
|
||||
<p>The -f 10 specifies the usage of 10 simultaneous processes.</p>
|
||||
<p>Note that other than the command module, ansible modules do not work like simple scripts. They make the remote system look like you state, and run the commands neccessary to get it there. This is commonly refered to
|
||||
as ‘idempotency’.</p>
|
||||
</div>
|
||||
<div class="section" id="id1">
|
||||
<h2>Examples 3<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h2>
|
||||
<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>
|
||||
<div class="section" id="file-transfer-templating">
|
||||
<h2>File Transfer & 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>
|
||||
<div class="section" id="examples-4">
|
||||
<h2>Examples 4<a class="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>
|
||||
<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 ‘facter’ and ‘ohai’ prefixes for each.</p>
|
||||
</div>
|
||||
<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 ‘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>
|
||||
</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 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’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 ‘copy’ or ‘template’ can be backgrounded. Typically you’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>
|
||||
|
||||
|
@ -123,22 +123,22 @@ hendrerit mi tincidunt dui fermentum placerat.</p>
|
|||
<div class="sphinxsidebarwrapper">
|
||||
<h3><a href="index.html">Table Of Contents</a></h3>
|
||||
<ul>
|
||||
<li><a class="reference internal" href="#">Examples</a><ul>
|
||||
<li><a class="reference internal" href="#examples-1">Examples 1</a></li>
|
||||
<li><a class="reference internal" href="#examples-2">Examples 2</a></li>
|
||||
<li><a class="reference internal" href="#examples-3">Examples 3</a></li>
|
||||
<li><a class="reference internal" href="#id1">Examples 3</a></li>
|
||||
<li><a class="reference internal" href="#examples-4">Examples 4</a></li>
|
||||
<li><a class="reference internal" href="#">Command Line 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="#file-transfer-templating">File Transfer & 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>
|
||||
<li><a class="reference internal" href="#time-limited-background-operations">Time Limited Background Operations</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4>Previous topic</h4>
|
||||
<p class="topless"><a href="playbooks.html"
|
||||
title="previous chapter">Playbooks</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"
|
||||
|
@ -147,7 +147,7 @@ hendrerit mi tincidunt dui fermentum placerat.</p>
|
|||
<div id="searchbox" style="display: none">
|
||||
<h3>Quick search</h3>
|
||||
<form class="search" action="search.html" method="get">
|
||||
<input type="text" name="q" size="18" />
|
||||
<input type="text" name="q" />
|
||||
<input type="submit" value="Go" />
|
||||
<input type="hidden" name="check_keywords" value="yes" />
|
||||
<input type="hidden" name="area" value="default" />
|
||||
|
@ -168,18 +168,18 @@ hendrerit mi tincidunt dui fermentum placerat.</p>
|
|||
<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"
|
||||
<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> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer">
|
||||
© Copyright 2012 Michael DeHaan.
|
||||
Last updated on Mar 07, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
|
||||
Last updated on Mar 09, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.8.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -59,7 +59,7 @@
|
|||
<div id="searchbox" style="display: none">
|
||||
<h3>Quick search</h3>
|
||||
<form class="search" action="search.html" method="get">
|
||||
<input type="text" name="q" size="18" />
|
||||
<input type="text" name="q" />
|
||||
<input type="submit" value="Go" />
|
||||
<input type="hidden" name="check_keywords" value="yes" />
|
||||
<input type="hidden" name="area" value="default" />
|
||||
|
@ -84,8 +84,8 @@
|
|||
</div>
|
||||
<div class="footer">
|
||||
© Copyright 2012 Michael DeHaan.
|
||||
Last updated on Mar 07, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
|
||||
Last updated on Mar 09, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.8.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -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="YAML Scripts" href="YAMLScripts.html" />
|
||||
<link rel="next" title="The Inventory File, Patterns, and Groups" href="patterns.html" />
|
||||
<link rel="prev" title="Ansible" href="index.html" />
|
||||
</head>
|
||||
<body>
|
||||
|
@ -34,7 +34,7 @@
|
|||
<a href="genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="YAMLScripts.html" title="YAML Scripts"
|
||||
<a href="patterns.html" title="The Inventory File, Patterns, and Groups"
|
||||
accesskey="N">next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="index.html" title="Ansible"
|
||||
|
@ -50,64 +50,96 @@
|
|||
|
||||
<div class="section" id="getting-started">
|
||||
<h1>Getting Started<a class="headerlink" href="#getting-started" title="Permalink to this headline">¶</a></h1>
|
||||
<p>How to ansible</p>
|
||||
<p>How to download ansible and get started using it</p>
|
||||
<div class="admonition-see-also admonition seealso">
|
||||
<p class="first admonition-title">See also</p>
|
||||
<dl class="last docutils">
|
||||
<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.</dd>
|
||||
<dt><a class="reference internal" href="examples.html"><em>Command Line Examples</em></a></dt>
|
||||
<dd>Examples of basic commands</dd>
|
||||
<dt><a class="reference internal" href="playbooks.html"><em>Playbooks: Ansible for Deployment, Configuration Management, and Orchestration</em></a></dt>
|
||||
<dd>Learning ansible’s configuration management language</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="what-you-need">
|
||||
<h2>What you need<a class="headerlink" href="#what-you-need" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
|
||||
placerat nibh, non feugiat risus varius vitae. Donec eu libero
|
||||
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
|
||||
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
|
||||
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
|
||||
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 class="section" id="requirements">
|
||||
<h2>Requirements<a class="headerlink" href="#requirements" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Requirements for Ansible are extremely minimal.</p>
|
||||
<p>If you are running python 2.6 on the <strong>overlord</strong> machine (the machine that you’ll be talking to the other machines from), you will need:</p>
|
||||
<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>
|
||||
<li><tt class="docutils literal"><span class="pre">python-jinja2</span></tt> (for playbooks)</li>
|
||||
</ul>
|
||||
<p>If you are running less than Python 2.6, you will also need:</p>
|
||||
<ul class="simple">
|
||||
<li>The Python 2.4 or 2.5 backport of the <tt class="docutils literal"><span class="pre">multiprocessing</span></tt> module<ul>
|
||||
<li><a class="reference external" href="http://code.google.com/p/python-multiprocessing/wiki/Install">Installation and Testing Instructions</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><tt class="docutils literal"><span class="pre">simplejson</span></tt></li>
|
||||
</ul>
|
||||
<p>On the managed nodes, to use templating, you will need:</p>
|
||||
<ul class="simple">
|
||||
<li><tt class="docutils literal"><span class="pre">python-jinja2</span></tt> (you can install this with ansible)</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="developer-requirements">
|
||||
<h2>Developer Requirements<a class="headerlink" href="#developer-requirements" title="Permalink to this headline">¶</a></h2>
|
||||
<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 the ansible.github.com project only)</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="getting-ansible">
|
||||
<h2>Getting Ansible<a class="headerlink" href="#getting-ansible" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Tagged releases are available as tar.gz files from the Ansible github
|
||||
project page:</p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference external" href="https://github.com/ansible/ansible/downloads">Ansible/downloads</a></li>
|
||||
</ul>
|
||||
<p>You can also clone the git repository yourself and install Ansible in
|
||||
one of two ways:</p>
|
||||
<div class="section" id="python-distutils">
|
||||
<h3>Python Distutils<a class="headerlink" href="#python-distutils" title="Permalink to this headline">¶</a></h3>
|
||||
<p>You can also install Ansible using Python Distutils:</p>
|
||||
<div class="highlight-python"><pre>$ git clone git://github.com/ansible/ansible.git
|
||||
$ cd ./ansible
|
||||
$ sudo make install</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="via-rpm">
|
||||
<h3>Via RPM<a class="headerlink" href="#via-rpm" title="Permalink to this headline">¶</a></h3>
|
||||
<p>In the near future, pre-built RPMs will be available through your distribution. Until that time you
|
||||
can use the <tt class="docutils literal"><span class="pre">make</span> <span class="pre">rpm</span></tt> command:</p>
|
||||
<div class="highlight-python"><pre>$ git clone git://github.com/ansible/ansible.git
|
||||
$ cd ./ansible
|
||||
$ make rpm
|
||||
$ sudo rpm -Uvh ~/rpmbuild/RPMS/noarch/ansible-1.0-1.noarch.rpm</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="your-first-commands">
|
||||
<h2>Your first commands<a class="headerlink" href="#your-first-commands" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Edit /etc/ansible/hosts and put one or more remote systems in it, for which you have your SSH
|
||||
key in <tt class="docutils literal"><span class="pre">authorized_keys</span></tt>:</p>
|
||||
<div class="highlight-python"><pre>192.168.1.50
|
||||
aserver.example.org
|
||||
bserver.example.org</pre>
|
||||
</div>
|
||||
<p>Set up SSH agent to avoid retyping passwords:</p>
|
||||
<div class="highlight-python"><pre>ssh-agent bash
|
||||
ssh-add ~/.ssh/id_rsa</pre>
|
||||
</div>
|
||||
<p>Now ping all your nodes:</p>
|
||||
<div class="highlight-python"><pre>ansible all -m ping</pre>
|
||||
</div>
|
||||
<p>Now run a live command on all of your nodes:</p>
|
||||
<div class="highlight-python"><pre>ansible all /bin/echo hello</pre>
|
||||
</div>
|
||||
<p>Congratulations. You’ve just contacted your nodes with Ansible. It’s now time to read some
|
||||
of the more real-world examples, and explore what you can do with different modules, as well
|
||||
as the Ansible playbooks language. Ansible is not just about running commands, but you already
|
||||
have a working infrastructure!</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -120,7 +152,14 @@ hendrerit mi tincidunt dui fermentum placerat.</p>
|
|||
<h3><a href="index.html">Table Of Contents</a></h3>
|
||||
<ul>
|
||||
<li><a class="reference internal" href="#">Getting Started</a><ul>
|
||||
<li><a class="reference internal" href="#what-you-need">What you need</a></li>
|
||||
<li><a class="reference internal" href="#requirements">Requirements</a></li>
|
||||
<li><a class="reference internal" href="#developer-requirements">Developer Requirements</a></li>
|
||||
<li><a class="reference internal" href="#getting-ansible">Getting Ansible</a><ul>
|
||||
<li><a class="reference internal" href="#python-distutils">Python Distutils</a></li>
|
||||
<li><a class="reference internal" href="#via-rpm">Via RPM</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference internal" href="#your-first-commands">Your first commands</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -129,8 +168,8 @@ hendrerit mi tincidunt dui fermentum placerat.</p>
|
|||
<p class="topless"><a href="index.html"
|
||||
title="previous chapter">Ansible</a></p>
|
||||
<h4>Next topic</h4>
|
||||
<p class="topless"><a href="YAMLScripts.html"
|
||||
title="next chapter">YAML Scripts</a></p>
|
||||
<p class="topless"><a href="patterns.html"
|
||||
title="next chapter">The Inventory File, Patterns, and Groups</a></p>
|
||||
<h3>This Page</h3>
|
||||
<ul class="this-page-menu">
|
||||
<li><a href="_sources/gettingstarted.txt"
|
||||
|
@ -139,7 +178,7 @@ hendrerit mi tincidunt dui fermentum placerat.</p>
|
|||
<div id="searchbox" style="display: none">
|
||||
<h3>Quick search</h3>
|
||||
<form class="search" action="search.html" method="get">
|
||||
<input type="text" name="q" size="18" />
|
||||
<input type="text" name="q" />
|
||||
<input type="submit" value="Go" />
|
||||
<input type="hidden" name="check_keywords" value="yes" />
|
||||
<input type="hidden" name="area" value="default" />
|
||||
|
@ -160,7 +199,7 @@ hendrerit mi tincidunt dui fermentum placerat.</p>
|
|||
<a href="genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="YAMLScripts.html" title="YAML Scripts"
|
||||
<a href="patterns.html" title="The Inventory File, Patterns, and Groups"
|
||||
>next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="index.html" title="Ansible"
|
||||
|
@ -170,8 +209,8 @@ hendrerit mi tincidunt dui fermentum placerat.</p>
|
|||
</div>
|
||||
<div class="footer">
|
||||
© Copyright 2012 Michael DeHaan.
|
||||
Last updated on Mar 07, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
|
||||
Last updated on Mar 09, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.8.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
232
html/index.html
232
html/index.html
|
@ -46,128 +46,36 @@
|
|||
|
||||
<div class="section" id="ansible">
|
||||
<h1>Ansible<a class="headerlink" href="#ansible" title="Permalink to this headline">¶</a></h1>
|
||||
<p>Ansible is a extra-simple tool/API for doing ‘parallel remote things’
|
||||
over SSH – whether executing commands, running “modules”, or
|
||||
executing larger ‘playbooks’ that can serve as a configuration
|
||||
management or deployment system.</p>
|
||||
<p>While <a class="reference external" href="http://fedorahosted.org/func">Func installation</a> which I
|
||||
co-wrote, aspired to avoid using SSH and have it’s own daemon
|
||||
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 <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
|
||||
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.
|
||||
Want to only code plugins in bash or clojure? Ansible doesn’t care.
|
||||
The docs will fit on one page and the source will be blindingly
|
||||
obvious.</p>
|
||||
<div class="section" id="design-principles">
|
||||
<h2>Design Principles<a class="headerlink" href="#design-principles" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Ansible is a radically simple deployment, configuration, and command execution framework.
|
||||
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’s core is a little over 1000 lines.</p>
|
||||
<p>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 “playbooks”.</p>
|
||||
<p>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.</p>
|
||||
<p>Why use Ansible versus something else? (Puppet, Chef, Fabric, Capistrano,
|
||||
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.</p>
|
||||
<p>Systems management doesn’t have to be complicated. Ansible’s docs will remain
|
||||
short & 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>
|
||||
<ul class="simple">
|
||||
<li>Dead simple setup</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>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>
|
||||
<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>
|
||||
<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>
|
||||
<li><tt class="docutils literal"><span class="pre">python-jinja2</span></tt> (for playbooks)</li>
|
||||
<li><tt class="docutils literal"><span class="pre">Asciidoc</span></tt> (for building documentation)</li>
|
||||
</ul>
|
||||
<p>If you are running less than Python 2.6, you will also need:</p>
|
||||
<ul class="simple">
|
||||
<li>The Python 2.4 or 2.5 backport of the <tt class="docutils literal"><span class="pre">multiprocessing</span></tt> module<ul>
|
||||
<li><a class="reference external" href="http://code.google.com/p/python-multiprocessing/wiki/Install">Installation and Testing Instructions</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><tt class="docutils literal"><span class="pre">simplejson</span></tt></li>
|
||||
</ul>
|
||||
<p>On the managed nodes, to use templating, you will need:</p>
|
||||
<ul class="simple">
|
||||
<li><tt class="docutils literal"><span class="pre">python-jinja2</span></tt> (you can install this with ansible)</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="getting-ansible">
|
||||
<h2>Getting Ansible<a class="headerlink" href="#getting-ansible" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Tagged releases are available as tar.gz files from the Ansible github
|
||||
project page:</p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference external" href="https://github.com/ansible/ansible/downloads">Ansible/downloads</a></li>
|
||||
</ul>
|
||||
<p>You can also clone the git repository yourself and install Ansible in
|
||||
one of two ways:</p>
|
||||
<div class="section" id="python-distutils">
|
||||
<h3>Python Distutils<a class="headerlink" href="#python-distutils" title="Permalink to this headline">¶</a></h3>
|
||||
<p>You can install Ansible using Python Distutils:</p>
|
||||
<div class="highlight-python"><pre>$ git clone git://github.com/ansible/ansible.git
|
||||
$ cd ./ansible
|
||||
$ sudo make install</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="via-rpm">
|
||||
<h3>Via RPM<a class="headerlink" href="#via-rpm" title="Permalink to this headline">¶</a></h3>
|
||||
<p>In the future, pre-built RPMs may be available. Until that time you
|
||||
can use the <tt class="docutils literal"><span class="pre">make</span> <span class="pre">rpm</span></tt> command:</p>
|
||||
<div class="highlight-python"><pre>$ git clone git://github.com/ansible/ansible.git
|
||||
$ cd ./ansible
|
||||
$ make rpm
|
||||
$ sudo rpm -Uvh ~/rpmbuild/RPMS/noarch/ansible-1.0-1.noarch.rpm</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="contents">
|
||||
<h1>Contents<a class="headerlink" href="#contents" title="Permalink to this headline">¶</a></h1>
|
||||
<div class="toctree-wrapper compound">
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="gettingstarted.html">Getting Started</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="gettingstarted.html#what-you-need">What you need</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="YAMLScripts.html">YAML Scripts</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="YAMLScripts.html#yaml-basics">YAML Basics</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="patterns.html">Patterns</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="modules.html">Modules</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="playbooks.html">Playbooks</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="examples.html">Examples</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="examples.html#examples-1">Examples 1</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="examples.html#examples-2">Examples 2</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="examples.html#examples-3">Examples 3</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="examples.html#id1">Examples 3</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="examples.html#examples-4">Examples 4</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="communicate.html">Communicate</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>
|
||||
<li class="toctree-l2"><a class="reference internal" href="man.html#ansible-modules-5">ansible-modules(5)</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="man.html#ansible-playbook-5">ansible-playbook(5)</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="communicate-or-get-involved">
|
||||
<h1>Communicate or Get Involved<a class="headerlink" href="#communicate-or-get-involved" title="Permalink to this headline">¶</a></h1>
|
||||
<div class="section" id="communicate-and-get-involved">
|
||||
<h2>Communicate and Get Involved<a class="headerlink" href="#communicate-and-get-involved" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Your ideas and contributions are welcome. We’re also happy to help you with questions about Ansible.</p>
|
||||
<ul class="simple">
|
||||
<li>Join the <a class="reference external" href="http://groups.google.com/group/ansible-project">ansible-project mailing list</a> on Google Groups</li>
|
||||
<li>Join <a class="reference external" href="irc://irc.freenode.net/#ansible">#ansible</a> on the <a class="reference external" href="http://freenode.net/">freenode IRC network</a></li>
|
||||
|
@ -176,6 +84,87 @@ $ sudo rpm -Uvh ~/rpmbuild/RPMS/noarch/ansible-1.0-1.noarch.rpm</pre>
|
|||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="contents">
|
||||
<h1>Contents<a class="headerlink" href="#contents" title="Permalink to this headline">¶</a></h1>
|
||||
<div class="toctree-wrapper compound">
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="gettingstarted.html">Getting Started</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="gettingstarted.html#requirements">Requirements</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="gettingstarted.html#developer-requirements">Developer Requirements</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="gettingstarted.html#getting-ansible">Getting Ansible</a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="gettingstarted.html#python-distutils">Python Distutils</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="gettingstarted.html#via-rpm">Via RPM</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="gettingstarted.html#your-first-commands">Your first commands</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="patterns.html">The Inventory File, Patterns, and Groups</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="patterns.html#inventory-file-format">Inventory File Format</a></li>
|
||||
<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">Command Line 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#file-transfer-templating">File Transfer & 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>
|
||||
<li class="toctree-l2"><a class="reference internal" href="examples.html#time-limited-background-operations">Time Limited Background Operations</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#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>
|
||||
<li class="toctree-l2"><a class="reference internal" href="modules.html#git">git</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="modules.html#ohai">ohai</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="modules.html#ping">ping</a></li>
|
||||
<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#writing-your-own-modules">Writing your own modules</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="YAMLScripts.html">YAML Format</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="YAMLScripts.html#yaml-basics">YAML Basics</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="playbooks.html">Playbooks: Ansible for Deployment, Configuration Management, and Orchestration</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="playbooks.html#playbook-example">Playbook Example</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="playbooks.html#hosts-line">Hosts line</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="playbooks.html#vars-section">Vars section</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="playbooks.html#tasks-list">Tasks list</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="playbooks.html#task-name-and-action">Task name and action</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="playbooks.html#notify-statements">Notify statements</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="playbooks.html#handlers">Handlers</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="playbooks.html#includes">Includes</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="playbooks.html#using-includes-to-assign-classes-of-systems">Using Includes To Assign Classes of Systems</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="playbooks.html#asynchronous-actions-and-polling">Asynchronous Actions and Polling</a></li>
|
||||
<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="api.html">Using the Python API</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="api.html#detailed-api-example">Detailed API Example</a></li>
|
||||
</ul>
|
||||
</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>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="about-the-author">
|
||||
<h2>About the Author<a class="headerlink" href="#about-the-author" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Ansible was originally developed by Michael DeHaan, a Raleigh, NC based software developer and architect.
|
||||
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, a precursor to Ansible, which is used
|
||||
to orchestrate systems in lots of diverse places. He’s worked on systems software for
|
||||
IBM, Motorola, Red Hat’s Emerging Technologies Group, Puppet Labs, and rPath.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -187,19 +176,14 @@ $ sudo rpm -Uvh ~/rpmbuild/RPMS/noarch/ansible-1.0-1.noarch.rpm</pre>
|
|||
<h3><a href="#">Table Of Contents</a></h3>
|
||||
<ul>
|
||||
<li><a class="reference internal" href="#">Ansible</a><ul>
|
||||
<li><a class="reference internal" href="#design-principles">Design Principles</a></li>
|
||||
<li><a class="reference internal" href="#requirements">Requirements</a></li>
|
||||
<li><a class="reference internal" href="#getting-ansible">Getting Ansible</a><ul>
|
||||
<li><a class="reference internal" href="#python-distutils">Python Distutils</a></li>
|
||||
<li><a class="reference internal" href="#via-rpm">Via RPM</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference internal" href="#design-goals">Design Goals</a></li>
|
||||
<li><a class="reference internal" href="#communicate-and-get-involved">Communicate and Get Involved</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference internal" href="#contents">Contents</a><ul>
|
||||
<li><a class="reference internal" href="#about-the-author">About the Author</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference internal" href="#communicate-or-get-involved">Communicate or Get Involved</a></li>
|
||||
</ul>
|
||||
|
||||
<h4>Next topic</h4>
|
||||
|
@ -213,7 +197,7 @@ $ sudo rpm -Uvh ~/rpmbuild/RPMS/noarch/ansible-1.0-1.noarch.rpm</pre>
|
|||
<div id="searchbox" style="display: none">
|
||||
<h3>Quick search</h3>
|
||||
<form class="search" action="search.html" method="get">
|
||||
<input type="text" name="q" size="18" />
|
||||
<input type="text" name="q" />
|
||||
<input type="submit" value="Go" />
|
||||
<input type="hidden" name="check_keywords" value="yes" />
|
||||
<input type="hidden" name="area" value="default" />
|
||||
|
@ -241,8 +225,8 @@ $ sudo rpm -Uvh ~/rpmbuild/RPMS/noarch/ansible-1.0-1.noarch.rpm</pre>
|
|||
</div>
|
||||
<div class="footer">
|
||||
© Copyright 2012 Michael DeHaan.
|
||||
Last updated on Mar 07, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
|
||||
Last updated on Mar 09, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.8.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -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="prev" title="Communicate" href="communicate.html" />
|
||||
<link rel="prev" title="Using the Python API" href="api.html" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="related">
|
||||
|
@ -33,7 +33,7 @@
|
|||
<a href="genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="communicate.html" title="Communicate"
|
||||
<a href="api.html" title="Using the Python API"
|
||||
accesskey="P">previous</a> |</li>
|
||||
<li><a href="index.html">Ansible v0.0.1 documentation</a> »</li>
|
||||
</ul>
|
||||
|
@ -46,25 +46,13 @@
|
|||
|
||||
<div class="section" id="man-pages">
|
||||
<span id="man"></span><h1>Man Pages<a class="headerlink" href="#man-pages" title="Permalink to this headline">¶</a></h1>
|
||||
<p>Ansile ships with a handfull of manpages to help you on your journey.</p>
|
||||
<p>Ansible’s manpage lists available command line options.</p>
|
||||
<div class="section" id="ansible-1">
|
||||
<h2>ansible(1)<a class="headerlink" href="#ansible-1" title="Permalink to this headline">¶</a></h2>
|
||||
<ul class="simple">
|
||||
<li><a class="reference external" href="man/ansible.1.html">View ansible.1</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="ansible-modules-5">
|
||||
<h2>ansible-modules(5)<a class="headerlink" href="#ansible-modules-5" title="Permalink to this headline">¶</a></h2>
|
||||
<ul class="simple">
|
||||
<li><a class="reference external" href="man/ansible-modules.5.html">View ansible-modules.5</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="ansible-playbook-5">
|
||||
<h2>ansible-playbook(5)<a class="headerlink" href="#ansible-playbook-5" title="Permalink to this headline">¶</a></h2>
|
||||
<ul class="simple">
|
||||
<li><a class="reference external" href="man/ansible-playbook.5.html">View ansible-playbook.5</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -77,15 +65,13 @@
|
|||
<ul>
|
||||
<li><a class="reference internal" href="#">Man Pages</a><ul>
|
||||
<li><a class="reference internal" href="#ansible-1">ansible(1)</a></li>
|
||||
<li><a class="reference internal" href="#ansible-modules-5">ansible-modules(5)</a></li>
|
||||
<li><a class="reference internal" href="#ansible-playbook-5">ansible-playbook(5)</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4>Previous topic</h4>
|
||||
<p class="topless"><a href="communicate.html"
|
||||
title="previous chapter">Communicate</a></p>
|
||||
<p class="topless"><a href="api.html"
|
||||
title="previous chapter">Using the Python API</a></p>
|
||||
<h3>This Page</h3>
|
||||
<ul class="this-page-menu">
|
||||
<li><a href="_sources/man.txt"
|
||||
|
@ -94,7 +80,7 @@
|
|||
<div id="searchbox" style="display: none">
|
||||
<h3>Quick search</h3>
|
||||
<form class="search" action="search.html" method="get">
|
||||
<input type="text" name="q" size="18" />
|
||||
<input type="text" name="q" />
|
||||
<input type="submit" value="Go" />
|
||||
<input type="hidden" name="check_keywords" value="yes" />
|
||||
<input type="hidden" name="area" value="default" />
|
||||
|
@ -115,15 +101,15 @@
|
|||
<a href="genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="communicate.html" title="Communicate"
|
||||
<a href="api.html" title="Using the Python API"
|
||||
>previous</a> |</li>
|
||||
<li><a href="index.html">Ansible v0.0.1 documentation</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer">
|
||||
© Copyright 2012 Michael DeHaan.
|
||||
Last updated on Mar 07, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
|
||||
Last updated on Mar 09, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.8.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -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" type="text/css" href="./docbook-xsl.css" /><meta name="generator" content="DocBook XSL Stylesheets V1.76.1" /></head><body><div xml:lang="en" class="refentry" title="ansible-modules" lang="en"><a id="id327073"></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="id373277"></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" type="text/css" href="./docbook-xsl.css" /><meta name="generator" content="DocBook XSL Stylesheets V1.76.1" /></head><body><div xml:lang="en" class="refentry" title="ansible-modules" lang="en"><a id="id458930"></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="id303952"></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" type="text/css" href="./docbook-xsl.css" /><meta name="generator" content="DocBook XSL Stylesheets V1.76.1" /></head><body><div xml:lang="en" class="refentry" title="ansible" lang="en"><a id="id355813"></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 <host-pattern> [-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="id547970"></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 <host-pattern> [-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>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
|
||||
<title>Modules — Ansible v0.0.1 documentation</title>
|
||||
<title>Ansible Modules — Ansible v0.0.1 documentation</title>
|
||||
<link rel="stylesheet" href="_static/default.css" type="text/css" />
|
||||
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
||||
<script type="text/javascript">
|
||||
|
@ -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="Playbooks" href="playbooks.html" />
|
||||
<link rel="prev" title="Patterns" href="patterns.html" />
|
||||
<link rel="next" title="YAML Format" href="YAMLScripts.html" />
|
||||
<link rel="prev" title="Command Line Examples" href="examples.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="playbooks.html" title="Playbooks"
|
||||
<a href="YAMLScripts.html" title="YAML Format"
|
||||
accesskey="N">next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="patterns.html" title="Patterns"
|
||||
<a href="examples.html" title="Command Line Examples"
|
||||
accesskey="P">previous</a> |</li>
|
||||
<li><a href="index.html">Ansible v0.0.1 documentation</a> »</li>
|
||||
</ul>
|
||||
|
@ -48,56 +48,147 @@
|
|||
<div class="bodywrapper">
|
||||
<div class="body">
|
||||
|
||||
<div class="section" id="modules">
|
||||
<h1>Modules<a class="headerlink" href="#modules" title="Permalink to this headline">¶</a></h1>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
|
||||
placerat nibh, non feugiat risus varius vitae. Donec eu libero
|
||||
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
|
||||
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
|
||||
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
|
||||
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 class="section" id="ansible-modules">
|
||||
<h1>Ansible Modules<a class="headerlink" href="#ansible-modules" title="Permalink to this headline">¶</a></h1>
|
||||
<p>Ansible ships with a number of modules that can be executed directly on remote hosts or through
|
||||
ansible playbooks.</p>
|
||||
<div class="admonition-see-also admonition seealso">
|
||||
<p class="first admonition-title">See also</p>
|
||||
<dl class="last docutils">
|
||||
<dt><a class="reference internal" href="examples.html"><em>Command Line Examples</em></a></dt>
|
||||
<dd>Examples of using modules in /usr/bin/ansible</dd>
|
||||
<dt><a class="reference internal" href="playbooks.html"><em>Playbooks: Ansible for Deployment, Configuration Management, and Orchestration</em></a></dt>
|
||||
<dd>Examples of using modules with /usr/bin/ansible-playbook</dd>
|
||||
<dt><a class="reference internal" href="api.html"><em>Using the Python API</em></a></dt>
|
||||
<dd>Examples of using modules with the Python API</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<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’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>
|
||||
<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.
|
||||
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 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>This module also returns md5sum information about the resultant file.</p>
|
||||
</div>
|
||||
<div class="section" id="facter">
|
||||
<h2>facter<a class="headerlink" href="#facter" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Runs the discovery program ‘facter’ on the remote system, returning
|
||||
JSON data that can be useful for inventory purposes.</p>
|
||||
<p>Requires that ‘facter’ and ‘ruby-json’ be installed on the remote end.</p>
|
||||
<p>This module is informative only - it takes no parameters & does not support change hooks,
|
||||
nor does it make any changes on the system. Playbooks do not actually use
|
||||
this module, they use the ‘setup’ 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 (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>
|
||||
<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>
|
||||
<div class="section" id="ohai">
|
||||
<h2>ohai<a class="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>
|
||||
<p>Playbooks should not call the ohai module, playbooks call the ‘setup’
|
||||
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 ‘1’ on
|
||||
successful contact.</p>
|
||||
<p>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.</p>
|
||||
</div>
|
||||
<div class="section" id="service">
|
||||
<h2>service<a class="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>
|
||||
<div class="section" id="setup">
|
||||
<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 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 ‘<a class="reference internal" href="#facter">facter</a>‘ and ‘<a class="reference internal" href="#ohai">ohai</a>” so it’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>
|
||||
</div>
|
||||
<div class="section" id="template">
|
||||
<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. 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>This module also returns md5sum information about the resultant file.</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>
|
||||
<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.</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">'changed'</span> <span class="p">:</span> <span class="bp">True</span><span class="p">,</span>
|
||||
<span class="s">'something'</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 ‘failure’
|
||||
element with a True value, and a ‘msg’ element describing the nature of the failure.
|
||||
Other return values are up to the module.</p>
|
||||
<blockquote>
|
||||
<div><dl class="docutils">
|
||||
<dt>{</dt>
|
||||
<dd>‘failure’ : True,
|
||||
‘msg’ : “here is what happened...”</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>
|
||||
|
||||
|
||||
|
@ -106,12 +197,29 @@ hendrerit mi tincidunt dui fermentum placerat.</p>
|
|||
</div>
|
||||
<div class="sphinxsidebar">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<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="#command">command</a></li>
|
||||
<li><a class="reference internal" href="#copy">copy</a></li>
|
||||
<li><a class="reference internal" href="#facter">facter</a></li>
|
||||
<li><a class="reference internal" href="#git">git</a></li>
|
||||
<li><a class="reference internal" href="#ohai">ohai</a></li>
|
||||
<li><a class="reference internal" href="#ping">ping</a></li>
|
||||
<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="#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">Patterns</a></p>
|
||||
<p class="topless"><a href="examples.html"
|
||||
title="previous chapter">Command Line Examples</a></p>
|
||||
<h4>Next topic</h4>
|
||||
<p class="topless"><a href="playbooks.html"
|
||||
title="next chapter">Playbooks</a></p>
|
||||
<p class="topless"><a href="YAMLScripts.html"
|
||||
title="next chapter">YAML Format</a></p>
|
||||
<h3>This Page</h3>
|
||||
<ul class="this-page-menu">
|
||||
<li><a href="_sources/modules.txt"
|
||||
|
@ -120,7 +228,7 @@ hendrerit mi tincidunt dui fermentum placerat.</p>
|
|||
<div id="searchbox" style="display: none">
|
||||
<h3>Quick search</h3>
|
||||
<form class="search" action="search.html" method="get">
|
||||
<input type="text" name="q" size="18" />
|
||||
<input type="text" name="q" />
|
||||
<input type="submit" value="Go" />
|
||||
<input type="hidden" name="check_keywords" value="yes" />
|
||||
<input type="hidden" name="area" value="default" />
|
||||
|
@ -141,18 +249,18 @@ hendrerit mi tincidunt dui fermentum placerat.</p>
|
|||
<a href="genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="playbooks.html" title="Playbooks"
|
||||
<a href="YAMLScripts.html" title="YAML Format"
|
||||
>next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="patterns.html" title="Patterns"
|
||||
<a href="examples.html" title="Command Line Examples"
|
||||
>previous</a> |</li>
|
||||
<li><a href="index.html">Ansible v0.0.1 documentation</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer">
|
||||
© Copyright 2012 Michael DeHaan.
|
||||
Last updated on Mar 07, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
|
||||
Last updated on Mar 09, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.8.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -7,7 +7,7 @@
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
|
||||
<title>Patterns — Ansible v0.0.1 documentation</title>
|
||||
<title>The Inventory File, Patterns, and Groups — Ansible v0.0.1 documentation</title>
|
||||
<link rel="stylesheet" href="_static/default.css" type="text/css" />
|
||||
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
||||
<script type="text/javascript">
|
||||
|
@ -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="Modules" href="modules.html" />
|
||||
<link rel="prev" title="YAML Scripts" href="YAMLScripts.html" />
|
||||
<link rel="next" title="Command Line Examples" href="examples.html" />
|
||||
<link rel="prev" title="Getting Started" href="gettingstarted.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="modules.html" title="Modules"
|
||||
<a href="examples.html" title="Command Line Examples"
|
||||
accesskey="N">next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="YAMLScripts.html" title="YAML Scripts"
|
||||
<a href="gettingstarted.html" title="Getting Started"
|
||||
accesskey="P">previous</a> |</li>
|
||||
<li><a href="index.html">Ansible v0.0.1 documentation</a> »</li>
|
||||
</ul>
|
||||
|
@ -48,56 +48,60 @@
|
|||
<div class="bodywrapper">
|
||||
<div class="body">
|
||||
|
||||
<div class="section" id="patterns">
|
||||
<h1>Patterns<a class="headerlink" href="#patterns" title="Permalink to this headline">¶</a></h1>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
|
||||
placerat nibh, non feugiat risus varius vitae. Donec eu libero
|
||||
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
|
||||
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
|
||||
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
|
||||
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 class="section" id="the-inventory-file-patterns-and-groups">
|
||||
<h1>The Inventory File, Patterns, and Groups<a class="headerlink" href="#the-inventory-file-patterns-and-groups" title="Permalink to this headline">¶</a></h1>
|
||||
<p>How to select hosts you wish to manage</p>
|
||||
<div class="admonition-see-also admonition seealso">
|
||||
<p class="first admonition-title">See also</p>
|
||||
<dl class="last docutils">
|
||||
<dt><a class="reference internal" href="examples.html"><em>Command Line Examples</em></a></dt>
|
||||
<dd>Examples of basic commands</dd>
|
||||
<dt><a class="reference internal" href="playbooks.html"><em>Playbooks: Ansible for Deployment, Configuration Management, and Orchestration</em></a></dt>
|
||||
<dd>Learning ansible’s configuration management language</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="inventory-file-format">
|
||||
<h2>Inventory File Format<a class="headerlink" href="#inventory-file-format" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Ansible works against multiple systems in your infrastructure at the
|
||||
same time. It does this by selecting portions of systems listed in Ansible’s inventory file,
|
||||
which defaults to /etc/ansible/hosts, and looks like this:</p>
|
||||
<div class="highlight-python"><div class="highlight"><pre><span class="n">mail</span><span class="o">.</span><span class="n">example</span><span class="o">.</span><span class="n">com</span>
|
||||
|
||||
<span class="p">[</span><span class="n">webservers</span><span class="p">]</span>
|
||||
<span class="n">foo</span><span class="o">.</span><span class="n">example</span><span class="o">.</span><span class="n">com</span>
|
||||
<span class="n">bar</span><span class="o">.</span><span class="n">example</span><span class="o">.</span><span class="n">com</span>
|
||||
|
||||
<span class="p">[</span><span class="n">dbservers</span><span class="p">]</span>
|
||||
<span class="n">one</span><span class="o">.</span><span class="n">example</span><span class="o">.</span><span class="n">com</span>
|
||||
<span class="n">two</span><span class="o">.</span><span class="n">example</span><span class="o">.</span><span class="n">com</span>
|
||||
<span class="n">three</span><span class="o">.</span><span class="n">example</span><span class="o">.</span><span class="n">com</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="selecting-targets">
|
||||
<h2>Selecting Targets<a class="headerlink" href="#selecting-targets" title="Permalink to this headline">¶</a></h2>
|
||||
<p>These patterns target all hosts in the inventory file:</p>
|
||||
<div class="highlight-python"><pre>all
|
||||
*</pre>
|
||||
</div>
|
||||
<p>It is also possible to address specific hosts:</p>
|
||||
<div class="highlight-python"><pre>one.example.com
|
||||
one.example.com:two.example.com</pre>
|
||||
</div>
|
||||
<p>The following patterns address one or more groups, which are denoted with the bracket
|
||||
headers in the inventory file:</p>
|
||||
<div class="highlight-python"><pre>webservers
|
||||
webservers:dbservers</pre>
|
||||
</div>
|
||||
<p>Individual hosts, but not groups, can also be referenced using wildcards:</p>
|
||||
<blockquote>
|
||||
<div><a href="#id1"><span class="problematic" id="id2">*</span></a>.example.com
|
||||
<a href="#id3"><span class="problematic" id="id4">*</span></a>.com</div></blockquote>
|
||||
<p>It’s also ok to mix wildcard patterns and groups at the same time:</p>
|
||||
<div class="highlight-python"><pre>one*.com:dbservers</pre>
|
||||
</div>
|
||||
<p>NOTE: It is not possible to target a host not in the inventory file.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -106,12 +110,21 @@ hendrerit mi tincidunt dui fermentum placerat.</p>
|
|||
</div>
|
||||
<div class="sphinxsidebar">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<h3><a href="index.html">Table Of Contents</a></h3>
|
||||
<ul>
|
||||
<li><a class="reference internal" href="#">The Inventory File, Patterns, and Groups</a><ul>
|
||||
<li><a class="reference internal" href="#inventory-file-format">Inventory File Format</a></li>
|
||||
<li><a class="reference internal" href="#selecting-targets">Selecting Targets</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4>Previous topic</h4>
|
||||
<p class="topless"><a href="YAMLScripts.html"
|
||||
title="previous chapter">YAML Scripts</a></p>
|
||||
<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">Modules</a></p>
|
||||
<p class="topless"><a href="examples.html"
|
||||
title="next chapter">Command Line Examples</a></p>
|
||||
<h3>This Page</h3>
|
||||
<ul class="this-page-menu">
|
||||
<li><a href="_sources/patterns.txt"
|
||||
|
@ -120,7 +133,7 @@ hendrerit mi tincidunt dui fermentum placerat.</p>
|
|||
<div id="searchbox" style="display: none">
|
||||
<h3>Quick search</h3>
|
||||
<form class="search" action="search.html" method="get">
|
||||
<input type="text" name="q" size="18" />
|
||||
<input type="text" name="q" />
|
||||
<input type="submit" value="Go" />
|
||||
<input type="hidden" name="check_keywords" value="yes" />
|
||||
<input type="hidden" name="area" value="default" />
|
||||
|
@ -141,18 +154,18 @@ hendrerit mi tincidunt dui fermentum placerat.</p>
|
|||
<a href="genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="modules.html" title="Modules"
|
||||
<a href="examples.html" title="Command Line Examples"
|
||||
>next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="YAMLScripts.html" title="YAML Scripts"
|
||||
<a href="gettingstarted.html" title="Getting Started"
|
||||
>previous</a> |</li>
|
||||
<li><a href="index.html">Ansible v0.0.1 documentation</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer">
|
||||
© Copyright 2012 Michael DeHaan.
|
||||
Last updated on Mar 07, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
|
||||
Last updated on Mar 09, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.8.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -7,7 +7,7 @@
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
|
||||
<title>Playbooks — Ansible v0.0.1 documentation</title>
|
||||
<title>Playbooks: Ansible for Deployment, Configuration Management, and Orchestration — Ansible v0.0.1 documentation</title>
|
||||
<link rel="stylesheet" href="_static/default.css" type="text/css" />
|
||||
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
||||
<script type="text/javascript">
|
||||
|
@ -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="Examples" href="examples.html" />
|
||||
<link rel="prev" title="Modules" href="modules.html" />
|
||||
<link rel="next" title="Using the Python API" href="api.html" />
|
||||
<link rel="prev" title="YAML Format" href="YAMLScripts.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="examples.html" title="Examples"
|
||||
<a href="api.html" title="Using the Python API"
|
||||
accesskey="N">next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="modules.html" title="Modules"
|
||||
<a href="YAMLScripts.html" title="YAML Format"
|
||||
accesskey="P">previous</a> |</li>
|
||||
<li><a href="index.html">Ansible v0.0.1 documentation</a> »</li>
|
||||
</ul>
|
||||
|
@ -48,56 +48,181 @@
|
|||
<div class="bodywrapper">
|
||||
<div class="body">
|
||||
|
||||
<div class="section" id="playbooks">
|
||||
<h1>Playbooks<a class="headerlink" href="#playbooks" title="Permalink to this headline">¶</a></h1>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
|
||||
placerat nibh, non feugiat risus varius vitae. Donec eu libero
|
||||
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
|
||||
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
|
||||
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
|
||||
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 class="section" id="playbooks-ansible-for-deployment-configuration-management-and-orchestration">
|
||||
<h1>Playbooks: Ansible for Deployment, Configuration Management, and Orchestration<a class="headerlink" href="#playbooks-ansible-for-deployment-configuration-management-and-orchestration" title="Permalink to this headline">¶</a></h1>
|
||||
<div class="admonition-see-also admonition seealso">
|
||||
<p class="first admonition-title">See also</p>
|
||||
<dl class="last docutils">
|
||||
<dt><a class="reference internal" href="YAMLScripts.html"><em>YAML Format</em></a></dt>
|
||||
<dd>Learn about YAML syntax</dd>
|
||||
<dt><a class="reference internal" href="modules.html"><em>Ansible Modules</em></a></dt>
|
||||
<dd>Learn about available modules and writing your own</dd>
|
||||
<dt><a class="reference internal" href="patterns.html"><em>The Inventory File, Patterns, and Groups</em></a></dt>
|
||||
<dd>Learn about how to select hosts</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<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
|
||||
of one or more ‘plays’ in a list. By composing a playbook of multiple ‘plays’, it is possible
|
||||
to orchestrate multi-machine deployments, running certain steps on all machines in
|
||||
the webservers group, then certain steps on the database server group, then more commands
|
||||
back on the webservers group, etc:</p>
|
||||
<div class="highlight-python"><pre>---
|
||||
- hosts: webservers
|
||||
vars:
|
||||
http_port: 80
|
||||
max_clients: 200
|
||||
user: root
|
||||
tasks:
|
||||
- include: base.yml somevar=3 othervar=4
|
||||
- name: write the apache config file
|
||||
action: template src=/srv/httpd.j2 dest=/etc/httpd.conf
|
||||
notify:
|
||||
- restart apache
|
||||
- name: ensure apache is running
|
||||
action: service name=httpd state=started
|
||||
handlers:
|
||||
- include: handlers.yml</pre>
|
||||
</div>
|
||||
</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 a list of one or more groups or host patterns, seperated by colons, asdescribed in the ‘patterns’ 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 and values that can be used in the plays. These can be used in templates
|
||||
or ‘action’ lines and are dereferenced using <tt class="docutils literal"><span class="pre">`jinja2`</span></tt> syntax like this:</p>
|
||||
<div class="highlight-python"><pre>{{ varname }}</pre>
|
||||
</div>
|
||||
<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 ‘<a href="#id1"><span class="problematic" id="id2">facter_</span></a>‘
|
||||
and Ohai variables are prefixed with ‘<a href="#id3"><span class="problematic" id="id4">ohai_</span></a>‘. So for instance, if I wanted to write the
|
||||
hostname into the /etc/motd file, I could say:</p>
|
||||
<div class="highlight-python"><pre>- name: write the motd
|
||||
- action: template src=/srv/templates/motd.j2 dest=/etc/motd</pre>
|
||||
</div>
|
||||
<p>And in /srv/templates/motd.j2:</p>
|
||||
<div class="highlight-python"><pre>You are logged into {{ facter_hostname }}</pre>
|
||||
</div>
|
||||
<p>But we’re getting ahead of ourselves. Let’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’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>
|
||||
<p>Every task must have a name, which is included in the output from running the playbook.</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’s I know silly ... you could
|
||||
do it like so:</p>
|
||||
<div class="highlight-python"><pre>- name: make a directory
|
||||
- action: mkdir /tmp/{{ facter_hostname }}</pre>
|
||||
</div>
|
||||
</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 ‘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. 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. 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 (assume a variable named ‘user’):</p>
|
||||
<div class="highlight-python"><pre>{{ user }}</pre>
|
||||
</div>
|
||||
<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>
|
||||
<div class="highlight-python"><pre>- tasks:
|
||||
- include: wordpress.yml user=timmy
|
||||
- include: wordpress.yml user=alice
|
||||
- include: wordpress.yml user=bob</pre>
|
||||
</div>
|
||||
<p>In addition to the explicitly passed in parameters, all variables from the vars section
|
||||
are also available.</p>
|
||||
<p>The format of an included list of tasks or handlers looks just like a flat list of tasks. Here
|
||||
is an example of what base.yml might look like:</p>
|
||||
<div class="highlight-python"><pre>---
|
||||
- name: no selinux
|
||||
action: command /usr/sbin/setenforce 0
|
||||
- name: no iptables
|
||||
action: service name=iptables state=stopped
|
||||
- name: this is just to show variables work here, favcolor={{ favcolor }}
|
||||
action: command /bin/true</pre>
|
||||
</div>
|
||||
<p>As you can see above, variables in include files work just like they do in the main file.
|
||||
Including a variable in the name of a task is a contrived example, you could also
|
||||
pass them to the action command line or use them inside a template file.</p>
|
||||
<p>Note that include statements are only usable from the top level playbook file.
|
||||
At this time, includes can not include other includes.</p>
|
||||
</div>
|
||||
<div class="section" id="using-includes-to-assign-classes-of-systems">
|
||||
<h2>Using Includes To Assign Classes of Systems<a class="headerlink" href="#using-includes-to-assign-classes-of-systems" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Include files are best used to reuse logic between playbooks. You could imagine
|
||||
a playbook describing your entire infrastructure like this:</p>
|
||||
<div class="highlight-python"><pre>---
|
||||
- hosts: atlanta-webservers
|
||||
vars:
|
||||
datacenter: atlanta
|
||||
tasks:
|
||||
- include: base.yml
|
||||
- include: webservers.yml database=db.atlanta.com
|
||||
handlers:
|
||||
- include: generic-handlers.yml
|
||||
- hosts: atlanta-dbservers
|
||||
vars:
|
||||
datacenter: atlanta
|
||||
tasks:
|
||||
- include: base.yml
|
||||
- include: dbservers.yml
|
||||
handlers:
|
||||
- include: generic-handlers.yml</pre>
|
||||
</div>
|
||||
<p>There is one (or more) play defined for each group of systems, and each play maps
|
||||
each group includes one or more ‘class definitions’ telling the systems what they
|
||||
are supposed to do or be.</p>
|
||||
<p>Using a common handlers file could allow one task in ‘webservers’ to define ‘restart apache’,
|
||||
and it could be reused between multiple plays.</p>
|
||||
<p>Variables like ‘database’ above can be used in templates referenced from the
|
||||
configuration file to generate machine specific variables.</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>
|
||||
<p>(Information on this feature is pending)</p>
|
||||
</div>
|
||||
<div class="section" id="executing-a-playbook">
|
||||
<h2>Executing A Playbook<a class="headerlink" href="#executing-a-playbook" title="Permalink to this headline">¶</a></h2>
|
||||
<p>To run a playbook:</p>
|
||||
<div class="highlight-python"><pre>ansible-playbook playbook.yml</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -106,12 +231,30 @@ hendrerit mi tincidunt dui fermentum placerat.</p>
|
|||
</div>
|
||||
<div class="sphinxsidebar">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<h3><a href="index.html">Table Of Contents</a></h3>
|
||||
<ul>
|
||||
<li><a class="reference internal" href="#">Playbooks: Ansible for Deployment, Configuration Management, and Orchestration</a><ul>
|
||||
<li><a class="reference internal" href="#playbook-example">Playbook Example</a></li>
|
||||
<li><a class="reference internal" href="#hosts-line">Hosts line</a></li>
|
||||
<li><a class="reference internal" href="#vars-section">Vars section</a></li>
|
||||
<li><a class="reference internal" href="#tasks-list">Tasks list</a></li>
|
||||
<li><a class="reference internal" href="#task-name-and-action">Task name and action</a></li>
|
||||
<li><a class="reference internal" href="#notify-statements">Notify statements</a></li>
|
||||
<li><a class="reference internal" href="#handlers">Handlers</a></li>
|
||||
<li><a class="reference internal" href="#includes">Includes</a></li>
|
||||
<li><a class="reference internal" href="#using-includes-to-assign-classes-of-systems">Using Includes To Assign Classes of Systems</a></li>
|
||||
<li><a class="reference internal" href="#asynchronous-actions-and-polling">Asynchronous Actions and Polling</a></li>
|
||||
<li><a class="reference internal" href="#executing-a-playbook">Executing A Playbook</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4>Previous topic</h4>
|
||||
<p class="topless"><a href="modules.html"
|
||||
title="previous chapter">Modules</a></p>
|
||||
<p class="topless"><a href="YAMLScripts.html"
|
||||
title="previous chapter">YAML Format</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">Using the Python API</a></p>
|
||||
<h3>This Page</h3>
|
||||
<ul class="this-page-menu">
|
||||
<li><a href="_sources/playbooks.txt"
|
||||
|
@ -120,7 +263,7 @@ hendrerit mi tincidunt dui fermentum placerat.</p>
|
|||
<div id="searchbox" style="display: none">
|
||||
<h3>Quick search</h3>
|
||||
<form class="search" action="search.html" method="get">
|
||||
<input type="text" name="q" size="18" />
|
||||
<input type="text" name="q" />
|
||||
<input type="submit" value="Go" />
|
||||
<input type="hidden" name="check_keywords" value="yes" />
|
||||
<input type="hidden" name="area" value="default" />
|
||||
|
@ -141,18 +284,18 @@ hendrerit mi tincidunt dui fermentum placerat.</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="Using the Python API"
|
||||
>next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="modules.html" title="Modules"
|
||||
<a href="YAMLScripts.html" title="YAML Format"
|
||||
>previous</a> |</li>
|
||||
<li><a href="index.html">Ansible v0.0.1 documentation</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer">
|
||||
© Copyright 2012 Michael DeHaan.
|
||||
Last updated on Mar 07, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
|
||||
Last updated on Mar 09, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.8.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -90,8 +90,8 @@
|
|||
</div>
|
||||
<div class="footer">
|
||||
© Copyright 2012 Michael DeHaan.
|
||||
Last updated on Mar 07, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
|
||||
Last updated on Mar 09, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.8.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
File diff suppressed because one or more lines are too long
|
@ -1,20 +1,21 @@
|
|||
YAML Scripts
|
||||
============
|
||||
|
||||
This page provides a basic overview of correct YAML syntax.
|
||||
YAML Format
|
||||
===========
|
||||
|
||||
This page provides a basic overview of correct YAML syntax, which is how Ansible
|
||||
playbooks (our configuration management language) are expressed.
|
||||
You may also wish to read playbook examples and will quickly pick this up from those.
|
||||
|
||||
YAML Basics
|
||||
-----------
|
||||
|
||||
For `ansible`, every YAML script must be a list at it's root-most
|
||||
For `ansible`, every YAML file must be a list at it's root-most
|
||||
element. Each item in the list is a dictionary. These dictionaries
|
||||
represent all the options you can use to write a `ansible` script. In
|
||||
represent all the options you can use to write an `ansible` file. In
|
||||
addition, all YAML files (regardless of their association with
|
||||
`ansible` or not) should start with ``---``.
|
||||
|
||||
In YAML a list can be represented in two ways. In one way all members
|
||||
of a list are lines beginning at the same indentation level starting
|
||||
of a list are lines beginning at the same indenta`tion level starting
|
||||
with a ``-`` character::
|
||||
|
||||
---
|
||||
|
@ -74,7 +75,7 @@ Finally, you can combine these data structures::
|
|||
dotnet: Lame
|
||||
|
||||
That's all you really need to know about YAML to get started writing
|
||||
`Ansible` scripts.
|
||||
`Ansible` playbooks.
|
||||
|
||||
.. seealso::
|
||||
|
||||
|
|
118
rst/api.rst
118
rst/api.rst
|
@ -1,55 +1,73 @@
|
|||
API
|
||||
===
|
||||
Using the Python API
|
||||
====================
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
|
||||
placerat nibh, non feugiat risus varius vitae. Donec eu libero
|
||||
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
|
||||
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
|
||||
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
|
||||
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.
|
||||
The Python API is very powerful, and is how the ansible CLI and ansible-playbook
|
||||
are implemented.
|
||||
|
||||
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.
|
||||
It's pretty simple::
|
||||
|
||||
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.
|
||||
import ansible.runner
|
||||
|
||||
runner = ansible.runner.Runner(
|
||||
module_name='ping',
|
||||
module_args='',
|
||||
pattern='web*',
|
||||
forks=10
|
||||
)
|
||||
datastructure = runner.run()
|
||||
|
||||
The run method returns results per host, grouped by whether they
|
||||
could be contacted or not. Return types are module specific, as
|
||||
expressed in the 'ansible-modules' documentation.::
|
||||
|
||||
{
|
||||
"dark" : {
|
||||
"web1.example.com" : "failure message"
|
||||
}
|
||||
"contacted" : {
|
||||
"web2.example.com" : 1
|
||||
}
|
||||
}
|
||||
|
||||
A module can return any type of JSON data it wants, so Ansible can
|
||||
be used as a framework to rapidly build powerful applications and scripts.
|
||||
|
||||
Detailed API Example
|
||||
````````````````````
|
||||
|
||||
The following script prints out the uptime information for all hosts::
|
||||
|
||||
#!/usr/bin/python
|
||||
|
||||
import ansible.runner
|
||||
import sys
|
||||
|
||||
# construct the ansible runner and execute on all hosts
|
||||
results = ansible.runner.Runner(
|
||||
pattern='*', forks=10,
|
||||
module_name='command', module_args=['/usr/bin/uptime'],
|
||||
).run()
|
||||
|
||||
if results is None:
|
||||
print "No hosts found"
|
||||
sys.exit(1)
|
||||
|
||||
print "UP ***********"
|
||||
for (hostname, result) in results['contacted'].items():
|
||||
if not 'failed' in result:
|
||||
print "%s >>> %s" % (hostname, result['stdout'])
|
||||
|
||||
print "FAILED *******"
|
||||
for (hostname, result) in results['contacted'].items():
|
||||
if 'failed' in result:
|
||||
print "%s >>> %s" % (hostname, result['msg'])
|
||||
|
||||
print "DOWN *********"
|
||||
for (hostname, result) in results['dark'].items():
|
||||
print "%s >>> %s" % (hostname, result)
|
||||
|
||||
Advanced programmers may also wish to read the source to ansible itself, for
|
||||
it uses the Runner() API (with all available options) to implement the
|
||||
command line tools ``ansible`` and ``ansible-playbook``.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
Communicate
|
||||
===========
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
|
||||
placerat nibh, non feugiat risus varius vitae. Donec eu libero
|
||||
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
|
||||
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
|
||||
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
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
130
rst/examples.rst
130
rst/examples.rst
|
@ -1,71 +1,81 @@
|
|||
Examples
|
||||
========
|
||||
Command Line Examples
|
||||
=====================
|
||||
|
||||
Examples 1
|
||||
``````````
|
||||
The following examples show how to use `/usr/bin/ansible` for running ad-hoc tasks.
|
||||
Start here. For configuration management and deployments, you'll want to pick up on
|
||||
using `/usr/bin/ansible-playbook` -- the concepts port over directly.
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
|
||||
placerat nibh, non feugiat risus varius vitae. Donec eu libero
|
||||
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
|
||||
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
|
||||
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
|
||||
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.
|
||||
.. seealso::
|
||||
|
||||
:doc:`modules`
|
||||
A list of available modules
|
||||
:doc:`playbooks`
|
||||
Alternative ways to use ansible
|
||||
|
||||
|
||||
Examples 2
|
||||
``````````
|
||||
Parallelism and Shell Commands
|
||||
``````````````````````````````
|
||||
|
||||
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.
|
||||
Let's use ansible's command line tool to reboot all web servers in Atlanta, 10 at a time::
|
||||
|
||||
Examples 3
|
||||
``````````
|
||||
ssh-agent bash
|
||||
ssh-add ~/.ssh/id_rsa.pub
|
||||
|
||||
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.
|
||||
ansible atlanta -a "/sbin/reboot" -f 10
|
||||
|
||||
Examples 3
|
||||
``````````
|
||||
The -f 10 specifies the usage of 10 simultaneous processes.
|
||||
|
||||
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.
|
||||
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'.
|
||||
|
||||
File Transfer & Templating
|
||||
``````````````````````````
|
||||
|
||||
Ansible can SCP lots of files to multiple machines in parallel, and optionally use them as template sources.
|
||||
|
||||
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 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"
|
||||
ansible webservers -m template -a "src=/srv/ntp.j2 dest=/etc/ntp.conf"
|
||||
|
||||
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.
|
||||
|
||||
Deploying From Source Control
|
||||
`````````````````````````````
|
||||
|
||||
Deploy your webapp straight from git::
|
||||
|
||||
ansible webservers -m git -a "repo=git://foo dest=/srv/myapp version=HEAD"
|
||||
|
||||
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
|
||||
|
||||
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. 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 4
|
||||
``````````
|
||||
|
||||
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.
|
||||
|
|
|
@ -1,67 +1,104 @@
|
|||
Getting Started
|
||||
===============
|
||||
|
||||
How to ansible
|
||||
|
||||
How to download ansible and get started using it
|
||||
|
||||
.. seealso::
|
||||
|
||||
:doc:`YAMLScripts`
|
||||
Complete documentation of the YAML syntax `ansible` understands.
|
||||
:doc:`examples`
|
||||
Examples of basic commands
|
||||
:doc:`playbooks`
|
||||
Learning ansible's configuration management language
|
||||
|
||||
Requirements
|
||||
````````````
|
||||
|
||||
Requirements for Ansible are extremely minimal.
|
||||
|
||||
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``
|
||||
* ``python-jinja2`` (for playbooks)
|
||||
|
||||
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)
|
||||
|
||||
Developer Requirements
|
||||
``````````````````````
|
||||
|
||||
For developers, you may wish to have:
|
||||
|
||||
* ``asciidoc`` (for building manpage documentation)
|
||||
* ``python-sphinx`` (for building content for the ansible.github.com project only)
|
||||
|
||||
|
||||
What you need
|
||||
-------------
|
||||
Getting Ansible
|
||||
```````````````
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
|
||||
placerat nibh, non feugiat risus varius vitae. Donec eu libero
|
||||
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
|
||||
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
|
||||
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
|
||||
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.
|
||||
Tagged releases are available as tar.gz files from the Ansible github
|
||||
project page:
|
||||
|
||||
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.
|
||||
* `Ansible/downloads <https://github.com/ansible/ansible/downloads>`_
|
||||
|
||||
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.
|
||||
You can also clone the git repository yourself and install Ansible in
|
||||
one of two ways:
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
Python Distutils
|
||||
++++++++++++++++
|
||||
|
||||
You can also install Ansible using Python Distutils::
|
||||
|
||||
$ git clone git://github.com/ansible/ansible.git
|
||||
$ cd ./ansible
|
||||
$ sudo make install
|
||||
|
||||
Via RPM
|
||||
+++++++
|
||||
|
||||
In the near future, pre-built RPMs will be available through your distribution. Until that time you
|
||||
can use the ``make rpm`` command::
|
||||
|
||||
$ git clone git://github.com/ansible/ansible.git
|
||||
$ cd ./ansible
|
||||
$ make rpm
|
||||
$ sudo rpm -Uvh ~/rpmbuild/RPMS/noarch/ansible-1.0-1.noarch.rpm
|
||||
|
||||
Your first commands
|
||||
```````````````````
|
||||
|
||||
Edit /etc/ansible/hosts and put one or more remote systems in it, for which you have your SSH
|
||||
key in ``authorized_keys``::
|
||||
|
||||
192.168.1.50
|
||||
aserver.example.org
|
||||
bserver.example.org
|
||||
|
||||
Set up SSH agent to avoid retyping passwords::
|
||||
|
||||
ssh-agent bash
|
||||
ssh-add ~/.ssh/id_rsa
|
||||
|
||||
Now ping all your nodes::
|
||||
|
||||
ansible all -m ping
|
||||
|
||||
Now run a live command on all of your nodes::
|
||||
|
||||
ansible all /bin/echo hello
|
||||
|
||||
Congratulations. You've just contacted your nodes with Ansible. It's now time to read some
|
||||
of the more real-world examples, and explore what you can do with different modules, as well
|
||||
as the Ansible playbooks language. Ansible is not just about running commands, but you already
|
||||
have a working infrastructure!
|
||||
|
||||
|
|
128
rst/index.rst
128
rst/index.rst
|
@ -5,102 +5,49 @@
|
|||
Ansible
|
||||
=======
|
||||
|
||||
Ansible is a extra-simple tool/API for doing 'parallel remote things'
|
||||
over SSH -- whether executing commands, running "modules", or
|
||||
executing larger 'playbooks' that can serve as a configuration
|
||||
management or deployment system.
|
||||
Ansible is a radically simple deployment, configuration, and command execution framework.
|
||||
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's core is a little over 1000 lines.
|
||||
|
||||
While `Func installation <http://fedorahosted.org/func>`_ which I
|
||||
co-wrote, aspired to avoid using SSH and have it's own daemon
|
||||
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.
|
||||
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 "playbooks".
|
||||
|
||||
Why use Ansible versus something else? (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
|
||||
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?) 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.
|
||||
Want to only code plugins in bash or clojure? Ansible doesn't care.
|
||||
The docs will fit on one page and the source will be blindingly
|
||||
obvious.
|
||||
|
||||
Systems management doesn't have to be complicated. Ansible's docs will remain
|
||||
short & simple, and the source will be blindingly obvious.
|
||||
|
||||
|
||||
Design Principles
|
||||
`````````````````
|
||||
Design Goals
|
||||
````````````
|
||||
|
||||
* Dead simple setup
|
||||
* 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
|
||||
* 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
|
||||
````````````````````````````
|
||||
|
||||
Requirements
|
||||
````````````
|
||||
Your ideas and contributions are welcome. We're also happy to help you with questions about Ansible.
|
||||
|
||||
Requirements are extremely minimal.
|
||||
* Join the `ansible-project mailing list <http://groups.google.com/group/ansible-project>`_ on Google Groups
|
||||
* Join `#ansible <irc://irc.freenode.net/#ansible>`_ on the `freenode IRC network <http://freenode.net/>`_
|
||||
* Visit the `project page <https://github.com/ansible/ansible>`_ on Github
|
||||
|
||||
If you are running python 2.6 on the **overlord** machine, you will
|
||||
need:
|
||||
- View the `issue tracker <https://github.com/ansible/ansible/issues>`_
|
||||
|
||||
* ``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
|
||||
project page:
|
||||
|
||||
* `Ansible/downloads <https://github.com/ansible/ansible/downloads>`_
|
||||
|
||||
You can also clone the git repository yourself and install Ansible in
|
||||
one of two ways:
|
||||
|
||||
|
||||
Python Distutils
|
||||
++++++++++++++++
|
||||
|
||||
You can install Ansible using Python Distutils::
|
||||
|
||||
$ git clone git://github.com/ansible/ansible.git
|
||||
$ cd ./ansible
|
||||
$ sudo make install
|
||||
|
||||
|
||||
Via RPM
|
||||
+++++++
|
||||
|
||||
In the future, pre-built RPMs may be available. Until that time you
|
||||
can use the ``make rpm`` command::
|
||||
|
||||
$ git clone git://github.com/ansible/ansible.git
|
||||
$ cd ./ansible
|
||||
$ make rpm
|
||||
$ sudo rpm -Uvh ~/rpmbuild/RPMS/noarch/ansible-1.0-1.noarch.rpm
|
||||
|
||||
|
||||
Contents
|
||||
========
|
||||
|
@ -109,21 +56,22 @@ Contents
|
|||
:maxdepth: 3
|
||||
|
||||
gettingstarted
|
||||
YAMLScripts
|
||||
patterns
|
||||
modules
|
||||
playbooks
|
||||
examples
|
||||
modules
|
||||
YAMLScripts
|
||||
playbooks
|
||||
api
|
||||
communicate
|
||||
man
|
||||
|
||||
About the Author
|
||||
````````````````
|
||||
|
||||
Communicate or Get Involved
|
||||
===========================
|
||||
Ansible was originally developed by Michael DeHaan, a Raleigh, NC based software developer and architect.
|
||||
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, a precursor to Ansible, which is used
|
||||
to orchestrate systems in lots of diverse places. He's worked on systems software for
|
||||
IBM, Motorola, Red Hat's Emerging Technologies Group, Puppet Labs, and rPath.
|
||||
|
||||
* Join the `ansible-project mailing list <http://groups.google.com/group/ansible-project>`_ on Google Groups
|
||||
* Join `#ansible <irc://irc.freenode.net/#ansible>`_ on the `freenode IRC network <http://freenode.net/>`_
|
||||
* Visit the `project page <https://github.com/ansible/ansible>`_ on Github
|
||||
|
||||
- View the `issue tracker <https://github.com/ansible/ansible/issues>`_
|
||||
|
|
11
rst/man.rst
11
rst/man.rst
|
@ -3,19 +3,10 @@
|
|||
Man Pages
|
||||
=========
|
||||
|
||||
Ansile ships with a handfull of manpages to help you on your journey.
|
||||
Ansible's manpage lists available command line options.
|
||||
|
||||
ansible(1)
|
||||
----------
|
||||
|
||||
* `View ansible.1 <man/ansible.1.html>`_
|
||||
|
||||
ansible-modules(5)
|
||||
------------------
|
||||
|
||||
* `View ansible-modules.5 <man/ansible-modules.5.html>`_
|
||||
|
||||
ansible-playbook(5)
|
||||
-------------------
|
||||
|
||||
* `View ansible-playbook.5 <man/ansible-playbook.5.html>`_
|
||||
|
|
244
rst/modules.rst
244
rst/modules.rst
|
@ -1,55 +1,199 @@
|
|||
Modules
|
||||
=======
|
||||
Ansible Modules
|
||||
===============
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
|
||||
placerat nibh, non feugiat risus varius vitae. Donec eu libero
|
||||
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
|
||||
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
|
||||
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
|
||||
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.
|
||||
Ansible ships with a number of modules that can be executed directly on remote hosts or through
|
||||
ansible playbooks.
|
||||
|
||||
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.
|
||||
.. seealso::
|
||||
|
||||
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.
|
||||
:doc:`examples`
|
||||
Examples of using modules in /usr/bin/ansible
|
||||
:doc:`playbooks`
|
||||
Examples of using modules with /usr/bin/ansible-playbook
|
||||
:doc:`api`
|
||||
Examples of using modules with the Python API
|
||||
|
||||
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
|
||||
```````
|
||||
|
||||
The command module takes the command name followed by a list of arguments, space delimited.
|
||||
This is the only module that does not use key=value style parameters.
|
||||
|
||||
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.
|
||||
|
||||
|
||||
copy
|
||||
````
|
||||
|
||||
The copy module moves a file on the local box to remote locations.
|
||||
|
||||
*src*::
|
||||
|
||||
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.
|
||||
|
||||
|
||||
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. Playbooks do not actually use
|
||||
this module, they use the 'setup' module behind the scenes.
|
||||
|
||||
|
||||
git
|
||||
```
|
||||
|
||||
Deploys software (or files) 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.
|
||||
|
||||
Playbooks should not call the ohai module, playbooks call the 'setup'
|
||||
module behind the scenes instead.
|
||||
|
||||
ping
|
||||
````
|
||||
|
||||
A trivial test module, this module always returns the integer '1' on
|
||||
successful contact.
|
||||
|
||||
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.
|
||||
|
||||
|
||||
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 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.
|
||||
All variables are then bubbled up to the caller.
|
||||
|
||||
*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. This can be a relative
|
||||
or absolute path.
|
||||
|
||||
*dest*
|
||||
|
||||
location to render the template on the remote server
|
||||
|
||||
|
||||
This module also returns md5sum information about the resultant file.
|
||||
|
||||
|
||||
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::
|
||||
|
||||
{
|
||||
'changed' : True,
|
||||
'something' : 42
|
||||
}
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
|
108
rst/patterns.rst
108
rst/patterns.rst
|
@ -1,55 +1,63 @@
|
|||
Patterns
|
||||
========
|
||||
The Inventory File, Patterns, and Groups
|
||||
========================================
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
|
||||
placerat nibh, non feugiat risus varius vitae. Donec eu libero
|
||||
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
|
||||
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
|
||||
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
|
||||
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.
|
||||
How to select hosts you wish to manage
|
||||
|
||||
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.
|
||||
.. seealso::
|
||||
|
||||
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.
|
||||
:doc:`examples`
|
||||
Examples of basic commands
|
||||
:doc:`playbooks`
|
||||
Learning ansible's configuration management language
|
||||
|
||||
Inventory File Format
|
||||
+++++++++++++++++++++
|
||||
|
||||
Ansible works against multiple systems in your infrastructure at the
|
||||
same time. It does this by selecting portions of systems listed in Ansible's inventory file,
|
||||
which defaults to /etc/ansible/hosts, and looks like this::
|
||||
|
||||
mail.example.com
|
||||
|
||||
[webservers]
|
||||
foo.example.com
|
||||
bar.example.com
|
||||
|
||||
[dbservers]
|
||||
one.example.com
|
||||
two.example.com
|
||||
three.example.com
|
||||
|
||||
|
||||
Selecting Targets
|
||||
+++++++++++++++++
|
||||
|
||||
These patterns target all hosts in the inventory file::
|
||||
|
||||
all
|
||||
*
|
||||
|
||||
It is also possible to address specific hosts::
|
||||
|
||||
one.example.com
|
||||
one.example.com:two.example.com
|
||||
|
||||
|
||||
The following patterns address one or more groups, which are denoted with the bracket
|
||||
headers in the inventory file::
|
||||
|
||||
webservers
|
||||
webservers:dbservers
|
||||
|
||||
Individual hosts, but not groups, can also be referenced using wildcards:
|
||||
|
||||
*.example.com
|
||||
*.com
|
||||
|
||||
It's also ok to mix wildcard patterns and groups at the same time::
|
||||
|
||||
one*.com:dbservers
|
||||
|
||||
NOTE: It is not possible to target a host not in the inventory file.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
|
|
@ -1,55 +1,205 @@
|
|||
Playbooks
|
||||
=========
|
||||
Playbooks: Ansible for Deployment, Configuration Management, and Orchestration
|
||||
==============================================================================
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
|
||||
placerat nibh, non feugiat risus varius vitae. Donec eu libero
|
||||
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
|
||||
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
|
||||
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
|
||||
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.
|
||||
.. seealso::
|
||||
|
||||
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.
|
||||
:doc:`YAMLScripts`
|
||||
Learn about YAML syntax
|
||||
:doc:`modules`
|
||||
Learn about available modules and writing your own
|
||||
:doc:`patterns`
|
||||
Learn about how to select hosts
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
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
|
||||
````````````````
|
||||
|
||||
Playbooks are expressed in YAML format and have a minimum of syntax. Each playbook is composed
|
||||
of one or more 'plays' in a list. By composing a playbook of multiple 'plays', it is possible
|
||||
to orchestrate multi-machine deployments, running certain steps on all machines in
|
||||
the webservers group, then certain steps on the database server group, then more commands
|
||||
back on the webservers group, etc::
|
||||
|
||||
---
|
||||
- hosts: webservers
|
||||
vars:
|
||||
http_port: 80
|
||||
max_clients: 200
|
||||
user: root
|
||||
tasks:
|
||||
- include: base.yml somevar=3 othervar=4
|
||||
- name: write the apache config file
|
||||
action: template src=/srv/httpd.j2 dest=/etc/httpd.conf
|
||||
notify:
|
||||
- restart apache
|
||||
- name: ensure apache is running
|
||||
action: service name=httpd state=started
|
||||
handlers:
|
||||
- include: handlers.yml
|
||||
|
||||
Hosts line
|
||||
``````````
|
||||
|
||||
The hosts line is a list of one or more groups or host patterns, seperated by colons, asdescribed in the 'patterns' documentation. This is just like the first parameter to /usr/bin/ansible.
|
||||
|
||||
Vars section
|
||||
````````````
|
||||
|
||||
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 }}
|
||||
|
||||
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_'. 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,
|
||||
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
|
||||
`````````````````````
|
||||
|
||||
Every task must have a name, which is included in the output from running the playbook.
|
||||
|
||||
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.
|
||||
|
||||
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. 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. 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 (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
|
||||
|
||||
In addition to the explicitly passed in parameters, all variables from the vars section
|
||||
are also available.
|
||||
|
||||
The format of an included list of tasks or handlers looks just like a flat list of tasks. Here
|
||||
is an example of what base.yml might look like::
|
||||
|
||||
---
|
||||
- name: no selinux
|
||||
action: command /usr/sbin/setenforce 0
|
||||
- name: no iptables
|
||||
action: service name=iptables state=stopped
|
||||
- name: this is just to show variables work here, favcolor={{ favcolor }}
|
||||
action: command /bin/true
|
||||
|
||||
As you can see above, variables in include files work just like they do in the main file.
|
||||
Including a variable in the name of a task is a contrived example, you could also
|
||||
pass them to the action command line or use them inside a template file.
|
||||
|
||||
Note that include statements are only usable from the top level playbook file.
|
||||
At this time, includes can not include other includes.
|
||||
|
||||
Using Includes To Assign Classes of Systems
|
||||
```````````````````````````````````````````
|
||||
|
||||
Include files are best used to reuse logic between playbooks. You could imagine
|
||||
a playbook describing your entire infrastructure like this::
|
||||
|
||||
---
|
||||
- hosts: atlanta-webservers
|
||||
vars:
|
||||
datacenter: atlanta
|
||||
tasks:
|
||||
- include: base.yml
|
||||
- include: webservers.yml database=db.atlanta.com
|
||||
handlers:
|
||||
- include: generic-handlers.yml
|
||||
- hosts: atlanta-dbservers
|
||||
vars:
|
||||
datacenter: atlanta
|
||||
tasks:
|
||||
- include: base.yml
|
||||
- include: dbservers.yml
|
||||
handlers:
|
||||
- include: generic-handlers.yml
|
||||
|
||||
There is one (or more) play defined for each group of systems, and each play maps
|
||||
each group includes one or more 'class definitions' telling the systems what they
|
||||
are supposed to do or be.
|
||||
|
||||
Using a common handlers file could allow one task in 'webservers' to define 'restart apache',
|
||||
and it could be reused between multiple plays.
|
||||
|
||||
Variables like 'database' above can be used in templates referenced from the
|
||||
configuration file to generate machine specific variables.
|
||||
|
||||
Asynchronous Actions and Polling
|
||||
````````````````````````````````
|
||||
|
||||
(Information on this feature is pending)
|
||||
|
||||
Executing A Playbook
|
||||
````````````````````
|
||||
|
||||
To run a playbook::
|
||||
|
||||
ansible-playbook playbook.yml
|
||||
|
||||
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.
|
||||
|
|
Loading…
Reference in a new issue