It's not clear whether you 1) installed Ansible inside the virtual machine, 
or 2) locally.

1.
If you installed it inside your virtual machine, and want to test against 
the localhost, then your /etc/ansible/hosts file can just be

[webservers]
testserver ansible_connection=local

2.
If you've installed ansible locally, and wish to test it against your 
virtual machine, then the settings you've used (ansible_ssh_host=127.0.0.1 
ansible_ssh_port=2222) would be valid if you're running your instance using 
Vagrant.  As a default vagrant instance listens on 127.0.0.1:2222  (it 
performs port forwarding from 2222->22).  If you're using Vagrant then 
obviously you'll need to do a 'vagrant up' to start the instance otherwise 
it won't be able to connect.

If you're using something other than Vagrant, e.g. just plain VirtualBox, 
then you'll need to setup networking so that you can communicate between 
your local machine and the instance, and then you'll need to update the 
inventory to use the correct address/port details.

Also, OpenSSH is installed by default on most Linux servers.

Hope that helps


On Monday, 25 May 2015 14:41:53 UTC+1, vamsee krishna wrote:
>
> Hi All,
>
> I'm new to Ansible. started working on Ansible basics.
>
> I installed Ubuntu 14.04 in virtual box and installed Ansible using the 
> following commands
>
> $ sudo apt-get install software-properties-common$ sudo apt-add-repository 
> ppa:ansible/ansible$ sudo apt-get update$ sudo apt-get install ansible
>
> from Ansible documentation
>
> Later I updated the hosts file in /etc/ansible to
>
> [webservers]
>
> testserver ansible_ssh_host=127.0.0.1 ansible_ssh_port=2222
>
> and tried to ping using the command 
>
> ansible webservers -m ping and I'm getting an error message 
>
> testserver | FAILED => SSH Error: ssh: connect to host 127.0.0.1 port 2222: 
> Connection refused while connecting to 127.0.0.1:2222
>
> It is sometimes useful to re-run the command using -vvvv, which prints SSH 
> debug output to help diagnose the issue.
>
> When I googled for connection refused type issues I thought that I should 
> be installing Open SSH server in Ubuntu and did the same using the command
>
>
> sudo apt-get install openssh-server
>
>
> Even then I'm getting the same error.
>
> Please let me know if i did some thing wrong or provide any links that i 
> could follow to solve the above issue
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/55577a32-811e-4793-aa40-7c3332f73b1a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to