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

Include and exclude filters not being honored. #452

Closed
1 task done
dswan2 opened this issue Aug 10, 2021 · 1 comment · Fixed by #456
Closed
1 task done

Include and exclude filters not being honored. #452

dswan2 opened this issue Aug 10, 2021 · 1 comment · Fixed by #456
Labels
bug This issue/PR relates to a bug inventory inventory plugin jira needs_verified Some one might want to take a look at this and reproduce it to confirm plugins plugin (any type) python3

Comments

@dswan2
Copy link

dswan2 commented Aug 10, 2021

Summary

When I attempt to generate a yaml inventory file using the dynamic inventory, I am still catching a lot of hosts that should be filtered out.

My dynamic inventory:

aws ec2 ansible dynamic inventory plugin

#plugin: aws_ec2
plugin: amazon.aws.aws_ec2
aws_profile: acme-prod
regions:

  • us-east-1
  • eu-west-1

include_filters:

  • instance-state-name: running
  • tag:Stack:
    • 'preprod'
    • 'acme-preprod'
    • 'acme-preprod'

exclude_filters:

  • tag:Component:
    • 'windows_client_service'

Command line:
ansible-inventory -i preprod_aws_ec2.yaml --list -y > /var/tmp/preprod_aws_ec2.yaml

Validation (Failed. Should not contain Component: windows-client-service):

dynamic_inventory $ grep windows /var/tmp/preprod_aws_ec2.yaml |grep Component
Component: windows-client-service
Component: windows-client-service

Issue Type

Bug Report

Component Name

aws_ec2

Ansible Version

ansible [core 2.11.3]
  config file = /Users/dswan2/..../dynamic_inventory/ansible.cfg
  configured module search path = ['/Users/dswan2/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/Cellar/ansible/4.3.0/libexec/lib/python3.9/site-packages/ansible
  ansible collection location = /Users/dswan2/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.9.6 (default, Jun 29 2021, 05:25:02) [Clang 12.0.5 (clang-1205.0.22.9)]
  jinja version = 3.0.1
  libyaml = True
dswan2@localhost dynamic_inventory $

Collection Versions

amazon.aws       1.5.0
amazon.aws                    1.5.0
community.aws                 1.5.0
netapp.aws                    21.6.0

AWS SDK versions

-bash: pip: command not found
 dynamic_inventory $ python3 -m pip show boto boto3 botocore
WARNING: Package(s) not found: boto
Name: boto3
Version: 1.18.10
Summary: The AWS SDK for Python
Home-page: https://github.com/boto/boto3
Author: Amazon Web Services
Author-email:
License: Apache License 2.0
Location: /Users/daniel.swan/Library/Python/3.9/lib/python/site-packages
Requires: botocore, jmespath, s3transfer
Required-by:
---
Name: botocore
Version: 1.21.10
Summary: Low-level, data-driven core of boto 3.
Home-page: https://github.com/boto/botocore
Author: Amazon Web Services
Author-email:
License: Apache License 2.0
Location: /Users/daniel.swan/Library/Python/3.9/lib/python/site-packages
Requires: python-dateutil, jmespath, urllib3
Required-by: s3transfer, boto3

Configuration

ANSIBLE_PIPELINING(...Redacted....Dynamic2Centralized_Inventory/dynamic_inventory/ansible.cfg) = True
DEFAULT_FORKS(...Redacted....Dynamic2Centralized_Inventory/dynamic_inventory/ansible.cfg) = 1000
DEFAULT_LOG_PATH(...Redacted....Dynamic2Centralized_Inventory/dynamic_inventory/ansible.cfg) = /var/log/ansible
DEFAULT_ROLES_PATH(...Redacted....Dynamic2Centralized_Inventory/dynamic_inventory/ansible.cfg) = ...redacted...
DEPRECATION_WARNINGS(...Redacted...Dynamic2Centralized_Inventory/dynamic_inventory/ansible.cfg) = False
HOST_KEY_CHECKING(...redacted...]Dynamic2Centralized_Inventory/dynamic_inventory/ansible.cfg) = False

OS / Environment

OSX Big Sur
Darwin Kernel Version 20.5.0: Sat May 8 05:10:33 PDT 2021; root:xnu-7195.121.3~9/RELEASE_X86_64 x86_64

Steps to Reproduce


Expected Results

I expect the putput to not contain any nodes where Component: windows-client-service

Actual Results

            Component: windows-client-service
            Component: windows-client-service

Code of Conduct

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

Files identified in the description:

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 inventory inventory plugin needs_triage plugins plugin (any type) python3 labels Aug 10, 2021
@goneri goneri added needs_verified Some one might want to take a look at this and reproduce it to confirm jira and removed needs_triage labels Aug 24, 2021
ansible-zuul bot pushed a commit that referenced this issue Aug 31, 2021
do not include {} boto filter by default

Depends-On: #480

When no filter: specified, do not include an empty dict in the list of
boto filters because it effectively matches any host.

Closes: #457
Closes: #452
ISSUE TYPE

Bugfix Pull Request

Reviewed-by: Mark Chappell <None>
Reviewed-by: Alina Buzachis <None>
Reviewed-by: None <None>
abikouo pushed a commit to abikouo/amazon.aws that referenced this issue Oct 24, 2023
…ec-docs-fix-indent

docs: Fix indentation in aws_config_recorder example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug inventory inventory plugin jira needs_verified Some one might want to take a look at this and reproduce it to confirm plugins plugin (any type) python3
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants