Category Archives: devops

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 --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 --recursive

$ 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 $*"

$ 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 (two-three 0255ab2e27) last updated 2018/12/07 12:05:40 (GMT -400)