Ansible Core 2.18 fails on remote host with Python 3.6 — future feature annotations is not defined during fact gathering

harshit.sheth
Thu, 06 Nov 2025 14:47:37 +0000
Get Help

Hello Team,

I’m encountering a blocking issue with Ansible Core 2.18.10 when running playbooks on remote hosts that only have Python 3.6.8 installed. The error occurs during the Gathering Facts phase and prevents the playbook from progressing.

Environment Details

Control Node:

Ansible version: ansible [core 2.18.10]

Python version: 3.12.12

OS: Linux (running via Semaphore)

Remote Host:

OS: RHEL / Ubuntu based VM

Python version: 3.6.8 (located at /usr/bin/python3)

Inventory Configuration:
[all:vars]
ansible_connection=ssh
ansible_ssh_common_args="-o StrictHostKeyChecking=no"
ansible_python_interpreter=/usr/bin/python3

Error Output

TASK [Gathering Facts] *********************************************************
fatal: [REDHAT_VM1]: FAILED! => changed=false
  ansible_facts: {}
  failed_modules:
    ansible.legacy.setup:
      exception: |-            SyntaxError: future feature annotations is not defined
      failed: true
      module_stderr: |-        Shared connection to 10.21.100.99 closed.
      module_stdout: |-        Traceback (most recent call last):
        ...
        SyntaxError: future feature annotations is not defined
      msg: |-
        MODULE FAILURE: No start of json char found
        See stdout/stderr for the exact error
      rc: 1
  msg: |-
    The following modules failed to execute: ansible.legacy.setup

Playbook Overview

My playbook includes multiple roles and tasks that depend on facts:

- name: Common configuration - ping + hostname entry + repo update + packages + RHEL Subscription
  hosts: all
  become_user: root
  become: true
  gather_facts: true
  roles:
    - common-bootstart
...
- name: Active Directory AD-join + Sudoers + SNMP + SSSD
- name: Linux hardening
- name: Linux Firewall
- name: Software installation

These roles rely on facts like:

ansible_os_family, ansible_distribution, ansible_pkg_mgr for conditional logic (RedHat vs Ubuntu)

ansible_hostname, ansible_default_ipv4.address for updating /etc/hosts

Constraints

I cannot upgrade Python on the remote hosts due to environment restrictions.

I need gather_facts: true because many roles depend on system facts for conditional logic and configuration.

What I Need Help With

Is there a way to force Ansible 2.18 to use Python 3.6-compatible modules?

Can I configure Ansible to avoid using __future__.annotations in remote execution?

Are there collections or module versions that still support Python 3.6?

Any known workarounds to enable fact gathering or simulate it without upgrading Python?

4 posts - 3 participants