# ec2.ini pattern\_exclude and instance\_filters

**URL:** <https://forum.ansible.com/t/ec2-ini-pattern-exclude-and-instance-filters/22348>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [August 22, 2016, 6:14pm UTC](https://forum.ansible.com/t/ec2-ini-pattern-exclude-and-instance-filters/22348 "2016-08-22T18:14:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guy\_Knights](https://avatars.discourse-cdn.com/v4/letter/g/db5fbb/32.png) [@Guy\_Knights](https://forum.ansible.com/u/Guy_Knights)\
**Post date:** [August 22, 2016, 6:14pm UTC](https://forum.ansible.com/t/ec2-ini-pattern-exclude-and-instance-filters/22348/1 "2016-08-22T18:14:15Z")

</div>

I’m trying to remove certain ec2 hosts from having ansible run on them by using the instance\_filters and/or pattern\_exclude options in the ini file for ec2.py, but it doesn’t seem to be working. I tried using the following syntax for instance\_filters:

instance\_filters = “tag:Environment=prod,!Platform=windows”

However when I run a playbook it gives me the following error:

The filter ‘!Platform’ is invalid", while: getting EC2 instances  
inventory/prod/ec2.py:3: Error parsing host definition ‘’‘’': No closing quotation

I removed the double quotes and I get a similar error:

The filter ‘~Platform’ is invalid", while: getting EC2 instances  
inventory/prod/ec2.py:3: Error parsing host definition ‘’‘’': No closing quotation

I also tried changing them to single quotes but once again got yet another slightly different error:

The filter ‘‘tag:Environment’ is invalid", while: getting EC2 instances  
inventory/prod/ec2.py:3: Error parsing host definition ‘’’‘’: No closing quotation

Meanwhile, I tried playing with pattern\_exclude instead. I added the following:

pattern\_exclude = ‘\*-ad’

When I run this, it still tries to excute the playbook on servers whose names match the pattern ‘example-ec2-ad’.

What am I doing wrong here?

Thanks,  
Guy

---

<div class="post-metadata">

**Author:** ![Guy\_Knights](https://avatars.discourse-cdn.com/v4/letter/g/db5fbb/32.png) [@Guy\_Knights](https://forum.ansible.com/u/Guy_Knights)\
**Post date:** [August 22, 2016, 6:23pm UTC](https://forum.ansible.com/t/ec2-ini-pattern-exclude-and-instance-filters/22348/2 "2016-08-22T18:23:55Z")

</div>

Oops, just noting that I accidentally mistyped the instance\_filter line in the second error above (The filter ‘~Platform’ is invalid").
