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?
aws ec2 describe-instances --filter Name=tag,Values=environment=qa
has to say, since it's possible you are expecting a shorter list than is really coming back. You can also just run that inventory manually to ensure you and it are on the same pageEC2_INI_PATH=whatever python ./ec2.py --list
– mdanielaws
utility but I had to use this syntax:aws ec2 describe-instances --filter Name=tag:environment,Values=qa
– kfreezy