mirror of https://github.com/ansible/ansible.git
Docs updates
parent
89a00e6385
commit
12fd193450
@ -1 +1 @@
|
||||
Subproject commit 8e20ed3714b7a43279ecfd38a7812b28e1533f03
|
||||
Subproject commit 96d39a0dff9ccba4074479ca42eac0068733b803
|
@ -1,55 +1,35 @@
|
||||
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.
|
||||
|
||||
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.
|
||||
```
|
||||
|
||||
The Python API is very powerful, and is how the ansible CLI and ansible-playbook
|
||||
are implemented.
|
||||
|
||||
It's pretty simple::
|
||||
|
||||
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.
|
||||
|
||||
|
||||
|
@ -1,71 +1,65 @@
|
||||
Examples
|
||||
========
|
||||
|
||||
Examples 1
|
||||
``````````
|
||||
|
||||
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.
|
||||
|
||||
|
||||
Examples 2
|
||||
``````````
|
||||
|
||||
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.
|
||||
|
||||
Examples 3
|
||||
``````````
|
||||
|
||||
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.
|
||||
|
||||
Examples 3
|
||||
``````````
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
.. seealso::
|
||||
|
||||
:doc:`modules`
|
||||
A list of available modules
|
||||
:doc:`playbooks`
|
||||
Alternative ways to use ansible
|
||||
|
||||
|
||||
Parallelism and Shell Commands
|
||||
``````````````````````````````
|
||||
|
||||
Reboot all web servers in Atlanta, 10 at a time::
|
||||
|
||||
ssh-agent bash
|
||||
ssh-add ~/.ssh/id_rsa.pub
|
||||
|
||||
ansible atlanta -a "/sbin/reboot" -f 10
|
||||
|
||||
The -f 10 specifies the usage of 10 simultaneous processes.
|
||||
|
||||
Note that other than the command module, ansible modules do not work like simple scripts. They make the remote system look like you state, and run the commands neccessary to get it there.
|
||||
|
||||
|
||||
Example 2: Time Limited Background Operations
|
||||
`````````````````````````````````````````````
|
||||
|
||||
|
||||
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.
|
||||
|
||||
|
||||
Examples 3: 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 below) 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.
|
||||
|
||||
Examples 3: 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.
|
||||
|
||||
|
||||
|
@ -1,67 +1,100 @@
|
||||
Getting Started
|
||||
===============
|
||||
|
||||
How to ansible
|
||||
|
||||
How to download ansible and get started using it
|
||||
|
||||
.. seealso::
|
||||
|
||||
:doc:`examples`
|
||||
Examples of basic commands
|
||||
:doc:`YAMLScripts`
|
||||
Complete documentation of the YAML syntax `ansible` understands.
|
||||
|
||||
|
||||
What you need
|
||||
-------------
|
||||
|
||||
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.
|
||||
Complete documentation of the YAML syntax `ansible` understands for playbooks.
|
||||
:doc:`playbooks`
|
||||
Learning ansible's configuration management language
|
||||
:doc:`modules`
|
||||
Learn about modules that ship with ansible
|
||||
|
||||
Requirements
|
||||
````````````
|
||||
|
||||
Requirements are extremely minimal.
|
||||
|
||||
If you are running python 2.6 on the **overlord** machine, 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 ansible.github.com)
|
||||
|
||||
|
||||
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 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
|
||||
|
||||
Now try this:
|
||||
|
||||
ssh-agent bash
|
||||
ssh-add ~/.ssh/id_rsa
|
||||
ansible all -m ping
|
||||
|
||||
Congratulations. You've just contacted your nodes with Ansible. It's now time to read some
|
||||
of the more real-world examples.
|
||||
|
||||
|
@ -1,55 +1,201 @@
|
||||
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.
|
||||
|
||||
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.
|
||||
Ansible Modules
|
||||
===============
|
||||
|
||||
.. seealso::
|
||||
|
||||
: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
|
||||
|
||||
|
||||
About Modules
|
||||
`````````````
|
||||
|
||||
Ansible ships with a number of modules that can be executed directly on remote hosts or through
|
||||
ansible playbooks.
|
||||
|
||||
|
||||
Idempotence
|
||||
```````````
|
||||
|
||||
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.
|
||||
|
||||
|
||||
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
|
||||
|
||||
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 absolute path to a file to copy to the remote server
|
||||
|
||||
|
||||
*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.
|
||||
|
||||
|
||||
git
|
||||
```
|
||||
|
||||
Deploys software from git checkouts.
|
||||
|
||||
*repo*::
|
||||
|
||||
git or http protocol address of the repo to checkout
|
||||
|
||||
*dest*::
|
||||
|
||||
where to check it out, an absolute directory path
|
||||
|
||||
*version*::
|
||||
|
||||
what version to check out -- either the git SHA, the literal string 'HEAD', or a tag name
|
||||
|
||||
|
||||
ohai
|
||||
````
|
||||
|
||||
Similar to the facter module, this returns JSON inventory data. Ohai
|
||||
data is a bit more verbose and nested than facter.
|
||||
|
||||
Requires that 'ohai' be installed on the remote end.
|
||||
|
||||
This module is information only - it takes no parameters & does not
|
||||
support change hooks, nor does it make any changes on the system.
|
||||
|
||||
|
||||
ping
|
||||
````
|
||||
|
||||
A trivial test module, this module always returns the integer '1' on
|
||||
successful contact.
|
||||
|
||||
This module does not support change hooks.
|
||||
|
||||
This module is informative only - it takes no parameters & does not
|
||||
support change hooks, nor does it make any changes on the system.
|
||||
|
||||
|
||||
service
|
||||
```````
|
||||
|
||||
Controls services on remote machines.
|
||||
|
||||
*state*
|
||||
|
||||
Values are 'started', 'stopped', or 'restarted'. Started/stopped
|
||||
are idempotent actions that will not run commands unless neccessary.
|
||||
'restarted' will always bounce the service
|
||||
|
||||
|
||||
*name*
|
||||
|
||||
The name of the service
|
||||
|
||||
|
||||
setup
|
||||
`````
|
||||
|
||||
Writes a JSON file containing key/value data, for use in templating.
|
||||
Call this once before using the template modules. Playbooks will
|
||||
execute this module automatically as the first step in each play.
|
||||
|
||||
If facter or ohai are installed, variables from these programs will also
|
||||
be snapshotted into the JSON file for usage in templating. These variables
|
||||
are prefixed with 'facter_' and 'ohai_" so it's easy to tell their source.
|
||||
|
||||
*metadata*
|
||||
|
||||
Optionally overrides the default JSON file location of /etc/ansible/setup or ~/ansible/setup
|
||||
depending on what remote user has been specified.
|
||||
|
||||
If used, also supply the metadata parameter to the template module.
|
||||
|
||||
*anything*
|
||||
|
||||
any other parameters can be named basically anything, and set a key=value
|
||||
pair in the JSON file for use in templating.
|
||||
|
||||
|
||||
template
|
||||
````````
|
||||
|
||||
Templates a file out to a remote server. Call the setup module prior to usage.
|
||||
|
||||
*src*
|
||||
|
||||
path of a Jinja2 formatted template on the local server
|
||||
|
||||
|
||||
*dest*
|
||||
|
||||
location to render the template on the remote server
|
||||
|
||||
|
||||
*metadata*
|
||||
|
||||
location of a JSON file to use to supply template data. Default is /etc/ansible/setup
|
||||
which is the same as the default for the setup module. Change if running as a non-root
|
||||
remote user who does not have permissions on /etc/ansible.
|
||||
|
||||
|
||||
This module also returns md5sum information about the resultant file.
|
||||
|
||||
|
||||
user
|
||||
````
|
||||
|
||||
This module is in plan.
|
||||
|
||||
|
||||
yum
|
||||
```
|
||||
|
||||
This module is in plan.
|
||||
|
||||
|
||||
WRITING YOUR OWN MODULES
|
||||
````````````````````````
|
||||
|
||||
To write your own modules, simply follow the convention of those already available in
|
||||
/usr/share/ansible. Modules must return JSON but can be written in any language.
|
||||
Modules should return hashes, but hashes can be nested.
|
||||
To support change hooks, modules should return hashes with a changed: True/False
|
||||
element at the top level. Modules can also choose to indicate a failure scenario
|
||||
by returning a top level 'failure' element with a True value, and a 'msg' element
|
||||
describing the nature of the failure. Other values are up to the module.
|
||||
|
@ -1,55 +1,69 @@
|
||||
Patterns
|
||||
========
|
||||
|
||||
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.
|
||||
How to select hosts you wish to manage
|
||||
|
||||
.. seealso::
|
||||
|
||||
:doc:`examples`
|
||||
Examples of basic commands
|
||||
:doc:`playbooks`
|
||||
Learning ansible's configuration management language
|
||||
|
||||
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
|
||||
|
||||
Targetting All Systems
|
||||
``````````````````````
|
||||
|
||||
The pattern 'all' or '*' targets all systems in the inventory file.
|
||||
|
||||
Specific Hosts
|
||||
``````````````
|
||||
|
||||
It is possible to address specific hosts:
|
||||
|
||||
one.example.com
|
||||
one.example.com:two.example.com
|
||||
|
||||
Groups
|
||||
``````
|
||||
|
||||
The following patterns address one or more groups:
|
||||
|
||||
webservers
|
||||
webservers:dbservers
|
||||
|
||||
There is also a magic group 'ungrouped' which selects systems not in a group.
|
||||
|
||||
Wildcards
|
||||
`````````
|
||||
|
||||
Individual hosts, but not groups, can also be referenced using wildcards:
|
||||
|
||||
*.example.com
|
||||
*.com
|
||||
|
||||
Mixing Things Up
|
||||
````````````````
|
||||
|
||||
Specific hosts, wildcards, and groups can all be mixed in the same pattern
|
||||
|
||||
one*.com:dbservers
|
||||
|
||||
It is not possible to target a host not in the inventory file.
|
||||
|
||||
|
||||
|
||||
|
@ -1,55 +1,118 @@
|
||||
Playbooks
|
||||
=========
|
||||
|
||||
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.
|
||||
.. seealso::
|
||||
|
||||
:doc:`YAMLScripts`
|
||||
Learn about YAML syntax
|
||||
:doc:`modules`
|
||||
Learn about available modules and writing your own
|
||||
:doc:`patterns`
|
||||
Learn about how to select hosts
|
||||
|
||||
|
||||
Playbooks are a completely different way to use ansible and are particularly awesome.
|
||||
|
||||
They are the basis for a really simple configuration management and deployment system, unlike any that already exist, and one that is very well suited to deploying complex multi-machine applications. While you might run the main ansible program for ad-hoc tasks, playbooks are more likely to be kept in source control and used to push out your configuration or assure the configurations of your remote systems are in spec.
|
||||
|
||||
|
||||
Playbook Example
|
||||
````````````````
|
||||
|
||||
Playbooks are expressed in YAML format and have a minimum of syntax. Each playbook is composed
|
||||
of one or more patterns in a list. By composing a playbook of multiple patterns, 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: all
|
||||
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 alist of one or more groups or host patterns, seperated by colons.
|
||||
|
||||
webservers:dbservers:*.foo.example.com
|
||||
|
||||
Vars section
|
||||
````````````
|
||||
|
||||
A list of variables that can be used in the 'action' lines of the template, or in
|
||||
included templates. Variables are deferenced like this::
|
||||
|
||||
{{ varname }}
|
||||
|
||||
These variables will be pushed down to the managed systems for use in templating operations.
|
||||
|
||||
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'.
|
||||
|
||||
Tasks list
|
||||
``````````
|
||||
|
||||
Tasks are executed in order, one at a time, against all machines matched by the host
|
||||
pattern, before moving on to the next task. Failed tasks are taken out of the rotation.
|
||||
|
||||
Task name and comment
|
||||
`````````
|
||||
|
||||
Each task has a name (required) and optional comment. This is for informational purposes only
|
||||
|
||||
Task action
|
||||
```````````
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
Handlers
|
||||
````````
|
||||
|
||||
Handlers are lists of tasks, not really any different from regular tasks, that are referenced
|
||||
by name.
|
||||
|
||||
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:
|
||||
|
||||
{{ variable }}
|
||||
|
||||
Asynchronous Actions and Polling
|
||||
````````````````````````````````
|
||||
|
||||
(Information on this feature is pending)
|
||||
|
||||
Executing A Playbook
|
||||
````````````````````
|
||||
|
||||
To run a playbook::
|
||||
|
||||
ansible-playbook playbook.yml
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,55 +1,35 @@
|
||||
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.
|
||||
|
||||
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.
|
||||
```
|
||||
|
||||
The Python API is very powerful, and is how the ansible CLI and ansible-playbook
|
||||
are implemented.
|
||||
|
||||
It's pretty simple::
|
||||
|
||||
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.
|
||||
|
||||
|
||||
|
@ -1,71 +1,65 @@
|
||||
Examples
|
||||
========
|
||||
|
||||
Examples 1
|
||||
``````````
|
||||
|
||||
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.
|
||||
|
||||
|
||||
Examples 2
|
||||
``````````
|
||||
|
||||
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.
|
||||
|
||||
Examples 3
|
||||
``````````
|
||||
|
||||
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.
|
||||
|
||||
Examples 3
|
||||
``````````
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
.. seealso::
|
||||
|
||||
:doc:`modules`
|
||||
A list of available modules
|
||||
:doc:`playbooks`
|
||||
Alternative ways to use ansible
|
||||
|
||||
|
||||
Parallelism and Shell Commands
|
||||
``````````````````````````````
|
||||
|
||||
Reboot all web servers in Atlanta, 10 at a time::
|
||||
|
||||
ssh-agent bash
|
||||
ssh-add ~/.ssh/id_rsa.pub
|
||||
|
||||
ansible atlanta -a "/sbin/reboot" -f 10
|
||||
|
||||
The -f 10 specifies the usage of 10 simultaneous processes.
|
||||
|
||||
Note that other than the command module, ansible modules do not work like simple scripts. They make the remote system look like you state, and run the commands neccessary to get it there.
|
||||
|
||||
|
||||
Example 2: Time Limited Background Operations
|
||||
`````````````````````````````````````````````
|
||||
|
||||
|
||||
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.
|
||||
|
||||
|
||||
Examples 3: 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 below) 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.
|
||||
|
||||
Examples 3: 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.
|
||||
|
||||
|
||||
|
@ -1,67 +1,100 @@
|
||||
Getting Started
|
||||
===============
|
||||
|
||||
How to ansible
|
||||
|
||||
How to download ansible and get started using it
|
||||
|
||||
.. seealso::
|
||||
|
||||
:doc:`examples`
|
||||
Examples of basic commands
|
||||
:doc:`YAMLScripts`
|
||||
Complete documentation of the YAML syntax `ansible` understands.
|
||||
|
||||
|
||||
What you need
|
||||
-------------
|
||||
|
||||
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.
|
||||
Complete documentation of the YAML syntax `ansible` understands for playbooks.
|
||||
:doc:`playbooks`
|
||||
Learning ansible's configuration management language
|
||||
:doc:`modules`
|
||||
Learn about modules that ship with ansible
|
||||
|
||||
Requirements
|
||||
````````````
|
||||
|
||||
Requirements are extremely minimal.
|
||||
|
||||
If you are running python 2.6 on the **overlord** machine, 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 ansible.github.com)
|
||||
|
||||
|
||||
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 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
|
||||
|
||||
Now try this:
|
||||
|
||||
ssh-agent bash
|
||||
ssh-add ~/.ssh/id_rsa
|
||||
ansible all -m ping
|
||||
|
||||
Congratulations. You've just contacted your nodes with Ansible. It's now time to read some
|
||||
of the more real-world examples.
|
||||
|
||||
|
@ -1,55 +1,201 @@
|
||||
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.
|
||||
|
||||
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.
|
||||
Ansible Modules
|
||||
===============
|
||||
|
||||
.. seealso::
|
||||
|
||||
: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
|
||||
|
||||
|
||||
About Modules
|
||||
`````````````
|
||||
|
||||
Ansible ships with a number of modules that can be executed directly on remote hosts or through
|
||||
ansible playbooks.
|
||||
|
||||
|
||||
Idempotence
|
||||
```````````
|
||||
|
||||
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.
|
||||
|
||||
|
||||
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
|
||||
|
||||
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 absolute path to a file to copy to the remote server
|
||||
|
||||
|
||||
*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.
|
||||
|
||||
|
||||
git
|
||||
```
|
||||
|
||||
Deploys software from git checkouts.
|
||||
|
||||
*repo*::
|
||||
|
||||
git or http protocol address of the repo to checkout
|
||||
|
||||
*dest*::
|
||||
|
||||
where to check it out, an absolute directory path
|
||||
|
||||
*version*::
|
||||
|
||||
what version to check out -- either the git SHA, the literal string 'HEAD', or a tag name
|
||||
|
||||
|
||||
ohai
|
||||
````
|
||||
|
||||
Similar to the facter module, this returns JSON inventory data. Ohai
|
||||
data is a bit more verbose and nested than facter.
|
||||
|
||||
Requires that 'ohai' be installed on the remote end.
|
||||
|
||||
This module is information only - it takes no parameters & does not
|
||||
support change hooks, nor does it make any changes on the system.
|
||||
|
||||
|
||||
ping
|
||||
````
|
||||
|
||||
A trivial test module, this module always returns the integer '1' on
|
||||
successful contact.
|
||||
|
||||
This module does not support change hooks.
|
||||
|
||||
This module is informative only - it takes no parameters & does not
|
||||
support change hooks, nor does it make any changes on the system.
|
||||
|
||||
|
||||
service
|
||||
```````
|
||||
|
||||
Controls services on remote machines.
|
||||
|
||||
*state*
|
||||
|
||||
Values are 'started', 'stopped', or 'restarted'. Started/stopped
|
||||
are idempotent actions that will not run commands unless neccessary.
|
||||
'restarted' will always bounce the service
|
||||
|
||||
|
||||
*name*
|
||||
|
||||
The name of the service
|
||||
|
||||
|
||||
setup
|
||||
`````
|
||||
|
||||
Writes a JSON file containing key/value data, for use in templating.
|
||||
Call this once before using the template modules. Playbooks will
|
||||
execute this module automatically as the first step in each play.
|
||||
|
||||
If facter or ohai are installed, variables from these programs will also
|
||||
be snapshotted into the JSON file for usage in templating. These variables
|
||||
are prefixed with 'facter_' and 'ohai_" so it's easy to tell their source.
|
||||
|
||||
*metadata*
|
||||
|
||||
Optionally overrides the default JSON file location of /etc/ansible/setup or ~/ansible/setup
|
||||
depending on what remote user has been specified.
|
||||
|
||||
If used, also supply the metadata parameter to the template module.
|
||||
|
||||
*anything*
|
||||
|
||||
any other parameters can be named basically anything, and set a key=value
|
||||
pair in the JSON file for use in templating.
|
||||
|
||||
|
||||
template
|
||||
````````
|
||||
|
||||
Templates a file out to a remote server. Call the setup module prior to usage.
|
||||
|
||||
*src*
|
||||
|
||||
path of a Jinja2 formatted template on the local server
|
||||
|
||||
|
||||
*dest*
|
||||
|
||||
location to render the template on the remote server
|
||||
|
||||
|
||||
*metadata*
|
||||
|
||||
location of a JSON file to use to supply template data. Default is /etc/ansible/setup
|
||||
which is the same as the default for the setup module. Change if running as a non-root
|
||||
remote user who does not have permissions on /etc/ansible.
|
||||
|
||||
|
||||
This module also returns md5sum information about the resultant file.
|
||||
|
||||
|
||||
user
|
||||
````
|
||||
|
||||
This module is in plan.
|
||||
|
||||
|
||||
yum
|
||||
```
|
||||
|
||||
This module is in plan.
|
||||
|
||||
|
||||
WRITING YOUR OWN MODULES
|
||||
````````````````````````
|
||||
|
||||
To write your own modules, simply follow the convention of those already available in
|
||||
/usr/share/ansible. Modules must return JSON but can be written in any language.
|
||||
Modules should return hashes, but hashes can be nested.
|
||||
To support change hooks, modules should return hashes with a changed: True/False
|
||||
element at the top level. Modules can also choose to indicate a failure scenario
|
||||
by returning a top level 'failure' element with a True value, and a 'msg' element
|
||||
describing the nature of the failure. Other values are up to the module.
|
||||
|
@ -1,55 +1,69 @@
|
||||
Patterns
|
||||
========
|
||||
|
||||
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.
|
||||
How to select hosts you wish to manage
|
||||
|
||||
.. seealso::
|
||||
|
||||
:doc:`examples`
|
||||
Examples of basic commands
|
||||
:doc:`playbooks`
|
||||
Learning ansible's configuration management language
|
||||
|
||||
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
|
||||
|
||||
Targetting All Systems
|
||||
``````````````````````
|
||||
|
||||
The pattern 'all' or '*' targets all systems in the inventory file.
|
||||
|
||||
Specific Hosts
|
||||
``````````````
|
||||
|
||||
It is possible to address specific hosts:
|
||||
|
||||
one.example.com
|
||||
one.example.com:two.example.com
|
||||
|
||||
Groups
|
||||
``````
|
||||
|
||||
The following patterns address one or more groups:
|
||||
|
||||
webservers
|
||||
webservers:dbservers
|
||||
|
||||
There is also a magic group 'ungrouped' which selects systems not in a group.
|
||||
|
||||
Wildcards
|
||||
`````````
|
||||
|
||||
Individual hosts, but not groups, can also be referenced using wildcards:
|
||||
|
||||
*.example.com
|
||||
*.com
|
||||
|
||||
Mixing Things Up
|
||||
````````````````
|
||||
|
||||
Specific hosts, wildcards, and groups can all be mixed in the same pattern
|
||||
|
||||
one*.com:dbservers
|
||||
|
||||
It is not possible to target a host not in the inventory file.
|
||||
|
||||
|
||||
|
||||
|
@ -1,55 +1,118 @@
|
||||
Playbooks
|
||||
=========
|
||||
|
||||
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.
|
||||
.. seealso::
|
||||
|
||||
:doc:`YAMLScripts`
|
||||
Learn about YAML syntax
|
||||
:doc:`modules`
|
||||
Learn about available modules and writing your own
|
||||
:doc:`patterns`
|
||||
Learn about how to select hosts
|
||||
|
||||
|
||||
Playbooks are a completely different way to use ansible and are particularly awesome.
|
||||
|
||||
They are the basis for a really simple configuration management and deployment system, unlike any that already exist, and one that is very well suited to deploying complex multi-machine applications. While you might run the main ansible program for ad-hoc tasks, playbooks are more likely to be kept in source control and used to push out your configuration or assure the configurations of your remote systems are in spec.
|
||||
|
||||
|
||||
Playbook Example
|
||||
````````````````
|
||||
|
||||
Playbooks are expressed in YAML format and have a minimum of syntax. Each playbook is composed
|
||||
of one or more patterns in a list. By composing a playbook of multiple patterns, 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: all
|
||||
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 alist of one or more groups or host patterns, seperated by colons.::
|
||||
|
||||
webservers:dbservers:*.foo.example.com
|
||||
|
||||
Vars section
|
||||
````````````
|
||||
|
||||
A list of variables that can be used in the 'action' lines of the template, or in
|
||||
included templates. Variables are deferenced like this::
|
||||
|
||||
{{ varname }}
|
||||
|
||||
These variables will be pushed down to the managed systems for use in templating operations.
|
||||
|
||||
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'.
|
||||
|
||||
Tasks list
|
||||
``````````
|
||||
|
||||
Tasks are executed in order, one at a time, against all machines matched by the host
|
||||
pattern, before moving on to the next task. Failed tasks are taken out of the rotation.
|
||||
|
||||
Task name and comment
|
||||
`````````
|
||||
|
||||
Each task has a name (required) and optional comment. This is for informational purposes only
|
||||
|
||||
Task action
|
||||
```````````
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
Handlers
|
||||
````````
|
||||
|
||||
Handlers are lists of tasks, not really any different from regular tasks, that are referenced
|
||||
by name.
|
||||
|
||||
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:
|
||||
|
||||
{{ variable }}
|
||||
|
||||
Asynchronous Actions and Polling
|
||||
````````````````````````````````
|
||||
|
||||
(Information on this feature is pending)
|
||||
|
||||
Executing A Playbook
|
||||
````````````````````
|
||||
|
||||
To run a playbook::
|
||||
|
||||
ansible-playbook playbook.yml
|
||||
|
||||
|
Loading…
Reference in New Issue