Source Control in DevOps:
In our last tutorial we saw about DevOps practice based on Agile Manifesto. Here, we will see more about Source Control or Version Control in DevOps.
One of the key factors that the success of DevOps depends upon is the ‘Source control’.
Further Reading=> Complete Guide on DevOps
It is the Source control or version control that brought the collaboration and transparency between both the Development and Operations team and brought them under a single tool and single umbrella.
So, we will study,
- What is source control or version control?
- What to source control?
- How do we version control?
- Benefits of version control?
In DevOps Practice, in addition to development artifacts, even Operations team uses version control to control the changes to their artifacts.
Version controlling ‘Infrastructure set up and configuration details as a code’ is the key differentiator in DevOps practice. Standardizing the coding practices, carrying out development activity in parallel, removing the dependency, are the main benefits of source control.
DevOps Video Part 2 Block 2: Source Control – 11 minutes 22 seconds
Here, in this tutorial, we will study the importance of few practices of DevOps.
First one is Source control, the second one is Automation and the third one is ‘delivery of small increments of value’.
One of the key factors that the success of DevOps depends upon is the ‘Source control’.
The terms Source control and version control can be used interchangeably.
What is Source/Version Control?
We all know that change is inevitable and we believe that change is for betterment. Thus, changes happen day in and out to everything and anything. So, it is extremely important for a program to maintain the history of these changes to the program artifacts, which is called ‘Version control’.
Hence, Version control or Source control is to manage the changes to the project, be it code, documents, environment configuration, or anything else.
What to Source Control?
DevOps principle is to Version control everything which undergoes changes during the life cycle so that the changes are not missed out in anyways or by anybody in the project.
The primary difference from agile to DevOps is that in agile practice we have seen only the development team following version control for their code, releases, documents, and websites. But DevOps introduces version control for Operations as well.
It has been identified that a high number of failures, defects are not really due to bad code but due to misconfigurations. So, this statement stresses the requirement of version control in the production environment on configurations and infrastructure which are delivered as a script.
Thus, DevOps practice started version controlling the deployment scripts, environment configurations, infrastructure details etc., Even earlier dev used to follow version controlling of only code and documents, now they also include controlling automation scripts, installation scripts, migration scripts etc.,
We know in our traditional software development life cycle methodology, what we were version controlling.
So, in DevOps practice in addition to source code, automation scripts, documents, we practice version controlling everything which undergoes changes like, deployment scripts or installation scripts, rollback scripts, migration scripts etc., which are part of software installation.
Infrastructure definitions or scripts, which contain the server configuration details, pre-requisite software details and their versions, DB details, connectivity of multiple components, network details etc. need to be version controlled.
Environment-related configurations which include the environment variables that are to be set default, the features which need to be turned off or on by default etc., needs to be version controlled.
So, in broad words, Version control everything in a project which undergoes changes.
How do we Version Control them?
Earlier, version control used to happen manually in the absence of tools, where the team used to save a physical copy of back up and then make the changes.
These days lot of sophisticated version controlling tools have come to market, and it automatically takes care of version controlling by managing the check-in’s and check-outs by multiple people simultaneously thereby preventing the hassle of manual management.
These tools also enable the team to view the difference between versions very easily. Maybe a test or deployment script which passed in the previous version has failed in the current deployment.
One can quickly go through this tool to see the changes in the current version w.r.t the old version and helps them to understand the difference in the script and to debug the cause of failure very fast.
Possibly suggestion could be to use a single tool to version control all the assets of the project, and that helps in easy management and becomes a single source of truth.
What are the Benefits of Version Control?
Given below are the various benefits of Version Control:
#1) First of all version control ensures that dev is in source control and ops is in source control and the beauty of DevOps is that both of them are in source control and that too in the same source control tool and hence everyone can see what is there in the source and each version of it, clearly and transparently.
This enables the team to work together, have transparency and collaborate with each other. This also brings the team and their work under one umbrella, one tool.
#2) It prevents the team members from following their own knowledge, information and code to use.
#3) Source control helps in understanding the difference between versions and also the purpose of making these changes.
#4) Version control helps in carrying out development in parallel and managing the merges. More than one person can work on the same code or script or document by picking the base code from the source control and taking a copy of them on to their local machines and then merging back to the master, once the changes are done.
In case of any conflicts in the changes between two people, the tool will throw an error and highlight the area of conflict.
#5) In addition to this, version controlling infrastructure as a code allows anyone to create environments without having a dependency on individual’s knowledge and also helps in creating environment purely from the information available in the source control and not based on individuals intelligence.
#6) Version control makes the debugging of the software deployment failures and production issues very fast because the team can go back to the previous version and check what is the difference, in case of failures and fix it fast.
Hence, identification of production issues becomes easy and fast.