Error "future feature annotations is not defined" with Python on an AWS Ansible Playbook Execution

Hello. This is a fresh installation of Ansible on this LINUX server. I ma getting an error while I run a playbook that is supposed to get information about all the AWS RDS database instances. This server is able to run AWS CLI commands outside of Ansible, so the secrets and keys a re exported.

A test of a normal playbook that doesnt deal with AWS works fine. This playbook is supposed to create a new directory, and it does.

++++++++++++++++++/ETC/ANSIBLE/HOSTS+++++++++++++++++++++++++++++
[localhost]
#localhost ansible_connection=local ansible_python_interpreter=/usr/bin/python3
localhost ansible_host=localhost ansible_connection=local ansible_python_interpreter=/usr/bin/python3
[misoracle@ehsmg-mis-dba1 ansible]$
++++++++++++++++++++ANSIBLE.CFG++++++++++++++++++


[defaults]
#interpreter_python = /usr/bin/python3.12
interpreter_python = /usr/bin/python3

++++++++++++++++++OS PYTHON++++++++++++++++++++++++++++++++++++++++++++++++
[misoracle@ehsmg-mis-dba1 ansible]$ ansible --version | grep "python version"
  python version = 3.12.12 (main, Mar  3 2026, 05:34:06) [GCC 8.5.0 20210514 (Red Hat 8.5.0-28)] (/usr/bin/python3.12)
[misoracle@ehsmg-mis-dba1 ansible]$

++++++++++++++++++++++++++++++++++++ TEST PLAYBOOK TO CREATE A DIRECTORY WORKS FINE++++++++++++++++

[misoracle@ehsmg-mis-dba1 ansible]$ vi rds01.yml
---
- name: Gather and display AWS RDS instance information
  hosts: localhost
  connection: local
  gather_facts: false

  vars:
    ansible_python_interpreter: /usr/bin/python3

  tasks:

        - name: Recreate the Scratchpad | itsm_dcr
          ansible.builtin.file:
            path: /etc/ansible/deleteme_dir
            state: directory
            mode: "0755"

[misoracle@ehsmg-mis-dba1 ansible]$ ansible-playbook rds01.yml
[WARNING]: Found both group and host with same name: localhost

PLAY [Gather and display AWS RDS instance information] *******************************************************************************************************************************************************

TASK [Recreate the Scratchpad | itsm_dcr] ********************************************************************************************************************************************************************
changed: [localhost]

PLAY RECAP ***************************************************************************************************************************************************************************************************
localhost                  : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

[misoracle@ehsmg-mis-dba1 ansible]$ ls -ltr
total 16
drw-rw-r-- 2 misoracle misoracle    6 Feb  5  2024 roles
-rw-r--r-- 1 misoracle misoracle  666 Mar 24 14:37 ansible.cfg
-rw-rw-r-- 1 misoracle misoracle 1369 Mar 24 14:53 hosts
-rw-rw---- 1 misoracle misoracle 1046 Mar 24 14:57 rds_check.yml
-rw-rw---- 1 misoracle misoracle  411 Mar 24 15:04 rds01.yml
drwxr-xr-x 2 misoracle misoracle    6 Mar 24 15:04 deleteme_dir <=========================

But the playbook to get the AWS RDS info fails:

++++++++++++++++++++++ THE AWS PLAYBOOK FAILS+++++++++++++++++++++++++++++++

[misoracle@ehsmg-mis-dba1 ansible]$ more rds_check.yml
---
- name: Gather and display AWS RDS instance information
  hosts: localhost
  connection: local
  gather_facts: false

  vars:
    ansible_python_interpreter: /usr/bin/python3

  tasks:
    - name: Obtain information about all RDS instances
      amazon.aws.rds_instance_info:
      register: rds_instances_info
      # The module will return a list of dictionaries under the key 'instances'

    - name: Display details for each RDS instance
      ansible.builtin.debug:
        msg: |
          Instance ID: {{ item.db_instance_identifier }}
          Engine: {{ item.engine }}
          Status: {{ item.db_instance_status }}
          Endpoint Address: {{ item.endpoint.address }}
          Multi-AZ: {{ item.multi_az }}
      loop: "{{ rds_instances_info.instances }}"
      # Loop through the 'instances' list returned by the module

    - name: Display the full facts dictionary (optional)
      ansible.builtin.debug:
        var: rds_instances_info.instances
        # Use this to see all available data fields for a complete overview

The output:

[misoracle@ehsmg-mis-dba1 ansible]$ ansible-playbook rds_check.yml -vvv
ansible-playbook [core 2.16.3]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/misoracle/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.12/site-packages/ansible
  ansible collection location = /home/misoracle/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible-playbook
  python version = 3.12.12 (main, Mar  3 2026, 05:34:06) [GCC 8.5.0 20210514 (Red Hat 8.5.0-28)] (/usr/bin/python3.12)
  jinja version = 3.1.2
  libyaml = True
Using /etc/ansible/ansible.cfg as config file
host_list declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
script declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
auto declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Parsed /etc/ansible/hosts inventory source with ini plugin
[WARNING]: Found both group and host with same name: localhost
[WARNING]: Collection amazon.aws does not support Ansible version 2.16.3
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.

PLAYBOOK: rds_check.yml **************************************************************************************************************************************************************************************
1 plays in rds_check.yml

PLAY [Gather and display AWS RDS instance information] *******************************************************************************************************************************************************

TASK [Obtain information about all RDS instances] ************************************************************************************************************************************************************
task path: /etc/ansible/rds_check.yml:11
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: misoracle
<localhost> EXEC /bin/sh -c 'echo ~misoracle && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/misoracle/.ansible/tmp `"&& mkdir "` echo /home/misoracle/.ansible/tmp/ansible-tmp-1774379457.6232963-1227426-54449619609102 `" && echo ansible-tmp-1774379457.6232963-1227426-54449619609102="` echo /home/misoracle/.ansible/tmp/ansible-tmp-1774379457.6232963-1227426-54449619609102 `" ) && sleep 0'
Using module file /home/misoracle/.ansible/collections/ansible_collections/amazon/aws/plugins/modules/rds_instance_info.py
<localhost> PUT /home/misoracle/.ansible/tmp/ansible-local-1227423895st_5i/tmp_3svhil3 TO /home/misoracle/.ansible/tmp/ansible-tmp-1774379457.6232963-1227426-54449619609102/AnsiballZ_rds_instance_info.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/misoracle/.ansible/tmp/ansible-tmp-1774379457.6232963-1227426-54449619609102/ /home/misoracle/.ansible/tmp/ansible-tmp-1774379457.6232963-1227426-54449619609102/AnsiballZ_rds_instance_info.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python3 /home/misoracle/.ansible/tmp/ansible-tmp-1774379457.6232963-1227426-54449619609102/AnsiballZ_rds_instance_info.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/misoracle/.ansible/tmp/ansible-tmp-1774379457.6232963-1227426-54449619609102/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/home/misoracle/.ansible/tmp/ansible-tmp-1774379457.6232963-1227426-54449619609102/AnsiballZ_rds_instance_info.py", line 107, in <module>
    _ansiballz_main()
  File "/home/misoracle/.ansible/tmp/ansible-tmp-1774379457.6232963-1227426-54449619609102/AnsiballZ_rds_instance_info.py", line 99, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/misoracle/.ansible/tmp/ansible-tmp-1774379457.6232963-1227426-54449619609102/AnsiballZ_rds_instance_info.py", line 48, in invoke_module
    run_name='__main__', alter_sys=True)
  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 "/tmpsort/ansible_amazon.aws.rds_instance_info_payload_tws_o3ir/ansible_amazon.aws.rds_instance_info_payload.zip/ansible_collections/amazon/aws/plugins/modules/rds_instance_info.py", line 362, in <module>
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
  File "/tmpsort/ansible_amazon.aws.rds_instance_info_payload_tws_o3ir/ansible_amazon.aws.rds_instance_info_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/modules.py", line 56, in <module>
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 951, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 894, in _find_spec
  File "<frozen importlib._bootstrap_external>", line 1157, in find_spec
  File "<frozen importlib._bootstrap_external>", line 1131, in _get_spec
  File "<frozen importlib._bootstrap_external>", line 1112, in _legacy_get_spec
  File "<frozen importlib._bootstrap>", line 441, in spec_from_loader
  File "<frozen importlib._bootstrap_external>", line 544, in spec_from_file_location
  File "/tmpsort/ansible_amazon.aws.rds_instance_info_payload_tws_o3ir/ansible_amazon.aws.rds_instance_info_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/botocore.py", line 36
SyntaxError: future feature annotations is not defined
fatal: [localhost]: FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/home/misoracle/.ansible/tmp/ansible-tmp-1774379457.6232963-1227426-54449619609102/AnsiballZ_rds_instance_info.py\", line 107, in <module>\n    _ansiballz_main()\n  File \"/home/misoracle/.ansible/tmp/ansible-tmp-1774379457.6232963-1227426-54449619609102/AnsiballZ_rds_instance_info.py\", line 99, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/misoracle/.ansible/tmp/ansible-tmp-1774379457.6232963-1227426-54449619609102/AnsiballZ_rds_instance_info.py\", line 48, in invoke_module\n    run_name='__main__', alter_sys=True)\n  File \"/usr/lib64/python3.6/runpy.py\", line 205, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib64/python3.6/runpy.py\", line 96, in _run_module_code\n    mod_name, mod_spec, pkg_name, script_name)\n  File \"/usr/lib64/python3.6/runpy.py\", line 85, in _run_code\n    exec(code, run_globals)\n  File \"/tmpsort/ansible_amazon.aws.rds_instance_info_payload_tws_o3ir/ansible_amazon.aws.rds_instance_info_payload.zip/ansible_collections/amazon/aws/plugins/modules/rds_instance_info.py\", line 362, in <module>\n  File \"<frozen importlib._bootstrap>\", line 971, in _find_and_load\n  File \"<frozen importlib._bootstrap>\", line 955, in _find_and_load_unlocked\n  File \"<frozen importlib._bootstrap>\", line 656, in _load_unlocked\n  File \"<frozen importlib._bootstrap>\", line 626, in _load_backward_compatible\n  File \"/tmpsort/ansible_amazon.aws.rds_instance_info_payload_tws_o3ir/ansible_amazon.aws.rds_instance_info_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/modules.py\", line 56, in <module>\n  File \"<frozen importlib._bootstrap>\", line 971, in _find_and_load\n  File \"<frozen importlib._bootstrap>\", line 951, in _find_and_load_unlocked\n  File \"<frozen importlib._bootstrap>\", line 894, in _find_spec\n  File \"<frozen importlib._bootstrap_external>\", line 1157, in find_spec\n  File \"<frozen importlib._bootstrap_external>\", line 1131, in _get_spec\n  File \"<frozen importlib._bootstrap_external>\", line 1112, in _legacy_get_spec\n  File \"<frozen importlib._bootstrap>\", line 441, in spec_from_loader\n  File \"<frozen importlib._bootstrap_external>\", line 544, in spec_from_file_location\n  File \"/tmpsort/ansible_amazon.aws.rds_instance_info_payload_tws_o3ir/ansible_amazon.aws.rds_instance_info_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/botocore.py\", line 36\nSyntaxError: future feature annotations is not defined\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

PLAY RECAP ***************************************************************************************************************************************************************************************************
localhost                  : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

[misoracle@ehsmg-mis-dba1 ansible]$



Please help.

^ You might want to check your versions

The error message is normally about a Python/Ansible version mismatch, in this case I suspect the module expects a different version of Python than what you are using.

1 Like

You also might want to check your python version. The traceback indicates it is using python 3.6

  File "/usr/lib64/python3.6/runpy.py", line 205, in run_module

Looks like you have 3.12 but you have it commented out in your ansible.cfg and I believe it should be ansible_python_interpreter
Is:

[defaults]
#interpreter_python = /usr/bin/python3.12
interpreter_python = /usr/bin/python3

Should be:

[defaults]
ansible_python_interpreter = /usr/bin/python3.12
1 Like

if you have non homogeneous environments, you might want to set ansible_python_interpreter at the inventory level

@bcoca will test that in another VM, thank you

@derb I think the reason it is commented out that it didnt help (the 3.12), so I used the 3. But checking now just in case. Standby, please.

@bcoca it was set there as well. In /etc/ansible/hosts as a variable

@derb you were right. Here is what I did to fix it.

  1. Pointed to python3.12 inside the ansible.cfg
  2. Removed the variable ansible_python_interpreter: /usr/bin/python3.12 from the vars inside the playbook. I have no clue why that helped (since it is the correct python version), but as soon as I did that, the playbook errored out with an undefine variable for AWS region. Then I knew I am on the right path because it has used python3.12 to get to AWS, shich it couldnt before.
  3. As soon as I added the region var to the playbook - voila - I got my RDS instances data just fine.

Thank you for resolving my issue.

Nestor.