ansible-collections / amazon.aws

Ansible Collection for Amazon AWS
GNU General Public License v3.0
304 stars 332 forks source link

EC2 Dynamic Inventory Issue for AWX #2225

Open mxs-weixiong opened 3 weeks ago

mxs-weixiong commented 3 weeks ago

Summary`

Suddently ec2 dynamic inventory plugin not working. I not sure why as there is no config changes

Issue Type

Bug Report

Component Name

aws_ec2

Ansible Version

ansible-inventory [core 2.15.12]

Collection Versions

none

AWS SDK versions

none

Configuration

---
assume_role_arn: arn:aws:iam::xxxx:role/MXS-Ansible-Cross-Account-Role
hostnames:
  - name: 'private-ip-address'
keyed_groups:
  - key: tags.environment
    separator: ""
  - key: platform_details
    separator: ""
  - key: state.name
    separator: ""
compose:
 ansible_host: private_ip_address

OS / Environment

No response

Steps to Reproduce

Just trying to sync the inventory with ec2

Expected Results

Able to get the list of ec2 instance

Actual Results

ansible-inventory [core 2.15.12]
  config file = None
  configured module search path = ['/runner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/site-packages/ansible
  ansible collection location = /runner/.ansible/collections:/usr/share/ansible/collections:/usr/share/automation-controller/collections
  executable location = /usr/local/bin/ansible-inventory
  python version = 3.9.19 (main, Jun 11 2024, 00:00:00) [GCC 11.4.1 20231218 (Red Hat 11.4.1-3)] (/usr/bin/python3)
  jinja version = 3.1.4
  libyaml = True
No config file found; using defaults
redirecting (type: inventory) ansible.builtin.aws_ec2 to amazon.aws.aws_ec2
Using inventory plugin 'ansible_collections.amazon.aws.plugins.inventory.aws_ec2' to process inventory source '/runner/inventory/aws_ec2.yml'
[WARNING]:  * Failed to parse /runner/inventory/aws_ec2.yml with auto plugin:
Failed to describe instances: An error occurred (AuthFailure) when calling the
DescribeInstances operation: AWS was not able to validate the provided access
credentials
  File "/usr/local/lib/python3.9/site-packages/ansible/inventory/manager.py", line 293, in parse_source
    plugin.parse(self._inventory, self._loader, source, cache=cache)
  File "/usr/local/lib/python3.9/site-packages/ansible/plugins/inventory/auto.py", line 59, in parse
    plugin.parse(inventory, loader, path, cache=cache)
  File "/usr/share/ansible/collections/ansible_collections/amazon/aws/plugins/inventory/aws_ec2.py", line 816, in parse
    results = self._query(regions, include_filters, exclude_filters, strict_permissions, use_ssm_inventory)
  File "/usr/share/ansible/collections/ansible_collections/amazon/aws/plugins/inventory/aws_ec2.py", line 644, in _query
    for i in self._get_instances_by_region(
  File "/usr/share/ansible/collections/ansible_collections/amazon/aws/plugins/inventory/aws_ec2.py", line 547, in _get_instances_by_region
    self.fail_aws("Failed to describe instances", exception=e)
  File "/usr/share/ansible/collections/ansible_collections/amazon/aws/plugins/plugin_utils/base.py", line 35, in fail_aws
    self._do_fail(f"{message}: {to_native(exception)}")
  File "/usr/share/ansible/collections/ansible_collections/amazon/aws/plugins/plugin_utils/base.py", line 28, in _do_fail
    raise AnsibleError(message)
[WARNING]: Unable to parse /runner/inventory/aws_ec2.yml as an inventory source
ERROR! No inventory was parsed, please check your configuration and options.

Code of Conduct

abikouo commented 1 week ago

@mxs-weixiong this seems not related to the inventory plugin

Failed to describe instances: An error occurred (AuthFailure) when calling the
DescribeInstances operation: AWS was not able to validate the provided access

could you please check your credentials? Validate that they have not expired or been revoked?