Most of the DevOps tools are still in beta versions, many times the new version is not compatible with your existing scripts or have an error that stops your scripts working. To be able to keep multiple versions of the applications and easily switch between them, create symbolic links and point to the version you want to execute.
Create version specific locations
Create a folder for your optional applications.
Set you as the owner of the “opt” directory and it’s children
sudo chown -R YOUR_USER_NAME:wheel /opt
Set the security of the folder.
sudo chmod 755 /opt
We will create a directory structure to place each version of the application into its own folder.
Create a symbolic link to point to the application in the appropriate version folder. These are the examples for Packer, Terraform, and Vagrant. Notice, that the Vagrant application is in the “bin” directory, so the symbolic link has to point there.
Rename the current symbolic link to be able to quickly return to the prior version of the application. This can come handy when we need to destroy instances created with the prior version of Terraform.
mv terraform terraform_v_0.9.11
Create a new symbolic link that points to the latest version of the application.
# For Packer
ln -s /opt/packer/packer_1.0.0/packer packer
# For Terraform
ln -s /opt/terraform/terraform_0.10.0/terraform terraform
# For Vagrant
ln -s /opt/vagrant/vagrant_1.9.5/bin/vagrant vagrant #The vagrant application is in the bin folder
Add the main application folder to the path in the config file of your terminal
- for iTerm2 with zterminal: ~/.zshrc
- for other terminals: ~/.bash_profile
Vagrant has an installer, that places the bin and embedded folders to “/opt/vagrant”. To be able to keep multiple versions of Vagrant execute the following:
mkdir vagrant_MY_VERSION # Create a folder for the new version
sudo chown -R YOUR_USER_NAME:wheel bin # Set the owner, so you can move it
sudo chown -R YOUR_USER_NAME:wheel embedded # Set the owner, so you can move it
mv bin vagrant_MY_VERSION # Move the folder to the version specific location
mv embedded vagrant_MY_VERSION # Move the folder to the version specific location
rm vagrant # Delete the old version of the symbolic link
ln -s /opt/vagrant/vagrant_MY_VERSION/bin/vagrant vagrant # Create the symbolic link
To change the version you want to execute
- Delete the symbolic link,
- Create a new symbolic link pointing to the other version of the application as above.