Two ips get created, but can't disable DHCP without error. #103

Closed
purpleidea opened this Issue Dec 12, 2013 · 14 comments

Comments

Projects
None yet
3 participants
Contributor

purpleidea commented Dec 12, 2013

Hi, I've written a write up of vagrant-libvirt on Fedora 19 [1].

Here is one bug (and workaround) that I found. Fixes upstream would be awesome!
I was asked to report it:

With this Vagrantfile, you’ll get an IP address from DHCP, and a static IP address from the :ip definition. If you attempt to disable DHCP with :libvirt__dhcp_enabled => false you’ll see errors:
grep: /var/lib/libvirt/dnsmasq/*.leases: No such file or directory

[1] https://ttboj.wordpress.com/2013/12/09/vagrant-on-fedora-with-libvirt/

Cheers,
James

Collaborator

sciurus commented Dec 16, 2013

You must have at least one network interface with DHCP enabled.

Vagrant-libvirt depends on dnsmasq's DHCP leases file in order to find the IP address of the VM. It has to find this dynamic IP address before it can ssh in and set any static ip address you configured in your :ip definition in your Vagrantfile.

Speaking of #102 and #104 as well as this issue, I plan to dig into reproducing your errors and improving how vagrant-libvirt handles them as time allows.

Contributor

purpleidea commented Dec 17, 2013

Awesome, I look forward to it.

Cheers,
James

On Mon, Dec 16, 2013 at 4:02 PM, Brian Pitts notifications@github.comwrote:

You must have at least one network interface with DHCP enabled.

Vagrant-libvirt depends on dnsmasq's DHCP leases file in order to find the
IP address of the VM. It has to find this dynamic IP address before it can
ssh in and set any static ip address you configured in your :ip definition
in your Vagrantfile.

Speaking of #102 https://github.com/pradels/vagrant-libvirt/issues/102and
#104 pradels#104 as well as
this issue, I plan to dig into reproducing your errors and improving how
vagrant-libvirt handles them as time allows.


Reply to this email directly or view it on GitHubhttps://github.com/pradels/vagrant-libvirt/issues/103#issuecomment-30700205
.

Contributor

purpleidea commented Dec 17, 2013

I just hit a huge issue because of this...
So my puppetmaster (one vagrant guest) knows about the 4 other vagrant vm's because I've told it about them, and each of them gets a static ip address... Now one of the four guests tries to connect to the puppetmaster using the 'puppet agent' provisioner, and it fails... WHY? Well, it tried to connect using the OTHER ip address (the one that vagrant-libvirt insisted on with DHCP) and of course, puppet didn't know about that host.

SO it's essential that vagrant-libvirt use the static address to connect, if one is configured, and should not use or need DHCP in this instance. If no static address is provided, then it makes sense to use DHCP.

Collaborator

sciurus commented Dec 17, 2013

This problem occurs because you have two IP addresses on the same network, so linux can choose either one when routing traffic to that network. The solution is to have two different networks. One network (lets say the network named "default") should have DHCP enabled so that vagrant-libvirt can manage the VMs. The other network (for fun, lets name it "domokun") can have DHCP disabled and static ip addresses configured. Then, configure your puppet clients to talk to the puppetmaster using it's address on the domokun network.

This is what I do to manage a hadoop cluster via vagrant-libvirt. I have a default network at 192.168.122.1/24 that vagrant-libvirt uses for management, and I have a hadoop network at 192.168.1.1/24 that the nodes use to talk to each other.

Contributor

purpleidea commented Dec 18, 2013

I don't know that I agree that the guests should have to have more than one network.

IMO, if you specify a static ip address, then vagrant should use that, and not make a separate DHCP network.

Cheers

Collaborator

sciurus commented Jan 4, 2014

We need a network with DHCP because libvirt doesn't provide a usable out-of-band mechanism [0] for assigning a specific IP address to a VM. Vagrant has to be able to ssh to a VM before it can configure a static IP address. It configures it by running networking utilities and editing configuration scripts just as you would do if you had sshed in yourself and were configuring it manually. This is the same process vagrant uses to set the hostname, mount shared folders, etc. This isn't something specific to vagrant-libvirt, it's functionality any provider inherits from vagrant. All the provider needs is a way to tell vagrant what IP address the VM has. We can do this with libvirt and DHCP because athough we don't know what address libvirt will assign to the VM ahead of time, we can find it in dnsmasq's leases file.

[0] I say usable because at first glance you might think that the host element would work. However, this only works if you know all the hosts that will ever have a static IP address on the network at the time you create the network. Adding a new host later requires destroying, redefining, and restarting the network, which disconnect any running VMs from it.

Contributor

purpleidea commented Jan 4, 2014

Hmmm... I thought you could pass ip= to the kernel command line to get it to configure the ip statically for first boot ?

Would that work?

Collaborator

sciurus commented Jan 6, 2014

I think that would only work for linux, but vagrant also support the BSDs, various flavors of solaris, etc. Even if that wasn't a problem, AFAIK there's no mechanism for passing kernel boot options into the VM while using the BIOS bootloader.

Can I add a new issue? I'm working with libvirt as a provider for my vagrant project and when tap the command vagrant up --provider libvirt, I'm continuously getting this message.. "grep: /var/lib/libvirt/dnsmasq/*.leases: No such file or directory solved". The thing is I would like to connect the VMs with DHCP by eth0 interface (subnet 192.168.1.xxx) and keep using wlan0 interface (another subnet 192.168.10.xxx) in this case I'm getting a static IP.

The problem is because libvirt doesn't know how to manage the DNS?

I really doesn't know how to proceed. Any ideas about my problem?

Thanks in advance.

Collaborator

sciurus commented Jan 17, 2014

Hi ezecampoli, please open a new issue including your Vagrantfile and the output of virsh net-list and I will help you. Likely we already have fixes done or in-progress for what you are experiencing.

Contributor

purpleidea commented Jan 17, 2014

I think this issue happens because he hasn't specified DHCP for the first
private network defined...

On Fri, Jan 17, 2014 at 2:06 PM, Brian Pitts notifications@github.comwrote:

Hi ezecampoli, please open a new issue including your Vagrantfile and the
output of virsh net-list and I will help you. Likely we already have
fixes done or in-progress for what you are experiencing.


Reply to this email directly or view it on GitHubhttps://github.com/pradels/vagrant-libvirt/issues/103#issuecomment-32636702
.

Collaborator

sciurus commented Jan 17, 2014

Coming back to the original issue. There are two aspects of this that I are also tracked in other issues. We need to ensure the default network is created (#102) and has DHCP enabled (#123).

@sciurus sciurus added a commit to sciurus/vagrant-libvirt that referenced this issue Jan 18, 2014

@sciurus sciurus Fail if any existing networks configured to have DHCP do not have it.…
… Relates to #103 and #123.
4630650
Collaborator

sciurus commented Jan 18, 2014

Can we close this now?

Collaborator

sciurus commented Jul 19, 2014

@pronix close this please.

sciurus closed this Sep 29, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment