'Module failed to start Ansible

I'm new in Ansible. I'm working on an Ubunto machine. On the VM, I installed Ansible along with to apply play books to.

When I run a playbook I receive the following error.

fatal: [localhost]: FAILED! => {
    "ansible_facts": {},
    "changed": false,
    "msg": "The following modules failed to execute: setup\n  setup: The module failed to execute correctly, you probably need to set the interpreter.\nSee stdout/stderr for the exact error\n"
}

Can you let me know where I should begin looking? Also advise on any more information you need to help troubleshoot this issue.

Thanks in advance



Solution 1:[1]

I had a similar situation, and I deleted ansible_python_interpreter=/usr/bin/python3 from my inventory and it worked.

Solution 2:[2]

I faced similar kind of issue. I had python3 installed on destination machine and manager node which I was using had python 2.7. When I installed python 2.7 on destination machine, module got executed successfully.

Solution 3:[3]

To fix, I added ansible_python_interpreter=/usr/bin/python3 to the host in my hosts file.

eg.

[web]
123.4.5.6

became:

[web]
123.4.5.6 ansible_python_interpreter=/usr/bin/python3

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jkdev
Solution 2 Narasimha Athreya
Solution 3 robrecord