SSH trouble with Ansible 1.3.2 and LXC

Hi,

Newbie here. I am using Ansible 1.3.2 on Ubuntu 13.04 and LXC. I have copied my SSH public key into the box’s ~/.ssh/authorized_keys and I can SSH passwordlessly on the command line. When I try Ansible commands I get SSH error:

~/mybox$ ansible-playbook -vvv -i hosts.txt site.yml

PLAY [tomcat-servers] *********************************************************

GATHERING FACTS ***************************************************************
ESTABLISH CONNECTION FOR USER: ubuntu
EXEC [‘ssh’, ‘-tt’, ‘-q’, ‘-o’, ‘ControlMaster=auto’, ‘-o’, ‘ControlPersist=60s’, ‘-o’, ‘ControlPath=/home/shantanukumar/.ansible/cp/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=ubuntu’, ‘-o’, ‘ConnectTimeout=10’, ‘hosts’, “/bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-1380318604.29-40373890357519 && chmod a+rx $HOME/.ansible/tmp/ansible-1380318604.29-40373890357519 && echo $HOME/.ansible/tmp/ansible-1380318604.29-40373890357519’”]
fatal: [hosts] => SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue

PLAY RECAP ********************************************************************
to retry, use: --limit @/home/shantanukumar/site.retry

hosts : ok=0 changed=0 unreachable=1 failed=0

Could you run it with the -vvvv (4 v’s) as recommend and show the output?

Hi James,

Could you run it with the -vvvv (4 v’s) as recommend and show the output?

I ran it with 4 v’s and here’s the output:

~/mybox$ ansible-playbook -vvvv -i hosts.txt site.yml

PLAY [tomcat-servers] *********************************************************

GATHERING FACTS ***************************************************************
ESTABLISH CONNECTION FOR USER: ubuntu
EXEC [‘ssh’, ‘-tt’, ‘-vvv’, ‘-o’, ‘ControlMaster=auto’, ‘-o’, ‘ControlPersist=60s’, ‘-o’, ‘ControlPath=/home/shantanukumar/.ansible/cp/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=ubuntu’, ‘-o’, ‘ConnectTimeout=10’, ‘hosts’, “/bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-1380319822.8-236525636193412 && chmod a+rx $HOME/.ansible/tmp/ansible-1380319822.8-236525636193412 && echo $HOME/.ansible/tmp/ansible-1380319822.8-236525636193412’”]
fatal: [hosts] => SSH encountered an unknown error. The output was:
OpenSSH_6.1p1 Debian-4, OpenSSL 1.0.1c 10 May 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: auto-mux: Trying existing master
debug1: Control socket “/home/shantanukumar/.ansible/cp/ansible-ssh-hosts-22-ubuntu” does not exist
debug2: ssh_connect: needpriv 0
ssh: Could not resolve hostname hosts: No such file or directory

PLAY RECAP ********************************************************************
to retry, use: --limit @/home/shantanukumar/site.retry

hosts : ok=0 changed=0 unreachable=1 failed=0

So it looks like your hosts.txt file is not formatted properly, could you show that please?

So it looks like your hosts.txt file is not formatted properly, could you show that please?

The file content is verbatim below:

~/mybox$ cat hosts.txt
[hosts]
#10.0.3.181
10.0.3.188

[tomcat-servers]
hosts

Shantanu

Put the names of your tomcat servers under the group label
If you have two hosts named foo and bar it would look like this:

[tomcat-servers]
foo
bar

It should be:

[tomcat-servers:children]

to signify that the name is a group of groups.

Thanks James and Michael!

Shantanu