Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws_ec2 inventory plugin - Filters does not support AND logic of multiple tag-key values #1354

Open
1 task done
viv-dev opened this issue Feb 9, 2023 · 1 comment · May be fixed by #1365
Open
1 task done

aws_ec2 inventory plugin - Filters does not support AND logic of multiple tag-key values #1354

viv-dev opened this issue Feb 9, 2023 · 1 comment · May be fixed by #1365
Assignees
Labels
feature This issue/PR relates to a feature request has_pr

Comments

@viv-dev
Copy link

viv-dev commented Feb 9, 2023

Summary

It seems that there is no way to query ec2 instances via multiple tag-key filters that have AND logic since filters is a dict and include_filters treats all variations as OR conditions.

Issue Type

Bug Report

Component Name

amazon.aws.aws_ec2

Ansible Version

ansible [core 2.14.2]

Collection Versions

Collection Version
---------- -------
amazon.aws 5.1.0  

AWS SDK versions

Name: boto3
Version: 1.26.60

Name: botocore
Version: 1.29.60

Configuration

No response

OS / Environment

No response

Steps to Reproduce

plugin: amazon.aws.aws_ec2

hostnames:
  - tag:Name

filters:
  # Applies as OR logic
  # Because filters is a dict can't specify multiple separate tag-key filters
  tag-key:
    - Role
    - Team
plugin: amazon.aws.aws_ec2

hostnames:
  - tag:Name

include_filters:
  # Applies as OR logic
  - tag-key: Role
  - tag-key: Team
plugin: amazon.aws.aws_ec2

hostnames:
  - tag:Name

include_filters:
  # Also applies as OR logic
  - tag-key: 
      - Role
      - Team

Expected Results

That there is a way to apply AND logic for multiple tag keys as per the aws command below:

aws ec2 describe-instances --filter Name=tag-key,Values=Role Name=tag-key,Values=Team

This is in line with the AWS documentation which says that multiple filters with the same name are treated with the AND condition:

https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instances.html#options

Actual Results

Both the filters version and include_filters return instances that have either the tag Role defined or Team defined, but not explicitly the ones that only have both.

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibullbot
Copy link

Files identified in the description:
None

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot ansibullbot added bug This issue/PR relates to a bug needs_triage labels Feb 9, 2023
@tremble tremble changed the title Filters does not support AND logic of multiple tag-key values aws_ec2 inventory plugin - Filters does not support AND logic of multiple tag-key values Feb 9, 2023
@tremble tremble added the feature This issue/PR relates to a feature request label Feb 9, 2023
@abikouo abikouo removed the bug This issue/PR relates to a bug label Feb 10, 2023
@abikouo abikouo self-assigned this Feb 10, 2023
@abikouo abikouo linked a pull request Feb 13, 2023 that will close this issue
abikouo pushed a commit to abikouo/amazon.aws that referenced this issue Sep 18, 2023
…l_response_codes is set (ansible-collections#1354)

elb_target_group make health_check_protocol required if health_check_path or successful_response_codes is set

fixes: ansible-collections#29
SUMMARY
health_check_path and successful_response_codes were previously silently dropped on the floor if health_check_protocol wasn't set.
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
elb_target_group
ADDITIONAL INFORMATION

Reviewed-by: Alina Buzachis <None>
abikouo pushed a commit to abikouo/amazon.aws that referenced this issue Sep 18, 2023
…l_response_codes is set (ansible-collections#1354)

elb_target_group make health_check_protocol required if health_check_path or successful_response_codes is set

fixes: ansible-collections#29
SUMMARY
health_check_path and successful_response_codes were previously silently dropped on the floor if health_check_protocol wasn't set.
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
elb_target_group
ADDITIONAL INFORMATION

Reviewed-by: Alina Buzachis <None>
abikouo pushed a commit to abikouo/amazon.aws that referenced this issue Oct 24, 2023
…l_response_codes is set (ansible-collections#1354)

elb_target_group make health_check_protocol required if health_check_path or successful_response_codes is set

fixes: ansible-collections#29
SUMMARY
health_check_path and successful_response_codes were previously silently dropped on the floor if health_check_protocol wasn't set.
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
elb_target_group
ADDITIONAL INFORMATION

Reviewed-by: Alina Buzachis <None>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This issue/PR relates to a feature request has_pr
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants