7. Modules¶
7.1. About Modules¶
changes with Ansible are done by modules
Ansible provides a lot of common modules (called the module library)
common modules are written in Python
you can write your own modules in any language
Core Modules shipped with Ansible Core
Extra Modules via github, new also as own package
modules can be used to only check a state without executing
some modules can also be used to compare the state and show the differences
every module has a documentation with examples
- Online Docs
ansible-docBinary
Hint
If you’re familiar with role/profiles design pattern in Puppet, keep in mind there is no such thing in Ansible. Ansible modules are roles.
Important
Use modules, they are tested, often used and idempotent.
7.1.1. Links¶
7.2. Popular Modules¶
There are modules for almost everything:
- Package Management (like
yum,apt) - Remote Execution (
command,shell) - Service Management (like
service) - File Handling (
copy,template) - SCM (like
git,subversion) - User / Group Handling (like
user,group) - Web / Database Management
- Cloud Services
- Network Services
And there are many more, checkout the links below with all the categories.
7.3. Run a modul as ad-hoc command¶
ansible -m <modul> -a <argument> <host(s)/hostgroup>
# install tree package on db hosts
ansible -m package -a "name=tree state=present" db