Essential Ansible Modules
From bib. source
For example, it is possible to create a group using the group module, like so (with “app” as ansible inventory file group) (Geerling 2023, 34):
$ ansible app -b -m group -a "name=admin state=present"The substrings comprised of a space-separated sequence of terms joined by equal signs qualify as a list of parameters and their arguments for the given module in use, in this case the group module.
An example for creating a user would be as follows:
$ ansible app -b -m user -a "name=johndoe group=admin createhome=yes"The pattern then is that the module is selected via the -m option, whereas the value provided for that module, containing parameters valid for it, are written under the -a option (as explained in 20250322150219-Ansible_Modules_via_CLI).
The other Ansible modules are as follows:
| module | role | parameters |
|---|---|---|
group | management of system groups | - name- state- gid- system |
user | management of system users | - name- group- createhome- generate_ssh_key- uid- shell- password |
package | management of system packages | - name- state |
stat | acquisition of file or directory metadata | - path |
copy | copying or duplication of files | - src- dest |
fetch | ? | - src- dest- flat |
file | creation of files and directories | - dest- mode- state |
unarchive | ? | ? |
rsync | file synchronization tool for either local or remote files/directories | ? |
synchronize | ? | ? |
shell | run commands on the remote shell | ? |
cron | managing crontab tasks | ? |
git | usage of git software | ? |
service | manages systemd service units | - name- state- enabled |
pip | python package management | ? |
firewalld | system firewall configuration | ? |
user_management group_management configuration_management command_line command_line_interface bash_script bash_scripting bash Bourne_Again_Shell Bourne_Again_Shell_script Bourne_Again_Shell_scripting module modules
bibliography
- “Ad-Hoc Commands.” In Ansible for DevOps: Server and Configuration Management for Humans, 2nd ed., 18–46. Leanpub, 2023.