One PC can connect when running ansible but not when running ansible-playbook

Here is a problem that’s driving me crazy for the last 10 hours and I can’t sort it.

Let’s call it PC1 and I use this:

ansible -s -K -i hosts -m setup host1 -u username -vvvv

This is running just fine and delivers all the facts.

Now let’s run this on the same PC1:

ansible-playbook -K -i hosts test.yml -u username -vvvv

test.yml has the following content:

  • name: “Gather Facts”
    hosts: host1
    connection: ssh
    gather_facts: true
    sudo: yes

That is hanging indefinitely. The output is like this:

EXEC [‘ssh’, ‘-tt’, ‘-vvv’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘ControlMaster=auto’, ‘-o’, ‘ControlPersist=60s’, ‘-o’, ‘ControlPath=/tmp/ansible-ssh-%h-%p-%r’, ‘-o’, ‘Port=22’, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘User=username’, ‘-o’, ‘ConnectTimeout=10’, ‘host1’, “/bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-1380631415.49-10764847459179 && chmod a+rx $HOME/.ansible/tmp/ansible-1380631415.49-10764847459179 && echo $HOME/.ansible/tmp/ansible-1380631415.49-10764847459179’”]

When running through ansible, the setup module is working fine. Running through ansible-playbook, we don’t get anything on the remote host. If we do the exactly same thing on another PC2, then both works fine. What could that be??? I hope anyone has an idea, I’m running out of them.

FYI:

/usr/bin/ansible defaults to the current CLI user, /usr/bin/ansible-playbook does not.

The username on the remote host is different, that’s why I have provided “-u username” in both cases and expected both to make use of the parameter. The output states that is establshes a connection with the given name.

Just found the reason for the difference. That PC1 had an old ansible.cfg file with transport=parameiko set.

We’ve changed that to ssh and now both (ansible and ansible-playbook) both can’t access the remote host anymore.

With “ssh host1” the connection works and accessing sudo does work too.

What else can we try to get this PC work with that host?

I’m very unclear as to your environment.

I would suggest hoping on IRC and perhaps someone can help you in more real time?

Thanks Michael, I really felt the same and thought I had tried everything on that particular PC (Ubuntu 13.04 driven), the same environment that I used on another PC for quite some time now with no issues.

Guess what? A reboot sorted the issue. I struggle to understand what has been the issue but it’s now sorted.