mirror of https://github.com/ansible/ansible.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
86 lines
2.7 KiB
ReStructuredText
86 lines
2.7 KiB
ReStructuredText
13 years ago
|
Ansible Modules
|
||
|
===============
|
||
|
|
||
12 years ago
|
.. image:: http://ansible.cc/docs/_static/ansible_fest_2013.png
|
||
|
:alt: ansiblefest 2013
|
||
12 years ago
|
:target: http://ansibleworks.com/fest
|
||
12 years ago
|
|
||
12 years ago
|
.. contents::
|
||
|
:depth: 2
|
||
|
:backlinks: top
|
||
|
|
||
|
Introduction
|
||
|
````````````
|
||
|
|
||
|
|
||
12 years ago
|
Ansible ships with a number of modules (called the 'module library')
|
||
13 years ago
|
that can be executed directly on remote hosts or through :doc:`playbooks`.
|
||
|
Users can also write their own modules. These modules can control system
|
||
12 years ago
|
resources, like services, packages, or files (anything really), or
|
||
|
handle executing system commands.
|
||
13 years ago
|
|
||
13 years ago
|
Let's review how we execute three different modules from the command line::
|
||
|
|
||
|
ansible webservers -m service -a "name=httpd state=running"
|
||
|
ansible webservers -m ping
|
||
|
ansible webservers -m command -a "/sbin/reboot -t now"
|
||
|
|
||
12 years ago
|
Each module supports taking arguments. Nearly all modules take ``key=value``
|
||
|
arguments, space delimited. Some modules take no arguments, and the
|
||
12 years ago
|
command/shell modules simply take the string of the command you want to run.
|
||
13 years ago
|
|
||
13 years ago
|
From playbooks, Ansible modules are executed in a very similar way::
|
||
|
|
||
|
- name: reboot the servers
|
||
12 years ago
|
action: command /sbin/reboot -t now
|
||
13 years ago
|
|
||
12 years ago
|
Version 0.8 and higher support the following shorter syntax::
|
||
|
|
||
|
- name: reboot the servers
|
||
|
command: /sbin/reboot -t now
|
||
|
|
||
13 years ago
|
All modules technically return JSON format data, though if you are using the
|
||
13 years ago
|
command line or playbooks, you don't really need to know much about
|
||
13 years ago
|
that. If you're writing your own module, you care, and this means you do
|
||
13 years ago
|
not have to write modules in any particular language -- you get to choose.
|
||
13 years ago
|
|
||
12 years ago
|
Modules are `idempotent`, meaning they will seek to avoid changes to the system unless a change needs to be made. When using Ansible
|
||
|
playbooks, these modules can trigger 'change events' in the form of notifying 'handlers'
|
||
|
to run additional tasks.
|
||
13 years ago
|
|
||
12 years ago
|
Documention for each module can be accessed from the command line with the
|
||
|
ansible-doc as well as the man command::
|
||
|
|
||
|
ansible-doc command
|
||
|
|
||
|
man ansible.template
|
||
|
|
||
13 years ago
|
Let's see what's available in the Ansible module library, out of the box:
|
||
13 years ago
|
|
||
13 years ago
|
|
||
12 years ago
|
.. include:: modules/_list.rst
|
||
13 years ago
|
|
||
13 years ago
|
|
||
13 years ago
|
Writing your own modules
|
||
|
````````````````````````
|
||
13 years ago
|
|
||
13 years ago
|
See :doc:`moduledev`.
|
||
13 years ago
|
|
||
|
.. seealso::
|
||
|
|
||
12 years ago
|
:doc:`contrib`
|
||
12 years ago
|
User contributed playbooks, modules, and articles
|
||
13 years ago
|
:doc:`examples`
|
||
13 years ago
|
Examples of using modules in /usr/bin/ansible
|
||
13 years ago
|
:doc:`playbooks`
|
||
13 years ago
|
Examples of using modules with /usr/bin/ansible-playbook
|
||
13 years ago
|
:doc:`moduledev`
|
||
|
How to write your own modules
|
||
13 years ago
|
:doc:`api`
|
||
|
Examples of using modules with the Python API
|
||
13 years ago
|
`Mailing List <http://groups.google.com/group/ansible-project>`_
|
||
13 years ago
|
Questions? Help? Ideas? Stop by the list on Google Groups
|
||
|
`irc.freenode.net <http://irc.freenode.net>`_
|
||
|
#ansible IRC chat channel
|
||
|
|