From the course: Ansible: From Basics to Guru by Pearson

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Configuring dynamic inventory

Configuring dynamic inventory

Let's briefly talk about Dynamic Inventory in AWS. So Dynamic Inventory, as you know, is provided as an Ansible plugin. And using Python scripts as Dynamic Inventory really is old school. You shouldn't be doing that anymore. Using AWS Dynamic Inventory requires you to use a YAML file that is in Opt Ansible inventory, awsec2.yaml. Don't ever store this file in your Git repository as it contains sensitive information. And next you will need to enable the plugin in ansible.cfg. So this is what the dynamic inventory will look like. So you have the plugin, awsec2, and the AWS access key, which is your key, as well as the secret key. And then you need keyed groups, key and prefix set to tag that's just default stuff that is in there. Most importantly, you have this dynamic inventory with your key and your secret. And that is important if ever you want to reach out to two hosts in the AWS environment. To use the dynamic inventory configuration, you also should not forget to edit the Ansible…

Contents