简体   繁体   中英

Ansible AWS dynamic inventory instance filters not working

I've setup Amazon's dynamic inventory for Ansible according to https://aws.amazon.com/blogs/apn/getting-started-with-ansible-and-dynamic-amazon-ec2-inventory-management/ . I'm able to get an inventory of every EC2 instance on this account but I'd like to filter that down using tags. I've set instance_filters in my ec2.ini but the script still returns the entire inventory.

instance_filters = tag:environment=qa
ansible all -i ec2.py -m ping

I also made sure the environment variable to point to ec2.ini was set.

export EC2_INI_PATH=/path/to/ec2.ini/its/different/on/my/machine/I/swear

What steps/configs am I missing that actually filters EC2 instances?

The instance_filters config was working as expected. The problem was that the extra "hosts" I was picking up were actually ElasiCache clusters. In order to exclude those from inventory I had to add the config below to ec2.ini.

elasticache = False

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM