Introduction

ansible-core is the minimal, essential runtime that powers Ansible. It includes the command-line tools (ansible-playbook, ansible-galaxy, ansible-doc), the execution engine, and a curated set of built-in modules — everything you need to run playbooks without the 85+ community collections bundled in the full ansible package.

Understanding the difference between ansible-core and the ansible community package is crucial for managing dependencies, planning upgrades, and building lean automation environments.

ansible-core vs Ansible Community Package

Featureansible-coreansible (community package)
CLI tools✅ All included✅ All included
Built-in modules~70 modules~70 modules
Community collections❌ Install separately✅ 85+ pre-installed
Package size~15 MB~200+ MB
Release cycleEvery ~4 monthsFollows ansible-core
Best forProduction, CI/CD, containersQuick start, learning

What's Included in ansible-core

# CLI tools included
ansible
ansible-playbook
ansible-galaxy
ansible-doc
ansible-vault
ansible-console
ansible-config
ansible-inventory
ansible-pull

Built-in Modules (ansible.builtin)

ansible-core ships with essential modules:

  • Files: copy, file, template, lineinfile, blockinfile, fetch, stat, find
  • System: service, systemd, user, group, cron, hostname, sysctl
  • Commands: command, shell, raw, script, expect
  • Packages: apt, yum, dnf, pip, package
  • Net: uri, get_url
  • Logic: assert, debug, fail, set_fact, pause, wait_for
  • Includes: include_tasks, import_tasks, include_role, import_role

Everything else — Docker, AWS, Azure, Windows, network devices — comes from collections.

Installation

# Install latest ansible-core
pip install ansible-core

# Install specific version
pip install ansible-core==2.17.0

# Upgrade
pip install --upgrade ansible-core

System Packages

# RHEL/CentOS/Fedora
sudo dnf install ansible-core

# Ubuntu/Debian
sudo apt install ansible-core

# macOS (via Homebrew)
brew install ansible

In Containers

For minimal container images, install only ansible-core:

FROM python:3.12-slim
RUN pip install --no-cache-dir ansible-core==2.17.0
COPY requirements.yml /tmp/
RUN ansible-galaxy collection install -r /tmp/requirements.yml

Version Management

Check Installed Version

ansible --version
# ansible [core 2.17.0]
#   config file = /etc/ansible/ansible.cfg
#   python version = 3.12.3
#   jinja version = 3.1.3
#   libyaml = True

Version Compatibility Matrix

ansible-corePython (controller)Python (managed)Status
2.173.10 – 3.123.7 – 3.12Current
2.163.10 – 3.123.7 – 3.12Maintained
2.153.9 – 3.113.7 – 3.11EOL

Pin Versions in Requirements

# requirements.txt
ansible-core>=2.16,<2.18

Adding Collections

With ansible-core, install only the collections you need:

# Install individual collections
ansible-galaxy collection install community.general
ansible-galaxy collection install amazon.aws
ansible-galaxy collection install kubernetes.core

# Install from requirements file
ansible-galaxy collection install -r requirements.yml

requirements.yml:

collections:
  - name: community.general
    version: ">=8.0.0"
  - name: ansible.posix
    version: ">=1.5.0"
  - name: community.docker
  - name: kubernetes.core

List Installed Collections

ansible-galaxy collection list

Configuration

ansible.cfg

[defaults]
# Collections search path
collections_path = ~/.ansible/collections:/usr/share/ansible/collections

# Module search path
library = ./library

# Roles path
roles_path = ~/.ansible/roles:/usr/share/ansible/roles

# Python interpreter
interpreter_python = auto_silent

# Performance
forks = 20
pipelining = True

[inventory]
# Enable inventory plugins
enable_plugins = host_list, script, auto, yaml, ini, toml

[ssh_connection]
# SSH performance
ssh_args = -C -o ControlMaster=auto -o ControlPersist=60s
pipelining = True

Practical Use Cases

Minimal CI/CD Pipeline

# .github/workflows/deploy.yml
name: Deploy
on:
  push:
    branches: [main]
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install ansible-core
        run: pip install ansible-core==2.17.0
      - name: Install required collections
        run: ansible-galaxy collection install -r requirements.yml
      - name: Deploy
        run: ansible-playbook -i inventory deploy.yml

Production Playbook (ansible-core Only)

Using only built-in modules — no collections needed:

---
- name: Configure web server
  hosts: web_servers
  become: true
  tasks:
    - name: Install packages
      ansible.builtin.dnf:
        name:
          - nginx
          - certbot
        state: present

    - name: Deploy config
      ansible.builtin.template:
        src: nginx.conf.j2
        dest: /etc/nginx/nginx.conf
      notify: restart nginx

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

  handlers:
    - name: restart nginx
      ansible.builtin.systemd:
        name: nginx
        state: restarted

Check Module Origin

# Is a module built-in or from a collection?
ansible-doc -t module ansible.builtin.copy
# → Built-in

ansible-doc -t module community.general.docker_container
# → Requires community.general collection

Migrating from ansible to ansible-core

If you're currently using the full ansible package:

  1. Identify collections in use:

    grep -r "community\.\|amazon\.\|azure\.\|kubernetes\." playbooks/
    
  2. Create requirements.yml with needed collections

  3. Replace package:

    pip uninstall ansible
    pip install ansible-core
    ansible-galaxy collection install -r requirements.yml
    
  4. Test everything — some implicit dependencies may surface

Conclusion

ansible-core is the lean, production-ready foundation of Ansible automation. It gives you all the CLI tools, the execution engine, and ~70 essential built-in modules without the overhead of 85+ bundled collections. For CI/CD pipelines, containers, and production environments, ansible-core with explicit requirements.yml is the best practice — you get exactly what you need, nothing more. Use the full ansible package for learning and rapid prototyping, then slim down to ansible-core for production.