Running playbook against local machine fails

I’m new to Ansible and just started trying it out for use on some of my systems. I’m able to run a playbook against a remote machine, but when I try to run it locally it fails. In the playbook I’ve set host: 127.0.0.1 and connection: local.

This is what I see when it runs:

TASK: [test of local copy] *********************
failed: [127.0.0.1] => {“failed”: true, “parsed”: false}
FATAL: all hosts have already failed – aborting

I get the same failure when trying to run something on the localhost from the command line. Any ideas?

Do you have 127 in your hosts file?

Brian Coca

Yes.

A few standard questions that we should always ask on reports like these:

(A) What version of Ansible? (That parsed message should appear with
a lot more detail) If this is not latest (1.0), please try latest.

(B) Have you tried -v -v -v, what was the output if you got any more detail?

(C) For starters, please supply your playbook, your inventory file,
and also the CLI invocation you are using. Redact them as neccessary,
but try to include as much as you can.

Michael, Thanks for the response. Here’s the additional information.

ansible --version reports 1.0. I’m running Arch Linux and this is the package from their AUR repository. Looks like it just clones the git repo for ansible and then builds it. The repo was as of 07 Jan.

My hosts file:

127.0.0.1
src5

Output from running: ansible 127.0.0.1 -v -v -v -m setup --tree /tmp/facts --connection=local.

<127.0.0.1> EXEC mkdir -p $HOME/.ansible/tmp/ansible-1358429770.6-229707097735235 && chmod a+rx $HOME/.ansible/tmp/ansible-1358429770.6-229707097735235 && echo $HOME/.ansible/tmp/ansible-1358429770.6-229707097735235
<127.0.0.1> REMOTE_MODULE setup
<127.0.0.1> PUT /tmp/tmpw2MSzM TO /home/dan/.ansible/tmp/ansible-1358429770.6-229707097735235/setup
<127.0.0.1> EXEC /usr/bin/python /home/dan/.ansible/tmp/ansible-1358429770.6-229707097735235/setup; rm -rf /home/dan/.ansible/tmp/ansible-1358429770.6-229707097735235/ >/dev/null 2>&1
127.0.0.1 | FAILED >> {
“failed”: true,
“msg”: “”,
“parsed”: false
}

My playbook:


  • name: example play
    hosts: 127.0.0.1
    connection: local
    gather_facts: no
    user: dan

tasks:

  • name: test of local copy
    action: copy src=…/files/myconfig.conf dest=/home/dan

Running the playbook gives more or less the same error as running ansible in command-line mode.

Dan

You are getting an error while trying to run the setup module.

On the remote box, if you do a checkout of ansible and run
./hacking/env-setup -M setup, it should be able to help you see more
of what is going on.

It seems like you possibly might need to set
ansible_python_interpreter as an inventory variable seeing it's Arch
and python could be in a different place, but that's just a guess.

It should really report the full stderr output so I'm a bit unsure why
that is happening.

Good catch! Arch has python v.3 installed as python and python v.2 is python2. Specifying ansible_python_interpreter=/usr/bin/python2 in the hosts file solved the problem.

Thanks.