ansible-for-devops icon indicating copy to clipboard operation
ansible-for-devops copied to clipboard

Unreachable vagrant boxes

Open lazytowntechie opened this issue 3 years ago • 14 comments

Currently having issue with running my ansible playbook after running vagrant up. image

Here's my Vagrant file:

# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  # General Vagrant VM configuration.
  config.vm.box = "geerlingguy/centos8"
  config.ssh.insert_key = false
  config.vm.synced_folder ".", "/vagrant", disabled: true
  config.vm.provider :virtualbox do |v|
    v.memory = 512
    v.linked_clone = true
  end

  # Application server 1.
  config.vm.define "app1" do |app|
    app.vm.hostname = "orc-app1.test"
    app.vm.network :private_network, ip: "192.168.60.4"
  end

  # Application server 2.
  config.vm.define "app2" do |app|
    app.vm.hostname = "orc-app2.test"
    app.vm.network :private_network, ip: "192.168.60.5"
  end

  # Database server.
  config.vm.define "db" do |db|
    db.vm.hostname = "orc-db.test"
    db.vm.network :private_network, ip: "192.168.60.6"
  end
end

Here's my hosts.ini file:

# Application servers
[app]
192.168.60.4
192.168.60.5

# Database server
[db]
192.168.60.6:2201

# Group 'multi' with all servers
[multi:children]
app
db

# Variables that will be applied to all servers
[multi:vars]
ansible_user=vagrant
ansible_ssh_private_key_file=~/.vagrant.d/insecure_private_key

lazytowntechie avatar Sep 03 '21 10:09 lazytowntechie

Same here! I'm also having this issue there is only one slight difference in the hosts.ini file, as I do not declare the port in the [db] machine.

Divi6 avatar Oct 08 '21 18:10 Divi6

I am also having the same issue? Can someone please help?

nitinsinghit avatar Oct 14 '21 13:10 nitinsinghit

Same here! I'm also having this issue there is only one slight difference in the hosts.ini file, as I do not declare the port in the [db] machine.

Did you figure this out?

nitinsinghit avatar Oct 14 '21 13:10 nitinsinghit

Currently having issue with running my ansible playbook after running vagrant up. image

Here's my Vagrant file:

# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  # General Vagrant VM configuration.
  config.vm.box = "geerlingguy/centos8"
  config.ssh.insert_key = false
  config.vm.synced_folder ".", "/vagrant", disabled: true
  config.vm.provider :virtualbox do |v|
    v.memory = 512
    v.linked_clone = true
  end

  # Application server 1.
  config.vm.define "app1" do |app|
    app.vm.hostname = "orc-app1.test"
    app.vm.network :private_network, ip: "192.168.60.4"
  end

  # Application server 2.
  config.vm.define "app2" do |app|
    app.vm.hostname = "orc-app2.test"
    app.vm.network :private_network, ip: "192.168.60.5"
  end

  # Database server.
  config.vm.define "db" do |db|
    db.vm.hostname = "orc-db.test"
    db.vm.network :private_network, ip: "192.168.60.6"
  end
end

Here's my hosts.ini file:

# Application servers
[app]
192.168.60.4
192.168.60.5

# Database server
[db]
192.168.60.6:2201

# Group 'multi' with all servers
[multi:children]
app
db

# Variables that will be applied to all servers
[multi:vars]
ansible_user=vagrant
ansible_ssh_private_key_file=~/.vagrant.d/insecure_private_key

Were you able to figure this out?

nitinsinghit avatar Oct 14 '21 13:10 nitinsinghit

No unfortunately, it seems to work randomly when you run vagrant up as if it's on a different ssh port every-time however I did this on my work laptop so I'll need to try it on my personal laptop and see if I get different results

lazytowntechie avatar Oct 14 '21 16:10 lazytowntechie

Can you vagrant ssh to any of the boxes? Does the file ~/.vagrant.d/insecure_private_key exist and does it have an RSA private key?

kenhia avatar Oct 16 '21 05:10 kenhia

Can you vagrant ssh to any of the boxes? Does the file ~/.vagrant.d/insecure_private_key exist and does it have an RSA private key?

yes and yes

nitinsinghit avatar Oct 18 '21 13:10 nitinsinghit

The private network / IPs defined in the Vagrantfile may have static routes in your work laptop that take precedence over the 'local private' network defined there.

I'd start by checking any routes on the computer you're running vagrant on.

You might try changing the network block as well (maybe 10.0.0.*?). If you do change the network block in the Vagrantfile, remember to change the IPs in your hosts.ini file as well.

meleschi avatar Dec 30 '21 14:12 meleschi

Thanks @meleschi Must have that IP subnet in my routes somewhere. Odd thought that so many of us do...

I changed to 192.168.99.x and got this:

The IP address configured for the host-only network is not within the
allowed ranges. Please update the address used to be within the allowed
ranges and run the command again.

  Address: 192.168.99.4
  Ranges: 192.168.56.0/21

Valid ranges can be modified in the /etc/vbox/networks.conf file. For
more information including valid format see:

  https://www.virtualbox.org/manual/ch06.html#network_hostonly

which is a subnet range that allows addresses from 192.168.56.1 - 192.168.63.254

I changed the addresses to 192.168.57.x and it worked.

mcheck avatar Jan 28 '22 05:01 mcheck

I am using the VMware_desktop provisioner rather than VirtualBox, so this comment may not be applicable to those of you using VirtualBox.

In my Vagrantfile, when I use the syntax for a private_network as> app.vm.network :private_network, ip: "192.168.60.x" each of my hosts is in a separate vmnet, and oddly I could connect to the first host, but not the other 2. Manually changing the vmnet to match the first host fixed my connectivity issues.

Reviewing the Vagrant docs, I noticed the syntax was listed as> app.vm.network "private_network", ip: "192.168.60.x" Using this syntax, Vagrant provisioned all my hosts on the same vmnet - everything worked!

After looking at the Vagrant docs again (i'm new to vagrant), I did see the :private_network syntax used for Docker, so I'm not sure what the difference really is yet.

DonPwrShellHunt avatar Apr 24 '22 12:04 DonPwrShellHunt

This is not working at all for me. I am on my personal laptop running Fedora Silverblue 36. I am getting this result: (please excuse the long paste:

[mmc@fedora adhocCommands]$ ansible multi -a "hostname"
The authenticity of host '192.168.60.4 (192.168.60.4)' can't be established.
ED25519 key fingerprint is SHA256:QUsnXefOSFqgDFGcDE3iMAW82LNxeR4jfqtRkHcDsZM.
This key is not known by any other names
The authenticity of host '192.168.60.5 (192.168.60.5)' can't be established.
ED25519 key fingerprint is SHA256:QUsnXefOSFqgDFGcDE3iMAW82LNxeR4jfqtRkHcDsZM.
This key is not known by any other names
The authenticity of host '192.168.60.6 (192.168.60.6)' can't be established.
ED25519 key fingerprint is SHA256:QUsnXefOSFqgDFGcDE3iMAW82LNxeR4jfqtRkHcDsZM.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Please type 'yes', 'no' or the fingerprint: yes
Please type 'yes', 'no' or the fingerprint: yes
Please type 'yes', 'no' or the fingerprint: yes
192.168.60.5 | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: Warning: Permanently added '192.168.60.5' (ED25519) to the list of known hosts.\r\[email protected]: Permission denied (publickey,password).",
    "unreachable": true
}
  
Please type 'yes', 'no' or the fingerprint: yes
Please type 'yes', 'no' or the fingerprint: yes
Please type 'yes', 'no' or the fingerprint: yes

has anyone figured this out????

g33kdad avatar Jun 05 '22 19:06 g33kdad

Can you vagrant ssh to any of the boxes? Does the file ~/.vagrant.d/insecure_private_key exist and does it have an RSA private key?

yes and yes

Did you find an answer to this? I am having the same issue, i think....

g33kdad avatar Jun 05 '22 20:06 g33kdad

SOLVED*

When I used the files from the github repository and not the text from the book, it worked. It would seem the version of the book I have is behind... i'll have to look into that

g33kdad avatar Jun 05 '22 20:06 g33kdad