Essential Ansible Modules

From bib. source

One of the most common uses for Ansible’s ad-hoc commands in my day-to-day usage is user and group management. […] Ansible’s user and group modules make things pretty simple and standard across any Linux flavor.

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:

moduleroleparameters
groupmanagement of system groups- name
- state
- gid
- system
usermanagement of system users- name
- group
- createhome
- generate_ssh_key
- uid
- shell
- password
packagemanagement of system packages- name
- state
statacquisition of file or directory metadata- path
copycopying or duplication of files- src
- dest
fetch?- src
- dest
- flat
filecreation of files and directories- dest
- mode
- state
unarchive??
rsyncfile synchronization tool for either local or remote files/directories?
synchronize??
shellrun commands on the remote shell?
cronmanaging crontab tasks?
gitusage of git software?
servicemanages systemd service units- name
- state
- enabled
pippython package management?
firewalldsystem 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.