Run multiple versions of Ansible from source concurrently

If you run Ansible from source you may have noticed that you have to re-source the hacking/env-setup script if you want to switch to a different version. In my case I keep Ansible 2.3 around to support legacy CentOS 5 systems. It’s relatively simple to just run the hacking script when you run ansible:

clone and checkout the legacy version:
$ git clone https://github.com/ansible/ansible.git --recursive
$ mv ansible ansible2.3
$ cd ansible2.3
$ git tag
$ git checkout v2.3.3.0-1
$ cd ..

clone and checkout the latest version:
$ git clone https://github.com/ansible/ansible.git --recursive

test:
$ source ~/.profile
$ vi ~/.profile
alias ansible-playbook2.3="source /path/to/ansible2.3/hacking/env-setup -q && path/to/ansible2.3/bin/ansible-playbook $*"
alias ansible-playbook="source /path/to/ansible/hacking/env-setup -q && /path/to/ansible/bin/ansible-playbook $*"
:wq

$ ansible-playbook --version
ansible-playbook 2.6.2 (devel c997811f45) last updated 2018/08/01 12:40:35 (GMT -400)
...
$ ansible-playbook2.3 --version
ansible-playbook 2.3.3.0 (two-three 0255ab2e27) last updated 2018/12/07 12:05:40 (GMT -400)
...
$

This entry was posted in ansible, devops on by .

About morgan

Morgan is a freelance IT consultant living in Philadelphia. He lives with his girlfriend in an old house in Fishtown that they may never finish renovating. His focus is enterprise Messaging (think email) and Directory. Many of his customers are education, school districts and Universities. He also gets involved with most aspects of enterprise Linux and UNIX (mostly Solaris) administration, Perl, hopefully Ruby, PHP, some Java and C programming. He holds a romantic attachment to software development though he spends most of his time making software work rather than making software. He rides motorcycles both on and off the track, reads literature with vague thoughts of giving up IT to teach English literature.

Leave a Reply

Your email address will not be published. Required fields are marked *