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

ec2 inventory plugin does not work without region or regions field #1551

Closed
1 task done
Zokormazo opened this issue May 16, 2023 · 4 comments · Fixed by #1552
Closed
1 task done

ec2 inventory plugin does not work without region or regions field #1551

Zokormazo opened this issue May 16, 2023 · 4 comments · Fixed by #1552
Labels
bug This issue/PR relates to a bug

Comments

@Zokormazo
Copy link

Zokormazo commented May 16, 2023

Summary

According to https://docs.ansible.com/ansible/latest/collections/amazon/aws/aws_ec2_inventory.html ec2 inventory plugin should retrieve nodes from all the regions except the restricted ones (eg gov ones) if you don't specify regions. region key is not documented there.

but starting 6.0 this does not work anymore.

Similar to the old ansible/ansible#45288 a

Issue Type

Bug Report

Component Name

ec2_inventory

Ansible Version

$  ansible --version
ansible [core 2.15.0rc2.post0]

Collection Versions

$ ansible-galaxy collection list

Collection                  Version
--------------------------- -------
amazon.aws                  6.0.0 

AWS SDK versions

$ # pip3 show boto boto3 botocore
WARNING: Package(s) not found: boto
Name: boto3
Version: 1.24.95
Summary: The AWS SDK for Python
Home-page: https://github.com/boto/boto3
Author: Amazon Web Services
Author-email: None
License: Apache License 2.0
Location: /usr/local/lib/python3.9/site-packages
Requires: jmespath, botocore, s3transfer
Required-by: 
---
Name: botocore
Version: 1.27.95
Summary: Low-level, data-driven core of boto 3.
Home-page: https://github.com/boto/botocore
Author: Amazon Web Services
Author-email: None
License: Apache License 2.0
Location: /usr/local/lib/python3.9/site-packages
Requires: jmespath, python-dateutil, urllib3
Required-by: s3transfer, boto3

Configuration

$ ansible-config dump --only-changed
CONFIG_FILE() = /etc/ansible/ansible.cfg

OS / Environment

ubi8 based execution environment

Steps to Reproduce

plugin: amazon.aws.aws_ec2
#regions:
#  - us-east-1
# region: us-east-1

Expected Results

Inventories plugin works against all unrestricted regions

Actual Results

Inventory plugin fails because of lack of regions

* Failed to parse /runner/inventory/aws_ec2.yml with auto plugin:
The amazon.aws.aws_ec2 plugin requires a region and none was found in
configuration, environment variables or module parameters

Code of Conduct

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

tremble commented May 16, 2023

@Zokormazo,

Thanks for taking the time to open this issue.

It's actually asking for region not regions. I suspect that it's failing to find a default region to use to connect to the EC2 endpoint and grab a list of regions. Could you try setting region (pick any region) and see if it still queries the right regions for you?

@Zokormazo
Copy link
Author

@tremble
Checked, and the ec2 plugin works specifying a region.

But this does not invalidate the behaviour change. With 5.1.0 , going without region or regions works. With 6.0 does not

@Zokormazo Zokormazo changed the title ec2 inventory plugin does not work without regions field ec2 inventory plugin does not work without region or regions field May 16, 2023
@tremble
Copy link
Contributor

tremble commented May 16, 2023

@Zokormazo,

Thanks, that confirms the issue is where I thought it was and gives us a work around if necessary. Hopefully, #1552 will properly fix the issue.

@Zokormazo
Copy link
Author

Thanks for the fast turnaround !

@gravesm gravesm added bug This issue/PR relates to a bug and removed needs_triage labels May 16, 2023
softwarefactory-project-zuul bot pushed a commit that referenced this issue May 17, 2023
…ing to pull a list of regions (#1552)

inventory plugins - Hard code fall-back region to connect to when trying to pull a list of regions

SUMMARY
fixes: #1551
If no regions and no region is provided, then botocore will sometimes refuse to connect to the EC2 endpoint for us to then pull a list of regions...
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
aws_ec2 inventory plugin
ADDITIONAL INFORMATION
Nominally botocore should be falling back to a default region, but there are no guarantees

Reviewed-by: Alina Buzachis
patchback bot pushed a commit that referenced this issue May 17, 2023
…ing to pull a list of regions (#1552)

inventory plugins - Hard code fall-back region to connect to when trying to pull a list of regions

SUMMARY
fixes: #1551
If no regions and no region is provided, then botocore will sometimes refuse to connect to the EC2 endpoint for us to then pull a list of regions...
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
aws_ec2 inventory plugin
ADDITIONAL INFORMATION
Nominally botocore should be falling back to a default region, but there are no guarantees

Reviewed-by: Alina Buzachis
(cherry picked from commit c992070)
softwarefactory-project-zuul bot pushed a commit that referenced this issue May 17, 2023
…ing to pull a list of regions (#1552) (#1556)

[PR #1552/c9920701 backport][stable-6] inventory plugins - Hard code fall-back region to connect to when trying to pull a list of regions

This is a backport of PR #1552 as merged into main (c992070).
SUMMARY
fixes: #1551
If no regions and no region is provided, then botocore will sometimes refuse to connect to the EC2 endpoint for us to then pull a list of regions...
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
aws_ec2 inventory plugin
ADDITIONAL INFORMATION
Nominally botocore should be falling back to a default region, but there are no guarantees

Reviewed-by: Mark Chappell
abikouo pushed a commit to abikouo/amazon.aws that referenced this issue Sep 18, 2023
…llections#1551)

ecs_ecr - Use compare_policies instead of naive dict sort

Depends-On: ansible-collections#1550
SUMMARY
When comparing policies on the repos ecs_ecr currently uses a very naive sort function.  Since we have something more comprehensive, use it.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
plugins/modules/ecs_ecr.py
ADDITIONAL INFORMATION
ecs_ecr is currently the only module using sort_json_policy_dict and it has poor test coverage.

Reviewed-by: Markus Bergholz <[email protected]>
abikouo pushed a commit to abikouo/amazon.aws that referenced this issue Sep 18, 2023
…llections#1551)

ecs_ecr - Use compare_policies instead of naive dict sort

Depends-On: ansible-collections#1550
SUMMARY
When comparing policies on the repos ecs_ecr currently uses a very naive sort function.  Since we have something more comprehensive, use it.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
plugins/modules/ecs_ecr.py
ADDITIONAL INFORMATION
ecs_ecr is currently the only module using sort_json_policy_dict and it has poor test coverage.

Reviewed-by: Markus Bergholz <[email protected]>
abikouo pushed a commit to abikouo/amazon.aws that referenced this issue Oct 24, 2023
…llections#1551)

ecs_ecr - Use compare_policies instead of naive dict sort

Depends-On: ansible-collections#1550
SUMMARY
When comparing policies on the repos ecs_ecr currently uses a very naive sort function.  Since we have something more comprehensive, use it.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
plugins/modules/ecs_ecr.py
ADDITIONAL INFORMATION
ecs_ecr is currently the only module using sort_json_policy_dict and it has poor test coverage.

Reviewed-by: Markus Bergholz <[email protected]>
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
Projects
None yet
3 participants