This content is part of the Essential Guide: Build the Kubernetes home lab that's right for your job

DevOps lab: Learn to use GitHub for infrastructure deployments

This article is part of a series to help IT ops professionals learn DevOps by building a home lab. In the second step, Git version control allows ops to manage infrastructure as code.

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.

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
DevOps lab

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 Git config commands and your name and email address:

Set up Git

Then initialize Git in that folder, add the VagrantFile and commit the current file with the following commands:

Commit to Git

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:

A GitHub repository

Clone the files then copy some to your project folder. Then make all of the shell scripts executable:

Shell scripts in Git

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.

Next Steps

New to Git and distributed version control? Here are some Git examples and Jenkins-Git integration tutorials designed to help you master the popular source code versioning tool:

Use this Git guide to expand your source code tool knowledge

Dig Deeper on Managing Virtual Containers