My ultimate goal as a DevOps engineer is providing solutions focusing on aligning IT systems to company’s culture and business processes. Limiting the time spent on creating bespoke tools and scripts that not all sysops are able to understand or maintain properly. Any custom tool is hard to maintain without a basic software engineering background and it needs a proper design, documentation, QA and all diligence and discipline required along the way.
From imperative to declarative
To achieve this result I need to shift from a developer mindset where is imperative (creating flows) writing programs or automation scripts to declarative, specifying just the desired state of a system in a YAML or JSON files that are a “lingua franca” between devs and sysops providing an up-to-date documentation that can be safely managed on a SCM (like GIT).
Paradigm shift or just shifting problems?
Labs Are Essentials
But being too familiar with a well known process is that you give for granted that other users can pickup the complexity, customise it according to their needs and eventually solve issues by themselves. But as you probably know, I was wrong.
So Instead of creating powershell scripts for provisioning VMs I started looking for alternatives. In order to provide tools to colleagues that are abstracted by the platform or human readable (for a non-programmer), I found a framework by HashiCorp called Vagrant. It is great tool!
What is Vagrant?
Vagrant and Hyper-V Limitations
How to manage all different VMs and describe that environment?
In case your VM are just windows, maybe Boxstarter (https://boxstarter.org/) that leverages chocolatey it the way to go, especially if your configuration can be summarized in few lines of code in a gists.
Do you need a custom image?
Lab description
- Ubuntu 1804
- Centos 7
- Windows 2016
- Windows 2012 R2
How to spin up a LAB with Vagrant
- Introduction
- General : https://www.vagrantup.com/docs/index.html
- CLI Commands: https://www.vagrantup.com/docs/cli/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# -*- mode: ruby -*- # vi: set ft=ruby : # All Vagrant configuration is done below. The "2" in Vagrant.configure # configures the configuration version (we support older styles for # backwards compatibility). Please don't change it unless you know what # you're doing. ## ## Paolo Frigo, https://www.scriptinglibrary.com ## Vagrant.configure("2") do |config| ## LINUX VMS config.vm.define "lab-ubuntu01" do |ubuntu01| ubuntu01.vm.box = "generic/ubuntu1804" ubuntu01.vm.hostname = "lab-ubuntu01" ubuntu01.vm.network "private_network", ip: "172.16.1.10" ubuntu01.vm.provider "hyperv" do |hv| hv.memory = 1024 end end config.vm.define "lab-centos01" do |centos01| centos01.vm.box = "generic/centos7" centos01.vm.hostname = "lab-centos01" centos01.vm.network "private_network", ip: "172.16.1.11" centos01.vm.provider "hyperv" do |hv| hv.memory = 1024 end end ## WINDOWS VMS config.vm.define "lab-win01" do |win01| win01.vm.box = "mwrock/Windows2016" win01.vm.hostname = "lab-windows01" win01.vm.communicator = "winrm" win01.winrm.username = "vagrant" win01.winrm.password = "vagrant" win01.vm.network "private_network", ip: "172.16.1.22" win01.vm.provider "hyperv" do |hv| hv.memory = 2048 end end config.vm.define "lab-win02" do |win02| win02.vm.box = "mwrock/Windows2012R2" win02.vm.hostname = "lab-windows02" win02.vm.communicator = "winrm" win02.winrm.username = "vagrant" win02.winrm.password = "vagrant" win02.vm.network "private_network", ip: "172.16.1.23" win02.vm.provider "hyperv" do |hv| hv.memory = 2048 end end end |
Spin up the environment with :
1 |
vagrant up |