12

I've installed Ansible 1.2.3 on Ubuntu Precise 64.

Running ansible-playbook -i ansible_hosts playbook.yml give me this error:

ERROR: problem running ansible_hosts --list ([Errno 8] Exec format error)

Here's the content of ansible_hosts:

[development]
localhost   ansible_connection=local

and playbook.yml:

---
- hosts: development
  sudo: yes
  tasks:
    - name: install curl
      apt: pkg=curl update_cache=yes

How can I make this work?

mll
  • 505
  • 1
  • 4
  • 14

7 Answers7

22

For me, the problem was solved by removing "execute" permission on the ansible files (playbook, inventories etc):

find . -type f -exec chmod -x {} \;
Chris Beach
  • 4,302
  • 2
  • 31
  • 50
11

I have a similar problem:

$ ansible --version

ansible 1.5.4

$ ansible-playbook -i hosts main.yml

ERROR: problem running /mnt/d/Works/ansible-zipkin/hosts --list ([Errno 8] Exec format error)

My steps for Debian/Ubuntu:

$ sudo apt-get purge ansible
$ sudo apt-get install software-properties-common
$ sudo apt-add-repository ppa:ansible/ansible
$ sudo apt-get update
$ sudo apt-get install ansible
$ ansible --version

ansible 2.2.1.0

$ ansible-playbook -i hosts main.yml

Now it works!!!

Andrei Krasutski
  • 4,913
  • 1
  • 29
  • 35
5

you have to remove execution rights on ansible_hosts

chmod a-x ansible_hosts

if this doesn't work. try it with sudo

sudo chmod a-x ansible_hosts
amine
  • 502
  • 5
  • 14
  • 2
    Also keep in mind that in vagrant, if these files are mounted in Windows (config.vm.synced_folder) then chmod does not work. I ended copying the entire folder so that I could run chmod on the inventory files. – Philippe Sep 10 '15 at 18:55
  • Right, if you are running vagrant from a Windows system, then you wont be able to run chmod directly under the /vagrant shared folder.In such a case, you will need to copy/move the files away from the /vagrant directory. – Binita Bharati Dec 18 '16 at 11:34
2

Execute permissions are used for dynamic inventory scripts like for example rax.py. This one in particular builds an inventory by getting it from RackSpace. If you're maintaining your inventory manually your inventory file should not be executable.

Jason Prawn
  • 1,003
  • 11
  • 20
2

I ran into this and solved it by using shell instead of command.

Matthias Winkelmann
  • 15,870
  • 7
  • 64
  • 76
0

I am just learning ansible. From the best of my knowledge, it seems apt module does not have a key named 'pkg'. Probably, what you are looking for is 'name' [1]

I think, changing following line

apt: pkg=curl update_cache=yes 

with

apt: name=curl update_cache=yes

should solve the problem.

Ref: http://docs.ansible.com/apt_module.html

Prosunjit Biswas
  • 935
  • 9
  • 16
0

This is fixed with ansible 2.0 https://github.com/ansible/ansible/issues/10068

TlmaK0
  • 3,578
  • 2
  • 31
  • 51