Closed chrismeyersfsu closed 3 years ago
Files identified in the description:
plugins/inventory/aws_ec2.py
](https://github.com/['ansible-collections/amazon.aws', 'ansible-collections/community.aws', 'ansible-collections/community.vmware']/blob/main/plugins/inventory/aws_ec2.py)If these files are inaccurate, please update the component name
section of the description or use the !component
bot command.
Summary
include_filters
is matching on ALL hosts when I expect it to match 0 hosts.I think what is happening is that
filters
is the initial filter that is being applied and theninclude_filters
are being applied to that set of matching hosts. If you don't specify ANYfilters
then it's equivalent toTrue
as the initial filter. Then, wheninclude_filters
gets applied you get something likeTrue || include_filter_1 || include_filter_2
. Effectively, theinclude_filters
become a NOOP iffilters
is not specified. I confirmed this suspicion with somepdb
in the code.https://github.com/ansible-collections/amazon.aws/blob/5876c14510420af190b309365a0843008696b602/plugins/inventory/aws_ec2.py#L712
include_filters = [self.get_option('filters')] + self.get_option('include_filters')
<-- in my debugging this is[{}, {'key-name': 'jenkins'}]
. Notice the first{}
, when the filter list is passed toansible_dict_to_boto3_filter_list(filter)
the empty dict is equivalent toTrue
.https://github.com/ansible-collections/amazon.aws/pull/456 I have a potential fix here, but I feel like it may not take into account the
exclude_filters
feature.Issue Type
Bug Report
Component Name
aws_ec2
Ansible Version
Collection Versions
AWS SDK versions
Configuration
OS / Environment
CentOS Linux release 8.4.2105
Steps to Reproduce
ansible-inventory -i aws_ec2.yml --list
filters:
feature.include_filters
does NOT match anything in your EC2 infrastructure.Expected Results
I expected 0 hosts to be returned because I assumed that at least 1 filter in the
include_filters
list had to match.Actual Results
Code of Conduct