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.
mkdir /opt
Set you as the owner of the “opt” directory and its children.
YOUR_GROUP should be on:
- MacOS: wheel
- Ubuntu: your username
sudo chown -R YOUR_USER_NAME:YOUR_GROUP /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. This example uses Packer.
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.
If there is an existing symbolic link that points to the latest version of the application, rename it 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.
cd /opt/terraform mv terraform terraform_v_0.9.11
cd /opt/packer mv packer packer_v_1.0.4
Create a new symbolic link that points to the latest version of the application.
# For Packer cd /opt/packer ln -s /opt/packer/packer_1.2.0/packer packer # For Terraform cd /opt/terraform ln -s /opt/terraform/terraform_0.10.0/terraform terraform # For Vagrant cd /opt/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
PATH=/opt/packer:$PATH PATH=/opt/terraform:$PATH PATH=/opt/vagrant:$PATH
Vagrant
For Vagrant installation see Vagrant
To change the version you want to execute
- Delete the symbolic link,
cd /opt/packer rm packer
- Create a new symbolic link pointing to the other version of the application as above.