Skip to content

ec2_metadata_facts returns "AttributeError: 'int' object has no attribute 'items'" #1134

@isuftin

Description

@isuftin

Summary

When calling amazon.aws.ec2_metadata_facts against a remote RHEL 8 instance, I get the error AttributeError: 'int' object has no attribute 'items'

Issue Type

Bug Report

Component Name

ec2_metadata_facts

Ansible Version

ansible [core 2.13.4]
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.9.14 (main, Sep 22 2022, 14:32:21) [GCC 11.2.1 20220219]
  jinja version = 3.1.2
  libyaml = False

Collection Versions

$ ansible-galaxy collection list

Collection    Version
------------- -------
amazon.aws    5.0.1  
ansible.posix 1.4.0  

AWS SDK versions

$ pip show boto boto3 botocore
Name: boto
Version: 2.49.0
Summary: Amazon Web Services Library
Home-page: https://github.com/boto/boto/
Author: Mitch Garnaat
Author-email: [email protected]
License: MIT
Location: /usr/local/lib/python3.9/site-packages
Requires:
Required-by:
---
Name: boto3
Version: 1.24.88
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: /usr/local/lib/python3.9/site-packages
Requires: botocore, jmespath, s3transfer
Required-by:
---
Name: botocore
Version: 1.27.88
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: /usr/local/lib/python3.9/site-packages
Requires: jmespath, python-dateutil, urllib3
Required-by: boto3, s3transfer

Configuration

$ ansible-config dump --only-changed
ANSIBLE_FORCE_COLOR(env: ANSIBLE_FORCE_COLOR) = True

OS / Environment

Target OS: RHEL 8 EC2 instance

Steps to Reproduce

This is being run as part of an overall molecule playbook. I'm not sure the best way to get a decent reproduction case here.

- hosts: all
  tasks:
    - name: Test
      amazon.aws.ec2_metadata_facts:

Expected Results

No error

Actual Results

fatal: [aws-ctek-rhel8-ec2-rundeck-5]: FAILED! => changed=false 
  module_stderr: |-
    OpenSSH_9.0p1, OpenSSL 1.1.1q  5 Jul 2022
    debug1: Reading configuration data /etc/ssh/ssh_config
    debug2: resolve_canonicalize: hostname internal.aws.ip is address
    debug1: auto-mux: Trying existing master
    debug2: fd 3 setting O_NONBLOCK
    debug2: mux_client_hello_exchange: master version 4
    debug3: mux_client_forwards: request forwardings: 0 local, 0 remote
    debug3: mux_client_request_session: entering
    debug3: mux_client_request_alive: entering
    debug3: mux_client_request_alive: done pid = 319
    debug3: mux_client_request_session: session request sent
    debug1: mux_client_request_session: master session id: 2
    /tmp/ansible_amazon.aws.ec2_metadata_facts_payload_ydfpudq4/ansible_amazon.aws.ec2_metadata_facts_payload.zip/ansible/module_utils/urls.py:176: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography and will be removed in a future release.
    Traceback (most recent call last):
      File "<stdin>", line 107, in <module>
      File "<stdin>", line 99, in _ansiballz_main
      File "<stdin>", line 48, in invoke_module
      File "/usr/lib64/python3.6/runpy.py", line 205, in run_module
        return _run_module_code(code, init_globals, run_name, mod_spec)
      File "/usr/lib64/python3.6/runpy.py", line 96, in _run_module_code
        mod_name, mod_spec, pkg_name, script_name)
      File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
        exec(code, run_globals)
      File "/tmp/ansible_amazon.aws.ec2_metadata_facts_payload_ydfpudq4/ansible_amazon.aws.ec2_metadata_facts_payload.zip/ansible_collections/amazon/aws/plugins/modules/ec2_metadata_facts.py", line 598, in <module>
      File "/tmp/ansible_amazon.aws.ec2_metadata_facts_payload_ydfpudq4/ansible_amazon.aws.ec2_metadata_facts_payload.zip/ansible_collections/amazon/aws/plugins/modules/ec2_metadata_facts.py", line 591, in main
      File "/tmp/ansible_amazon.aws.ec2_metadata_facts_payload_ydfpudq4/ansible_amazon.aws.ec2_metadata_facts_payload.zip/ansible_collections/amazon/aws/plugins/modules/ec2_metadata_facts.py", line 568, in run
      File "/tmp/ansible_amazon.aws.ec2_metadata_facts_payload_ydfpudq4/ansible_amazon.aws.ec2_metadata_facts_payload.zip/ansible_collections/amazon/aws/plugins/modules/ec2_metadata_facts.py", line 529, in fetch
    AttributeError: 'int' object has no attribute 'items'
    debug3: mux_client_read_packet: read header failed: Broken pipe
    debug2: Received exit status from master 1
  module_stdout: ''
  msg: |-
    MODULE FAILURE
    See stdout/stderr for the exact error
  rc: 1

Code of Conduct

  • I agree to follow the Ansible Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions