Guests should clean up after themselves
This commit is contained in:
parent
092e8a95b3
commit
3561c1c5ba
|
@ -70,7 +70,6 @@ module Vagrant
|
||||||
networks_to_configure = networks.select { |n| n[:_auto_config] }
|
networks_to_configure = networks.select { |n| n[:_auto_config] }
|
||||||
env[:ui].info I18n.t("vagrant.actions.vm.network.configuring")
|
env[:ui].info I18n.t("vagrant.actions.vm.network.configuring")
|
||||||
env[:vm].guest.configure_networks(networks_to_configure)
|
env[:vm].guest.configure_networks(networks_to_configure)
|
||||||
env[:vm].channel.sudo("su -c 'rm /tmp/vagrant-*'")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ module Vagrant
|
||||||
# Remove previous Vagrant-managed network interfaces
|
# Remove previous Vagrant-managed network interfaces
|
||||||
vm.channel.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/rc.conf > /tmp/vagrant-network-interfaces")
|
vm.channel.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/rc.conf > /tmp/vagrant-network-interfaces")
|
||||||
vm.channel.sudo("cat /tmp/vagrant-network-interfaces > /etc/rc.conf")
|
vm.channel.sudo("cat /tmp/vagrant-network-interfaces > /etc/rc.conf")
|
||||||
|
vm.channel.sudo("rm /tmp/vagrant-network-interfaces")
|
||||||
|
|
||||||
# Configure the network interfaces
|
# Configure the network interfaces
|
||||||
interfaces = Set.new
|
interfaces = Set.new
|
||||||
|
@ -45,6 +46,7 @@ module Vagrant
|
||||||
|
|
||||||
# Reconfigure the network interfaces
|
# Reconfigure the network interfaces
|
||||||
vm.channel.sudo("cat /tmp/vagrant-network-entry >> /etc/rc.conf")
|
vm.channel.sudo("cat /tmp/vagrant-network-entry >> /etc/rc.conf")
|
||||||
|
vm.channel.sudo("rm /tmp/vagrant-network-entry")
|
||||||
vm.channel.sudo("/etc/rc.d/network restart")
|
vm.channel.sudo("/etc/rc.d/network restart")
|
||||||
|
|
||||||
interfaces.each do |interface|
|
interfaces.each do |interface|
|
||||||
|
|
|
@ -14,6 +14,7 @@ module Vagrant
|
||||||
# from the interface file.
|
# from the interface file.
|
||||||
vm.channel.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/network/interfaces > /tmp/vagrant-network-interfaces")
|
vm.channel.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/network/interfaces > /tmp/vagrant-network-interfaces")
|
||||||
vm.channel.sudo("su -c 'cat /tmp/vagrant-network-interfaces > /etc/network/interfaces'")
|
vm.channel.sudo("su -c 'cat /tmp/vagrant-network-interfaces > /etc/network/interfaces'")
|
||||||
|
vm.channel.sudo("rm /tmp/vagrant-network-interfaces")
|
||||||
|
|
||||||
# Accumulate the configurations to add to the interfaces file as
|
# Accumulate the configurations to add to the interfaces file as
|
||||||
# well as what interfaces we're actually configuring since we use that
|
# well as what interfaces we're actually configuring since we use that
|
||||||
|
@ -45,6 +46,7 @@ module Vagrant
|
||||||
end
|
end
|
||||||
|
|
||||||
vm.channel.sudo("cat /tmp/vagrant-network-entry >> /etc/network/interfaces")
|
vm.channel.sudo("cat /tmp/vagrant-network-entry >> /etc/network/interfaces")
|
||||||
|
vm.channel.sudo("rm /tmp/vagrant-network-entry")
|
||||||
|
|
||||||
# Bring back up each network interface, reconfigured
|
# Bring back up each network interface, reconfigured
|
||||||
interfaces.each do |interface|
|
interfaces.each do |interface|
|
||||||
|
|
|
@ -21,6 +21,7 @@ module Vagrant
|
||||||
vm.channel.sudo("touch #{network_scripts_dir}/ifcfg-p7p#{network[:interface]}")
|
vm.channel.sudo("touch #{network_scripts_dir}/ifcfg-p7p#{network[:interface]}")
|
||||||
vm.channel.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' #{network_scripts_dir}/ifcfg-p7p#{network[:interface]} > /tmp/vagrant-ifcfg-p7p#{network[:interface]}")
|
vm.channel.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' #{network_scripts_dir}/ifcfg-p7p#{network[:interface]} > /tmp/vagrant-ifcfg-p7p#{network[:interface]}")
|
||||||
vm.channel.sudo("cat /tmp/vagrant-ifcfg-p7p#{network[:interface]} > #{network_scripts_dir}/ifcfg-p7p#{network[:interface]}")
|
vm.channel.sudo("cat /tmp/vagrant-ifcfg-p7p#{network[:interface]} > #{network_scripts_dir}/ifcfg-p7p#{network[:interface]}")
|
||||||
|
vm.channel.sudo("rm /tmp/vagrant-ifcfg-p7p#{network[:interface]}")
|
||||||
|
|
||||||
# Render and upload the network entry file to a deterministic
|
# Render and upload the network entry file to a deterministic
|
||||||
# temporary location.
|
# temporary location.
|
||||||
|
@ -41,6 +42,7 @@ module Vagrant
|
||||||
interfaces.each do |interface|
|
interfaces.each do |interface|
|
||||||
vm.channel.sudo("/sbin/ifdown p7p#{interface} 2> /dev/null", :error_check => false)
|
vm.channel.sudo("/sbin/ifdown p7p#{interface} 2> /dev/null", :error_check => false)
|
||||||
vm.channel.sudo("cat /tmp/vagrant-network-entry_#{interface} >> #{network_scripts_dir}/ifcfg-p7p#{interface}")
|
vm.channel.sudo("cat /tmp/vagrant-network-entry_#{interface} >> #{network_scripts_dir}/ifcfg-p7p#{interface}")
|
||||||
|
vm.channel.sudo("rm /tmp/vagrant-network-entry_#{interface}")
|
||||||
vm.channel.sudo("/sbin/ifup p7p#{interface} 2> /dev/null")
|
vm.channel.sudo("/sbin/ifup p7p#{interface} 2> /dev/null")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -67,6 +67,8 @@ module Vagrant
|
||||||
:options => network)
|
:options => network)
|
||||||
vm.channel.upload(StringIO.new(entry), "/tmp/vagrant-network-entry")
|
vm.channel.upload(StringIO.new(entry), "/tmp/vagrant-network-entry")
|
||||||
vm.channel.sudo("su -m root -c 'cat /tmp/vagrant-network-entry >> /etc/rc.conf'")
|
vm.channel.sudo("su -m root -c 'cat /tmp/vagrant-network-entry >> /etc/rc.conf'")
|
||||||
|
vm.channel.sudo("rm /tmp/vagrant-network-entry")
|
||||||
|
|
||||||
if network[:type].to_sym == :static
|
if network[:type].to_sym == :static
|
||||||
vm.channel.sudo("ifconfig em#{network[:interface]} inet #{network[:ip]} netmask #{network[:netmask]}")
|
vm.channel.sudo("ifconfig em#{network[:interface]} inet #{network[:ip]} netmask #{network[:netmask]}")
|
||||||
elsif network[:type].to_sym == :dhcp
|
elsif network[:type].to_sym == :dhcp
|
||||||
|
|
|
@ -12,6 +12,7 @@ module Vagrant
|
||||||
# Remove any previous host only network additions to the interface file
|
# Remove any previous host only network additions to the interface file
|
||||||
vm.channel.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/conf.d/net > /tmp/vagrant-network-interfaces")
|
vm.channel.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/conf.d/net > /tmp/vagrant-network-interfaces")
|
||||||
vm.channel.sudo("cat /tmp/vagrant-network-interfaces > /etc/conf.d/net")
|
vm.channel.sudo("cat /tmp/vagrant-network-interfaces > /etc/conf.d/net")
|
||||||
|
vm.channel.sudo("rm /tmp/vagrant-network-interfaces")
|
||||||
|
|
||||||
# Configure each network interface
|
# Configure each network interface
|
||||||
networks.each do |network|
|
networks.each do |network|
|
||||||
|
@ -30,6 +31,7 @@ module Vagrant
|
||||||
vm.channel.sudo("ln -fs /etc/init.d/net.lo /etc/init.d/net.eth#{network[:interface]}")
|
vm.channel.sudo("ln -fs /etc/init.d/net.lo /etc/init.d/net.eth#{network[:interface]}")
|
||||||
vm.channel.sudo("/etc/init.d/net.eth#{network[:interface]} stop 2> /dev/null")
|
vm.channel.sudo("/etc/init.d/net.eth#{network[:interface]} stop 2> /dev/null")
|
||||||
vm.channel.sudo("cat /tmp/vagrant-network-entry >> /etc/conf.d/net")
|
vm.channel.sudo("cat /tmp/vagrant-network-entry >> /etc/conf.d/net")
|
||||||
|
vm.channel.sudo("rm /tmp/vagrant-network-entry")
|
||||||
vm.channel.sudo("/etc/init.d/net.eth#{network[:interface]} start")
|
vm.channel.sudo("/etc/init.d/net.eth#{network[:interface]} start")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,6 +22,7 @@ module Vagrant
|
||||||
vm.channel.sudo("touch #{network_scripts_dir}/ifcfg-eth#{network[:interface]}")
|
vm.channel.sudo("touch #{network_scripts_dir}/ifcfg-eth#{network[:interface]}")
|
||||||
vm.channel.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' #{network_scripts_dir}/ifcfg-eth#{network[:interface]} > /tmp/vagrant-ifcfg-eth#{network[:interface]}")
|
vm.channel.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' #{network_scripts_dir}/ifcfg-eth#{network[:interface]} > /tmp/vagrant-ifcfg-eth#{network[:interface]}")
|
||||||
vm.channel.sudo("cat /tmp/vagrant-ifcfg-eth#{network[:interface]} > #{network_scripts_dir}/ifcfg-eth#{network[:interface]}")
|
vm.channel.sudo("cat /tmp/vagrant-ifcfg-eth#{network[:interface]} > #{network_scripts_dir}/ifcfg-eth#{network[:interface]}")
|
||||||
|
vm.channel.sudo("rm /tmp/vagrant-ifcfg-eth#{network[:interface]}")
|
||||||
|
|
||||||
# Render and upload the network entry file to a deterministic
|
# Render and upload the network entry file to a deterministic
|
||||||
# temporary location.
|
# temporary location.
|
||||||
|
@ -42,6 +43,7 @@ module Vagrant
|
||||||
interfaces.each do |interface|
|
interfaces.each do |interface|
|
||||||
vm.channel.sudo("/sbin/ifdown eth#{interface} 2> /dev/null", :error_check => false)
|
vm.channel.sudo("/sbin/ifdown eth#{interface} 2> /dev/null", :error_check => false)
|
||||||
vm.channel.sudo("cat /tmp/vagrant-network-entry_#{interface} >> #{network_scripts_dir}/ifcfg-eth#{interface}")
|
vm.channel.sudo("cat /tmp/vagrant-network-entry_#{interface} >> #{network_scripts_dir}/ifcfg-eth#{interface}")
|
||||||
|
vm.channel.sudo("rm /tmp/vagrant-network-entry_#{interface}")
|
||||||
vm.channel.sudo("/sbin/ifup eth#{interface} 2> /dev/null")
|
vm.channel.sudo("/sbin/ifup eth#{interface} 2> /dev/null")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue