Reader small image

You're reading from  Ansible for Real-Life Automation

Product typeBook
Published inSep 2022
PublisherPackt
ISBN-139781803235417
Edition1st Edition
Concepts
Right arrow
Author (1)
Gineesh Madapparambath
Gineesh Madapparambath
author image
Gineesh Madapparambath

Gineesh Madapparambath has over 15 years of experience in IT service management and consultancy with experience in planning, deploying, and supporting Linux-based projects. He has designed, developed, and deployed automation solutions based on Ansible and Ansible Automation Platform (formerly Ansible Tower) for bare metal and virtual server building, patching, container management, network operations, and custom monitoring. Gineesh has coordinated, designed, and deployed servers in data centers globally and has cross-cultural experience in classic, private cloud (OpenStack and VM ware), and public cloud environments (AWS, Azure, and Google Cloud Platform). Gineesh has handled multiple roles such as systems engineer, automation specialist, infrastructure designer, and content author. His primary focus is on IT and application automation using Ansible, containerization using OpenShift (and Kubernetes), and infrastructure automation using Terraform.
Read more about Gineesh Madapparambath

Right arrow

Implementing Automation in a DevOps Workflow

DevOps is a combination of practices, tools, and philosophies that can help increase the speed, efficiency, and security of software development, application delivery, and infrastructure management processes. DevOps practices and methods are common in organizations now due to several advantages, such as faster and frequent deployments, improvement in quality, fewer errors, and high transparency via automation. By combining automation, collaboration, and integration, it is possible to develop and implement efficient DevOps practices, ensuring much higher quality output from your IT operations team.

Due to the numerous integrations, supported plugins, and modules, Ansible is a great tool for automating the tasks in your DevOps workflows. Ansible can help you automate different stages in the software development life cycle (SDLC), such as building applications, scanning the source code, storing artifacts in repositories, deploying the application...

Technical requirements

The following are the technical requirements for this chapter:

  • A Linux machine for the Ansible control node (with internet access)
  • Three Linux machines for installing and configuring applications
  • Basic knowledge of DevOps methodologies, CI/CD tools (Jenkins), and the Git workflow
  • Basic knowledge of Terraform

All the Ansible code, playbooks, commands, and snippets for this chapter can be found in this book’s GitHub repository at https://github.com/PacktPublishing/Ansible-for-Real-life-Automation/tree/main/Chapter-09.

A quick introduction to DevOps

In simple words, DevOps is the combination of development (Dev) and operations (Ops), but in reality, DevOps is a combination of ideas, tools, and practices that help increase the speed and efficiency of software development, delivery, and infrastructure management processes. There are several known best practices we can follow and include in the DevOps workflow, as follows:

  • Team collaboration and transparent communication
  • CI/CD
  • Infrastructure as code (IaC) and automated infrastructure management
  • Containerization and microservices
  • Logging, monitoring, and feedback loops

One of the key concepts in DevOps practices is to reduce the time and effort required for application life cycle management, such as integration, build, test, release, and deployment. Using DevOps methodologies and tools, it is possible to automate this process. This is known as CI/CD.

Learning about DevOps

Refer to the following guides to understand...

Serving applications using a load balancer

So far, you have learned how to deploy applications to multiple servers using Ansible with all the necessary prerequisites, dependencies, and basic health checks. But if the application or website is running on multiple servers, then you will need to tell the end user about multiple servers so that they can access the website. It is a best practice to serve the application from a single entity such as a load balancer, as shown in the following diagram, so that the end user doesn’t need to know the actual web or application server IP addresses. It will also help you implement high availability and rolling updates for the application:

Figure 9.15 – Website hosted on multiple servers with a load balancer

Since we are handling the application deployment using Ansible inside the CI/CD workflow, we can include the load balancer installation and configuration tasks inside the pipeline, as shown in the following...

Rolling updates using Ansible

Continuous deployment is a method meant for frequent application deployment (together with CI/CD) and frequent updates of your application or website rather than you having to wait for scheduled downtime and deployment cycles. But you also need to ensure the application will be available during the update process. So far, you have learned that application high availability can be achieved using a load balancer. In this section, you will learn how to update the application on web servers without downtime.

Steps involved in an application update

Depending on your application’s type and the components involved, the update process may contain different steps and procedures. The following diagram shows the generic steps involved in the application update process, which is running behind a load balancer:

Figure 9.23 – Steps involved in an application update

It is possible to automate all such tasks using Ansible,...

Using Ansible as a provisioning tool in Terraform

Ansible can be used as an IaC tool, as you learned in Chapter 7, Managing Your Virtualization and Cloud Platforms. At the same time, it is a common practice in the industry to use the right tool for the right task – for example, Terraform for IaC, Ansible for IT automation, Jenkins for CI/CD pipelines, and so on. Instead of comparing similar tools, integrate them in the right place and achieve better results.

Terraform is an open source tool by HashiCorp for implementing IaC practices. Terraform can be used to deploy and manage the cloud-based infrastructure and applications using infrastructure code written in a declarative configuration language called HashiCorp Configuration Language (HCL). Depending on the cloud platform and components, use the provider modules and resources available. Refer to https://registry.terraform.io/browse/providers to explore the available and supported providers.

For example, the following...

Summary

In this chapter, you explored the basic concepts, processes, and technical terms surrounding DevOps, such as CI/CD and continuous deployment. You also learned about some of the possibilities of Ansible integration within the DevOps workflow. Then, you learned how to use Ansible inside a continuous deployment workflow using Jenkins. After that, you learned about how to perform rolling updates without downtime while using Ansible as part of continuous application deployment. Finally, you learned how to integrate Ansible with Terraform for IaC provisioning.

In the next chapter, you will learn how to build, run, and manage containers using Ansible.

Further reading

To learn more about the topics that were covered in this chapter, take a look at the following resources:

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Ansible for Real-Life Automation
Published in: Sep 2022Publisher: PacktISBN-13: 9781803235417
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime

Author (1)

author image
Gineesh Madapparambath

Gineesh Madapparambath has over 15 years of experience in IT service management and consultancy with experience in planning, deploying, and supporting Linux-based projects. He has designed, developed, and deployed automation solutions based on Ansible and Ansible Automation Platform (formerly Ansible Tower) for bare metal and virtual server building, patching, container management, network operations, and custom monitoring. Gineesh has coordinated, designed, and deployed servers in data centers globally and has cross-cultural experience in classic, private cloud (OpenStack and VM ware), and public cloud environments (AWS, Azure, and Google Cloud Platform). Gineesh has handled multiple roles such as systems engineer, automation specialist, infrastructure designer, and content author. His primary focus is on IT and application automation using Ansible, containerization using OpenShift (and Kubernetes), and infrastructure automation using Terraform.
Read more about Gineesh Madapparambath