Book Image

Ansible 2 Cloud Automation Cookbook

By : Aditya Patawari, Vikas Aggarwal
Book Image

Ansible 2 Cloud Automation Cookbook

By: Aditya Patawari, Vikas Aggarwal

Overview of this book

Ansible has a large collection of inbuilt modules to manage various cloud resources. The book begins with the concepts needed to safeguard your credentials and explain how you interact with cloud providers to manage resources. Each chapter begins with an introduction and prerequisites to use the right modules to manage a given cloud provider. Learn about Amazon Web Services, Google Cloud, Microsoft Azure, and other providers. Each chapter shows you how to create basic computing resources, which you can then use to deploy an application. Finally, you will be able to deploy a sample application to demonstrate various usage patterns and utilities of resources.
Table of Contents (11 chapters)

Using dynamic inventory

In our previous recipes and the previous chapter, we have seen how easily we can create AWS resources. When running production loads on AWS Cloud, we tend to scale out and scale in the resources according to traffic and workloads. But with this dynamic nature of the cloud to scale in and out, managing a static inventory file for Ansible is an operational task and overhead, and it becomes really difficult if we want to implement features such as autoscaling.

With the help of dynamic inventory, we can solve this. Ansible provides an EC2 dynamic inventory script called ec2.py (https://github.com/ansible/ansible/blob/devel/contrib/inventory/ec2.py).

How to do it...

  1. We will be running Ansible ad hoc commands...