# \[Playbook\] - CentOS - module FAILED "The following modules failed to execute: ansible.legacy.setup"

**URL:** <https://forum.ansible.com/t/playbook-centos-module-failed-the-following-modules-failed-to-execute-ansible-legacy-setup/44520>\
**Category:** Get Help\
**Tags:** fedora, ubuntu\
**Created:** [September 20, 2025, 3:02pm UTC](https://forum.ansible.com/t/playbook-centos-module-failed-the-following-modules-failed-to-execute-ansible-legacy-setup/44520 "2025-09-20T15:02:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jelmouss](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jelmouss/32/9457_2.png) [@jelmouss](https://forum.ansible.com/u/jelmouss)\
**Post date:** [September 20, 2025, 3:02pm UTC](https://forum.ansible.com/t/playbook-centos-module-failed-the-following-modules-failed-to-execute-ansible-legacy-setup/44520/1 "2025-09-20T15:02:06Z")

</div>

Bonjour,

Environnement:  
3 Machines tournant sous Vagrant

- Ubuntu (controlplane)

- Ubuntu (node)

- CentOS10 (node)

- Exécution du playbook sur node Ubuntu = exécution correct pas d’erreur.

- Exécution du playbook sur node centos = Retourne une erreur.

- Exécution du playbook sur node Ubuntu et centos = retourne une erreur.  
Le playbook refuse de s’exécuter une le node CentOS!

PS: python est bien à jour sur le node CentOS  
PS: même problématique avec environnement fedora.

- my code Error!  
fatal: [172.16.154.143]: FAILED! =\> {“ansible\_facts”: {}, “changed”: false, “failed\_modules”: {“ansible.legacy.setup”: {“ansible\_facts”: {“discovered\_interpreter\_python”: “/usr/bin/python”}, “deprecations”: [{“msg”: “Distribution centos 10 on host 172.16.154.143 should use /usr/libexec/platform-python, but is using /usr/bin/python for backward compatibility with prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See [Interpreter Discovery — Ansible Documentation](https://docs.ansible.com/ansible/2.10/reference_appendices/interpreter_discovery.html) for more information”, “version”: “2.12”}], “exception”: “Traceback (most recent call last):\r\n File "/home/vagrant/.ansible/tmp/ansible-tmp-1758378931.3669925-8418-85586770537722/AnsiballZ\_setup.py", line 102, in \r\n \_ansiballz\_main()\r\n File "/home/vagrant/.ansible/tmp/ansible-tmp-1758378931.3669925-8418-85586770537722/AnsiballZ\_setup.py", line 94, in \_ansiballz\_main\r\n invoke\_module(zipped\_mod, temp\_path, ANSIBALLZ\_PARAMS)\r\n File "/home/vagrant/.ansible/tmp/ansible-tmp-1758378931.3669925-8418-85586770537722/AnsiballZ\_setup.py", line 37, in invoke\_module\r\n from ansible.module\_utils import basic\r\n File "/tmp/ansible\_ansible.legacy.setup\_payload\_fzdo9s94/ansible\_ansible.legacy.setup\_payload.zip/ansible/module\_utils/basic.py", line 176, in \r\nModuleNotFoundError: No module named ‘ansible.module\_utils.six.moves’\r\n”, “failed”: true, “module\_stderr”: “Shared connection to 172.16.154.143 closed.\r\n”, “module\_stdout”: “Traceback (most recent call last):\r\n File "/home/vagrant/.ansible/tmp/ansible-tmp-1758378931.3669925-8418-85586770537722/AnsiballZ\_setup.py", line 102, in \r\n \_ansiballz\_main()\r\n File "/home/vagrant/.ansible/tmp/ansible-tmp-1758378931.3669925-8418-85586770537722/AnsiballZ\_setup.py", line 94, in \_ansiballz\_main\r\n invoke\_module(zipped\_mod, temp\_path, ANSIBALLZ\_PARAMS)\r\n File "/home/vagrant/.ansible/tmp/ansible-tmp-1758378931.3669925-8418-85586770537722/AnsiballZ\_setup.py", line 37, in invoke\_module\r\n from ansible.module\_utils import basic\r\n File "/tmp/ansible\_ansible.legacy.setup\_payload\_fzdo9s94/ansible\_ansible.legacy.setup\_payload.zip/ansible/module\_utils/basic.py", line 176, in \r\nModuleNotFoundError: No module named ‘ansible.module\_utils.six.moves’\r\n”, “msg”: “MODULE FAILURE\nSee stdout/stderr for the exact error”, “rc”: 1}}, “msg”: “The following modules failed to execute: ansible.legacy.setup\n”}

- Set at least one tag (the experts follow the tags, so the right people will find you if you tag)

- PLaybook d’install apache (basique)

* * *

- hosts: all  
become: true  
tasks:
  - name: update repository index  
ansible.builtin.apt:  
update\_cache: yes  
when: ansible\_distribution == “Ubuntu”

  - name: install apache2 package  
ansible.builtin.apt:  
name: apache2  
state: latest  
when: ansible\_distribution == “Ubuntu”

  - name: install support for php  
ansible.builtin.apt:  
name: libapache2-mod-php  
state: latest  
when: ansible\_distribution == “Ubuntu”

  - name: update repository index  
ansible.builtin.yum:  
update\_cache: yes  
when: ansible\_distribution == “CentOS”

  - name: install httpd package  
ansible.builtin.yum:  
name: httpd  
state: latest  
when: ansible\_distribution == “CentOS”

  - name: add php support for apache  
ansible.builtin.yum:  
name: php  
state: latest  
when: ansible\_distribution == “CentOS”

Gros blocage sur ce probléme depuis deux jour, donc, par avance merci pour votre contribution et aide.

---

<div class="post-metadata">

**Author:** ![mikemorency](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mikemorency/32/2672_2.png) [@mikemorency](https://forum.ansible.com/u/mikemorency)\
**Post date:** [September 20, 2025, 4:22pm UTC](https://forum.ansible.com/t/playbook-centos-module-failed-the-following-modules-failed-to-execute-ansible-legacy-setup/44520/2 "2025-09-20T16:22:22Z")

</div>

What version of Ansible are you using, and what version of python is /usr/bin/python on the centos node?

---

<div class="post-metadata">

**Author:** ![jelmouss](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jelmouss/32/9457_2.png) [@jelmouss](https://forum.ansible.com/u/jelmouss)\
**Post date:** [September 20, 2025, 4:36pm UTC](https://forum.ansible.com/t/playbook-centos-module-failed-the-following-modules-failed-to-execute-ansible-legacy-setup/44520/3 "2025-09-20T16:36:19Z")

</div>

vagrant@controlplane:~/ansible\_course$ ansible --version  
**ansible 2.10.8**  
config file = /home/vagrant/ansible\_course/ansible.cfg  
configured module search path = [‘/home/vagrant/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]  
ansible python module location = /usr/lib/python3/dist-packages/ansible  
executable location = /usr/bin/ansible  
python version = 3.10.12 (main, Aug 15 2025, 14:32:43) [GCC 11.4.0]  
vagrant@controlplane:~/ansible\_course$

[vagrant@node06 ~]$ python3 --version  
Python 3.12.11  
[vagrant@node06 ~]$ python3 -VV  
Python 3.12.11 (main, Aug 14 2025, 00:00:00) [GCC 14.3.1 20250617 (Red Hat 14.3.1-2)]  
[vagrant@node06 ~]$  
[vagrant@node06 ~]$ whereis python  
python: /usr/bin/python /usr/share/man/man1/python.1.gz  
[vagrant@node06 ~]$

---

<div class="post-metadata">

**Author:** ![mikemorency](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mikemorency/32/2672_2.png) [@mikemorency](https://forum.ansible.com/u/mikemorency)\
**Post date:** [September 20, 2025, 4:54pm UTC](https://forum.ansible.com/t/playbook-centos-module-failed-the-following-modules-failed-to-execute-ansible-legacy-setup/44520/4 "2025-09-20T16:54:52Z")

</div>

Two issues:

1. Your ansible version is really old. I think 2.17 is the oldest, supported version right now. Did you install by package manager? If so, I would uninstall that and use pip to install it

2. You listed the wrong python version. Do `/usr/bin/python --version` or `python --version`. `python3` is a completely different install and one that ansible is not using

---

<div class="post-metadata">

**Author:** ![jelmouss](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jelmouss/32/9457_2.png) [@jelmouss](https://forum.ansible.com/u/jelmouss)\
**Post date:** [September 20, 2025, 5:06pm UTC](https://forum.ansible.com/t/playbook-centos-module-failed-the-following-modules-failed-to-execute-ansible-legacy-setup/44520/5 "2025-09-20T17:06:07Z")

</div>

1. Yes, ansible was installed by package manager  
Moreover i just try a apt command  
vagrant@controlplane:~/ansible\_course$ _sudo apt install ansible_  
Reading package lists… Done  
Building dependency tree… Done  
Reading state information… Done  
_ansible is already the newest version (2.10.7+merged+base+2.10.8+dfsg-1)._  
_0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded._  
vagrant@controlplane:~/ansible\_course$

2. [vagrant@node06 ~]$ /usr/bin/python --version  
**Python 3.12.11**  
[vagrant@node06 ~]$ python --version  
**Python 3.12.11**

Thanks Sir.

---

<div class="post-metadata">

**Author:** ![jelmouss](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jelmouss/32/9457_2.png) [@jelmouss](https://forum.ansible.com/u/jelmouss)\
**Post date:** [September 20, 2025, 6:31pm UTC](https://forum.ansible.com/t/playbook-centos-module-failed-the-following-modules-failed-to-execute-ansible-legacy-setup/44520/6 "2025-09-20T18:31:06Z")

</div>

hi,

#install python3 and pip on Ubuntu:  
sudo apt update  
sudo apt install python3-pip

```auto
sudo apt update && sudo apt upgrade -y
sudo apt install software-properties-common

sudo add-apt-repository --yes --update ppa:ansible/ansible

#Install Ansible
sudo apt install ansible -y

# finx broken install
sudo apt --fix-broken install

#Validate Ansible:
ansible ---version 
ansible [core 2.17.14]

Everything is running fine now, i think, topic can be closed.
```
