Book Image

Ansible for Real-Life Automation

By : Gineesh Madapparambath
Book Image

Ansible for Real-Life Automation

By: Gineesh Madapparambath

Overview of this book

Get ready to leverage the power of Ansible’s wide applicability to automate and manage IT infrastructure with Ansible for Real-Life Automation. This book will guide you in setting up and managing the free and open source automation tool and remote-managed nodes in the production and dev/staging environments. Starting with its installation and deployment, you’ll learn automation using simple use cases in your workplace. You’ll go beyond just Linux machines to use Ansible to automate Microsoft Windows machines, network devices, and private and public cloud platforms such as VMWare, AWS, and GCP. As you progress through the chapters, you’ll integrate Ansible into your DevOps workflow and deal with application container management and container platforms such as Kubernetes. This Ansible book also contains a detailed introduction to Red Hat Ansible Automation Platform to help you get up to speed with Red Hat AAP and integration with CI/CD and ITSM. What’s more, you’ll implement efficient automation solutions while learning best practices and methods to secure sensitive data using Ansible Vault and alternatives to automate non-supported platforms and operations using raw commands, command modules, and REST API calls. By the end of this book, you’ll be proficient in identifying and developing real-life automation use cases using Ansible.
Table of Contents (22 chapters)
1
Part 1: Using Ansible as Your Automation Tool
6
Part 2: Finding Use Cases and Integrations
16
Part 3: Managing Your Automation Development Flow with Best Practices

Executing commands inside a Kubernetes Pod

In a normal situation, we do not need to log in to a Pod or container, as the application is exposed on some ports and Services are talking over these exposed ports. However, when there are issues, we need to access the containers and check what is happening inside, by checking logs, accessing other Pods, or running any necessary troubleshooting commands.

Use the kubectl exec command if you are doing this troubleshooting or information gathering manually:

Figure 11.36 – Execute commands inside a Pod using the kubectl utility

However, when we automate Kubernetes operations using Ansible, use the k8s_exec module and automate the verification tasks or validation tasks as well.

For such scenarios, we can deploy debug Pods using suitable images (for example, images with required utilities, such as ping, curl, or netstat) and execute validation commands from these Pods. A typical deployment scenario with test...