Started learning and working with Ansible. As simple scenario running a Vagrant box in my local and trying run a command using Ansible on that from Host (Mac).
Not able to connect to running vagrant box whilst executing,
- tried using password (vagrant)
ansible --ask-pass -i ./host_inventory.yml -m command -a "sudo apt-get install openjdk-6-jdk" 127.0.0.1
- Tried using SSH. In this case I copied the public key that was created in host (Mac OS) to my Vagrant Box and added it authorized_keys
ansible -i ./host_inventory.yml -m command -a "sudo apt-get install openjdk-6-jdk" 127.0.0.1
for both getting this error,
127.0.0.1 | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: kex_exchange_identification: Connection closed by remote host",
"unreachable": true
}
My environment:
OS: Mac Os Catalina Vagrnt box running: Ubuntu10
Below is the content of host_inventory.yml file,
all:
hosts:
127.0.0.1:8080
In Vagrantfile I have forwarded ports as,
config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"
But I am able to ssh to the running Vagrant box.
Any suggestions please.
127.0.0
is not a valid ip – Marcin Orlowski