Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Ansible for Real-Life Automation

You're reading from  Ansible for Real-Life Automation

Product type Book
Published in Sep 2022
Publisher Packt
ISBN-13 9781803235417
Pages 480 pages
Edition 1st Edition
Languages
Concepts
Author (1):
Gineesh Madapparambath Gineesh Madapparambath
Profile icon Gineesh Madapparambath

Table of Contents (22) Chapters

Preface 1. Part 1: Using Ansible as Your Automation Tool
2. Chapter 1: Ansible Automation – Introduction 3. Chapter 2: Starting with Simple Automation 4. Chapter 3: Automating Your Daily Jobs 5. Chapter 4: Exploring Collaboration in Automation Development 6. Part 2: Finding Use Cases and Integrations
7. Chapter 5: Expanding Your Automation Landscape 8. Chapter 6: Automating Microsoft Windows and Network Devices 9. Chapter 7: Managing Your Virtualization and Cloud Platforms 10. Chapter 8: Helping the Database Team with Automation 11. Chapter 9: Implementing Automation in a DevOps Workflow 12. Chapter 10: Managing Containers Using Ansible 13. Chapter 11: Managing Kubernetes Using Ansible 14. Chapter 12: Integrating Ansible with Your Tools 15. Chapter 13: Using Ansible for Secret Management 16. Part 3: Managing Your Automation Development Flow with Best Practices
17. Chapter 14: Keeping Automation Simple and Efficient 18. Chapter 15: Automating Non-Standard Platforms and Operations 19. Chapter 16: Ansible Automation Best Practices for Production 20. Index 21. Other Books You May Enjoy

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 2022 Publisher: Packt ISBN-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.
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 AU $19.99/month. Cancel anytime}