ansible / ansible

Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy and maintain. Automate everything from code deployment to network configuration to cloud management, in a language that approaches plain English, using SSH, with no agents to install on remote systems. https://docs.ansible.com.
https://www.ansible.com/
GNU General Public License v3.0
63.05k stars 23.93k forks source link

SyntaxError: future feature annotations is not defined #84358

Open op7ic opened 1 day ago

op7ic commented 1 day ago

Summary

Hi folks,

I started to build new server using ansible + terraform and hit the following problem when invoking ansible:

Traceback (most recent call last): File "", line 107, in File "", line 99, in _ansiballz_main File "", line 44, in invoke_module File "", line 971, in _find_and_load File "", line 951, in _find_and_load_unlocked File "", line 894, in _find_spec File "", line 1157, in find_spec File "", line 1131, in _get_spec File "", line 1112, in _legacy_get_spec File "", line 441, in spec_from_loader File "", line 544, in spec_from_file_location File "/tmp/ansible_setup_payload_gkarwtna/ansible_setup_payload.zip/ansible/module_utils/basic.py", line 5 SyntaxError: future feature annotations is not defined

Error seems to reference the following code:

https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/basic.py

Issue Type

Bug Report

Component Name

https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/basic.py

Ansible Version

$ ansible --version
ansible [core 2.17.6]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/xxxx/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /home/xxxxx/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.12.3 (main, Sep 11 2024, 14:17:37) [GCC 13.2.0] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True

Configuration

# if using a version older than ansible-core 2.12 you should omit the '-t all'
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = /etc/ansible/ansible.cfg

OS / Environment

WSL

Steps to Reproduce

    - name: Domain configuration file
      include_vars:
        file: ../../../domain_setup.yml
        name: config_file
      tags: server

    - name: Read Config File and get credentials
      set_fact:
        ansible_user: "{{ config_file.wazuh_admin.username }}"
        ansible_password: "{{ config_file.wazuh_admin.password }}"
        velociraptor_debian: "{{ config_file.velociraptor_server.server_download }}"
        velociraptor_windows_msi: "{{ config_file.velociraptor_server.client_download }}"
        wazuh_server_ip: "{{ wazuh_server_ip }}"
      tags: server

    - name: Gather remote facts
      setup: {}
      tags: server

Code to invoke: ansible-playbook ansible/server.yml -vvv -t server

Expected Results

I would expect ansible to complete system build. It connects successfully but above error stops it from being able to work.

Actual Results

debug3: send packet: type 96
debug2: channel 0: input drain -> closed
debug2: channel 0: rcvd adjust 131072
debug2: channel 0: rcvd adjust 131072
debug2: channel 0: rcvd ext data 920
Traceback (most recent call last):
  File "<stdin>", line 107, in <module>
  File "<stdin>", line 99, in _ansiballz_main
  File "<stdin>", line 44, in invoke_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 "/tmp/ansible_setup_payload_gkarwtna/ansible_setup_payload.zip/ansible/module_utils/basic.py", line 5
SyntaxError: future feature annotations is not defined
debug2: channel 0: written 920 to efd 6
debug3: receive packet: type 98
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug3: receive packet: type 96
debug2: channel 0: rcvd eof
debug2: channel 0: output open -> drain
debug2: channel 0: obuf empty
debug2: chan_shutdown_write: channel 0: (i3 o1 sock -1 wfd 5 efd 6 [write])
debug2: channel 0: output drain -> closed
debug3: receive packet: type 97
debug2: channel 0: rcvd close
debug3: channel 0: will not send data after close
debug2: channel 0: almost dead
debug2: channel 0: gc: notify user
debug2: channel 0: gc: user detached
debug2: channel 0: send close
debug3: send packet: type 97
debug2: channel 0: is dead
debug2: channel 0: garbage collecting
debug1: channel 0: free: client-session, nchannels 1
debug3: channel 0: status: The following connections are open:
  #0 client-session (t4 [session] r0 i3/0 o3/0 e[write]/0 fd -1/-1/6 sock -1 cc -1 io 0x00/0x00)

Code of Conduct

ansibot commented 1 day ago

Files identified in the description:

None

If these files are incorrect, please update the component name section of the description or use the component bot command.

mkrizek commented 1 day ago

Duplicate of https://github.com/ansible/ansible/issues/82068