top of page

How to 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:


1. Login to the Ubuntu Master VM and open a terminal window

2. 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

3. Connect to Jenkins web interface via http://[IP]:8080, replacing IP with the IP of your Ubuntu master VM

4. Input the password from the file in step 2f

5. Install all suggested Plugins

6. Create Jenkins admin account and continue to Jenkins web interface

7. 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

8. 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'

9. Create SSH keys

a. 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

10. View contents of the public key and copy it to an external text editor

cat ~/.ssh/id_rsa.pub

11. Login as the Jenkins user

sudo su -s /bin/bash jenkins

12. Repeat steps 9 and 10 for the Jenkins user

13. Install Git for a later part, if not already installed

sudo apt-get install git -y

14. Install Curl for a later part, if not already installed

sudo apt-get install curl -y

What now?

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!


DevOps Lab Build Series Index

Part 5: Jira Cloud Integration

bottom of page