31,19 €
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.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 382
Veröffentlichungsjahr: 2022
A complete Ansible handbook filled with practical IT automation use cases
Gineesh Madapparambath
BIRMINGHAM—MUMBAI
Copyright © 2022 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author nor Packt Publishing or its dealers and distributors will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Group Product Manager: Rahul Nair
Publishing Product Manager: Meeta Rajani
Senior Content Development Editor: Sayali Pingale
Technical Editor: Shruthi Shetty
Copy Editor: Safis Editing
Project Manager: Neil Dmello
Proofreader: Safis Editing
Indexer: Hemangini Bari
Production Designer: Shyam Sundar Korumilli
Marketing Coordinator: Nimisha Dua
Senior Marketing Coordinator: Sanjana Gupta
First published: September 2022
Production reference: 1020922
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
978-1-80323-541-7
www.packt.com
To my wife, Deepthy, for supporting and motivating me as always. To my son, Abhay, for allowing me to take time away from playing with him to write the book. To my parents and my ever-supportive friends, for their motivation and help.
- 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 VMware), 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.
Vijay Jadhav is a solutions architect based out of Mumbai, India, with over two decades of experience in different roles in the IT industry. For the last 10 years, he has been working as an SME in cloud computing designing cloud-native applications using microservices-based architecture, and automated provisioning and de-provisioning of cloud resources using IaaC tools such as Ansible and Terraform. He currently works as a cloud architect at Cisco driving the innovation and adoption of next-gen technologies.
Vijay is a husband and a dad to an 8-year-old son. He spends his spare time (if such a thing does truly exist) watching popular movies and web series on OTT platforms.
Sean Cavanaugh is a senior principal technical marketing manager for Red Hat Ansible Automation Platform, where he brings over 12 years of experience in building and automating computer networks. Sean previously worked for both Cumulus Networks (acquired by Nvidia) and Cisco Systems where he helped customers deploy, manage, and automate their network infrastructures. He resides in Chapel Hill, NC, with his wife and children, and tweets from @IpvSean.
I’d like to thank my wife, who is truly my partner. She has her own career and workload outside the IT industry but is always committed to helping me succeed in all my endeavors. I have had a really exciting career getting to work with very intelligent people that constantly challenge me and make me a better person. Thank you to all my co-workers past and present that have helped me along my path.
Sreejith Anujan is a cloud technology professional with more than 15 years of experience in on-premises data center solutions and 10 years of experience in working with public cloud providers. He enjoys working with customers on their enablement plans to upskill the technical team on container and automation tooling. In his current role as a principal instructor within Red Hat, Sreejith is responsible for designing and delivering custom and tailored technology training and workshops to strategic customers across the Asia-Pacific region.
I would like to show my gratitude to the free software and open source community volunteers who have helped me in my journey so far. The sense of collaboration and free contribution are two values that make me cherish being part of those communities. A huge shout-out to my family, especially my wife for supporting our kids while I was busy traveling across the APAC region for my professional commitments!
Automation is the key to IT modernization, and using the right automation tool is a crucial step in the automation journey for organizations. Ansible is an open source automation software that you can use for automating most of your operations with IT and application infrastructure components including servers, storage, network, and application platforms. Ansible is one of the most well-known open source automation tools in the IT world right now and has strong community support, with more than 5,000 active contributors around the world.
Ansible is not a learn-by-reading technology. This book will help you to understand and practice the automation capabilities of Ansible with actual playbooks, configurations, and practical examples. It will help you to understand the basics of Ansible automation and slowly, you will learn how to use Ansible for automating your day-to-day tasks.
You will learn real-life IT automation use cases with practical examples, such as simple system reports, security scanning, and weekly rebooting Linux machines. After that, the book will teach you how to implement collaboration in Ansible automation and how to automate other devices and platforms, such as Microsoft Windows, network devices, VMware, AWS, and GCP. You will also learn how to use Ansible in a DevOps workflow with Jenkins integration and container and application management on Kubernetes. To expand your knowledge further on enterprise automation, the book will also teach you about Red Hat Ansible Automation Platform, secret management, and Ansible integration with other tools, such as Jira and ServiceNow. There are chapters in this book that cover how to automate non-supported devices and platforms using raw commands and API calls using Ansible. Before the book concludes, you will also explore the Ansible best practices for storing managed node information, variables, credentials, and playbooks for production environments.
Upon finishing Ansible for Real-Life Automation, you will have the skills to find automation use cases in your work environment and design and deploy automation solutions using Ansible.
This book is intended for systems engineers and DevOps engineers who want to use Ansible as their automation tool. The book provides references and practical examples to start IT automation within your work environment.
Chapter 1, Ansible Automation – Introduction, gives you an introduction to Ansible and teaches you how to install and configure Ansible and configure managed nodes.
Chapter 2, Starting with Simple Automation, teaches you how to identify manual tasks to automate, find suitable Ansible modules, and use text editors for Ansible.
Chapter 3, Automating Your Daily Jobs, is the chapter where you started developing Ansible playbooks for real-life use cases, such as system information gathering, system reboot, and security scanning. You will also learn about Ansible collections, secrets in Ansible, and automating notifications.
Chapter 4, Exploring Collaboration in Automation Development, teaches you about the importance of version control in IT automation and the best practices to use source control management for storing Ansible artifacts.
Chapter 5, Expanding Your Automation Landscape, covers the methods to find automation use cases from your workplace and check the feasibility of automation. This chapter also teaches you how to use a dynamic inventory in Ansible.
Chapter 6, Automating Microsoft Windows and Network Devices, is where you discover the possibilities to automate Microsoft Windows and network devices using Ansible. This chapter will cover practical examples for Windows automation, VyOS fact gathering, and access control list creation on a Cisco ASA device.
Chapter 7, Managing Your Virtualization and Cloud Platforms, teaches you about Infrastructure as Code (IaC) and the methods to use Ansible as an IaC tool with practical examples for managing the VMware, AWS, and GCP platforms.
Chapter 8, Helping the Database Team with Automation, covers an introduction to database operations, such as installing the database server and creating databases, tables, and database users.
Chapter 9, Implementing Automation in a DevOps Workflow, is where you will be introduced to DevOps and the usage of Ansible in a DevOps workflow, with practical examples for reducing deployment time and managing application load balancers and rolling updates. The chapter also covers how to integrate Ansible with Terraform.
Chapter 10, Managing Containers Using Ansible, continues the look at Ansible and DevOps by covering the methods to manage application containers using Ansible. This chapter covers practical use cases such as deploying container hosts, using Ansible in CI/CD pipelines, building containers, and managing multi-container applications.
Chapter 11, Managing Kubernetes Using Ansible, goes into more container-based use cases with an introduction to Kubernetes and the method to manage Kubernetes clusters and applications using Ansible. The chapter teaches you how to deploy, manage, and scale containerized applications on the Kubernetes platform.
Chapter 12, Integrating Ansible with Your Tools, covers the introduction to the enterprise automation tool Red Hat Ansible Automation Platform (AAP). This chapter teaches you methods for using AAP for automation with practical examples, such as database management, Jenkins integration, and Slack notification.
Chapter 13, Using Ansible for Secret Management, explains the methods to handle sensitive data in automation using Ansible Vault and how to use encrypted data in Ansible playbooks.
Chapter 14, Keeping Automation Simple and Efficient, teaches you about the survey forms in Ansible automation controller and workflow job templates. This chapter also covers security automation and integrating Ansible with monitoring tools.
Chapter 15, Automating Non-Standard Platforms and Operations, teaches you the automate to handle non-supported platforms using raw commands and API commands. This chapter also teaches you how to develop custom Ansible modules for when there are no modules available.
Chapter 16, Ansible Automation Best Practices for Production, is where you learn the production best practices for Ansible, such as organizing Ansible artifacts, inventories, and variables. This chapter also covers the best practices for credential management and playbook development.
In this book, I will first guide you through the installation and deployment of the Ansible automation tool, and later, I will explain some real IT use cases and methods to use Ansible for automating such operations. Since the focus of the book is on different automation use cases, some of the chapters might have additional technical requirements, such as basic knowledge of a specific technology or access to a lab environment (such as a Kubernetes cluster). For this, I have also covered the methods to arrange the development environment if you want to practice. Always refer to the Ansible documentation at https://docs.ansible.com and other provided links in the chapters for further learning.
For testing and development, you can get no-cost RHEL (https://developers.redhat.com/articles/faqs-no-cost-red-hat-enterprise-linux) subscriptions. It is also possible to replace RHEL8 with other operating systems, such as Fedora, CentOS, or Ubuntu, but you might need to adjust some of the commands and modules in the playbook.
If you are reading a soft copy or digital version of this book, it is advised to type the commands and develop the playbooks by yourself rather than copy-pasting from the book. However, you can access the code, snippets, and playbooks from the book’s GitHub repository (a link is available in the next section) for reference.
You can download the example code files for this book from GitHub at https://github.com/PacktPublishing/Ansible-for-Real-life-Automation. If there’s an update to the code, it will be updated on the existing GitHub repository. You can point out any problems or issues in the code samples and submit any questions related to the book by raising issue tickets in this GitHub repository.
We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://packt.link/TVh0m.
There are a number of text conventions used throughout this book.
Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: “Configure the KUBECONFIG environment variable as our kubeconfig filename is different (/home/ansible/.kube/minikube-config) from the default filename (/home/ansible/.kube/config).”
A block of code is set as follows:
[ansible@ansible Chapter-11]$ export KUBECONFIG=$KUBECONFIG:/home/ansible/.kube/minikube-configSome of the code snippets and outputs are displayed as images for better readability and brevity.
Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: “Update your job template and add new vault credentials by going to Job Template | Edit, then clicking on the Search button near Credential.”
Tips or Important Notes
Appear like this.
Feedback from our readers is always welcome.
General feedback: If you have questions about any aspect of this book, mention the book title in the subject of your message and email us at [email protected].
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.
Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.
If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.
Once you’ve read Ansible for Real Life Automation, we’d love to hear your thoughts! Please click here to go straight to the Amazon review page for this book and share your feedback.
Your review is important to us and the tech community and will help us make sure we’re delivering excellent quality content.
In this part, you will get a clear idea of how to get started with Ansible automation and automate your basic daily jobs.
This part of the book comprises the following chapters:
Chapter 1, Ansible Automation – IntroductionChapter 2, Starting with Simple AutomationChapter 3, Automating Your Daily JobsChapter 4, Exploring Collaboration in Automation Development