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.
cd /opt/packer ln -s /opt/packer/packer_1.0.0/packer packer cd /opt/terraform ln -s /opt/terraform/terraform_0.9.7/terraform terraform cd /opt/vagrant ln -s /opt/vagrant/vagrant_1.9.1/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 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:
cd /opt/vagrant 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,
cd /opt/packer rm packer
- Create a new symbolic link pointing to the other version of the application as above.