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
|
API
|
||||||
===
|
```
|
||||||
|
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
|
The Python API is very powerful, and is how the ansible CLI and ansible-playbook
|
||||||
placerat nibh, non feugiat risus varius vitae. Donec eu libero
|
are implemented.
|
||||||
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
|
|
||||||
magna porta venenatis. Quisque scelerisque, sem non ultrices bibendum,
|
It's pretty simple::
|
||||||
dolor diam rutrum lectus, sed luctus neque neque vitae eros. Vivamus
|
|
||||||
mattis, ipsum ut bibendum gravida, lectus arcu venenatis elit, vitae
|
import ansible.runner
|
||||||
luctus diam leo sit amet ligula. Nunc egestas justo in nulla sagittis
|
|
||||||
ut suscipit sapien gravida. Morbi id dui nibh. Nullam diam massa,
|
runner = ansible.runner.Runner(
|
||||||
rhoncus a dignissim non, adipiscing vel arcu. Quisque ultricies
|
module_name='ping',
|
||||||
tincidunt purus ut sodales. Quisque scelerisque dapibus purus quis
|
module_args='',
|
||||||
egestas. Maecenas sagittis porttitor adipiscing. Duis eu magna
|
pattern='web*',
|
||||||
sem. Donec arcu felis, faucibus et malesuada non, blandit vitae
|
forks=10
|
||||||
metus. Fusce nec sapien dolor.
|
)
|
||||||
|
datastructure = runner.run()
|
||||||
Aenean ac fermentum nisl. Integer leo sem, rutrum nec dictum at,
|
|
||||||
pretium quis sapien. Duis felis metus, sodales sit amet gravida in,
|
The run method returns results per host, grouped by whether they
|
||||||
pretium ut arcu. Nulla ligula quam, aliquam sit amet sollicitudin
|
could be contacted or not. Return types are module specific, as
|
||||||
eget, molestie tincidunt ipsum. Nulla leo nunc, mattis sed auctor at,
|
expressed in the 'ansible-modules' documentation.::
|
||||||
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
|
"dark" : {
|
||||||
egestas nibh id mattis. In hac habitasse platea dictumst. Ut accumsan
|
"web1.example.com" : "failure message"
|
||||||
lorem eget leo dictum viverra.
|
}
|
||||||
|
"contacted" : {
|
||||||
Quisque egestas lorem sit amet felis tincidunt adipiscing. Aenean
|
"web2.example.com" : 1
|
||||||
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,
|
A module can return any type of JSON data it wants, so Ansible can
|
||||||
erat id scelerisque lobortis, nibh ipsum tristique elit, ac viverra
|
be used as a framework to rapidly build powerful applications and scripts.
|
||||||
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,65 @@
|
|||||||
Examples
|
Examples
|
||||||
========
|
========
|
||||||
|
|
||||||
Examples 1
|
.. seealso::
|
||||||
``````````
|
|
||||||
|
:doc:`modules`
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
|
A list of available modules
|
||||||
placerat nibh, non feugiat risus varius vitae. Donec eu libero
|
:doc:`playbooks`
|
||||||
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
|
Alternative ways to use ansible
|
||||||
magna porta venenatis. Quisque scelerisque, sem non ultrices bibendum,
|
|
||||||
dolor diam rutrum lectus, sed luctus neque neque vitae eros. Vivamus
|
|
||||||
mattis, ipsum ut bibendum gravida, lectus arcu venenatis elit, vitae
|
Parallelism and Shell Commands
|
||||||
luctus diam leo sit amet ligula. Nunc egestas justo in nulla sagittis
|
``````````````````````````````
|
||||||
ut suscipit sapien gravida. Morbi id dui nibh. Nullam diam massa,
|
|
||||||
rhoncus a dignissim non, adipiscing vel arcu. Quisque ultricies
|
Reboot all web servers in Atlanta, 10 at a time::
|
||||||
tincidunt purus ut sodales. Quisque scelerisque dapibus purus quis
|
|
||||||
egestas. Maecenas sagittis porttitor adipiscing. Duis eu magna
|
ssh-agent bash
|
||||||
sem. Donec arcu felis, faucibus et malesuada non, blandit vitae
|
ssh-add ~/.ssh/id_rsa.pub
|
||||||
metus. Fusce nec sapien dolor.
|
|
||||||
|
ansible atlanta -a "/sbin/reboot" -f 10
|
||||||
|
|
||||||
Examples 2
|
The -f 10 specifies the usage of 10 simultaneous processes.
|
||||||
``````````
|
|
||||||
|
Note that other than the command module, ansible modules do not work like simple scripts. They make the remote system look like you state, and run the commands neccessary to get it there.
|
||||||
Aenean ac fermentum nisl. Integer leo sem, rutrum nec dictum at,
|
|
||||||
pretium quis sapien. Duis felis metus, sodales sit amet gravida in,
|
|
||||||
pretium ut arcu. Nulla ligula quam, aliquam sit amet sollicitudin
|
Example 2: Time Limited Background Operations
|
||||||
eget, molestie tincidunt ipsum. Nulla leo nunc, mattis sed auctor at,
|
`````````````````````````````````````````````
|
||||||
suscipit ut metus. Suspendisse hendrerit, justo sagittis malesuada
|
|
||||||
molestie, nisi nunc placerat libero, vel vulputate elit tellus et
|
|
||||||
augue. Phasellus tempor lectus ac nisi aliquam faucibus. Donec feugiat
|
Long running operations can be backgrounded, and their status can be checked on later. The same job ID is given to the same task on all hosts, so you won't lose track. Polling support is pending in the command line.::
|
||||||
egestas nibh id mattis. In hac habitasse platea dictumst. Ut accumsan
|
|
||||||
lorem eget leo dictum viverra.
|
ansible all -B 3600 -a "/usr/bin/long_running_operation --do-stuff"
|
||||||
|
ansible all -n job_status -a jid=123456789
|
||||||
Examples 3
|
|
||||||
``````````
|
Any module other than 'copy' or 'template' can be backgrounded.
|
||||||
|
|
||||||
Quisque egestas lorem sit amet felis tincidunt adipiscing. Aenean
|
|
||||||
ornare fermentum accumsan. Aenean eu mauris arcu, id pulvinar
|
Examples 3: File Transfer & Templating
|
||||||
quam. Suspendisse nec massa vel augue laoreet ultricies in convallis
|
``````````````````````````````````````
|
||||||
dolor. Mauris sodales porta enim, non ultricies dolor luctus
|
|
||||||
in. Phasellus eu tortor lectus, vel porttitor nulla. Mauris vulputate,
|
Ansible can SCP lots of files to multiple machines in parallel, and optionally use them as template sources.
|
||||||
erat id scelerisque lobortis, nibh ipsum tristique elit, ac viverra
|
|
||||||
arcu sem a ante. Praesent nec metus vestibulum augue eleifend
|
To just transfer a file directly to many different servers::
|
||||||
suscipit. In feugiat, sem nec dignissim consequat, velit tortor
|
|
||||||
scelerisque metus, sit amet mollis nisl sem eu nibh. Quisque in nibh
|
ansible atlanta copy -a "/etc/hosts /tmp/hosts"
|
||||||
turpis. Proin ac nisi ligula, a pretium augue.
|
|
||||||
|
To use templating, first run the setup module to put the template variables you would like to use on the remote host. Then use the template module to write the files using the templates. Templates are written in Jinja2 format. Playbooks (covered below) will run the setup module for you, making this even simpler.::
|
||||||
Examples 3
|
|
||||||
``````````
|
ansible webservers -m setup -a "favcolor=red ntp_server=192.168.1.1"
|
||||||
|
ansible webservers -m template -a "src=/srv/motd.j2 dest=/etc/motd"
|
||||||
In nibh eros, laoreet id interdum vel, sodales sed tortor. Sed
|
ansible webservers -m template -a "src=/srv/ntp.j2 dest=/etc/ntp.conf"
|
||||||
ullamcorper, sem vel mattis consectetur, nibh turpis molestie nisl,
|
|
||||||
eget lobortis mi magna sed metus. Cras justo est, tempus quis
|
Need something like the fqdn in a template? If facter or ohai are installed, data from these projects will also be made available to the template engine, using 'facter' and 'ohai' prefixes for each.
|
||||||
adipiscing ut, hendrerit convallis sem. Mauris ullamcorper, sapien et
|
|
||||||
luctus iaculis, urna elit egestas ipsum, et tristique enim risus vitae
|
Examples 3: Deploying From Source Control
|
||||||
nunc. Vivamus aliquet lorem eu urna pulvinar hendrerit malesuada nunc
|
`````````````````````````````````````````
|
||||||
sollicitudin. Cras in mi rhoncus quam egestas dignissim vel sit amet
|
|
||||||
lacus. Maecenas interdum viverra laoreet. Quisque elementum
|
Deploy your webapp straight from git::
|
||||||
sollicitudin ullamcorper.
|
|
||||||
|
ansible webservers -m git -a "repo=git://foo dest=/srv/myapp version=HEAD"
|
||||||
Examples 4
|
|
||||||
``````````
|
Since ansible modules can notify change handlers (see 'Playbooks') it is possible to tell ansible to run specific tasks when the code is updated, such as deploying Perl/Python/PHP/Ruby directly from git and then restarting apache.
|
||||||
|
|
||||||
Pellentesque mauris sem, malesuada at lobortis in, porta eget
|
|
||||||
urna. Duis aliquet quam eget risus elementum quis auctor ligula
|
|
||||||
gravida. Phasellus et ullamcorper libero. Nam elementum ultricies
|
|
||||||
tellus, in sagittis magna aliquet quis. Ut sit amet tellus id erat
|
|
||||||
tristique lobortis. Suspendisse est enim, tristique eu convallis id,
|
|
||||||
rutrum nec lacus. Fusce iaculis diam non felis rutrum lobortis. Proin
|
|
||||||
hendrerit mi tincidunt dui fermentum placerat.
|
|
||||||
|
@ -1,67 +1,100 @@
|
|||||||
Getting Started
|
Getting Started
|
||||||
===============
|
===============
|
||||||
|
|
||||||
How to ansible
|
How to download ansible and get started using it
|
||||||
|
|
||||||
|
|
||||||
.. seealso::
|
.. seealso::
|
||||||
|
|
||||||
|
:doc:`examples`
|
||||||
|
Examples of basic commands
|
||||||
:doc:`YAMLScripts`
|
:doc:`YAMLScripts`
|
||||||
Complete documentation of the YAML syntax `ansible` understands.
|
Complete documentation of the YAML syntax `ansible` understands for playbooks.
|
||||||
|
:doc:`playbooks`
|
||||||
|
Learning ansible's configuration management language
|
||||||
What you need
|
:doc:`modules`
|
||||||
-------------
|
Learn about modules that ship with ansible
|
||||||
|
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
|
Requirements
|
||||||
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,
|
Requirements are extremely minimal.
|
||||||
dolor diam rutrum lectus, sed luctus neque neque vitae eros. Vivamus
|
|
||||||
mattis, ipsum ut bibendum gravida, lectus arcu venenatis elit, vitae
|
If you are running python 2.6 on the **overlord** machine, you will
|
||||||
luctus diam leo sit amet ligula. Nunc egestas justo in nulla sagittis
|
need:
|
||||||
ut suscipit sapien gravida. Morbi id dui nibh. Nullam diam massa,
|
|
||||||
rhoncus a dignissim non, adipiscing vel arcu. Quisque ultricies
|
* ``paramiko``
|
||||||
tincidunt purus ut sodales. Quisque scelerisque dapibus purus quis
|
* ``PyYAML``
|
||||||
egestas. Maecenas sagittis porttitor adipiscing. Duis eu magna
|
* ``python-jinja2`` (for playbooks)
|
||||||
sem. Donec arcu felis, faucibus et malesuada non, blandit vitae
|
|
||||||
metus. Fusce nec sapien dolor.
|
If you are running less than Python 2.6, you will also need:
|
||||||
|
|
||||||
Aenean ac fermentum nisl. Integer leo sem, rutrum nec dictum at,
|
* The Python 2.4 or 2.5 backport of the ``multiprocessing`` module
|
||||||
pretium quis sapien. Duis felis metus, sodales sit amet gravida in,
|
|
||||||
pretium ut arcu. Nulla ligula quam, aliquam sit amet sollicitudin
|
- `Installation and Testing Instructions <http://code.google.com/p/python-multiprocessing/wiki/Install>`_
|
||||||
eget, molestie tincidunt ipsum. Nulla leo nunc, mattis sed auctor at,
|
|
||||||
suscipit ut metus. Suspendisse hendrerit, justo sagittis malesuada
|
* ``simplejson``
|
||||||
molestie, nisi nunc placerat libero, vel vulputate elit tellus et
|
|
||||||
augue. Phasellus tempor lectus ac nisi aliquam faucibus. Donec feugiat
|
On the managed nodes, to use templating, you will need:
|
||||||
egestas nibh id mattis. In hac habitasse platea dictumst. Ut accumsan
|
|
||||||
lorem eget leo dictum viverra.
|
* ``python-jinja2`` (you can install this with ansible)
|
||||||
|
|
||||||
Quisque egestas lorem sit amet felis tincidunt adipiscing. Aenean
|
Developer Requirements
|
||||||
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
|
For developers, you may wish to have:
|
||||||
in. Phasellus eu tortor lectus, vel porttitor nulla. Mauris vulputate,
|
|
||||||
erat id scelerisque lobortis, nibh ipsum tristique elit, ac viverra
|
* ``asciidoc`` (for building manpage documentation)
|
||||||
arcu sem a ante. Praesent nec metus vestibulum augue eleifend
|
* ``python-sphinx`` (for building content for ansible.github.com)
|
||||||
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.
|
Getting Ansible
|
||||||
|
```````````````
|
||||||
In nibh eros, laoreet id interdum vel, sodales sed tortor. Sed
|
|
||||||
ullamcorper, sem vel mattis consectetur, nibh turpis molestie nisl,
|
Tagged releases are available as tar.gz files from the Ansible github
|
||||||
eget lobortis mi magna sed metus. Cras justo est, tempus quis
|
project page:
|
||||||
adipiscing ut, hendrerit convallis sem. Mauris ullamcorper, sapien et
|
|
||||||
luctus iaculis, urna elit egestas ipsum, et tristique enim risus vitae
|
* `Ansible/downloads <https://github.com/ansible/ansible/downloads>`_
|
||||||
nunc. Vivamus aliquet lorem eu urna pulvinar hendrerit malesuada nunc
|
|
||||||
sollicitudin. Cras in mi rhoncus quam egestas dignissim vel sit amet
|
You can also clone the git repository yourself and install Ansible in
|
||||||
lacus. Maecenas interdum viverra laoreet. Quisque elementum
|
one of two ways:
|
||||||
sollicitudin ullamcorper.
|
|
||||||
|
|
||||||
Pellentesque mauris sem, malesuada at lobortis in, porta eget
|
Python Distutils
|
||||||
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
|
You can also install Ansible using Python Distutils::
|
||||||
tristique lobortis. Suspendisse est enim, tristique eu convallis id,
|
|
||||||
rutrum nec lacus. Fusce iaculis diam non felis rutrum lobortis. Proin
|
$ git clone git://github.com/ansible/ansible.git
|
||||||
hendrerit mi tincidunt dui fermentum placerat.
|
$ 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
|
Ansible Modules
|
||||||
=======
|
===============
|
||||||
|
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
|
.. seealso::
|
||||||
placerat nibh, non feugiat risus varius vitae. Donec eu libero
|
|
||||||
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
|
:doc:`examples`
|
||||||
magna porta venenatis. Quisque scelerisque, sem non ultrices bibendum,
|
Examples of using modules in /usr/bin/ansible
|
||||||
dolor diam rutrum lectus, sed luctus neque neque vitae eros. Vivamus
|
:doc:`playbooks`
|
||||||
mattis, ipsum ut bibendum gravida, lectus arcu venenatis elit, vitae
|
Examples of using modules with /usr/bin/ansible-playbook
|
||||||
luctus diam leo sit amet ligula. Nunc egestas justo in nulla sagittis
|
:doc:`api`
|
||||||
ut suscipit sapien gravida. Morbi id dui nibh. Nullam diam massa,
|
Examples of using modules with the Python API
|
||||||
rhoncus a dignissim non, adipiscing vel arcu. Quisque ultricies
|
|
||||||
tincidunt purus ut sodales. Quisque scelerisque dapibus purus quis
|
|
||||||
egestas. Maecenas sagittis porttitor adipiscing. Duis eu magna
|
About Modules
|
||||||
sem. Donec arcu felis, faucibus et malesuada non, blandit vitae
|
`````````````
|
||||||
metus. Fusce nec sapien dolor.
|
|
||||||
|
Ansible ships with a number of modules that can be executed directly on remote hosts or through
|
||||||
Aenean ac fermentum nisl. Integer leo sem, rutrum nec dictum at,
|
ansible playbooks.
|
||||||
pretium quis sapien. Duis felis metus, sodales sit amet gravida in,
|
|
||||||
pretium ut arcu. Nulla ligula quam, aliquam sit amet sollicitudin
|
|
||||||
eget, molestie tincidunt ipsum. Nulla leo nunc, mattis sed auctor at,
|
Idempotence
|
||||||
suscipit ut metus. Suspendisse hendrerit, justo sagittis malesuada
|
```````````
|
||||||
molestie, nisi nunc placerat libero, vel vulputate elit tellus et
|
|
||||||
augue. Phasellus tempor lectus ac nisi aliquam faucibus. Donec feugiat
|
Most modules other than command are idempotent, meaning they will seek to avoid changes
|
||||||
egestas nibh id mattis. In hac habitasse platea dictumst. Ut accumsan
|
unless a change needs to be made. When using ansible playbooks, these modules can
|
||||||
lorem eget leo dictum viverra.
|
trigger change events. Unless otherwise noted, all modules support change hooks.
|
||||||
|
|
||||||
Quisque egestas lorem sit amet felis tincidunt adipiscing. Aenean
|
|
||||||
ornare fermentum accumsan. Aenean eu mauris arcu, id pulvinar
|
command
|
||||||
quam. Suspendisse nec massa vel augue laoreet ultricies in convallis
|
```````
|
||||||
dolor. Mauris sodales porta enim, non ultricies dolor luctus
|
|
||||||
in. Phasellus eu tortor lectus, vel porttitor nulla. Mauris vulputate,
|
The command module takes the command name followed by a list of arguments, space delimited.
|
||||||
erat id scelerisque lobortis, nibh ipsum tristique elit, ac viverra
|
This is the only module that does not use key=value style parameters.
|
||||||
arcu sem a ante. Praesent nec metus vestibulum augue eleifend
|
|
||||||
suscipit. In feugiat, sem nec dignissim consequat, velit tortor
|
Example usage::
|
||||||
scelerisque metus, sit amet mollis nisl sem eu nibh. Quisque in nibh
|
|
||||||
turpis. Proin ac nisi ligula, a pretium augue.
|
/sbin/shutdown -t now
|
||||||
|
|
||||||
In nibh eros, laoreet id interdum vel, sodales sed tortor. Sed
|
This module does not support change hooks and returns the return code from the program as well as timing information about how long the command was running for.
|
||||||
ullamcorper, sem vel mattis consectetur, nibh turpis molestie nisl,
|
|
||||||
eget lobortis mi magna sed metus. Cras justo est, tempus quis
|
|
||||||
adipiscing ut, hendrerit convallis sem. Mauris ullamcorper, sapien et
|
copy
|
||||||
luctus iaculis, urna elit egestas ipsum, et tristique enim risus vitae
|
````
|
||||||
nunc. Vivamus aliquet lorem eu urna pulvinar hendrerit malesuada nunc
|
|
||||||
sollicitudin. Cras in mi rhoncus quam egestas dignissim vel sit amet
|
The copy module moves a file on the local box to remote locations.
|
||||||
lacus. Maecenas interdum viverra laoreet. Quisque elementum
|
|
||||||
sollicitudin ullamcorper.
|
*src*::
|
||||||
|
|
||||||
Pellentesque mauris sem, malesuada at lobortis in, porta eget
|
Local absolute path to a file to copy to the remote server
|
||||||
urna. Duis aliquet quam eget risus elementum quis auctor ligula
|
|
||||||
gravida. Phasellus et ullamcorper libero. Nam elementum ultricies
|
|
||||||
tellus, in sagittis magna aliquet quis. Ut sit amet tellus id erat
|
*dest*::
|
||||||
tristique lobortis. Suspendisse est enim, tristique eu convallis id,
|
|
||||||
rutrum nec lacus. Fusce iaculis diam non felis rutrum lobortis. Proin
|
Remote absolute path where the file should end up
|
||||||
hendrerit mi tincidunt dui fermentum placerat.
|
|
||||||
|
|
||||||
|
This module also returns md5sum information about the resultant file.
|
||||||
|
|
||||||
|
|
||||||
|
facter
|
||||||
|
``````
|
||||||
|
|
||||||
|
Runs the discovery program 'facter' on the remote system, returning
|
||||||
|
JSON data that can be useful for inventory purposes.
|
||||||
|
|
||||||
|
Requires that 'facter' and 'ruby-json' be installed on the remote end.
|
||||||
|
|
||||||
|
This module is informative only - it takes no parameters & does not support change hooks,
|
||||||
|
nor does it make any changes on the system.
|
||||||
|
|
||||||
|
|
||||||
|
git
|
||||||
|
```
|
||||||
|
|
||||||
|
Deploys software from git checkouts.
|
||||||
|
|
||||||
|
*repo*::
|
||||||
|
|
||||||
|
git or http protocol address of the repo to checkout
|
||||||
|
|
||||||
|
*dest*::
|
||||||
|
|
||||||
|
where to check it out, an absolute directory path
|
||||||
|
|
||||||
|
*version*::
|
||||||
|
|
||||||
|
what version to check out -- either the git SHA, the literal string 'HEAD', or a tag name
|
||||||
|
|
||||||
|
|
||||||
|
ohai
|
||||||
|
````
|
||||||
|
|
||||||
|
Similar to the facter module, this returns JSON inventory data. Ohai
|
||||||
|
data is a bit more verbose and nested than facter.
|
||||||
|
|
||||||
|
Requires that 'ohai' be installed on the remote end.
|
||||||
|
|
||||||
|
This module is information only - it takes no parameters & does not
|
||||||
|
support change hooks, nor does it make any changes on the system.
|
||||||
|
|
||||||
|
|
||||||
|
ping
|
||||||
|
````
|
||||||
|
|
||||||
|
A trivial test module, this module always returns the integer '1' on
|
||||||
|
successful contact.
|
||||||
|
|
||||||
|
This module does not support change hooks.
|
||||||
|
|
||||||
|
This module is informative only - it takes no parameters & does not
|
||||||
|
support change hooks, nor does it make any changes on the system.
|
||||||
|
|
||||||
|
|
||||||
|
service
|
||||||
|
```````
|
||||||
|
|
||||||
|
Controls services on remote machines.
|
||||||
|
|
||||||
|
*state*
|
||||||
|
|
||||||
|
Values are 'started', 'stopped', or 'restarted'. Started/stopped
|
||||||
|
are idempotent actions that will not run commands unless neccessary.
|
||||||
|
'restarted' will always bounce the service
|
||||||
|
|
||||||
|
|
||||||
|
*name*
|
||||||
|
|
||||||
|
The name of the service
|
||||||
|
|
||||||
|
|
||||||
|
setup
|
||||||
|
`````
|
||||||
|
|
||||||
|
Writes a JSON file containing key/value data, for use in templating.
|
||||||
|
Call this once before using the template modules. Playbooks will
|
||||||
|
execute this module automatically as the first step in each play.
|
||||||
|
|
||||||
|
If facter or ohai are installed, variables from these programs will also
|
||||||
|
be snapshotted into the JSON file for usage in templating. These variables
|
||||||
|
are prefixed with 'facter_' and 'ohai_" so it's easy to tell their source.
|
||||||
|
|
||||||
|
*metadata*
|
||||||
|
|
||||||
|
Optionally overrides the default JSON file location of /etc/ansible/setup or ~/ansible/setup
|
||||||
|
depending on what remote user has been specified.
|
||||||
|
|
||||||
|
If used, also supply the metadata parameter to the template module.
|
||||||
|
|
||||||
|
*anything*
|
||||||
|
|
||||||
|
any other parameters can be named basically anything, and set a key=value
|
||||||
|
pair in the JSON file for use in templating.
|
||||||
|
|
||||||
|
|
||||||
|
template
|
||||||
|
````````
|
||||||
|
|
||||||
|
Templates a file out to a remote server. Call the setup module prior to usage.
|
||||||
|
|
||||||
|
*src*
|
||||||
|
|
||||||
|
path of a Jinja2 formatted template on the local server
|
||||||
|
|
||||||
|
|
||||||
|
*dest*
|
||||||
|
|
||||||
|
location to render the template on the remote server
|
||||||
|
|
||||||
|
|
||||||
|
*metadata*
|
||||||
|
|
||||||
|
location of a JSON file to use to supply template data. Default is /etc/ansible/setup
|
||||||
|
which is the same as the default for the setup module. Change if running as a non-root
|
||||||
|
remote user who does not have permissions on /etc/ansible.
|
||||||
|
|
||||||
|
|
||||||
|
This module also returns md5sum information about the resultant file.
|
||||||
|
|
||||||
|
|
||||||
|
user
|
||||||
|
````
|
||||||
|
|
||||||
|
This module is in plan.
|
||||||
|
|
||||||
|
|
||||||
|
yum
|
||||||
|
```
|
||||||
|
|
||||||
|
This module is in plan.
|
||||||
|
|
||||||
|
|
||||||
|
WRITING YOUR OWN MODULES
|
||||||
|
````````````````````````
|
||||||
|
|
||||||
|
To write your own modules, simply follow the convention of those already available in
|
||||||
|
/usr/share/ansible. Modules must return JSON but can be written in any language.
|
||||||
|
Modules should return hashes, but hashes can be nested.
|
||||||
|
To support change hooks, modules should return hashes with a changed: True/False
|
||||||
|
element at the top level. Modules can also choose to indicate a failure scenario
|
||||||
|
by returning a top level 'failure' element with a True value, and a 'msg' element
|
||||||
|
describing the nature of the failure. Other values are up to the module.
|
||||||
|
@ -1,55 +1,69 @@
|
|||||||
Patterns
|
Patterns
|
||||||
========
|
========
|
||||||
|
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
|
How to select hosts you wish to manage
|
||||||
placerat nibh, non feugiat risus varius vitae. Donec eu libero
|
|
||||||
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
|
.. seealso::
|
||||||
magna porta venenatis. Quisque scelerisque, sem non ultrices bibendum,
|
|
||||||
dolor diam rutrum lectus, sed luctus neque neque vitae eros. Vivamus
|
:doc:`examples`
|
||||||
mattis, ipsum ut bibendum gravida, lectus arcu venenatis elit, vitae
|
Examples of basic commands
|
||||||
luctus diam leo sit amet ligula. Nunc egestas justo in nulla sagittis
|
:doc:`playbooks`
|
||||||
ut suscipit sapien gravida. Morbi id dui nibh. Nullam diam massa,
|
Learning ansible's configuration management language
|
||||||
rhoncus a dignissim non, adipiscing vel arcu. Quisque ultricies
|
|
||||||
tincidunt purus ut sodales. Quisque scelerisque dapibus purus quis
|
Ansible works against multiple systems in your infrastructure at the
|
||||||
egestas. Maecenas sagittis porttitor adipiscing. Duis eu magna
|
same time. It does this by selecting portions of systems listed in Ansible's inventory file,
|
||||||
sem. Donec arcu felis, faucibus et malesuada non, blandit vitae
|
which defaults to /etc/ansible/hosts, and looks like this::
|
||||||
metus. Fusce nec sapien dolor.
|
|
||||||
|
mail.example.com
|
||||||
Aenean ac fermentum nisl. Integer leo sem, rutrum nec dictum at,
|
|
||||||
pretium quis sapien. Duis felis metus, sodales sit amet gravida in,
|
[webservers]
|
||||||
pretium ut arcu. Nulla ligula quam, aliquam sit amet sollicitudin
|
foo.example.com
|
||||||
eget, molestie tincidunt ipsum. Nulla leo nunc, mattis sed auctor at,
|
bar.example.com
|
||||||
suscipit ut metus. Suspendisse hendrerit, justo sagittis malesuada
|
|
||||||
molestie, nisi nunc placerat libero, vel vulputate elit tellus et
|
[dbservers]
|
||||||
augue. Phasellus tempor lectus ac nisi aliquam faucibus. Donec feugiat
|
one.example.com
|
||||||
egestas nibh id mattis. In hac habitasse platea dictumst. Ut accumsan
|
two.example.com
|
||||||
lorem eget leo dictum viverra.
|
three.example.com
|
||||||
|
|
||||||
Quisque egestas lorem sit amet felis tincidunt adipiscing. Aenean
|
Targetting All Systems
|
||||||
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
|
The pattern 'all' or '*' targets all systems in the inventory file.
|
||||||
in. Phasellus eu tortor lectus, vel porttitor nulla. Mauris vulputate,
|
|
||||||
erat id scelerisque lobortis, nibh ipsum tristique elit, ac viverra
|
Specific Hosts
|
||||||
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
|
It is possible to address specific hosts:
|
||||||
turpis. Proin ac nisi ligula, a pretium augue.
|
|
||||||
|
one.example.com
|
||||||
In nibh eros, laoreet id interdum vel, sodales sed tortor. Sed
|
one.example.com:two.example.com
|
||||||
ullamcorper, sem vel mattis consectetur, nibh turpis molestie nisl,
|
|
||||||
eget lobortis mi magna sed metus. Cras justo est, tempus quis
|
Groups
|
||||||
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
|
The following patterns address one or more groups:
|
||||||
sollicitudin. Cras in mi rhoncus quam egestas dignissim vel sit amet
|
|
||||||
lacus. Maecenas interdum viverra laoreet. Quisque elementum
|
webservers
|
||||||
sollicitudin ullamcorper.
|
webservers:dbservers
|
||||||
|
|
||||||
Pellentesque mauris sem, malesuada at lobortis in, porta eget
|
There is also a magic group 'ungrouped' which selects systems not in a group.
|
||||||
urna. Duis aliquet quam eget risus elementum quis auctor ligula
|
|
||||||
gravida. Phasellus et ullamcorper libero. Nam elementum ultricies
|
Wildcards
|
||||||
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
|
Individual hosts, but not groups, can also be referenced using wildcards:
|
||||||
hendrerit mi tincidunt dui fermentum placerat.
|
|
||||||
|
*.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
|
Playbooks
|
||||||
=========
|
=========
|
||||||
|
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
|
.. seealso::
|
||||||
placerat nibh, non feugiat risus varius vitae. Donec eu libero
|
|
||||||
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
|
:doc:`YAMLScripts`
|
||||||
magna porta venenatis. Quisque scelerisque, sem non ultrices bibendum,
|
Learn about YAML syntax
|
||||||
dolor diam rutrum lectus, sed luctus neque neque vitae eros. Vivamus
|
:doc:`modules`
|
||||||
mattis, ipsum ut bibendum gravida, lectus arcu venenatis elit, vitae
|
Learn about available modules and writing your own
|
||||||
luctus diam leo sit amet ligula. Nunc egestas justo in nulla sagittis
|
:doc:`patterns`
|
||||||
ut suscipit sapien gravida. Morbi id dui nibh. Nullam diam massa,
|
Learn about how to select hosts
|
||||||
rhoncus a dignissim non, adipiscing vel arcu. Quisque ultricies
|
|
||||||
tincidunt purus ut sodales. Quisque scelerisque dapibus purus quis
|
|
||||||
egestas. Maecenas sagittis porttitor adipiscing. Duis eu magna
|
Playbooks are a completely different way to use ansible and are particularly awesome.
|
||||||
sem. Donec arcu felis, faucibus et malesuada non, blandit vitae
|
|
||||||
metus. Fusce nec sapien dolor.
|
They are the basis for a really simple configuration management and deployment system, unlike any that already exist, and one that is very well suited to deploying complex multi-machine applications. While you might run the main ansible program for ad-hoc tasks, playbooks are more likely to be kept in source control and used to push out your configuration or assure the configurations of your remote systems are in spec.
|
||||||
|
|
||||||
Aenean ac fermentum nisl. Integer leo sem, rutrum nec dictum at,
|
|
||||||
pretium quis sapien. Duis felis metus, sodales sit amet gravida in,
|
Playbook Example
|
||||||
pretium ut arcu. Nulla ligula quam, aliquam sit amet sollicitudin
|
````````````````
|
||||||
eget, molestie tincidunt ipsum. Nulla leo nunc, mattis sed auctor at,
|
|
||||||
suscipit ut metus. Suspendisse hendrerit, justo sagittis malesuada
|
Playbooks are expressed in YAML format and have a minimum of syntax. Each playbook is composed
|
||||||
molestie, nisi nunc placerat libero, vel vulputate elit tellus et
|
of one or more patterns in a list. By composing a playbook of multiple patterns, it is possible
|
||||||
augue. Phasellus tempor lectus ac nisi aliquam faucibus. Donec feugiat
|
to orchestrate multi-machine deployments, running certain steps on all machines in
|
||||||
egestas nibh id mattis. In hac habitasse platea dictumst. Ut accumsan
|
the webservers group, then certain steps on the database server group, then more commands
|
||||||
lorem eget leo dictum viverra.
|
back on the webservers group, etc::
|
||||||
|
|
||||||
Quisque egestas lorem sit amet felis tincidunt adipiscing. Aenean
|
---
|
||||||
ornare fermentum accumsan. Aenean eu mauris arcu, id pulvinar
|
- hosts: all
|
||||||
quam. Suspendisse nec massa vel augue laoreet ultricies in convallis
|
vars:
|
||||||
dolor. Mauris sodales porta enim, non ultricies dolor luctus
|
http_port: 80
|
||||||
in. Phasellus eu tortor lectus, vel porttitor nulla. Mauris vulputate,
|
max_clients: 200
|
||||||
erat id scelerisque lobortis, nibh ipsum tristique elit, ac viverra
|
user: root
|
||||||
arcu sem a ante. Praesent nec metus vestibulum augue eleifend
|
tasks:
|
||||||
suscipit. In feugiat, sem nec dignissim consequat, velit tortor
|
- include: base.yml somevar=3 othervar=4
|
||||||
scelerisque metus, sit amet mollis nisl sem eu nibh. Quisque in nibh
|
- name: write the apache config file
|
||||||
turpis. Proin ac nisi ligula, a pretium augue.
|
action: template src=/srv/httpd.j2 dest=/etc/httpd.conf
|
||||||
|
notify:
|
||||||
In nibh eros, laoreet id interdum vel, sodales sed tortor. Sed
|
- restart apache
|
||||||
ullamcorper, sem vel mattis consectetur, nibh turpis molestie nisl,
|
- name: ensure apache is running
|
||||||
eget lobortis mi magna sed metus. Cras justo est, tempus quis
|
action: service name=httpd state=started
|
||||||
adipiscing ut, hendrerit convallis sem. Mauris ullamcorper, sapien et
|
handlers:
|
||||||
luctus iaculis, urna elit egestas ipsum, et tristique enim risus vitae
|
- include: handlers.yml
|
||||||
nunc. Vivamus aliquet lorem eu urna pulvinar hendrerit malesuada nunc
|
|
||||||
sollicitudin. Cras in mi rhoncus quam egestas dignissim vel sit amet
|
Hosts line
|
||||||
lacus. Maecenas interdum viverra laoreet. Quisque elementum
|
``````````
|
||||||
sollicitudin ullamcorper.
|
|
||||||
|
The hosts line is alist of one or more groups or host patterns, seperated by colons.
|
||||||
Pellentesque mauris sem, malesuada at lobortis in, porta eget
|
|
||||||
urna. Duis aliquet quam eget risus elementum quis auctor ligula
|
webservers:dbservers:*.foo.example.com
|
||||||
gravida. Phasellus et ullamcorper libero. Nam elementum ultricies
|
|
||||||
tellus, in sagittis magna aliquet quis. Ut sit amet tellus id erat
|
Vars section
|
||||||
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.
|
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
|
API
|
||||||
===
|
```
|
||||||
|
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
|
The Python API is very powerful, and is how the ansible CLI and ansible-playbook
|
||||||
placerat nibh, non feugiat risus varius vitae. Donec eu libero
|
are implemented.
|
||||||
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
|
|
||||||
magna porta venenatis. Quisque scelerisque, sem non ultrices bibendum,
|
It's pretty simple::
|
||||||
dolor diam rutrum lectus, sed luctus neque neque vitae eros. Vivamus
|
|
||||||
mattis, ipsum ut bibendum gravida, lectus arcu venenatis elit, vitae
|
import ansible.runner
|
||||||
luctus diam leo sit amet ligula. Nunc egestas justo in nulla sagittis
|
|
||||||
ut suscipit sapien gravida. Morbi id dui nibh. Nullam diam massa,
|
runner = ansible.runner.Runner(
|
||||||
rhoncus a dignissim non, adipiscing vel arcu. Quisque ultricies
|
module_name='ping',
|
||||||
tincidunt purus ut sodales. Quisque scelerisque dapibus purus quis
|
module_args='',
|
||||||
egestas. Maecenas sagittis porttitor adipiscing. Duis eu magna
|
pattern='web*',
|
||||||
sem. Donec arcu felis, faucibus et malesuada non, blandit vitae
|
forks=10
|
||||||
metus. Fusce nec sapien dolor.
|
)
|
||||||
|
datastructure = runner.run()
|
||||||
Aenean ac fermentum nisl. Integer leo sem, rutrum nec dictum at,
|
|
||||||
pretium quis sapien. Duis felis metus, sodales sit amet gravida in,
|
The run method returns results per host, grouped by whether they
|
||||||
pretium ut arcu. Nulla ligula quam, aliquam sit amet sollicitudin
|
could be contacted or not. Return types are module specific, as
|
||||||
eget, molestie tincidunt ipsum. Nulla leo nunc, mattis sed auctor at,
|
expressed in the 'ansible-modules' documentation.::
|
||||||
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
|
"dark" : {
|
||||||
egestas nibh id mattis. In hac habitasse platea dictumst. Ut accumsan
|
"web1.example.com" : "failure message"
|
||||||
lorem eget leo dictum viverra.
|
}
|
||||||
|
"contacted" : {
|
||||||
Quisque egestas lorem sit amet felis tincidunt adipiscing. Aenean
|
"web2.example.com" : 1
|
||||||
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,
|
A module can return any type of JSON data it wants, so Ansible can
|
||||||
erat id scelerisque lobortis, nibh ipsum tristique elit, ac viverra
|
be used as a framework to rapidly build powerful applications and scripts.
|
||||||
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,65 @@
|
|||||||
Examples
|
Examples
|
||||||
========
|
========
|
||||||
|
|
||||||
Examples 1
|
.. seealso::
|
||||||
``````````
|
|
||||||
|
:doc:`modules`
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
|
A list of available modules
|
||||||
placerat nibh, non feugiat risus varius vitae. Donec eu libero
|
:doc:`playbooks`
|
||||||
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
|
Alternative ways to use ansible
|
||||||
magna porta venenatis. Quisque scelerisque, sem non ultrices bibendum,
|
|
||||||
dolor diam rutrum lectus, sed luctus neque neque vitae eros. Vivamus
|
|
||||||
mattis, ipsum ut bibendum gravida, lectus arcu venenatis elit, vitae
|
Parallelism and Shell Commands
|
||||||
luctus diam leo sit amet ligula. Nunc egestas justo in nulla sagittis
|
``````````````````````````````
|
||||||
ut suscipit sapien gravida. Morbi id dui nibh. Nullam diam massa,
|
|
||||||
rhoncus a dignissim non, adipiscing vel arcu. Quisque ultricies
|
Reboot all web servers in Atlanta, 10 at a time::
|
||||||
tincidunt purus ut sodales. Quisque scelerisque dapibus purus quis
|
|
||||||
egestas. Maecenas sagittis porttitor adipiscing. Duis eu magna
|
ssh-agent bash
|
||||||
sem. Donec arcu felis, faucibus et malesuada non, blandit vitae
|
ssh-add ~/.ssh/id_rsa.pub
|
||||||
metus. Fusce nec sapien dolor.
|
|
||||||
|
ansible atlanta -a "/sbin/reboot" -f 10
|
||||||
|
|
||||||
Examples 2
|
The -f 10 specifies the usage of 10 simultaneous processes.
|
||||||
``````````
|
|
||||||
|
Note that other than the command module, ansible modules do not work like simple scripts. They make the remote system look like you state, and run the commands neccessary to get it there.
|
||||||
Aenean ac fermentum nisl. Integer leo sem, rutrum nec dictum at,
|
|
||||||
pretium quis sapien. Duis felis metus, sodales sit amet gravida in,
|
|
||||||
pretium ut arcu. Nulla ligula quam, aliquam sit amet sollicitudin
|
Example 2: Time Limited Background Operations
|
||||||
eget, molestie tincidunt ipsum. Nulla leo nunc, mattis sed auctor at,
|
`````````````````````````````````````````````
|
||||||
suscipit ut metus. Suspendisse hendrerit, justo sagittis malesuada
|
|
||||||
molestie, nisi nunc placerat libero, vel vulputate elit tellus et
|
|
||||||
augue. Phasellus tempor lectus ac nisi aliquam faucibus. Donec feugiat
|
Long running operations can be backgrounded, and their status can be checked on later. The same job ID is given to the same task on all hosts, so you won't lose track. Polling support is pending in the command line.::
|
||||||
egestas nibh id mattis. In hac habitasse platea dictumst. Ut accumsan
|
|
||||||
lorem eget leo dictum viverra.
|
ansible all -B 3600 -a "/usr/bin/long_running_operation --do-stuff"
|
||||||
|
ansible all -n job_status -a jid=123456789
|
||||||
Examples 3
|
|
||||||
``````````
|
Any module other than 'copy' or 'template' can be backgrounded.
|
||||||
|
|
||||||
Quisque egestas lorem sit amet felis tincidunt adipiscing. Aenean
|
|
||||||
ornare fermentum accumsan. Aenean eu mauris arcu, id pulvinar
|
Examples 3: File Transfer & Templating
|
||||||
quam. Suspendisse nec massa vel augue laoreet ultricies in convallis
|
``````````````````````````````````````
|
||||||
dolor. Mauris sodales porta enim, non ultricies dolor luctus
|
|
||||||
in. Phasellus eu tortor lectus, vel porttitor nulla. Mauris vulputate,
|
Ansible can SCP lots of files to multiple machines in parallel, and optionally use them as template sources.
|
||||||
erat id scelerisque lobortis, nibh ipsum tristique elit, ac viverra
|
|
||||||
arcu sem a ante. Praesent nec metus vestibulum augue eleifend
|
To just transfer a file directly to many different servers::
|
||||||
suscipit. In feugiat, sem nec dignissim consequat, velit tortor
|
|
||||||
scelerisque metus, sit amet mollis nisl sem eu nibh. Quisque in nibh
|
ansible atlanta copy -a "/etc/hosts /tmp/hosts"
|
||||||
turpis. Proin ac nisi ligula, a pretium augue.
|
|
||||||
|
To use templating, first run the setup module to put the template variables you would like to use on the remote host. Then use the template module to write the files using the templates. Templates are written in Jinja2 format. Playbooks (covered below) will run the setup module for you, making this even simpler.::
|
||||||
Examples 3
|
|
||||||
``````````
|
ansible webservers -m setup -a "favcolor=red ntp_server=192.168.1.1"
|
||||||
|
ansible webservers -m template -a "src=/srv/motd.j2 dest=/etc/motd"
|
||||||
In nibh eros, laoreet id interdum vel, sodales sed tortor. Sed
|
ansible webservers -m template -a "src=/srv/ntp.j2 dest=/etc/ntp.conf"
|
||||||
ullamcorper, sem vel mattis consectetur, nibh turpis molestie nisl,
|
|
||||||
eget lobortis mi magna sed metus. Cras justo est, tempus quis
|
Need something like the fqdn in a template? If facter or ohai are installed, data from these projects will also be made available to the template engine, using 'facter' and 'ohai' prefixes for each.
|
||||||
adipiscing ut, hendrerit convallis sem. Mauris ullamcorper, sapien et
|
|
||||||
luctus iaculis, urna elit egestas ipsum, et tristique enim risus vitae
|
Examples 3: Deploying From Source Control
|
||||||
nunc. Vivamus aliquet lorem eu urna pulvinar hendrerit malesuada nunc
|
`````````````````````````````````````````
|
||||||
sollicitudin. Cras in mi rhoncus quam egestas dignissim vel sit amet
|
|
||||||
lacus. Maecenas interdum viverra laoreet. Quisque elementum
|
Deploy your webapp straight from git::
|
||||||
sollicitudin ullamcorper.
|
|
||||||
|
ansible webservers -m git -a "repo=git://foo dest=/srv/myapp version=HEAD"
|
||||||
Examples 4
|
|
||||||
``````````
|
Since ansible modules can notify change handlers (see 'Playbooks') it is possible to tell ansible to run specific tasks when the code is updated, such as deploying Perl/Python/PHP/Ruby directly from git and then restarting apache.
|
||||||
|
|
||||||
Pellentesque mauris sem, malesuada at lobortis in, porta eget
|
|
||||||
urna. Duis aliquet quam eget risus elementum quis auctor ligula
|
|
||||||
gravida. Phasellus et ullamcorper libero. Nam elementum ultricies
|
|
||||||
tellus, in sagittis magna aliquet quis. Ut sit amet tellus id erat
|
|
||||||
tristique lobortis. Suspendisse est enim, tristique eu convallis id,
|
|
||||||
rutrum nec lacus. Fusce iaculis diam non felis rutrum lobortis. Proin
|
|
||||||
hendrerit mi tincidunt dui fermentum placerat.
|
|
||||||
|
@ -1,67 +1,100 @@
|
|||||||
Getting Started
|
Getting Started
|
||||||
===============
|
===============
|
||||||
|
|
||||||
How to ansible
|
How to download ansible and get started using it
|
||||||
|
|
||||||
|
|
||||||
.. seealso::
|
.. seealso::
|
||||||
|
|
||||||
|
:doc:`examples`
|
||||||
|
Examples of basic commands
|
||||||
:doc:`YAMLScripts`
|
:doc:`YAMLScripts`
|
||||||
Complete documentation of the YAML syntax `ansible` understands.
|
Complete documentation of the YAML syntax `ansible` understands for playbooks.
|
||||||
|
:doc:`playbooks`
|
||||||
|
Learning ansible's configuration management language
|
||||||
What you need
|
:doc:`modules`
|
||||||
-------------
|
Learn about modules that ship with ansible
|
||||||
|
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
|
Requirements
|
||||||
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,
|
Requirements are extremely minimal.
|
||||||
dolor diam rutrum lectus, sed luctus neque neque vitae eros. Vivamus
|
|
||||||
mattis, ipsum ut bibendum gravida, lectus arcu venenatis elit, vitae
|
If you are running python 2.6 on the **overlord** machine, you will
|
||||||
luctus diam leo sit amet ligula. Nunc egestas justo in nulla sagittis
|
need:
|
||||||
ut suscipit sapien gravida. Morbi id dui nibh. Nullam diam massa,
|
|
||||||
rhoncus a dignissim non, adipiscing vel arcu. Quisque ultricies
|
* ``paramiko``
|
||||||
tincidunt purus ut sodales. Quisque scelerisque dapibus purus quis
|
* ``PyYAML``
|
||||||
egestas. Maecenas sagittis porttitor adipiscing. Duis eu magna
|
* ``python-jinja2`` (for playbooks)
|
||||||
sem. Donec arcu felis, faucibus et malesuada non, blandit vitae
|
|
||||||
metus. Fusce nec sapien dolor.
|
If you are running less than Python 2.6, you will also need:
|
||||||
|
|
||||||
Aenean ac fermentum nisl. Integer leo sem, rutrum nec dictum at,
|
* The Python 2.4 or 2.5 backport of the ``multiprocessing`` module
|
||||||
pretium quis sapien. Duis felis metus, sodales sit amet gravida in,
|
|
||||||
pretium ut arcu. Nulla ligula quam, aliquam sit amet sollicitudin
|
- `Installation and Testing Instructions <http://code.google.com/p/python-multiprocessing/wiki/Install>`_
|
||||||
eget, molestie tincidunt ipsum. Nulla leo nunc, mattis sed auctor at,
|
|
||||||
suscipit ut metus. Suspendisse hendrerit, justo sagittis malesuada
|
* ``simplejson``
|
||||||
molestie, nisi nunc placerat libero, vel vulputate elit tellus et
|
|
||||||
augue. Phasellus tempor lectus ac nisi aliquam faucibus. Donec feugiat
|
On the managed nodes, to use templating, you will need:
|
||||||
egestas nibh id mattis. In hac habitasse platea dictumst. Ut accumsan
|
|
||||||
lorem eget leo dictum viverra.
|
* ``python-jinja2`` (you can install this with ansible)
|
||||||
|
|
||||||
Quisque egestas lorem sit amet felis tincidunt adipiscing. Aenean
|
Developer Requirements
|
||||||
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
|
For developers, you may wish to have:
|
||||||
in. Phasellus eu tortor lectus, vel porttitor nulla. Mauris vulputate,
|
|
||||||
erat id scelerisque lobortis, nibh ipsum tristique elit, ac viverra
|
* ``asciidoc`` (for building manpage documentation)
|
||||||
arcu sem a ante. Praesent nec metus vestibulum augue eleifend
|
* ``python-sphinx`` (for building content for ansible.github.com)
|
||||||
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.
|
Getting Ansible
|
||||||
|
```````````````
|
||||||
In nibh eros, laoreet id interdum vel, sodales sed tortor. Sed
|
|
||||||
ullamcorper, sem vel mattis consectetur, nibh turpis molestie nisl,
|
Tagged releases are available as tar.gz files from the Ansible github
|
||||||
eget lobortis mi magna sed metus. Cras justo est, tempus quis
|
project page:
|
||||||
adipiscing ut, hendrerit convallis sem. Mauris ullamcorper, sapien et
|
|
||||||
luctus iaculis, urna elit egestas ipsum, et tristique enim risus vitae
|
* `Ansible/downloads <https://github.com/ansible/ansible/downloads>`_
|
||||||
nunc. Vivamus aliquet lorem eu urna pulvinar hendrerit malesuada nunc
|
|
||||||
sollicitudin. Cras in mi rhoncus quam egestas dignissim vel sit amet
|
You can also clone the git repository yourself and install Ansible in
|
||||||
lacus. Maecenas interdum viverra laoreet. Quisque elementum
|
one of two ways:
|
||||||
sollicitudin ullamcorper.
|
|
||||||
|
|
||||||
Pellentesque mauris sem, malesuada at lobortis in, porta eget
|
Python Distutils
|
||||||
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
|
You can also install Ansible using Python Distutils::
|
||||||
tristique lobortis. Suspendisse est enim, tristique eu convallis id,
|
|
||||||
rutrum nec lacus. Fusce iaculis diam non felis rutrum lobortis. Proin
|
$ git clone git://github.com/ansible/ansible.git
|
||||||
hendrerit mi tincidunt dui fermentum placerat.
|
$ 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
|
Ansible Modules
|
||||||
=======
|
===============
|
||||||
|
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
|
.. seealso::
|
||||||
placerat nibh, non feugiat risus varius vitae. Donec eu libero
|
|
||||||
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
|
:doc:`examples`
|
||||||
magna porta venenatis. Quisque scelerisque, sem non ultrices bibendum,
|
Examples of using modules in /usr/bin/ansible
|
||||||
dolor diam rutrum lectus, sed luctus neque neque vitae eros. Vivamus
|
:doc:`playbooks`
|
||||||
mattis, ipsum ut bibendum gravida, lectus arcu venenatis elit, vitae
|
Examples of using modules with /usr/bin/ansible-playbook
|
||||||
luctus diam leo sit amet ligula. Nunc egestas justo in nulla sagittis
|
:doc:`api`
|
||||||
ut suscipit sapien gravida. Morbi id dui nibh. Nullam diam massa,
|
Examples of using modules with the Python API
|
||||||
rhoncus a dignissim non, adipiscing vel arcu. Quisque ultricies
|
|
||||||
tincidunt purus ut sodales. Quisque scelerisque dapibus purus quis
|
|
||||||
egestas. Maecenas sagittis porttitor adipiscing. Duis eu magna
|
About Modules
|
||||||
sem. Donec arcu felis, faucibus et malesuada non, blandit vitae
|
`````````````
|
||||||
metus. Fusce nec sapien dolor.
|
|
||||||
|
Ansible ships with a number of modules that can be executed directly on remote hosts or through
|
||||||
Aenean ac fermentum nisl. Integer leo sem, rutrum nec dictum at,
|
ansible playbooks.
|
||||||
pretium quis sapien. Duis felis metus, sodales sit amet gravida in,
|
|
||||||
pretium ut arcu. Nulla ligula quam, aliquam sit amet sollicitudin
|
|
||||||
eget, molestie tincidunt ipsum. Nulla leo nunc, mattis sed auctor at,
|
Idempotence
|
||||||
suscipit ut metus. Suspendisse hendrerit, justo sagittis malesuada
|
```````````
|
||||||
molestie, nisi nunc placerat libero, vel vulputate elit tellus et
|
|
||||||
augue. Phasellus tempor lectus ac nisi aliquam faucibus. Donec feugiat
|
Most modules other than command are idempotent, meaning they will seek to avoid changes
|
||||||
egestas nibh id mattis. In hac habitasse platea dictumst. Ut accumsan
|
unless a change needs to be made. When using ansible playbooks, these modules can
|
||||||
lorem eget leo dictum viverra.
|
trigger change events. Unless otherwise noted, all modules support change hooks.
|
||||||
|
|
||||||
Quisque egestas lorem sit amet felis tincidunt adipiscing. Aenean
|
|
||||||
ornare fermentum accumsan. Aenean eu mauris arcu, id pulvinar
|
command
|
||||||
quam. Suspendisse nec massa vel augue laoreet ultricies in convallis
|
```````
|
||||||
dolor. Mauris sodales porta enim, non ultricies dolor luctus
|
|
||||||
in. Phasellus eu tortor lectus, vel porttitor nulla. Mauris vulputate,
|
The command module takes the command name followed by a list of arguments, space delimited.
|
||||||
erat id scelerisque lobortis, nibh ipsum tristique elit, ac viverra
|
This is the only module that does not use key=value style parameters.
|
||||||
arcu sem a ante. Praesent nec metus vestibulum augue eleifend
|
|
||||||
suscipit. In feugiat, sem nec dignissim consequat, velit tortor
|
Example usage::
|
||||||
scelerisque metus, sit amet mollis nisl sem eu nibh. Quisque in nibh
|
|
||||||
turpis. Proin ac nisi ligula, a pretium augue.
|
/sbin/shutdown -t now
|
||||||
|
|
||||||
In nibh eros, laoreet id interdum vel, sodales sed tortor. Sed
|
This module does not support change hooks and returns the return code from the program as well as timing information about how long the command was running for.
|
||||||
ullamcorper, sem vel mattis consectetur, nibh turpis molestie nisl,
|
|
||||||
eget lobortis mi magna sed metus. Cras justo est, tempus quis
|
|
||||||
adipiscing ut, hendrerit convallis sem. Mauris ullamcorper, sapien et
|
copy
|
||||||
luctus iaculis, urna elit egestas ipsum, et tristique enim risus vitae
|
````
|
||||||
nunc. Vivamus aliquet lorem eu urna pulvinar hendrerit malesuada nunc
|
|
||||||
sollicitudin. Cras in mi rhoncus quam egestas dignissim vel sit amet
|
The copy module moves a file on the local box to remote locations.
|
||||||
lacus. Maecenas interdum viverra laoreet. Quisque elementum
|
|
||||||
sollicitudin ullamcorper.
|
*src*::
|
||||||
|
|
||||||
Pellentesque mauris sem, malesuada at lobortis in, porta eget
|
Local absolute path to a file to copy to the remote server
|
||||||
urna. Duis aliquet quam eget risus elementum quis auctor ligula
|
|
||||||
gravida. Phasellus et ullamcorper libero. Nam elementum ultricies
|
|
||||||
tellus, in sagittis magna aliquet quis. Ut sit amet tellus id erat
|
*dest*::
|
||||||
tristique lobortis. Suspendisse est enim, tristique eu convallis id,
|
|
||||||
rutrum nec lacus. Fusce iaculis diam non felis rutrum lobortis. Proin
|
Remote absolute path where the file should end up
|
||||||
hendrerit mi tincidunt dui fermentum placerat.
|
|
||||||
|
|
||||||
|
This module also returns md5sum information about the resultant file.
|
||||||
|
|
||||||
|
|
||||||
|
facter
|
||||||
|
``````
|
||||||
|
|
||||||
|
Runs the discovery program 'facter' on the remote system, returning
|
||||||
|
JSON data that can be useful for inventory purposes.
|
||||||
|
|
||||||
|
Requires that 'facter' and 'ruby-json' be installed on the remote end.
|
||||||
|
|
||||||
|
This module is informative only - it takes no parameters & does not support change hooks,
|
||||||
|
nor does it make any changes on the system.
|
||||||
|
|
||||||
|
|
||||||
|
git
|
||||||
|
```
|
||||||
|
|
||||||
|
Deploys software from git checkouts.
|
||||||
|
|
||||||
|
*repo*::
|
||||||
|
|
||||||
|
git or http protocol address of the repo to checkout
|
||||||
|
|
||||||
|
*dest*::
|
||||||
|
|
||||||
|
where to check it out, an absolute directory path
|
||||||
|
|
||||||
|
*version*::
|
||||||
|
|
||||||
|
what version to check out -- either the git SHA, the literal string 'HEAD', or a tag name
|
||||||
|
|
||||||
|
|
||||||
|
ohai
|
||||||
|
````
|
||||||
|
|
||||||
|
Similar to the facter module, this returns JSON inventory data. Ohai
|
||||||
|
data is a bit more verbose and nested than facter.
|
||||||
|
|
||||||
|
Requires that 'ohai' be installed on the remote end.
|
||||||
|
|
||||||
|
This module is information only - it takes no parameters & does not
|
||||||
|
support change hooks, nor does it make any changes on the system.
|
||||||
|
|
||||||
|
|
||||||
|
ping
|
||||||
|
````
|
||||||
|
|
||||||
|
A trivial test module, this module always returns the integer '1' on
|
||||||
|
successful contact.
|
||||||
|
|
||||||
|
This module does not support change hooks.
|
||||||
|
|
||||||
|
This module is informative only - it takes no parameters & does not
|
||||||
|
support change hooks, nor does it make any changes on the system.
|
||||||
|
|
||||||
|
|
||||||
|
service
|
||||||
|
```````
|
||||||
|
|
||||||
|
Controls services on remote machines.
|
||||||
|
|
||||||
|
*state*
|
||||||
|
|
||||||
|
Values are 'started', 'stopped', or 'restarted'. Started/stopped
|
||||||
|
are idempotent actions that will not run commands unless neccessary.
|
||||||
|
'restarted' will always bounce the service
|
||||||
|
|
||||||
|
|
||||||
|
*name*
|
||||||
|
|
||||||
|
The name of the service
|
||||||
|
|
||||||
|
|
||||||
|
setup
|
||||||
|
`````
|
||||||
|
|
||||||
|
Writes a JSON file containing key/value data, for use in templating.
|
||||||
|
Call this once before using the template modules. Playbooks will
|
||||||
|
execute this module automatically as the first step in each play.
|
||||||
|
|
||||||
|
If facter or ohai are installed, variables from these programs will also
|
||||||
|
be snapshotted into the JSON file for usage in templating. These variables
|
||||||
|
are prefixed with 'facter_' and 'ohai_" so it's easy to tell their source.
|
||||||
|
|
||||||
|
*metadata*
|
||||||
|
|
||||||
|
Optionally overrides the default JSON file location of /etc/ansible/setup or ~/ansible/setup
|
||||||
|
depending on what remote user has been specified.
|
||||||
|
|
||||||
|
If used, also supply the metadata parameter to the template module.
|
||||||
|
|
||||||
|
*anything*
|
||||||
|
|
||||||
|
any other parameters can be named basically anything, and set a key=value
|
||||||
|
pair in the JSON file for use in templating.
|
||||||
|
|
||||||
|
|
||||||
|
template
|
||||||
|
````````
|
||||||
|
|
||||||
|
Templates a file out to a remote server. Call the setup module prior to usage.
|
||||||
|
|
||||||
|
*src*
|
||||||
|
|
||||||
|
path of a Jinja2 formatted template on the local server
|
||||||
|
|
||||||
|
|
||||||
|
*dest*
|
||||||
|
|
||||||
|
location to render the template on the remote server
|
||||||
|
|
||||||
|
|
||||||
|
*metadata*
|
||||||
|
|
||||||
|
location of a JSON file to use to supply template data. Default is /etc/ansible/setup
|
||||||
|
which is the same as the default for the setup module. Change if running as a non-root
|
||||||
|
remote user who does not have permissions on /etc/ansible.
|
||||||
|
|
||||||
|
|
||||||
|
This module also returns md5sum information about the resultant file.
|
||||||
|
|
||||||
|
|
||||||
|
user
|
||||||
|
````
|
||||||
|
|
||||||
|
This module is in plan.
|
||||||
|
|
||||||
|
|
||||||
|
yum
|
||||||
|
```
|
||||||
|
|
||||||
|
This module is in plan.
|
||||||
|
|
||||||
|
|
||||||
|
WRITING YOUR OWN MODULES
|
||||||
|
````````````````````````
|
||||||
|
|
||||||
|
To write your own modules, simply follow the convention of those already available in
|
||||||
|
/usr/share/ansible. Modules must return JSON but can be written in any language.
|
||||||
|
Modules should return hashes, but hashes can be nested.
|
||||||
|
To support change hooks, modules should return hashes with a changed: True/False
|
||||||
|
element at the top level. Modules can also choose to indicate a failure scenario
|
||||||
|
by returning a top level 'failure' element with a True value, and a 'msg' element
|
||||||
|
describing the nature of the failure. Other values are up to the module.
|
||||||
|
@ -1,55 +1,69 @@
|
|||||||
Patterns
|
Patterns
|
||||||
========
|
========
|
||||||
|
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
|
How to select hosts you wish to manage
|
||||||
placerat nibh, non feugiat risus varius vitae. Donec eu libero
|
|
||||||
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
|
.. seealso::
|
||||||
magna porta venenatis. Quisque scelerisque, sem non ultrices bibendum,
|
|
||||||
dolor diam rutrum lectus, sed luctus neque neque vitae eros. Vivamus
|
:doc:`examples`
|
||||||
mattis, ipsum ut bibendum gravida, lectus arcu venenatis elit, vitae
|
Examples of basic commands
|
||||||
luctus diam leo sit amet ligula. Nunc egestas justo in nulla sagittis
|
:doc:`playbooks`
|
||||||
ut suscipit sapien gravida. Morbi id dui nibh. Nullam diam massa,
|
Learning ansible's configuration management language
|
||||||
rhoncus a dignissim non, adipiscing vel arcu. Quisque ultricies
|
|
||||||
tincidunt purus ut sodales. Quisque scelerisque dapibus purus quis
|
Ansible works against multiple systems in your infrastructure at the
|
||||||
egestas. Maecenas sagittis porttitor adipiscing. Duis eu magna
|
same time. It does this by selecting portions of systems listed in Ansible's inventory file,
|
||||||
sem. Donec arcu felis, faucibus et malesuada non, blandit vitae
|
which defaults to /etc/ansible/hosts, and looks like this::
|
||||||
metus. Fusce nec sapien dolor.
|
|
||||||
|
mail.example.com
|
||||||
Aenean ac fermentum nisl. Integer leo sem, rutrum nec dictum at,
|
|
||||||
pretium quis sapien. Duis felis metus, sodales sit amet gravida in,
|
[webservers]
|
||||||
pretium ut arcu. Nulla ligula quam, aliquam sit amet sollicitudin
|
foo.example.com
|
||||||
eget, molestie tincidunt ipsum. Nulla leo nunc, mattis sed auctor at,
|
bar.example.com
|
||||||
suscipit ut metus. Suspendisse hendrerit, justo sagittis malesuada
|
|
||||||
molestie, nisi nunc placerat libero, vel vulputate elit tellus et
|
[dbservers]
|
||||||
augue. Phasellus tempor lectus ac nisi aliquam faucibus. Donec feugiat
|
one.example.com
|
||||||
egestas nibh id mattis. In hac habitasse platea dictumst. Ut accumsan
|
two.example.com
|
||||||
lorem eget leo dictum viverra.
|
three.example.com
|
||||||
|
|
||||||
Quisque egestas lorem sit amet felis tincidunt adipiscing. Aenean
|
Targetting All Systems
|
||||||
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
|
The pattern 'all' or '*' targets all systems in the inventory file.
|
||||||
in. Phasellus eu tortor lectus, vel porttitor nulla. Mauris vulputate,
|
|
||||||
erat id scelerisque lobortis, nibh ipsum tristique elit, ac viverra
|
Specific Hosts
|
||||||
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
|
It is possible to address specific hosts:
|
||||||
turpis. Proin ac nisi ligula, a pretium augue.
|
|
||||||
|
one.example.com
|
||||||
In nibh eros, laoreet id interdum vel, sodales sed tortor. Sed
|
one.example.com:two.example.com
|
||||||
ullamcorper, sem vel mattis consectetur, nibh turpis molestie nisl,
|
|
||||||
eget lobortis mi magna sed metus. Cras justo est, tempus quis
|
Groups
|
||||||
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
|
The following patterns address one or more groups:
|
||||||
sollicitudin. Cras in mi rhoncus quam egestas dignissim vel sit amet
|
|
||||||
lacus. Maecenas interdum viverra laoreet. Quisque elementum
|
webservers
|
||||||
sollicitudin ullamcorper.
|
webservers:dbservers
|
||||||
|
|
||||||
Pellentesque mauris sem, malesuada at lobortis in, porta eget
|
There is also a magic group 'ungrouped' which selects systems not in a group.
|
||||||
urna. Duis aliquet quam eget risus elementum quis auctor ligula
|
|
||||||
gravida. Phasellus et ullamcorper libero. Nam elementum ultricies
|
Wildcards
|
||||||
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
|
Individual hosts, but not groups, can also be referenced using wildcards:
|
||||||
hendrerit mi tincidunt dui fermentum placerat.
|
|
||||||
|
*.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
|
Playbooks
|
||||||
=========
|
=========
|
||||||
|
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In dignissim
|
.. seealso::
|
||||||
placerat nibh, non feugiat risus varius vitae. Donec eu libero
|
|
||||||
lectus. Ut non orci felis, eget mattis mauris. Etiam ut tellus in
|
:doc:`YAMLScripts`
|
||||||
magna porta venenatis. Quisque scelerisque, sem non ultrices bibendum,
|
Learn about YAML syntax
|
||||||
dolor diam rutrum lectus, sed luctus neque neque vitae eros. Vivamus
|
:doc:`modules`
|
||||||
mattis, ipsum ut bibendum gravida, lectus arcu venenatis elit, vitae
|
Learn about available modules and writing your own
|
||||||
luctus diam leo sit amet ligula. Nunc egestas justo in nulla sagittis
|
:doc:`patterns`
|
||||||
ut suscipit sapien gravida. Morbi id dui nibh. Nullam diam massa,
|
Learn about how to select hosts
|
||||||
rhoncus a dignissim non, adipiscing vel arcu. Quisque ultricies
|
|
||||||
tincidunt purus ut sodales. Quisque scelerisque dapibus purus quis
|
|
||||||
egestas. Maecenas sagittis porttitor adipiscing. Duis eu magna
|
Playbooks are a completely different way to use ansible and are particularly awesome.
|
||||||
sem. Donec arcu felis, faucibus et malesuada non, blandit vitae
|
|
||||||
metus. Fusce nec sapien dolor.
|
They are the basis for a really simple configuration management and deployment system, unlike any that already exist, and one that is very well suited to deploying complex multi-machine applications. While you might run the main ansible program for ad-hoc tasks, playbooks are more likely to be kept in source control and used to push out your configuration or assure the configurations of your remote systems are in spec.
|
||||||
|
|
||||||
Aenean ac fermentum nisl. Integer leo sem, rutrum nec dictum at,
|
|
||||||
pretium quis sapien. Duis felis metus, sodales sit amet gravida in,
|
Playbook Example
|
||||||
pretium ut arcu. Nulla ligula quam, aliquam sit amet sollicitudin
|
````````````````
|
||||||
eget, molestie tincidunt ipsum. Nulla leo nunc, mattis sed auctor at,
|
|
||||||
suscipit ut metus. Suspendisse hendrerit, justo sagittis malesuada
|
Playbooks are expressed in YAML format and have a minimum of syntax. Each playbook is composed
|
||||||
molestie, nisi nunc placerat libero, vel vulputate elit tellus et
|
of one or more patterns in a list. By composing a playbook of multiple patterns, it is possible
|
||||||
augue. Phasellus tempor lectus ac nisi aliquam faucibus. Donec feugiat
|
to orchestrate multi-machine deployments, running certain steps on all machines in
|
||||||
egestas nibh id mattis. In hac habitasse platea dictumst. Ut accumsan
|
the webservers group, then certain steps on the database server group, then more commands
|
||||||
lorem eget leo dictum viverra.
|
back on the webservers group, etc::
|
||||||
|
|
||||||
Quisque egestas lorem sit amet felis tincidunt adipiscing. Aenean
|
---
|
||||||
ornare fermentum accumsan. Aenean eu mauris arcu, id pulvinar
|
- hosts: all
|
||||||
quam. Suspendisse nec massa vel augue laoreet ultricies in convallis
|
vars:
|
||||||
dolor. Mauris sodales porta enim, non ultricies dolor luctus
|
http_port: 80
|
||||||
in. Phasellus eu tortor lectus, vel porttitor nulla. Mauris vulputate,
|
max_clients: 200
|
||||||
erat id scelerisque lobortis, nibh ipsum tristique elit, ac viverra
|
user: root
|
||||||
arcu sem a ante. Praesent nec metus vestibulum augue eleifend
|
tasks:
|
||||||
suscipit. In feugiat, sem nec dignissim consequat, velit tortor
|
- include: base.yml somevar=3 othervar=4
|
||||||
scelerisque metus, sit amet mollis nisl sem eu nibh. Quisque in nibh
|
- name: write the apache config file
|
||||||
turpis. Proin ac nisi ligula, a pretium augue.
|
action: template src=/srv/httpd.j2 dest=/etc/httpd.conf
|
||||||
|
notify:
|
||||||
In nibh eros, laoreet id interdum vel, sodales sed tortor. Sed
|
- restart apache
|
||||||
ullamcorper, sem vel mattis consectetur, nibh turpis molestie nisl,
|
- name: ensure apache is running
|
||||||
eget lobortis mi magna sed metus. Cras justo est, tempus quis
|
action: service name=httpd state=started
|
||||||
adipiscing ut, hendrerit convallis sem. Mauris ullamcorper, sapien et
|
handlers:
|
||||||
luctus iaculis, urna elit egestas ipsum, et tristique enim risus vitae
|
- include: handlers.yml
|
||||||
nunc. Vivamus aliquet lorem eu urna pulvinar hendrerit malesuada nunc
|
|
||||||
sollicitudin. Cras in mi rhoncus quam egestas dignissim vel sit amet
|
Hosts line
|
||||||
lacus. Maecenas interdum viverra laoreet. Quisque elementum
|
``````````
|
||||||
sollicitudin ullamcorper.
|
|
||||||
|
The hosts line is alist of one or more groups or host patterns, seperated by colons.::
|
||||||
Pellentesque mauris sem, malesuada at lobortis in, porta eget
|
|
||||||
urna. Duis aliquet quam eget risus elementum quis auctor ligula
|
webservers:dbservers:*.foo.example.com
|
||||||
gravida. Phasellus et ullamcorper libero. Nam elementum ultricies
|
|
||||||
tellus, in sagittis magna aliquet quis. Ut sit amet tellus id erat
|
Vars section
|
||||||
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.
|
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