hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.
https://www.vagrantup.com
Other
26.18k stars 4.43k forks source link

Vagrant doesn't work on Fedora 20 with libvirt #4104

Closed purpleidea closed 10 years ago

purpleidea commented 10 years ago

After building a Fedora 20 base box, and testing it with vagrant-libvirt, I would see this error:

The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

/sbin/ifdown 

Stdout from the command:

Stderr from the command:

usage: ifdown 

It seemed weird that vagrant was getting the syntax wrong. Tracing this, got me:

 INFO interface: info: Configuring and enabling network interfaces...
 INFO interface: info: ==> annex1: Configuring and enabling network interfaces...
 INFO ssh: SSH is ready!
 INFO guest: Execute capability: configure_networks [#, [{:type=>:static, :ip=>"192.168.143.3", :netmask=>"255.255.255.0", :interface=>1}, {:type=>:static, :ip=>"192.168.142.101", :netmask=>"255.255.255.0", :interface=>2}]] (fedora)
 INFO ssh: SSH is ready!
 INFO guest: Execute capability: network_scripts_dir [#] (fedora)
 INFO ssh: Execute: /usr/sbin/biosdevname -d | grep Kernel | cut -f2 -d: | sed -e 's/ //;' (sudo=true)
 INFO ssh: Execute: touch /etc/sysconfig/network-scripts/ifcfg- (sudo=true)
 INFO ssh: Execute: sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/sysconfig/network-scripts/ifcfg- > /tmp/vagrant-ifcfg- (sudo=true)
 INFO ssh: Execute: cat /tmp/vagrant-ifcfg- > /etc/sysconfig/network-scripts/ifcfg- (sudo=true)
 INFO ssh: Execute: rm /tmp/vagrant-ifcfg- (sudo=true)
 INFO ssh: Execute: touch /etc/sysconfig/network-scripts/ifcfg- (sudo=true)
 INFO ssh: Execute: sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/sysconfig/network-scripts/ifcfg- > /tmp/vagrant-ifcfg- (sudo=true)
 INFO ssh: Execute: cat /tmp/vagrant-ifcfg- > /etc/sysconfig/network-scripts/ifcfg- (sudo=true)
 INFO ssh: Execute: rm /tmp/vagrant-ifcfg- (sudo=true)
 INFO ssh: Execute: cat /tmp/vagrant-network-entry_ >> /etc/sysconfig/network-scripts/ifcfg- (sudo=true)
 INFO ssh: Execute: /sbin/ifdown  (sudo=true)
 INFO retryable: Retryable exception raised: #

...

Which shows: ifcfg- which is missing something.

I traced this down to the following command in the configure_networks.rb file:

machine.communicate.sudo("/usr/sbin/biosdevname -d | grep Kernel | cut -f2 -d: | sed -e 's/ //;'") do |_, result|

which if you run, you'll see that it doesn't work in a kvm powered virtual machine. Why? The man page of biosdevname has the answer:

Returns 4 if running in a virtual machine.

Which means that this script is bogus when running in a real virtual machine that knows it is one.

I haven't worked out how to patch this yet, since I'm not as familiar with the vagrant source, so if someone else could step up this would be appreciated. Of worthy mention: running CentOS 6.5 works fine. I think this is because there doesn't seem to be a specific capability with this bug in it, and whatever the default is, works great. If someone has more info on this, that would be great too. Workarounds are appreciated.

Cheers, James

purpleidea commented 10 years ago

Label: priority -> high Label: severity -> high

CyrilPeponnet commented 10 years ago

Looks like the same as #4078 for el/centos7

gildub commented 10 years ago

I've submitted PR#4297 as workaround.

purpleidea commented 10 years ago

@gildub oh awesome, thank you! I didn't test yet, but glad to see you've written a patch for this!

gildub commented 10 years ago

@purpleidea , my pleasure! Well I finally took the time to jump on Vagrant, and I can't go back now! Let's see how this patch goes. I really don't see why Fedora is using biosdevname and RHEL is not. RHEL7 is based on Fedora18/19 so there isn't much difference.

mitchellh commented 10 years ago

The PR looks good. Thanks! This should be fixed.