Hi,
Is there a way to make Molecule work with such an old version of Ansible?
Possibly an older version of Molecule, yes. Problem is, there isn’t to my knowledge a compatibility matrix to match Ansible versions to Molecule’s, although there was an issue opened at some point on this matter.
You could try to use pipdeptree package or something similar to get info on molecule package: pipdeptree -p molecule -j
, with a bit of jq
magic to parse the output, getting info specifically on ansible-core
package.
To try on different versions on molecule from the same era as ansible-core 2.9, which you could look for in molecule project releases, to try to find one that supports ansible-core <=2.9
.
I’d suggest you use python virtualenvs / venvs or containers, so you don’t break your Ansible install, as ansible-core
is a dependency for molecule
, which means pip
(and surely other Python packages managers) will try to upgrade it if you try to use a more recent version. Also lets you rebuild as needed.
That being said, I’d probably do it the other way around, upgrading Ansible binaries in on go (in a venv), then using current molecule version to work on my playbooks. After that, you could try to run your (tested) playbooks again in 2.9, if you really need to keep supporting this environment.
One last thing; it seems to me you are looking for a way to cleanup code, and as much useful molecule is, it’s more of a tool you’d use to test specific scenarios, or simply ensuring your role is working fine on specified platforms. ansible-lint
might be a better fit for your usecase IMO.
Disclaimer: I’m not very familiar with Python ecosystem, so take my suggestions with a grain of salt.