Skip to content

Lesson 3 of 13 · 20m

ansible-core, Collections, and Execution Environments

Why the 2.10 packaging split moved your modules into collections, which Python floors changed in 2.17, and how pins and EE images make a run reproducible.

pip install ansible does not install Ansible the way it did in 2019. The command is the same; the artifact is not. Since the 2.10 reorganization, the ansible package on PyPI is a meta-package — a thin bundle pinning ansible-core (the engine plus ~80 ansible.builtin.* modules) plus a few dozen community collections (the community.general, ansible.posix, amazon.aws namespaces where everything else moved). The monolith is gone. The module you remember isn't.

The mechanics: ansible-core is the runtime — ansible-playbook, the executor, the built-ins. Collections are namespaced content packs (namespace.collection) that ship modules, plugins, roles, and docs as a unit, installed under ~/.ansible/collections/ or collections/ beside your playbooks. That's why firewalld: became ansible.posix.firewalld: and docker_container: lives in community.docker. Bare short names still resolve through a redirect table for now; ansible-lint's fqcn rule exists because the redirects are a compatibility shim, not a guarantee.

The breakages this already caused

This wasn't theoretical churn; it was a flag day the ecosystem is still digesting.

  • ec2: was replaced by amazon.aws.ec2_instance: — a rename and an API change; playbooks written for 2.9 fail on task one.
  • apt_key was deprecated as apt-key itself went away upstream; the replacement is ansible.builtin.deb822_repository, which writes /etc/apt/sources.list.d/*.sources instead of the keyring file.
  • ansible-core 2.17 (May 2024) dropped Python 3.6 and 2.7 as managed-node interpreters — Python 3.7+ is the floor now. RHEL 8's platform-python is 3.6, so out of the box, 2.17 can't even discover an interpreter on a stock RHEL 8 image (ansible/ansible#83357 — the bug report is a parade of "RHEL 8, Ubuntu 18.04, openSUSE 15 just stopped working"). Red Hat's own answer: RHEL 8.10 ships ansible-core 2.16 for its lifecycle. If your fleet has old targets, ansible_python_interpreter or an older core isn't an edge case — it's the plan.
  • Version numbering split: the ansible package and ansible-core version independently. Ansible 12 tracks ansible-core 2.19 (2.19.0 shipped 2025-07-21); "we're on Ansible 11" tells a reviewer nothing about your actual engine.

The wrong mental model

"Upgrade Ansible and my playbooks keep working" was true for a decade and stopped being true in 2.10. The upgrade path now has two axes — core version and collection versions — and they break independently. A community.general minor release can rename a module parameter under a pinned engine. Treating collections as ambient (whatever pip or Galaxy hands you today) is how a routine Friday deploy starts failing on a parameter that didn't exist Thursday.

The fix is boring and total: pin everything, in files that live in the repo.

# requirements.yml — collection deps
collections:
  - name: community.general
    version: "10.1.0"
  - name: ansible.posix
    version: "2.0.0"
  - name: amazon.aws
    version: ">=9.0.0,<10.0.0"
# requirements.txt — engine deps
ansible-core==2.18.1

ansible-galaxy collection install -r requirements.yml + pip install -r requirements.txt reproduces the environment. If CI installs these, "works on my laptop" stops being an explanation.

Execution environments: the container answer

The same problem — "whose Python, whose collections, whose OS packages" — got an official containerized answer. An execution environment (EE) is an OCI image containing ansible-core, the pinned collections, their Python and system dependencies, and nothing else. ansible-builder produces one from a manifest:

# execution-environment.yml
version: 3
images:
  base_image:
    name: quay.io/fedora/fedora:latest
dependencies:
  ansible_core:
    package_pip: ansible-core==2.18.1
  galaxy: requirements.yml
  python: requirements.txt
  system: bindep.txt

ansible-builder build -t acme-ee:1.0, then ansible-navigator run site.yml --eei acme-ee:1.0 --mode stdout runs the playbook inside the image. AWX and Automation Platform run every job template in an EE — the image tag is the environment contract. Whether you adopt EEs or not, the lesson is the same: the version matrix is yours to pin, or the ecosystem pins it for you at the worst time.

Field notes

  • ansible --version reports the core version; ansible-galaxy collection list reports the content versions. You need both to reproduce a bug report.
  • collections: keyword on a play shortens FQCNs (collections: [community.general] lets haproxy: resolve) — fine inside a role, lazy at playbook top level where you want grep-ability.
  • Installing the ansible meta-package and pinning requirements.yml is belt-and-suspenders that mostly works; installing just ansible-core plus pinned collections is the lean path CI should take.

Was this lesson helpful?

Sign in to rate

Keep reading

Related articles from the SudoSecurity blog.