Is there a way to use a different Ansible-Core version for a particular playbook?

Viewed 66

I have upgraded my ansible & ansible-core as part of a system-upgrade to

local/ansible 5.0.1-1
    Official assortment of Ansible collections
local/ansible-core 2.12.0-1
    Radically simple IT automation platform

My Ansible scripts are failing because -include is no longer supported.

Is there a way for me to install an older version of Ansible core (for example: 2.9.7) and instruct Ansible to use that version of instead of 2.12?

or do I need to down-grade both Ansible 5.0.1-1 & the core together?

1 Answers

You can install whatever version you want in a python virtualenv and run the playbook from there.

QuickNdirty example. Prerequisite: having the virtualenv command installed in your distribution.

cd your_project
virtualenv ans2.9.7
. ./ans2.9.7/bin/activate
pip install ansible==2.9.7
ansible --version
ansible-playbook your-playbook.yml
deactivate

If you want to totally get rid of that environment

rm -rf ./ans2.9.7

If you want to keep it and reactivate it

. /path/to/ans2.9.7/bin/activate

You don't need to go through all the pip reinstall in that case. Just use ansible as normal.

To get out again from the venv

deactivate
Related