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

[WIP] Add new filter options to ec2 inventory plugin #58132

Open
wants to merge 4 commits into
base: devel
from

Conversation

Projects
None yet
4 participants
@jillr
Copy link
Contributor

commented Jun 20, 2019

Add filter options to enable filter syntax and functionality similar to
the AND/OR filter types available to the contrib/inventory/ec2.py script.
A new key, filter_syntax, is added to toggle the new behaviour and a special
subkey to filters is recognized to handle additional filter types when used
with filter_syntax: ec2_ini.

SUMMARY

ec2.py inventory script supports AND/OR filters, the plugin currently only takes AND filters. This difference can impede migrating to the plugin.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

lib/ansible/plugins/inventory/aws_ec2.py

ADDITIONAL INFORMATION
# Example aws_ec2.yml
# Use ec2_ini AND/OR filters
# This filter in the script would have looked like:
# EC2_INSTANCE_FILTERS='availability-zone=us-west-2b,hypervisor=xen,availability-zone=us-east1b&instance-type=t2.micro'
plugin: aws_ec2
filter_syntax: ec2_ini   ## toggles filters being AND/OR type instead of default AND type
filters:
  availability-zone: us-west-2b  ## Will match us-west-2b OR
  hypervisor: xen  ## xen hypervisor OR
  ec2ini_filters: {availability-zone: us-east-1b, instance-type: t2.micro}  ## us-east-1b AND type t2.micro

[WIP] Add new filter options to ec2 inventory plugin
Add filter options to enable filter syntax and functionality similar to
the AND/OR filter types available to the contrib/inventory/ec2.py script.
A new key, filter_syntax, is added to toggle the new behaviour and a special
subkey to filters is recognized to handle additional filter types when used
with filter_syntax: ec2_ini.
@ansibot

This comment has been minimized.

Copy link
Contributor

commented Jun 20, 2019

The test ansible-test sanity --test ansible-doc --python 2.6 [explain] failed with 1 error:

lib/ansible/plugins/inventory/aws_ec2.py:0:0: missing documentation (or could not parse documentation): expected string or buffer

The test ansible-test sanity --test ansible-doc --python 2.7 [explain] failed with 1 error:

lib/ansible/plugins/inventory/aws_ec2.py:0:0: missing documentation (or could not parse documentation): expected string or buffer

The test ansible-test sanity --test ansible-doc --python 3.5 [explain] failed with 1 error:

lib/ansible/plugins/inventory/aws_ec2.py:0:0: missing documentation (or could not parse documentation): expected string or bytes-like object

The test ansible-test sanity --test ansible-doc --python 3.6 [explain] failed with 1 error:

lib/ansible/plugins/inventory/aws_ec2.py:0:0: missing documentation (or could not parse documentation): expected string or bytes-like object

The test ansible-test sanity --test ansible-doc --python 3.7 [explain] failed with 1 error:

lib/ansible/plugins/inventory/aws_ec2.py:0:0: missing documentation (or could not parse documentation): expected string or bytes-like object

The test ansible-test sanity --test ansible-doc --python 3.8 [explain] failed with 1 error:

lib/ansible/plugins/inventory/aws_ec2.py:0:0: missing documentation (or could not parse documentation): expected string or bytes-like object

The test ansible-test sanity --test pep8 [explain] failed with 2 errors:

lib/ansible/plugins/inventory/aws_ec2.py:49:111: W291 trailing whitespace
lib/ansible/plugins/inventory/aws_ec2.py:678:50: E127 continuation line over-indented for visual indent

click here for bot help

@flowerysong

This comment has been minimized.

Copy link
Contributor

commented Jun 20, 2019

I would suggest that a better interface is to allow passing a list of filters that is ORed, while each filter within a list item is ANDed.

filters:
  - availability-zone: us-west-2b
  - hypervisor: xen
  - availability-zone: us-east-1b
    instance-type: t2.micro

This is backwards compatible without a separate toggle, since it can be distinguished from the old syntax by checking whether filters is a list, and should be fairly easy to implement.

EDIT: Maybe something like https://gist.github.com/flowerysong/b59e9ad53f3d77173a1bddb30fe1803e

@jillr

This comment has been minimized.

Copy link
Contributor Author

commented Jun 24, 2019

@flowerysong I like it - would you like to PR that to this branch?

@ansibot ansibot removed the ci_verified label Jun 25, 2019

@ansibot

This comment has been minimized.

Copy link
Contributor

commented Jun 28, 2019

@ansibot

This comment has been minimized.

Copy link
Contributor

commented Jun 28, 2019

The test ansible-test sanity --test docs-build [explain] failed with 1 error:

docs/docsite/rst/porting_guides/porting_guide_2.9.rst:241:0: undefined-label: undefined label: guide_aws (if the link has no caption the label must precede a section header)

The test ansible-test sanity --test changelog [explain] failed with 1 error:

changelogs/fragments/58132-ec2-inventory-filters.yml:0:0: section "minor_changes" list items must be type str not dict

click here for bot help

@ansibot ansibot added the ci_verified label Jun 28, 2019

@ansibot ansibot removed the ci_verified label Jun 28, 2019

@ansibot

This comment has been minimized.

Copy link
Contributor

commented Jun 28, 2019

The test ansible-test sanity --test docs-build [explain] failed with 1 error:

docs/docsite/rst/porting_guides/porting_guide_2.9.rst:241:0: undefined-label: undefined label: guide_aws (if the link has no caption the label must precede a section header)

The test ansible-test sanity --test changelog [explain] failed with 1 error:

changelogs/fragments/58132-ec2-inventory-filters.yml:0:0: section "minor_changes" list items must be type str not dict

click here for bot help

@ansibot ansibot added the ci_verified label Jun 28, 2019

@bcoca bcoca removed the needs_triage label Jul 2, 2019

@ansibot ansibot added the stale_ci label Jul 10, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.