Ansible for Real-Life Automation: A complete Ansible handbook filled with practical IT automation use cases
- Length: 480 pages
- Edition: 1
- Language: English
- Publisher: Packt Publishing
- Publication Date: 2022-09-30
- ISBN-10: 1803235411
- ISBN-13: 9781803235417
- Sales Rank: #244143 (See Top 100 Books)
Learn how to automate and manage your IT infrastructure and applications using Ansible
Key Features
- Develop Ansible automation use cases by automating day-to-day IT and application operations
- Use Ansible to automate private and public cloud, application containers, and container platforms
- Improve your DevOps workflow with Ansible
Book Description
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.
What you will learn
- Explore real-life IT automation use cases and employ Ansible for automation
- Develop playbooks with best practices for production environments
- Approach different automation use cases with the most suitable methods
- Use Ansible for infrastructure management and automate VMWare, AWS, and GCP
- Integrate Ansible with Terraform, Jenkins, OpenShift, and Kubernetes
- Manage container platforms such as Kubernetes and OpenShift with Ansible
- Get to know the Red Hat Ansible Automation Platform and its capabilities
Who this book is for
This book is for DevOps and systems engineers looking to adopt Ansible as their automation tool. To get started with this book, basic knowledge of Linux is necessary, along with an understanding of how tasks are done the manual way before setting out to automate them.
Ansible for Real-Life Automation Contributors About the author About the reviewers Preface Who this book is for What this book covers To get the most out of this book Download the example code files Download the color images Conventions used Get in touch Share Your Thoughts Part 1: Using Ansible as Your Automation Tool Chapter 1: Ansible Automation – Introduction Technical requirements Hello engineers! What is Ansible? Where should I use this tool? Prerequisites Ansible control node requirements Ansible managed node requirements Ansible is agentless Ansible architecture Ansible inventory Ansible plugins Ansible modules Ansible content collections Ansible playbook Ansible use cases Installing Ansible Verify dependencies Installing Ansible using the package manager Installing Ansible using Python pip Deploying Ansible Creating an Ansible inventory Configuring your managed nodes Setting up SSH key-based authentication Multiple users and credentials Ansible ad hoc commands Installing a package using Ansible Summary Further reading Chapter 2: Starting with Simple Automation Technical requirements Identifying manual tasks to be automated Finding the Ansible modules to use Configuring your text editor for Ansible Connecting to remote nodes Summary Further reading Chapter 3: Automating Your Daily Jobs Technical requirements Using Ansible to collect server details Ansible roles Ansible Jinja2 templates Collecting system information System scanning and remediation using Ansible Ansible --extra-vars Automated weekly system reboot using Ansible Automating notifications Encrypting sensitive data using Ansible Vault Summary Further reading Chapter 4: Exploring Collaboration in Automation Development Technical requirements The importance of version control in IT automation Selecting a Git server Where should I keep automation artifacts? Ansible and Git repositories – best practices Managing automation content in a Git server Setting up a GitHub account Creating your first Git repository Installing Git on a local machine Configuring SSH keys in GitHub Adding content to the Git repository Collaboration is the key to automation Using Git branching Implementing Git branching Summary Further reading Part 2: Finding Use Cases and Integrations Chapter 5: Expanding Your Automation Landscape Technical requirements Finding your automation use cases in your day-to-day work Assessing the tasks Ansible and ITSM Automation and Information Technology Infrastructure Library compliance Automation feasibility and usability How complex is the use case? Can I reduce human error? Can I reduce the deployment time and speed up my tasks? How frequently am I doing this task? How much time can I save by automating this task? Can I save some money? Involving teams in the automation journey Ansible dynamic inventory Using the Ansible dynamic inventory with AWS Summary Further reading Chapter 6: Automating Microsoft Windows and Network Devices Technical requirements Ansible remote connection methods Ansible connection variables SSH connection parameters Automating Microsoft Windows servers using Ansible Supported Microsoft Windows operating systems Microsoft Windows automation – Ansible control node prerequisites Microsoft Windows automation – managed node prerequisites Configuring the user account and WinRM on a Microsoft Windows machine Configuring Ansible to access the Microsoft Windows machine Microsoft Windows automation – using Ansible to create a Windows user Introduction to network automation Task execution on an Ansible control node Different connection methods VyOS information gathering using Ansible Creating ACL entries in a Cisco ASA device Summary Further reading Chapter 7: Managing Your Virtualization and Cloud Platforms Technical requirements Introduction to Infrastructure as Code Managing cloud platforms using Ansible Automating VMware vSphere resources using Ansible Ansible VMware automation prerequisites Provisioning VMware virtual machines in Ansible Using Ansible as an IaC tool for AWS Installing the Ansible AWS collection Creating Ansible IaC content for the AWS infrastructure Completing the IaC life cycle by using a destroy playbook Creating resources in GCP using Ansible Prerequisite for Ansible GCP automation GCP free trial Configuring GCP credentials Creating a GCP instance using Ansible Summary Further reading Chapter 8: Helping the Database Team with Automation Technical requirements Ansible for database operations Installing database servers Installing PostgreSQL using Ansible Installing Microsoft SQL Server on Linux Creating and managing databases using Ansible Ansible community.postgresql prerequisites Managing the database life cycle Automating PostgreSQL operations Managing PostgreSQL remote access Database backup and restore Automating a password reset using ITSM and Ansible Ansible playbook for resetting passwords Summary Further reading Chapter 9: Implementing Automation in a DevOps Workflow Technical requirements A quick introduction to DevOps Continuous delivery versus continuous deployment Ansible inside CI/CD tasks Using Ansible inside a Jenkins pipeline Serving applications using a load balancer Rolling updates using Ansible Steps involved in an application update Deploying updates in a batch of managed nodes Deploying updates on multiple servers without service downtime Using Ansible as a provisioning tool in Terraform Using Terraform’s local-exec provisioner with Ansible Using Terraform’s remote-exec provisioner with Ansible Summary Further reading Chapter 10: Managing Containers Using Ansible Technical requirements Managing the container host Ansible Docker prerequisites Installing Docker on the host using Ansible Ansible, containers, and CI/CD Managing containers using Ansible Starting a Docker container using Ansible Stopping Docker containers using Ansible Managing container images using Ansible Configuring Docker Registry access Building container images using Ansible Managing multi-container applications using Ansible Summary Further reading Chapter 11: Managing Kubernetes Using Ansible Technical requirements An introduction to Kubernetes The Kubernetes control plane Components on the nodes Managing Kubernetes clusters using Ansible Configuring Ansible for Kubernetes Python requirements Installing the Ansible Kubernetes collection Connecting Ansible to Kubernetes Installing the kubectl CLI tool Verifying the Kubernetes cluster details using Ansible Deploying applications to Kubernetes using Ansible Scaling Kubernetes applications Scaling Kubernetes Deployments using Ansible Executing commands inside a Kubernetes Pod Summary Further reading Chapter 12: Integrating Ansible with Your Tools Technical requirements Introduction to Red Hat AAP Features of Red Hat AAP Red Hat AAP components Ansible automation controller Automation execution environments The automation mesh Automation Hub Database management using Red Hat AAP Accessing the Ansible automation controller Creating a project in automation controller Creating the inventory and managed nodes Creating credentials in the automation controller Creating a new job template Executing an automation job from the automation controller Integrating Jenkins with AAP Ansible Tower plugin for Jenkins Multibranch pipelines in Jenkins Creating a Jenkinsfile Triggering a build in the Jenkins pipeline Further enhancements to the Jenkins pipeline Integrating an automation controller with Slack and notification services Creating email notifications in the automation controller Sending Slack notifications from the automation controller Summary Further reading Chapter 13: Using Ansible for Secret Management Technical requirements Handling sensitive data in Ansible Integrating with Vault services Interactive input using prompts Encrypting data using Ansible Vault Managing secrets using Ansible Vault Creating Vault files Encrypting existing files Adding Vault ID to an encryption Viewing the content of a Vault file Editing a Vault file Decrypting a Vault file Vault password rotation by rekeying Encrypting specific variables Using secrets in Ansible playbooks Hiding secrets from logs using no_log Ansible Vault for group_vars and host_vars Using Vault credentials in the Ansible Automation Platform Creating Vault credentials Summary Further reading Part 3: Managing Your Automation Development Flow with Best Practices Chapter 14: Keeping Automation Simple and Efficient Technical requirements Utilizing surveys and automated inputs Integrating Ansible with monitoring tools The role of Ansible in monitoring ServiceNow, Ansible, and zero-touch incident fixes Ansible for security automation Ansible workflow templates Summary Chapter 15: Automating Non-Standard Platforms and Operations Technical requirements Executing low-down raw commands Installing Python using the raw module Using raw commands for network operations Backup FortiOS configurations FortiOS software upgrade Raw commands on Cisco devices Using API calls for automation Automating a ToDo app using Ansible Interacting with the Akamai API Creating custom modules for Ansible Facts to check before creating a custom Ansible module Developing Ansible modules using bash scripts Developing Ansible modules using Python Using Ansible collections and contributing back Summary Further reading Chapter 16: Ansible Automation Best Practices for Production Technical requirements Organizing Ansible automation content Storing remote host information – inventory best practices Using meaningful hostnames Storing production, staging, and development hosts separately Ansible host variables and group variables Ansible group_vars Ansible host_vars Keeping your secret variables in a safe location Managing group_vars and host_vars in Ansible Ansible credentials best practices Avoid using default admin user accounts Split the login credentials for environments and nodes Avoid passwords in plain text Ansible playbook best practices Always give your tasks names Use the appropriate comments Extra lines and whitespaces Add tags to the tasks Use explicit declarations Use native YAML for playbooks Avoid hardcoding variables and details Use blocks in Ansible playbooks Use roles and subtasks Use meaningful names for variables Learn playbook optimization Summary Further reading Index Why subscribe? Other Books You May Enjoy Packt is searching for authors like you Share Your Thoughts
Donate to keep this site alive
How to download source code?
1. Go to: https://github.com/PacktPublishing
2. In the Find a repository… box, search the book title: Ansible for Real-Life Automation: A complete Ansible handbook filled with practical IT automation use cases
, sometime you may not get the results, please search the main title.
3. Click the book title in the search results.
3. Click Code to download.
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.