Skip to content

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 like daemon_reload)
  • Files and directories: file (permissions, symlinks, directories), stat (read-only inspection, pairs with register + when), copy, template (see Templates for Config Generation)
  • Partial file edits: lineinfile (single line), blockinfile (marked block), replace (regex substitution) — and when template is 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/dnf directly instead of the cross-distro package module?
  • What's the difference between lineinfile and blockinfile?
  • Why is stat commonly paired with register and when instead of used alone?

Next

Continue to URI and API Automation.