Contents
How to setup Ansible AWS dynamic inventory plugin?
When you are using Ansible with AWS, maintaining the inventory file will be a hectic task as AWS has frequently changed IPs, autoscaling instances, and much more. However, there is an easy solution called ansible dynamic inventory. Dynamic inventory is an ansible plugin that makes an API call to AWS to get the instance information in the run time.
What is the use of dynamic inventory in AWS?
The primary use case of AWS Ansible dynamic inventory is to execute Ansible playbooks or ad-hoc commands against a single or group of categorized or grouped instances based on tags, regions, or other ec2 parameters. You can group instances using tags, instances type, instance names, custom filters and more.
How does the EC2 Inventory script work in Ansible?
When the Ansible is interacting with a specific server, the EC2 inventory script is called again with the –host HOST option. This looks up the HOST in the index cache to get the instance ID, and then makes an API call to AWS to get information about that specific instance.
Why does Ansible run on top of Boto?
The reason I’ve done this is first, for convenience, and also, because the dynamic Amazon EC2 inventory script Ansible provides runs on top of Boto.
How to create group names in Ansible EC2?
Expose the host tags with ec2_tag_TAGNAME keys like the old ec2.py inventory script. The use of this feature is discouraged and we advise to migrate to the new “tags“ structure. By default this plugin is using a general group name sanitization to create safe and usable group names for use in Ansible.
What does replace dash in groups do in Ansible?
By default this plugin is using a general group name sanitization to create safe and usable group names for use in Ansible. This option allows you to override that, in efforts to allow migration from the old inventory script and matches the sanitization of groups when the script’s “replace_dash_in_groups“ option is set to “False“.