6

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

jww
  • 97,681
  • 90
  • 411
  • 885
HamidOvic
  • 123
  • 1
  • 2
  • 6
  • Hey @hamidovic, could you add the `playbook` you are trying to run? Also, please check the output of `which python` on your server. – guzmonne Jul 24 '19 at 02:17
  • It looks like you don't have Python on your local server. If it has been installed in some uncommon location, you may need to explicitly set it in your inventory file, like this: ```ansible_python_interpreter: "/usr/local/bin/python"``` – Anton Jul 25 '19 at 06:36
  • I ran into this today as well. In my case I removed /usr/bin/python3 in a task on a managed machine in order to create a new symbolic link in the next task ( instead of doing ln -sf ); this caused this next task to fail due to missing definition of /usr/bin/python3. – amagard Jan 21 '21 at 15:28

4 Answers4

7

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

jkdev
  • 11,360
  • 15
  • 54
  • 77
2

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
robrecord
  • 504
  • 5
  • 15
0

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.

0

I hope this helps, if you are running Linux, the below command is your friend:

sudo apt install python-is-python3

That should set a symlink from python3-python which is what ansible is screaming about.