File, Package, Service, and User Modules¶
Section status: outline
This page is scoped but not yet written in full prose. The sections below define what it will cover.
Why This Exists¶
These modules cover the large majority of what a typical configuration-management playbook does day to day — this page is the category reference, one level below Command vs. Shell and Module Decision Trees.
What It Will Cover¶
For each module below: purpose, common parameters, idempotency behavior, check-mode support, and a minimal + production example.
- Package management:
ansible.builtin.package(cross-distro),apt,dnf/yum(distro-specific, more parameters available) - Service management:
ansible.builtin.service(cross-init-system),systemd_service(systemd-specific features likedaemon_reload) - Files and directories:
file(permissions, symlinks, directories),stat(read-only inspection, pairs withregister+when),copy,template(see Templates for Config Generation) - Partial file edits:
lineinfile(single line),blockinfile(marked block),replace(regex substitution) — and whentemplateis the better choice instead, per Module Decision Trees - Users and access:
user,group,authorized_key(SSH key management — ties to SSH and Connectivity) - Scheduling:
cron - Mounts:
mount - Archives and downloads:
get_url,unarchive - Source control:
git
Interview Questions¶
- When would you choose
apt/dnfdirectly instead of the cross-distropackagemodule? - What's the difference between
lineinfileandblockinfile? - Why is
statcommonly paired withregisterandwheninstead of used alone?
Next¶
Continue to URI and API Automation.