Question:
I’m running into an error I’ve never seen before. Here is the command and the error:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
$ ansible-playbook create_api.yml PLAY [straw] ****************************************************************** GATHERING FACTS *************************************************************** failed: [104.55.47.224] => {"failed": true, "parsed": false} /bin/sh: 1: /usr/bin/python: not found TASK: [typical | install required system packages] ***************************** FATAL: no hosts matched or all hosts have already failed -- aborting PLAY RECAP ******************************************************************** to retry, use: --limit @/Users/john/create_api.retry 104.55.47.224 : ok=0 changed=0 unreachable=0 failed=1 |
Here is the create_api.yml file:
1 2 3 4 5 6 7 |
--- - hosts: api remote_user: root roles: - api |
And here is the hosts file:
1 2 3 |
[api] 104.55.47.224 |
I can remove the roles section and it won’t make it to the first TASK, it will instead make it will only make it to the line /bin/sh: 1: /usr/bin/python: not found
. What could be going on here?
Note: In case anyone is pinging the IP address and failing to get a response, you should know I’ve changed the IP address since pasting code.
Note:
python was installed locally, the problem was that it was not installed on the remote machine, which was running Ubuntu 15.04
Answer:
I stumbled upon this error running ansible on Ubuntu 15.10 server, because it ships with Python 3.4.3 and ansible requires Python 2.
This is how my provision.yml
looks now:
1 2 3 4 5 6 7 8 9 10 11 12 |
- hosts: my_app sudo: yes remote_user: root gather_facts: no pre_tasks: - name: 'install python2' raw: sudo apt-get -y install python tasks: - name: 'ensure user {{ project_name }} exists' user: name={{ project_name }} state=present |
- Don’t forget the -y (says yes to all questions) option with apt-get (or raw module will get stuck silently)
gather_facts: no
line is also critical (because we can’t gather facts without python)