ec2.ini pattern_exclude and instance_filters

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

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