Please enable JavaScript.
Coggle requires JavaScript to display documents.
Phase 5 — Modules (Enterprise Level) - Coggle Diagram
Phase 5 — Modules (Enterprise Level)
What is a Module?
Definition
A module is a reusable program executed by Ansible on managed nodes to perform a specific task.
Instead of manually typing Linux commands, Ansible modules automate the task.
Modules are idempotent.
Idempotent means running the same task multiple times does not make unnecessary changes.
Modules return structured results.
Changed
Failed
Success
Output
Error Messages
Most Linux modules execute remotely using Python.
Some modules (raw) do not require Python.
Module Execution Process
Controller
Reads Playbook
Reads Inventory
Selects Target Hosts
Connects through SSH
Copies Temporary Module
Executes Module
Collects Result
Deletes Temporary Files
Displays Output
Module Location
Built-in Modules
ansible.builtin
Collections
ansible.posix
community.general
community.docker
kubernetes.core
amazon.aws
View All Modules
ansible-doc -l
View Module Documentation
ansible-doc package
ansible-doc copy
ansible-doc systemd
Show Examples
ansible-doc copy
Linux Package Management Modules
package
Purpose
Universal package manager.
Automatically chooses apt, dnf, yum, zypper, etc.
Used For
Cross-platform playbooks.
Syntax
package
name
state
State Values
present
absent
latest
Example
Install nginx
Remove nginx
Upgrade nginx
Enterprise Usage
Mixed Ubuntu and RHEL environments
Generic playbooks
apt
Operating System
Ubuntu
Debian
Backend Command
apt
apt-get
Package Database
/var/lib/dpkg/
Configuration
/etc/apt/
Cache
/var/cache/apt/
Important Parameters
name
state
update_cache
upgrade
autoremove
State
present
absent
latest
Enterprise Tasks
Update Repository Cache
Install Security Updates
Remove Old Packages
Clean Dependencies
Linux Commands
apt update
apt install nginx
apt remove nginx
apt autoremove
yum
Operating System
RHEL 7
CentOS 7
Repository
/etc/yum.repos.d/
Cache
/var/cache/yum/
Configuration
/etc/yum.conf
Parameters
name
state
update_cache
Enterprise Usage
Legacy Enterprise Servers
dnf
Operating System
RHEL 8
RHEL 9
Rocky Linux
AlmaLinux
Configuration
/etc/dnf/
Repository
/etc/yum.repos.d/
Cache
/var/cache/dnf/
Parameters
name
state
update_cache
Enterprise Tasks
Monthly Patching
Security Updates
Software Deployment
Linux Commands
dnf install
dnf update
dnf remove
Service Management Modules
service
Purpose
Controls Linux services.
Backend
System V
Upstart
systemd
Parameters
name
state
enabled
States
started
stopped
restarted
reloaded
Enterprise Usage
Apache
SSH
MariaDB
NFS
Samba
systemd
Purpose
Controls services managed by systemd.
Configuration
/etc/systemd/system/
/usr/lib/systemd/system/
Parameters
name
state
enabled
daemon_reload
masked
Enterprise Usage
Restart Services
Enable at Boot
Reload Unit Files
Mask Critical Services
Linux Commands
systemctl status
systemctl start
systemctl stop
systemctl restart
systemctl reload
systemctl enable
systemctl disable
systemctl daemon-reload
File Management Modules
file
Purpose
Manage files, directories, symbolic links and permissions.
Parameters
path
state
owner
group
mode
recurse
States
file
directory
touch
absent
link
hard
Permissions
rwx
Numeric
644
755
600
700
Enterprise Tasks
Create Directories
Delete Files
Set Ownership
Change Permissions
Linux Commands
chmod
chown
mkdir
rm
touch
ln
copy
Purpose
Copy files from Controller to Managed Node.
Source
Controller
Destination
Remote Server
Parameters
src
dest
owner
group
mode
backup
force
Enterprise Usage
Configuration Files
Scripts
Certificates
SSH Keys
Default Source
project/files/
template
Purpose
Copy dynamic files using Jinja2 variables.
Extension
.j2
Source
project/templates/
Destination
Managed Node
Parameters
src
dest
owner
group
mode
Variables
hostvars
group_vars
host_vars
facts
Enterprise Usage
nginx.conf
httpd.conf
sshd_config
application.properties
lineinfile
Purpose
Add
Modify
Replace
Remove one line
Parameters
path
regexp
line
insertafter
insertbefore
state
Enterprise Usage
SSH Configuration
Sysctl
Hosts File
Limits.conf
blockinfile
Purpose
Insert multiple lines.
Parameters
path
block
marker
Enterprise Usage
Firewall Rules
SSH Blocks
Apache Configuration
Application Settings
User Management Modules
user
Purpose
Manage Linux users.
Files
/etc/passwd
/etc/shadow
/etc/group
Parameters
name
uid
shell
groups
append
password
home
state
Enterprise Tasks
Create Users
Lock Users
Expire Accounts
Assign Groups
Linux Commands
useradd
usermod
userdel
passwd
chage
group
Purpose
Manage Linux groups.
File
/etc/group
Parameters
name
gid
state
Enterprise Usage
RBAC
Department Groups
Project Groups
Linux Commands
groupadd
groupmod
groupdel
Job Scheduling
cron
Purpose
Schedule recurring tasks.
Configuration
/etc/crontab
/etc/cron.d/
/var/spool/cron/
Parameters
minute
hour
day
month
weekday
job
Enterprise Usage
Backup
Log Cleanup
Monitoring
Patch Reports
Linux Commands
crontab -e
crontab -l
System Control
reboot
Purpose
Restart Servers.
Parameters
reboot_timeout
test_command
pre_reboot_delay
post_reboot_delay
Enterprise Usage
Kernel Updates
Security Patches
mount
Purpose
Manage mounted file systems.
Configuration
/etc/fstab
Parameters
path
src
fstype
opts
state
Enterprise Usage
NFS
CIFS
SAN Storage
Cloud Storage
Linux Commands
mount
umount
findmnt
lsblk
df -h
File Transfer Modules
fetch
Purpose
Copy files from Managed Node to Controller.
Direction
Remote → Controller
Enterprise Usage
Log Collection
Backup Configurations
Incident Response
synchronize
Purpose
Synchronize directories using rsync.
Backend
rsync
Direction
Controller ↔ Managed Node
Managed Node ↔ Managed Node
Enterprise Usage
Website Deployment
Configuration Backup
Disaster Recovery
Linux Command
rsync
Command Execution Modules
command
Purpose
Execute Linux commands safely.
Features
No shell
No pipes
No variables
No redirects
Enterprise Usage
hostname
uptime
date
id
shell
Purpose
Execute shell commands.
Supports
Pipes
Redirects
Variables
Wildcards
Command Substitution
Enterprise Usage
grep
awk
sed
find
Complex Bash Scripts
script
Purpose
Copy local script and execute remotely.
Supported Scripts
Bash
Python
Perl
Enterprise Usage
Legacy Automation
Migration Scripts
Health Checks
raw
Purpose
Execute commands without Python.
Used For
Initial Server Bootstrap
Install Python
Rescue Systems
Minimal Linux Installations
Enterprise Usage
First-time Provisioning
Emergency Recovery
Network and Web Modules
uri
Purpose
Send HTTP and HTTPS requests.
Methods
GET
POST
PUT
DELETE
PATCH
Enterprise Usage
REST APIs
Jenkins
GitLab
AWX
Kubernetes
ServiceNow
get_url
Purpose
Download files from HTTP HTTPS FTP.
Parameters
url
dest
checksum
mode
Enterprise Usage
Download Packages
Download ISO
Download Certificates
Download Application Binaries
Linux Command Equivalent
wget
curl
unarchive
Purpose
Extract compressed archives.
Supported Formats
tar
tar.gz
tgz
zip
bz2
xz
Parameters
src
dest
remote_src
Enterprise Usage
Software Installation
Application Deployment
Backup Restoration
Linux Commands
tar
unzip
gzip
bzip2
Enterprise Module Best Practices
Use Fully Qualified Collection Names
ansible.builtin.copy
ansible.builtin.systemd
ansible.builtin.user
Use Idempotent Modules
Avoid shell when dedicated module exists.
Store Files
files/
Store Templates
templates/
Store Variables
group_vars/
host_vars/
Store Secrets
Ansible Vault
Validate Playbooks
ansible-playbook --syntax-check
ansible-lint
Test Before Production
--check
--diff
Increase Output
-v
-vv
-vvv
-vvvv
Gather Facts
setup module
View Module Documentation
ansible-doc -l
ansible-doc module_name
Enterprise Goal
Prefer dedicated modules over shell or command because modules are idempotent, easier to read, more secure, and provide structured results.