Ansible-core requires a minimum of Python2 version 2.7 or Python3 version 3.5. Current version: 2.6.6

Hello,

i am new tho this community and recently i have upgraded my ansible to 2.15, here is my anisble details:
ansible-config [core 2.15.6]
config file = /etc/ansible/ansible.cfg
configured module search path = [‘/root/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]
ansible python module location = /usr/lib/python3.9/site-packages/ansible
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
executable location = /bin/ansible-config
python version = 3.9.18 (main, Sep 7 2023, 00:00:00) [GCC 11.4.1 20230605 (Red Hat 11.4.1-2)] (/usr/bin/python3)
jinja version = 3.1.2
libyaml = True

but my target server is redhat 6 and python veresion is 2.6.6, while running a playbook, i am getting below error:

{
  "ansible_facts": {},
  "msg": "The following modules failed to execute: ansible.legacy.setup\n",
  "failed_modules": {
    "ansible.legacy.setup": {
      "failed": true,
      "msg": "ansible-core requires a minimum of Python2 version 2.7 or Python3 version 3.5. Current version: 2.6.6 (r266:84292, Aug  9 2016, 06:11:56) [GCC 4.4.7 20120313 (Red Hat 4.4.7-17)]",
      "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
      }
    }
  },
  "_ansible_verbose_override": true,
  "_ansible_no_log": null,
  "changed": false
}

how can i fix this without downgrading ansible

You can install a newer Python version on your RHEL 6 server.

The only alternative is sticking to the raw action (which makes Ansible not very useful), or downgrade ansible-core to an older version.

1 Like

Thanks for the response,

i cannot upgrade the python version of redhat 6 server as it is production and current python is in use, the application is very old and there is an upgrade coming in coming years

the current ansible is full tower installation where i was on old version of AWX. is it possible/recommended to downgrade the ansible to 2.12 ?

If you’re using Execution Environments, using an older ansible-core version like 2.12 shouldn’t be a problem.

About Python 2.6/2.7 on RHEL 6: I guess it should be able to install Python 2.7 next to Python 2.6. No idea whether that has some unexpected impact on your application though…

i have downgraded ansible-core to ansible-core-2.12.2-1 , still same issue

We are using ansible 2.10.17 successfully with old centOS6 hosts just fine!

1 Like

@WyoMurf while you can also use ansible-base 2.10, I would rather use ansible-core 2.12 in your case since that also supports Python 2.6, but has some improvements / features / bugfixes that ansible-base 2.10 does not have, like for example role argument spec validation (introduced in 2.11, improved in 2.12).

1 Like

I dont see this as solved but I also came here with the same problem, though my solution is going to be to install python3 on the rhel6s and add a variable to my inventories for the RHEL6 and some RHEL7s we have bound to 2.6.
Var should be
ansible_python_interpreter: /user/bin/python3
or where ever python installed at, as long as you dont change the servers configs to source python3 all will work still.