aws_ec2 inventory plugins: Creating host variables based on AWS tags

17 views
Skip to first unread message

Gert van den Berg

unread,
Sep 18, 2019, 5:57:15 AM9/18/19
to Ansible Project
Is there a way to create host variables based on the tags on an instance? (without manually listing each variable and tag under the compose section)

The idea is bascially to allow the equivalent of the INI-style inventory file using tags from AWS. (With the relevant variables using a prefix to identify them)

e.g. If an instance has these tags: (The array syntax is assumed from what works in the INI-style inventory)
ansible_swapfile_size=4G
ansible_extra_packages=["htop","iotop"]

I want these variables to be configured:
swapfile_size: 4G
extra_packages:
- htop
- iotop

compose seems to be capable of doing it if I list a fixed set of variables, but that means that if a new variable are added, the inventory would need to be edited.

Is there a way to dynamically generate variables based on tags?

Thanks,
Gert
Reply all
Reply to author
Forward
0 new messages