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: add includes_filters and excludes_filters #328

Conversation

goneri
Copy link
Member

@goneri goneri commented Apr 13, 2021

Expose a new include_filters and exclude_filters configuration keys that gives the user the ability to compose the final inventory list with several queries.

Closes: #248
Closes: #182

@goneri goneri changed the title aws_ec2 inventory: add includes_entries_matching keys [WIP] aws_ec2 inventory: add includes_entries_matching keys Apr 13, 2021
@ansibullbot ansibullbot added community_review integration tests/integration inventory inventory plugin needs_triage plugins plugin (any type) tests tests labels Apr 13, 2021
@goneri goneri force-pushed the aws_ec2-inventory-add-includes_entries_matching-keys_10818 branch 2 times, most recently from f50ce90 to 43c6596 Compare April 13, 2021 17:35
@ansibullbot ansibullbot added the WIP Work in progress label Apr 13, 2021
@goneri goneri changed the title [WIP] aws_ec2 inventory: add includes_entries_matching keys aws_ec2 inventory: add includes_entries_matching keys Apr 13, 2021
@ansibullbot ansibullbot added has_issue and removed WIP Work in progress labels Apr 13, 2021
@goneri goneri removed the has_issue label Apr 13, 2021
@goneri goneri requested a review from jillr April 13, 2021 18:06
@goneri goneri force-pushed the aws_ec2-inventory-add-includes_entries_matching-keys_10818 branch from 43c6596 to 09c7ccb Compare April 13, 2021 18:11
@goneri goneri requested a review from tremble April 13, 2021 19:05
@goneri
Copy link
Member Author

goneri commented Apr 13, 2021

Feedback on IRC (Cc: @flowerysong @tadeboro).

[15:06] <goneri> Feedback on https://github.com/ansible-collections/amazon.aws/pull/328 welcome.
[15:37] <flowerysong> goneri: I still think the correct interface for this is for filters: to accept a list, as discussed in https://github.com/ansible/ansible/pull/58132
[15:38] <flowerysong> goneri: Something like https://github.com/flowerysong/ansible-amazon.aws/commit/6546a299
[15:41] <tadeboro> I must agree with flowerysong here. Introducting yet another option that just adds hosts to existing filter result feels awkward.
[16:25] <goneri> I would also add an excludes_entries_matching for this one https://github.com/ansible-collections/amazon.aws/issues/182
[16:26] <goneri> in this case the two options would make sense. I don't really like when the behaviour of an option changes because of the type.
[16:26] <goneri> This leads to confusion.

@flowerysong
Copy link
Contributor

Having multiple options that do the same thing leads to even more confusion. If you really think that it's confusing, you can deprecate the old way of passing filters and require that the user specify a list.

@goneri
Copy link
Member Author

goneri commented Apr 13, 2021

[16:30] <tadeboro> For ServiceNow, we implemented https://github.com/ansible-collections/servicenow.itsm/blob/main/docs/servicenow.itsm.servicenow.itsm.now_inventory.rst#examples
[16:30] <goneri> I updated https://github.com/ansible-collections/amazon.aws/pull/328 with your comments
[16:30] <goneri> I guess it's better to continue there.
[16:30] <flowerysong> It doesn't change the behaviour, it just automatically wraps the dict in a list (similar to other options that accept lists.)
[16:30] <tadeboro> We allow users to specify the inclusion and exclusion criteria.
[16:31] <goneri> flowerysong: in one case we've got a OR and another one a AND.
[16:33] <goneri> tadeboro: interesting. I see the includes/excludes keys as a similarity, am I right?.
[16:34] <tadeboro> If you want to also introduce an exclusion criteria, then deprecating the filter and replacing it with something else maybe makes the most sense? Something like `include_filters` and `exclude_filters` maybe?
[16:35] <tadeboro> In ServiceNow's case, we structured things a bit dfferently because we combine inclusions and exclusion into a single query and then just partition the returned hosts.
[16:35] <goneri> Yes! I agree, includes_entries_matching is pretty lame :-)
[16:36] <goneri> Yes, I understand. With AWS, we need to do one request per filter, it's a bit more complicated.
[16:37] <goneri> I suggest to refresh my PR with your name suggestion: include_filters and exclude_filters. Would this work for you?
[16:38] <tadeboro> It would be a bit strange if I sad no after I suggested the names ;)
[16:38] <goneri> Great, I will push a PR tomorrow. Thanks flowerysong and tadeboro.

@goneri
Copy link
Member Author

goneri commented Apr 13, 2021

Having multiple options that do the same thing leads to even more confusion. If you really think that it's confusing, you can deprecate the old way of passing filters and require that the user specify a list.

I don't think we need to deprecate the current filters and force the users to adjust their configurations. These two news include_filters and exclude_filters would only accept list.

@goneri goneri changed the title aws_ec2 inventory: add includes_entries_matching keys WIP aws_ec2 inventory: add includes_filters and excludes_filters Apr 13, 2021
@ansibullbot ansibullbot added the WIP Work in progress label Apr 13, 2021
plugins/inventory/aws_ec2.py Outdated Show resolved Hide resolved
plugins/inventory/aws_ec2.py Outdated Show resolved Hide resolved
plugins/inventory/aws_ec2.py Show resolved Hide resolved
Comment on lines 41 to 43
# generate inventory config with includes_entries_matching and prepare the tests
ansible-playbook playbooks/create_inventory_config.yml -e "template='inventory_with_includes_entries_matching.yml.j2'" "$@"
ansible-playbook playbooks/test_populating_inventory_with_includes_entries_matching.yml "$@"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the template and playbook are missing.

I'm not sure why, but it looks like the integration tests didn't fire properly

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 indeed.

@goneri goneri force-pushed the aws_ec2-inventory-add-includes_entries_matching-keys_10818 branch from 09c7ccb to e4195a7 Compare April 14, 2021 13:21
@goneri goneri changed the title WIP aws_ec2 inventory: add includes_filters and excludes_filters aws_ec2 inventory: add includes_filters and excludes_filters Apr 14, 2021
@goneri goneri requested review from tremble and tadeboro April 14, 2021 22:57
@ansibullbot ansibullbot removed the WIP Work in progress label Apr 14, 2021
@tremble
Copy link
Contributor

tremble commented Apr 15, 2021

Mostly looks good, primarily nit-picking at this point.

Expose a new `include_filters` and `exclude_filters` configuration keys
that gives the user the ability to compose the final inventory list with
several queries.

Closes: ansible-collections#248
Closes: ansible-collections#182
@goneri goneri force-pushed the aws_ec2-inventory-add-includes_entries_matching-keys_10818 branch from ee066ca to 79d8840 Compare April 15, 2021 16:40
@jillr
Copy link
Collaborator

jillr commented Apr 16, 2021

Thanks very much @goneri, this looks good. Can you please work with the Tower team to schedule this with QE?

@goneri goneri added the gate label Apr 22, 2021
@ansible-zuul ansible-zuul bot merged commit dad4f88 into ansible-collections:main Apr 22, 2021
softwarefactory-project-zuul bot pushed a commit that referenced this pull request Jun 7, 2022
…_contrib_script_compatible_ec2_tag_keys (#858)

Add version_added: 1.5.0 for exclude_filters, include_filters and use_contrib_script_compatible_ec2_tag_keys

SUMMARY

Add version_added: 1.5.0 for exclude_filters, include_filters and use_contrib_script_compatible_ec2_tag_keys
include_filters and exclude_filters have been added #328 and released with amazon.aws 1.5.0
use_contrib_script_compatible_ec2_tag_keys has been added #331 and released with  amazon.aws 1.5.0
Let's update the aws_ec2 inventory plugin documentation with this information.
This should be a step towards closing this one #676 and #675
aws_ec2 documentation will be enriched with exhaustive examples in an upcoming PR.

ISSUE TYPE


Docs Pull Request

COMPONENT NAME

aws_ec2
ADDITIONAL INFORMATION

Reviewed-by: Mark Chappell <None>
patchback bot pushed a commit that referenced this pull request Jun 7, 2022
…_contrib_script_compatible_ec2_tag_keys (#858)

Add version_added: 1.5.0 for exclude_filters, include_filters and use_contrib_script_compatible_ec2_tag_keys

SUMMARY

Add version_added: 1.5.0 for exclude_filters, include_filters and use_contrib_script_compatible_ec2_tag_keys
include_filters and exclude_filters have been added #328 and released with amazon.aws 1.5.0
use_contrib_script_compatible_ec2_tag_keys has been added #331 and released with  amazon.aws 1.5.0
Let's update the aws_ec2 inventory plugin documentation with this information.
This should be a step towards closing this one #676 and #675
aws_ec2 documentation will be enriched with exhaustive examples in an upcoming PR.

ISSUE TYPE

Docs Pull Request

COMPONENT NAME

aws_ec2
ADDITIONAL INFORMATION

Reviewed-by: Mark Chappell <None>
(cherry picked from commit 5f05853)
softwarefactory-project-zuul bot pushed a commit that referenced this pull request Jun 7, 2022
…_contrib_script_compatible_ec2_tag_keys (#858) (#868)

[PR #858/5f058532 backport][stable-3] Add version_added: 1.5.0 for exclude_filters, include_filters and use_contrib_script_compatible_ec2_tag_keys

This is a backport of PR #858 as merged into main (5f05853).
SUMMARY

Add version_added: 1.5.0 for exclude_filters, include_filters and use_contrib_script_compatible_ec2_tag_keys
include_filters and exclude_filters have been added #328 and released with amazon.aws 1.5.0
use_contrib_script_compatible_ec2_tag_keys has been added #331 and released with  amazon.aws 1.5.0
Let's update the aws_ec2 inventory plugin documentation with this information.
This should be a step towards closing this one #676 and #675
aws_ec2 documentation will be enriched with exhaustive examples in an upcoming PR.

ISSUE TYPE


Docs Pull Request

COMPONENT NAME

aws_ec2
ADDITIONAL INFORMATION
jatorcasso pushed a commit to jatorcasso/amazon.aws that referenced this pull request Jun 27, 2022
…_contrib_script_compatible_ec2_tag_keys (ansible-collections#858)

Add version_added: 1.5.0 for exclude_filters, include_filters and use_contrib_script_compatible_ec2_tag_keys

SUMMARY

Add version_added: 1.5.0 for exclude_filters, include_filters and use_contrib_script_compatible_ec2_tag_keys
include_filters and exclude_filters have been added ansible-collections#328 and released with amazon.aws 1.5.0
use_contrib_script_compatible_ec2_tag_keys has been added ansible-collections#331 and released with  amazon.aws 1.5.0
Let's update the aws_ec2 inventory plugin documentation with this information.
This should be a step towards closing this one ansible-collections#676 and ansible-collections#675
aws_ec2 documentation will be enriched with exhaustive examples in an upcoming PR.

ISSUE TYPE


Docs Pull Request

COMPONENT NAME

aws_ec2
ADDITIONAL INFORMATION

Reviewed-by: Mark Chappell <None>
alinabuzachis pushed a commit to alinabuzachis/amazon.aws that referenced this pull request Sep 16, 2022
…passed (ansible-collections#328)

* Fix ec2_eip with both instance_id and private_ip_address
* Add changelog fragment for the ec2_eip fix

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@4d1aa98
goneri pushed a commit to alinabuzachis/amazon.aws that referenced this pull request Sep 21, 2022
…passed (ansible-collections#328)

* Fix ec2_eip with both instance_id and private_ip_address
* Add changelog fragment for the ec2_eip fix

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@4d1aa98
abikouo pushed a commit to abikouo/amazon.aws that referenced this pull request Sep 18, 2023
…passed (ansible-collections#328)

* Fix ec2_eip with both instance_id and private_ip_address
* Add changelog fragment for the ec2_eip fix
abikouo pushed a commit to abikouo/amazon.aws that referenced this pull request Sep 18, 2023
…passed (ansible-collections#328)

* Fix ec2_eip with both instance_id and private_ip_address
* Add changelog fragment for the ec2_eip fix
abikouo pushed a commit to abikouo/amazon.aws that referenced this pull request Oct 24, 2023
…passed (ansible-collections#328)

* Fix ec2_eip with both instance_id and private_ip_address
* Add changelog fragment for the ec2_eip fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community_review integration tests/integration inventory inventory plugin plugins plugin (any type) tests tests
Projects
None yet
7 participants