7

Can anyone tell how to install two or more ansible versions on one Ubuntu laptop?

When I publish my roles in galaxy.ansible.com, I want to set minimal requirement version in meta/main.yml. But now I have ansible 1.9 on my machine, so have dilemma:

  • Write 1.9 to meta/main.yml
  • Write to meta/main.yml lower version with fingers crossed

I've found next comment at ansible docs:

Debian/Ubuntu packages can also be built from the source checkout, run:
$ make deb

So I can compile 1.4, 1.5 for example for testing purposes. But I want to able to fast select which version to use - 1.4 and 1.5 for testing and 1.8 for normal daily usage.

Also, I've not found how to specify ansible version in Vagrantfile, so I must have ansible with proper version on my machine?

Thank you.

igormukhingmailcom
  • 465
  • 1
  • 6
  • 9

3 Answers3

5

I've found solution at http://www.cyberciti.biz/python-tutorials/linux-tutorial-install-ansible-configuration-management-and-it-automation-tool/.

With some modifications that is fully work example:

cd /tmp
git clone -b v1.4.0 --recursive https://github.com/ansible/ansible.git v1.4.0
source ./v1.4.0/hacking/env-setup
ansible --version # will print ansible 1.4
igormukhingmailcom
  • 465
  • 1
  • 6
  • 9
5

You can sudo pip install ansible==1.8.4 in one python virtualenv and pip install another version ansible==1.9.0.1 in different virtual environment. Multiple virtualenvs can be based on the same python version as well.

Another completely different solution is to install ansible within a docker container. Here is nice centos image with ansible already installed in it. There are also ubuntu and debian images.

Zasz
  • 12,330
  • 9
  • 43
  • 63
  • 1
    I think this is the easiest way. I had ansible 1.9 installed locally. To also install ansible 2, I just did `virtualenv ansible2; source ansible2/bin/activate; source ansible2/bin/pip install ansible`. – t2d Apr 08 '16 at 06:32
  • docker to the rescue again. Thanks – Bill Leeper Apr 24 '19 at 15:31
1

When I managed a research cluster at a university we used this modules utility to manage a few dozen different software applications (some of which we had three or four different versions of).

In a nutshell, the way this modules tool works is that you create configuration files for each program/application then use the command "module load XXX" or "module unload XXX" to switch environments. For example, we had multiple versions of python installed and a user could load a specific version once they logged into the cluster by issuing the command "module load python/2.4" or "module load python/2.6".

The configuration files can be very simple, just appending values to your PATH, or more complex, with conditionals, forcing the loading or unloading of other modules, etc. The documentation for these module files can be found here.

For what you're proposing, all you would do is install different versions of ansible in different directories, then use modules to modify your PATH, PYTHONPATH, and/or ANSIBLE_LIBRARY environment variables in the same way that the ansible/hacking/env-setup script does.

Bruce P
  • 19,995
  • 8
  • 63
  • 73