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

File Management Modules

ModulePurpose
ansible.builtin.copyCopy files from local to remote
ansible.builtin.templateDeploy Jinja2 templates
ansible.builtin.fileManage file properties (permissions, symlinks)
ansible.builtin.lineinfileAdd/replace lines in files
ansible.builtin.blockinfileInsert/update text blocks in files
ansible.builtin.fetchCopy files from remote to local
ansible.builtin.statGet file status information
ansible.builtin.findFind files matching criteria
ansible.builtin.unarchiveExtract archives on remote hosts
ansible.builtin.get_urlDownload files from URLs
ansible.posix.synchronizeRsync 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"

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

Package Management Modules

ModuleTarget
ansible.builtin.aptDebian/Ubuntu
ansible.builtin.yumRHEL/CentOS 7
ansible.builtin.dnfRHEL/CentOS 8+/Fedora
ansible.builtin.pipPython packages
ansible.builtin.packageOS-agnostic (auto-detects)
community.general.snapSnap packages
community.general.flatpakFlatpak packages
community.general.homebrewmacOS 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

Service Management Modules

ModulePurpose
ansible.builtin.systemdManage systemd services
ansible.builtin.serviceGeneric service management
ansible.builtin.service_factsGather 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 }}"

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

Command Execution Modules

ModuleUse Case
ansible.builtin.commandRun commands (no shell features)
ansible.builtin.shellRun commands with pipes/redirects
ansible.builtin.rawRun commands without Python
ansible.builtin.scriptRun local script on remote
ansible.builtin.expectInteractive 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

ModulePurpose
ansible.builtin.userManage user accounts
ansible.builtin.groupManage groups
ansible.posix.authorized_keyManage SSH authorized keys
- ansible.builtin.user:
    name: deploy
    groups: [sudo, docker]
    shell: /bin/bash
    append: true

Networking and Cloud Modules

CollectionPlatform
amazon.awsAWS (EC2, S3, RDS, etc.)
azure.azcollectionMicrosoft Azure
google.cloudGoogle Cloud Platform
community.vmwareVMware vSphere
community.dockerDocker containers
kubernetes.coreKubernetes
ansible.netcommonNetwork devices

System Modules

ModulePurpose
ansible.builtin.cronManage cron jobs
ansible.builtin.hostnameSet hostname
ansible.builtin.sysctlManage kernel parameters
ansible.posix.mountManage filesystem mounts
ansible.builtin.rebootReboot and wait
ansible.builtin.wait_forWait for conditions
ansible.builtin.setupGather system facts

Variable and Logic Modules

ModulePurpose
ansible.builtin.debugPrint variables and messages
ansible.builtin.set_factSet runtime variables
ansible.builtin.assertValidate conditions
ansible.builtin.failFail with custom message
ansible.builtin.pausePause execution
ansible.builtin.include_varsLoad variables from file
ansible.builtin.wait_forWait for conditions

Task Flow Modules

ModulePurpose
ansible.builtin.include_tasksDynamically include tasks
ansible.builtin.import_tasksStatically import tasks
ansible.builtin.include_roleDynamically include role
ansible.builtin.import_roleStatically import role
ansible.builtin.blockGroup 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.

Category: installation

Browse all Ansible tutorials · AnsiblePilot Home