How do you upgrade ansible-core safely across a large codebase?
AdvancedProductionTesting, CI/CD and Quality
Answer
Treat it like a language upgrade, because it is one. ansible-core 2.19 is the recent example: its templating changes made non-boolean conditionals and some implicit conversions errors, and plenty of old playbooks broke.
- Read the porting guide for the target version and grep for the deprecated patterns it lists.
- Clear all
[DEPRECATION WARNING]lines on the current version first; they are the next version's errors. - Build a new EE (or virtualenv) with the new core and pinned collections.
- Run lint, Molecule and
--checkruns of every playbook against staging in CI with both the old and new image. - Move one environment at a time: dev, staging, then prod, with the old image kept as a quick fallback.
Pin the core version everywhere (EE tag, requirements.txt), so nobody gets upgraded by a stray pip install -U.
More on Testing, CI/CD and Quality
What does a testing pyramid look like for Ansible code?BeginnerHow do you roll out `ansible-lint` profiles across a team without blocking everyone?IntermediateWhen do you use `skip_list`, `warn_list` and `# noqa`?IntermediateHow do you set up pre-commit hooks for an Ansible repo?BeginnerHow is a Molecule scenario laid out, and what does `molecule test` actually run?IntermediateDocker, Podman or real VMs as the Molecule driver: how do you choose?Advanced