top of page

Build Your First DevOps Lab – Part 2: Configuring the Ubuntu Master

Where do we start? That was the main question in the first part, right? Well, we have to start somewhere, and that somewhere is with the Ubuntu master VM. Starting with this VM makes the most sense as it is hosting the majority of the products that will be used in this lab build. It is the central hub for information in this DevOps lab.


Normally, I would not recommend doing this as it creates a single point of failure. However, because I wanted to be mindful of those that may not have the resources to split everything out into separate components, this configuration is what I decided on. This part will go over the tasks to get the Ubuntu master VM setup with Jenkins and Ansible, with Splunk coming in a later part.


Responsibilities of the Ubuntu Master

The Ubuntu Master VM will handle communications to our Ubuntu node, allowing us to configure and deploy to it remotely and autonomously. We can achieve autonomy via Jenkins. Jenkins helps automate the building, testing, and deploying parts of the software development lifecycle, allowing for a Continuous Integration and Continuous Delivery (CICD) pipeline. Jenkins has great integrations with other external systems, including GitHub, Jira, and more; both of which will be shown in this series. The installation of Jenkins is quite straight forward as you’ll soon see.


The other installation that will be covered here is Ansible, which is also just as simple. Ansible will help us run remote commands on the Ubuntu Node. If you are familiar with Jenkins, it is possible to add the Ubuntu Node as a Node in Jenkins, which would alleviate the need for Ansible altogether. However, this is not the best approach given how popular Ansible is. Knowing how to use it can be quite valuable, which is why we are using this approach instead.


Below you will find the necessary steps to get both Jenkins and Ansible installed on the Ubuntu Master VM:


  • Login to the Ubuntu Master VM and open a terminal window

  • Install Jenkins on Ubuntu master VM

a. Get Jenkins Authentication Key and add it to the list of keys used by apt to authenticate packages

wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -

b. Add Jenkins source to the apt list

sudo sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'

c. Update apt to make sure it uses the new source when installing Jenkins

sudo apt-get update

d. Install Java as a prerequisite for installing Jenkins

sudo apt-get -y install openjdk-8-jdk

e. Install Jenkins

sudo apt-get -y install jenkinS

f. View the contents of the InitialAdminPassword file for further steps

sudo cat /var/lib/jenkins/secrets/initialAdminPassword
  • Connect to Jenkins web interface via http://[IP]:8080, replacing IP with the IP of your Ubuntu master VM

  • Input the password from the file in step 2f

  • Install all suggested Plugins


  • Create Jenkins admin account and continue to Jenkins web interface

  • Run through commands to install Ansible on Master device

a. Add Ansible apt repository

sudo apt-add-repository ppa:ansible/ansible

b. Update apt so that it can make use of that new repository

sudo apt update

c. Install Ansible

sudo apt install ansible -y
  • Configure a new Ansible inventory file and make sure it is being read correctly

a. Be sure to replace the IP shown here under File Contents with the IP address for your Node


b. The argument in the inventory file is used to disable strict host checking for SSH; this can be removed after running the Jenkins pipeline for the first time in a future part if desired. This is done to prevent the Jenkins build from failing. If the argument wasn’t included, the Jenkins build would fail unless you previously SSH’ed into the node with the account that will be running the ansible command in Jenkins.

cd /etc/ansible
sudo vi inventory
ansible-inventory –list -i inventory
File Contents: 
[nodes]
172.16.24.138 ansible_ssh_common_args='-o StrictHostKeyChecking=no'
  • Create SSH keys

NOTE: Do not put a password in when prompted to do so. If you do, you will not be able to automate the Jenkins deployment as it will ask for you to input a password when ansible does an SSH connection to the Node.

ssh-keygen
  • View contents of the public key and copy it to an external text editor

cat ~/.ssh/id_rsa.pub
  • Login as the Jenkins user

sudo su -s /bin/bash jenkins
  • Repeat steps 9 and 10 for the Jenkins user

  • Install Git for a later part, if not already installed

sudo apt-get install git -y
  • Install Curl for a later part, if not already installed

sudo apt-get install curl -y

What's Next?

Well, this series is far from over. In the next part, I’ll discuss further the purpose of the Ubuntu node VM and walk through the configuration. Your Master node should be at a good spot moving forward to finish the rest of the configurations in a future part. The Ubuntu node is responsible for running our Docker containers, allowing us to achieve consistent runtime environments.


If you want to continue this configuration, check out part 3!


Part 3: Setting up your Ubuntu Node

Part 4: Configuring Splunk

Part 5: Jira Cloud Integration


If you want to discuss how you might be able to leverage DevOps in your environment, reach out to us here at CMG. You can even set up a meeting with us if you’d like. We’d love to discuss how we can help you with your DevOps automation and integration needs!

Comments


bottom of page