A simple ansible command encounters "ERROR: file hosts marked as executable"

new for affordable.

I installed available in ubuntu vm 14.04.1 using the ppa installation

user@ubuntu :~$ ansible --version ansible 1.7 

And created the hosts only with localhost

 user@ubuntu :~$ cat hosts localhost 

When I try to run this simple command

 user@ubuntu :~$ ansible -i hosts all -m ping --ask-pass SSH password: ERROR: The file hosts is marked as executable, but failed to execute correctly. If this is not supposed to be an executable script, correct this with `chmod -x hosts`. 

UPDATE , when I follow the instructions to remove the runtime for the hosts , it works.

But the message is still rather strange for me why do I need to execute the hosts file.

What happened to this?

+6
source share
2 answers

There are several types of files that can be transferred using the -i option.

In your case, Ansible suggested that since you had the executable bit set in the hosts file , it was a dynamic inventory executable.

Very often, a dynamic inventory file (2) is used for situations where you need to find the IP addresses of the hosts you want to work on. One example is when you need to request a directory service, or possibly an API, to get a list of hosts grouped on the fly.

+9
source

For this nasty error message:

ERROR: file inventory is marked as executable, but failed to execute correctly. If this should not be an executable script, fix it with chmod -x inventory .

I found a solution here

In Vagrantfile, I added the following:

 srv.vm.synced_folder '.', '/vagrant', :mount_options => ["fmode=666"] 
0
source

Source: https://habr.com/ru/post/974238/


All Articles