A DevOps deployment requires quickly provisioned infrastructure that adapts to application needs. The Vagrant VM workflow in the DevOps lab build's first step yielded some files containing code that creates and describes the lab infrastructure. Git version control software, or other preferred infrastructure as code tools, protects that code and archives older versions as we make changes.
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
A Git commit saves a consistent state -- a separate copy -- of the project on the DevOps lab machine. It enables the user to return to a previous fixed point if changes mess up the code. Learn to use GitHub, a distributed version control platform, as the central repository for infrastructure code, freeing saved versions from only existing on one computer.
⇇ Create a
Before checking in infrastructure as code using Git and GitHub, install Vagrant and spin up the VMs for this DevOps lab as immutable infrastructure. Or start here to get the lab up and running.
Start using Git
Install Git on the lab machine; it might automatically install when git runs for the first time. Have the terminal open in your project folder where the Vagrantfile resides.
Configure Git to let it know who you are with some config commands and your name and email address:
Then initialize Git in that folder, add the VagrantFile and commit the current file with the following commands:
Make changes in the DevOps lab freely; you can be confident that the deployment can roll back to this state at any time. Use GitHub to commit any time you make a significant and successful change. Use git add to add any new files. Try wild cards like git add *.sh to add all the shell scripts. During the following DevOps learning exercises, I will remind you to commit changes along the way.
The files for the experiments in this article are available to clone from my GitHub repository:
Clone the files then copy some to your project folder. Then make all of the shell scripts executable:
Author's note: There are a few listings that are too long to include in the text of this article, but are available in the repository.
Continue building this DevOps lab ⇉
With a basic grasp of how to use GitHub and Vagrant from these tutorials, begin working with Ansible to implement consistent configurations on one or multiple infrastructure stacks.
Get into the tools and services to build infrastructure as code