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 up" fails setting up multi host (host-only) environments with RHEL5 #381

Closed rubiojr closed 13 years ago

rubiojr commented 13 years ago

The culprit seems to be that /etc/sysconfig/network-scripts/ifcfg-eth1 does not exist (the base box was created with a single NIC):

sudo sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/sysconfig/network-scripts/ifcfg-eth1 > /tmp/vagrant-ifcfg-eth1

The command fails and vagrant up is aborted.

Env:

Vagrant 0.7.5 Vagrant Box is CentOS 5 based VirtualBox host is CentOS 5 Vagrantfile: https://gist.github.com/1004182

Output:

VirtualBox Version: 4.0.6 [v2v] Running any VM customizations... [v2v] Clearing any previously set forwarded ports... [v2v] Forwarding ports... [v2v] -- ssh: 22 => 2222 (adapter 1) [v2v] Creating shared folders metadata... [v2v] Preparing host only network... [v2v] Creating new host only network for environment... [v2v] Booting VM... [v2v] Waiting for VM to boot. This can take a few minutes. [v2v] VM booted and ready for use! [v2v] Enabling host only network... The following SSH command responded with a non-zero exit status. Vagrant assumes that this means the command failed!

sudo sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/sysconfig/network-scripts/ifcfg-eth1 > /tmp/vagrant-ifcfg-eth1

The output of the command prior to failing is outputted below:

sed: can't read /etc/sysconfig/network-scripts/ifcfg-eth1: No such file or directory

rubiojr commented 13 years ago

This little patch fixes the issue:

--- lib/vagrant/systems/redhat.rb.orig  2011-06-02 12:46:20.636416086 +0200
+++ lib/vagrant/systems/redhat.rb   2011-06-02 12:29:40.854435464 +0200
@@ -6,6 +6,7 @@
         # interface file.
         vm.ssh.execute do |ssh|
           # Clear out any previous entries
+          ssh.exec!("sudo touch /etc/sysconfig/network-scripts/ifcfg-eth#{net_options[:adapter]}")
           ssh.exec!("sudo sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/sysconfig/network-scripts/ifcfg-eth#{net_options[:adapter]} > /tmp/vagrant-ifcfg-eth#{net_options[:adapter]}")
           ssh.exec!("sudo su -c 'cat /tmp/vagrant-ifcfg-eth#{net_options[:adapter]} > /etc/sysconfig/network-scripts/ifcfg-eth#{net_options[:adapter]}'")
         end
mitchellh commented 13 years ago

Thanks! I've incorporated your patch and will push it shortly.