AnsiblePilot — Master Ansible Automation

AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,400 tutorials covering Ansible modules, playbooks, roles, collections, and real-world examples. Whether you are a beginner or an experienced engineer, our step-by-step guides help you automate Linux, Windows, cloud, containers, and network infrastructure.

Popular Topics

About Luca Berton

Luca Berton is an Ansible automation expert, author of 8 Ansible books published by Apress and Leanpub including "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example", and creator of the Ansible Pilot YouTube channel. He shares practical automation knowledge through tutorials, books, and video courses to help IT professionals and DevOps engineers master infrastructure automation.

Ansible Modules: Complete List & Guide to Built-in Modules (2026)

By Luca Berton · Published 2024-01-01 · Category: installation

Complete guide to Ansible modules. What are modules, how to use them, and a categorized reference of the most important built-in modules (ansible.builtin).

Ansible Modules: Complete List & Guide to Built-in Modules (2026)

Ansible modules are the building blocks of automation. Each module performs a specific task — installing packages, copying files, managing services, or configuring cloud resources. This guide covers what modules are, how to use them, and the most important built-in modules organized by category.

See also: Ansible Modules List: 50 Most Used Modules Quick Reference

What Are Ansible Modules?

Modules are units of code that Ansible executes on remote hosts. Each module: • Performs a single, specific task (install package, create user, copy file) • Is idempotent — running it multiple times produces the same result • Returns JSON with status, changes, and output • Can be used in playbooks or ad-hoc commands

Using Modules

In Playbooks

- name: Install nginx
  ansible.builtin.apt:
    name: nginx
    state: present

- name: Start nginx service ansible.builtin.systemd: name: nginx state: started enabled: true

In Ad-Hoc Commands

ansible all -m ping
ansible webservers -m apt -a "name=nginx state=present" --become
ansible all -m shell -a "uptime"

FQCN vs Short Names

# Fully Qualified Collection Name (recommended)
- ansible.builtin.copy:
    src: file.txt
    dest: /tmp/file.txt

# Short name (works but less explicit) - copy: src: file.txt dest: /tmp/file.txt

See also: Ansible Documentation: Complete Reference & Quick Start Guide (2026)

File Management Modules

| Module | Purpose | |--------|---------| | ansible.builtin.copy | Copy files from local to remote | | ansible.builtin.template | Deploy Jinja2 templates | | ansible.builtin.file | Manage file properties (permissions, symlinks) | | ansible.builtin.lineinfile | Add/replace lines in files | | ansible.builtin.blockinfile | Insert/update text blocks in files | | ansible.builtin.fetch | Copy files from remote to local | | ansible.builtin.stat | Get file status information | | ansible.builtin.find | Find files matching criteria | | ansible.builtin.unarchive | Extract archives on remote hosts | | ansible.builtin.get_url | Download files from URLs | | ansible.posix.synchronize | Rsync files between hosts |

- name: File management examples
  ansible.builtin.copy:
    src: nginx.conf
    dest: /etc/nginx/nginx.conf
    owner: root
    mode: '0644'
  notify: reload nginx

- ansible.builtin.file: path: /opt/app/logs state: directory mode: '0755'

- ansible.builtin.lineinfile: path: /etc/hosts line: "192.168.1.10 app.local"

Package Management Modules

| Module | Target | |--------|--------| | ansible.builtin.apt | Debian/Ubuntu | | ansible.builtin.yum | RHEL/CentOS 7 | | ansible.builtin.dnf | RHEL/CentOS 8+/Fedora | | ansible.builtin.pip | Python packages | | ansible.builtin.package | OS-agnostic (auto-detects) | | community.general.snap | Snap packages | | community.general.flatpak | Flatpak packages | | community.general.homebrew | macOS Homebrew |

- name: Install packages (Debian/Ubuntu)
  ansible.builtin.apt:
    name:
      - nginx
      - postgresql
      - python3-pip
    state: present
    update_cache: true

- name: Install packages (RHEL/CentOS) ansible.builtin.dnf: name: - httpd - mariadb-server state: present

- name: OS-agnostic package install ansible.builtin.package: name: git state: present

See also: Ansible Cheat Sheet: Quick Reference Commands & Syntax (2026)

Service Management Modules

| Module | Purpose | |--------|---------| | ansible.builtin.systemd | Manage systemd services | | ansible.builtin.service | Generic service management | | ansible.builtin.service_facts | Gather service status |

- ansible.builtin.systemd:
    name: nginx
    state: started
    enabled: true
    daemon_reload: true

- ansible.builtin.service_facts: - ansible.builtin.debug: msg: "nginx is {{ ansible_facts.services['nginx.service'].state }}"

Command Execution Modules

| Module | Use Case | |--------|----------| | ansible.builtin.command | Run commands (no shell features) | | ansible.builtin.shell | Run commands with pipes/redirects | | ansible.builtin.raw | Run commands without Python | | ansible.builtin.script | Run local script on remote | | ansible.builtin.expect | Interactive command automation |

- ansible.builtin.command: hostname -f
  register: result
  changed_when: false

- ansible.builtin.shell: ps aux | grep nginx | wc -l changed_when: false

User and Group Modules

| Module | Purpose | |--------|---------| | ansible.builtin.user | Manage user accounts | | ansible.builtin.group | Manage groups | | ansible.posix.authorized_key | Manage SSH authorized keys |

- ansible.builtin.user:
    name: deploy
    groups: [sudo, docker]
    shell: /bin/bash
    append: true

Networking and Cloud Modules

| Collection | Platform | |-----------|----------| | amazon.aws | AWS (EC2, S3, RDS, etc.) | | azure.azcollection | Microsoft Azure | | google.cloud | Google Cloud Platform | | community.vmware | VMware vSphere | | community.docker | Docker containers | | kubernetes.core | Kubernetes | | ansible.netcommon | Network devices |

System Modules

| Module | Purpose | |--------|---------| | ansible.builtin.cron | Manage cron jobs | | ansible.builtin.hostname | Set hostname | | ansible.builtin.sysctl | Manage kernel parameters | | ansible.posix.mount | Manage filesystem mounts | | ansible.builtin.reboot | Reboot and wait | | ansible.builtin.wait_for | Wait for conditions | | ansible.builtin.setup | Gather system facts |

Variable and Logic Modules

| Module | Purpose | |--------|---------| | ansible.builtin.debug | Print variables and messages | | ansible.builtin.set_fact | Set runtime variables | | ansible.builtin.assert | Validate conditions | | ansible.builtin.fail | Fail with custom message | | ansible.builtin.pause | Pause execution | | ansible.builtin.include_vars | Load variables from file | | ansible.builtin.wait_for | Wait for conditions |

Task Flow Modules

| Module | Purpose | |--------|---------| | ansible.builtin.include_tasks | Dynamically include tasks | | ansible.builtin.import_tasks | Statically import tasks | | ansible.builtin.include_role | Dynamically include role | | ansible.builtin.import_role | Statically import role | | ansible.builtin.block | Group tasks with error handling |

Finding and Installing Modules

Search for Modules

# List all installed modules
ansible-doc -l

# Search modules by keyword ansible-doc -l | grep -i docker

# Read module documentation ansible-doc ansible.builtin.copy

# Show module examples ansible-doc ansible.builtin.copy -s

Install Module Collections

ansible-galaxy collection install community.general
ansible-galaxy collection install amazon.aws
ansible-galaxy collection install community.docker

FAQ

What are the most used Ansible modules?

The most commonly used modules are: copy, template, file, apt/dnf, systemd/service, command/shell, user, debug, lineinfile, and get_url. These cover file management, package installation, service control, and system administration.

How many modules does Ansible have?

Ansible ships with thousands of modules across collections. The ansible.builtin collection includes ~70 core modules. The full Ansible package (with community.general etc.) provides 5,000+ modules covering cloud, network, security, and application platforms.

What is the difference between a module and a plugin in Ansible?

Modules execute tasks on remote hosts (install package, copy file). Plugins extend Ansible's core functionality on the control node — connection plugins, lookup plugins, filter plugins, callback plugins. Modules do the work; plugins modify how Ansible operates.

Should I use FQCN for module names?

Yes. Using Fully Qualified Collection Names (ansible.builtin.copy instead of copy) is recommended. It's explicit, avoids name conflicts between collections, and is required for modules outside ansible.builtin.

Conclusion

Ansible modules are the foundation of infrastructure automation. Start with the built-in modules for file management, packages, and services, then expand with collection modules for cloud, containers, and networking. Use ansible-doc to explore available modules and their parameters.

Related Articles

Getting Started with AnsibleAnsible Playbook: Complete GuideAnsible Galaxy: Install Collections & RolesAnsible Custom Modules: Write Your Own

Category: installation

Browse all Ansible tutorials · AnsiblePilot Home