Lots more guest capabilities converted
This commit is contained in:
parent
2c362d4d28
commit
5e09577a76
|
@ -7,7 +7,7 @@ module VagrantPlugins
|
||||||
module GuestFedora
|
module GuestFedora
|
||||||
module Cap
|
module Cap
|
||||||
class ConfigureNetworks
|
class ConfigureNetworks
|
||||||
include Vagrant::Util
|
extend Vagrant::Util
|
||||||
|
|
||||||
def self.configure_networks(machine, networks)
|
def self.configure_networks(machine, networks)
|
||||||
network_scripts_dir = machine.guest.capability("network_scripts_dir")
|
network_scripts_dir = machine.guest.capability("network_scripts_dir")
|
||||||
|
@ -20,10 +20,10 @@ module VagrantPlugins
|
||||||
|
|
||||||
# Remove any previous vagrant configuration in this network
|
# Remove any previous vagrant configuration in this network
|
||||||
# interface's configuration files.
|
# interface's configuration files.
|
||||||
vm.communicate.sudo("touch #{network_scripts_dir}/ifcfg-p7p#{network[:interface]}")
|
machine.communicate.sudo("touch #{network_scripts_dir}/ifcfg-p7p#{network[:interface]}")
|
||||||
vm.communicate.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' #{network_scripts_dir}/ifcfg-p7p#{network[:interface]} > /tmp/vagrant-ifcfg-p7p#{network[:interface]}")
|
machine.communicate.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' #{network_scripts_dir}/ifcfg-p7p#{network[:interface]} > /tmp/vagrant-ifcfg-p7p#{network[:interface]}")
|
||||||
vm.communicate.sudo("cat /tmp/vagrant-ifcfg-p7p#{network[:interface]} > #{network_scripts_dir}/ifcfg-p7p#{network[:interface]}")
|
machine.communicate.sudo("cat /tmp/vagrant-ifcfg-p7p#{network[:interface]} > #{network_scripts_dir}/ifcfg-p7p#{network[:interface]}")
|
||||||
vm.communicate.sudo("rm /tmp/vagrant-ifcfg-p7p#{network[:interface]}")
|
machine.communicate.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.
|
||||||
|
@ -35,17 +35,17 @@ module VagrantPlugins
|
||||||
temp.write(entry)
|
temp.write(entry)
|
||||||
temp.close
|
temp.close
|
||||||
|
|
||||||
vm.communicate.upload(temp.path, "/tmp/vagrant-network-entry_#{network[:interface]}")
|
machine.communicate.upload(temp.path, "/tmp/vagrant-network-entry_#{network[:interface]}")
|
||||||
end
|
end
|
||||||
|
|
||||||
# Bring down all the interfaces we're reconfiguring. By bringing down
|
# Bring down all the interfaces we're reconfiguring. By bringing down
|
||||||
# each specifically, we avoid reconfiguring p7p (the NAT interface) so
|
# each specifically, we avoid reconfiguring p7p (the NAT interface) so
|
||||||
# SSH never dies.
|
# SSH never dies.
|
||||||
interfaces.each do |interface|
|
interfaces.each do |interface|
|
||||||
vm.communicate.sudo("/sbin/ifdown p7p#{interface} 2> /dev/null", :error_check => false)
|
machine.communicate.sudo("/sbin/ifdown p7p#{interface} 2> /dev/null", :error_check => false)
|
||||||
vm.communicate.sudo("cat /tmp/vagrant-network-entry_#{interface} >> #{network_scripts_dir}/ifcfg-p7p#{interface}")
|
machine.communicate.sudo("cat /tmp/vagrant-network-entry_#{interface} >> #{network_scripts_dir}/ifcfg-p7p#{interface}")
|
||||||
vm.communicate.sudo("rm /tmp/vagrant-network-entry_#{interface}")
|
machine.communicate.sudo("rm /tmp/vagrant-network-entry_#{interface}")
|
||||||
vm.communicate.sudo("/sbin/ifup p7p#{interface} 2> /dev/null")
|
machine.communicate.sudo("/sbin/ifup p7p#{interface} 2> /dev/null")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,16 +6,11 @@ module VagrantPlugins
|
||||||
name "Fedora guest"
|
name "Fedora guest"
|
||||||
description "Fedora guest support."
|
description "Fedora guest support."
|
||||||
|
|
||||||
guest("fedora", "linux") do
|
guest("fedora", "redhat") do
|
||||||
require File.expand_path("../guest", __FILE__)
|
require File.expand_path("../guest", __FILE__)
|
||||||
Guest
|
Guest
|
||||||
end
|
end
|
||||||
|
|
||||||
guest_capability("fedora", "change_host_name") do
|
|
||||||
require_relative "cap/change_host_name"
|
|
||||||
Cap::ChangeHostName
|
|
||||||
end
|
|
||||||
|
|
||||||
guest_capability("fedora", "configure_networks") do
|
guest_capability("fedora", "configure_networks") do
|
||||||
require_relative "cap/configure_networks"
|
require_relative "cap/configure_networks"
|
||||||
Cap::ConfigureNetworks
|
Cap::ConfigureNetworks
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
module VagrantPlugins
|
||||||
|
module GuestFreeBSD
|
||||||
|
module Cap
|
||||||
|
class ChangeHostName
|
||||||
|
def self.change_host_name(machine, name)
|
||||||
|
machine.communicate.tap do |comm|
|
||||||
|
if !comm.test("sudo hostname --fqdn | grep '#{name}'")
|
||||||
|
comm.sudo("echo 'hostname=#{name.split('.')[0]}' > /etc/conf.d/hostname")
|
||||||
|
comm.sudo("sed -i 's@^\\(127[.]0[.]0[.]1[[:space:]]\\+\\)@\\1#{name} #{name.split('.')[0]} @' /etc/hosts")
|
||||||
|
comm.sudo("hostname #{name.split('.')[0]}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,43 @@
|
||||||
|
require "tempfile"
|
||||||
|
|
||||||
|
require "vagrant/util/template_renderer"
|
||||||
|
|
||||||
|
module VagrantPlugins
|
||||||
|
module GuestFreeBSD
|
||||||
|
module Cap
|
||||||
|
class ChangeHostName
|
||||||
|
extend Vagrant::Util
|
||||||
|
|
||||||
|
def self.configure_networks(machine, networks)
|
||||||
|
machine.communicate.tap do |comm|
|
||||||
|
# Remove any previous host only network additions to the interface file
|
||||||
|
comm.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/conf.d/net > /tmp/vagrant-network-interfaces")
|
||||||
|
comm.sudo("cat /tmp/vagrant-network-interfaces > /etc/conf.d/net")
|
||||||
|
comm.sudo("rm /tmp/vagrant-network-interfaces")
|
||||||
|
|
||||||
|
# Configure each network interface
|
||||||
|
networks.each do |network|
|
||||||
|
entry = TemplateRenderer.render("guests/gentoo/network_#{network[:type]}",
|
||||||
|
:options => network)
|
||||||
|
|
||||||
|
# Upload the entry to a temporary location
|
||||||
|
temp = Tempfile.new("vagrant")
|
||||||
|
temp.binmode
|
||||||
|
temp.write(entry)
|
||||||
|
temp.close
|
||||||
|
|
||||||
|
comm.upload(temp.path, "/tmp/vagrant-network-entry")
|
||||||
|
|
||||||
|
# Configure the interface
|
||||||
|
comm.sudo("ln -fs /etc/init.d/net.lo /etc/init.d/net.eth#{network[:interface]}")
|
||||||
|
comm.sudo("/etc/init.d/net.eth#{network[:interface]} stop 2> /dev/null")
|
||||||
|
comm.sudo("cat /tmp/vagrant-network-entry >> /etc/conf.d/net")
|
||||||
|
comm.sudo("rm /tmp/vagrant-network-entry")
|
||||||
|
comm.sudo("/etc/init.d/net.eth#{network[:interface]} start")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,55 +1,9 @@
|
||||||
require 'tempfile'
|
|
||||||
|
|
||||||
require "vagrant"
|
|
||||||
require 'vagrant/util/template_renderer'
|
|
||||||
|
|
||||||
require Vagrant.source_root.join("plugins/guests/linux/guest")
|
|
||||||
|
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
module GuestGentoo
|
module GuestGentoo
|
||||||
class Guest < VagrantPlugins::GuestLinux::Guest
|
class Guest < Vagrant.plugin("2", :guest)
|
||||||
# Make the TemplateRenderer top-level
|
|
||||||
include Vagrant::Util
|
|
||||||
|
|
||||||
def detect?(machine)
|
def detect?(machine)
|
||||||
machine.communicate.test("cat /etc/gentoo-release")
|
machine.communicate.test("cat /etc/gentoo-release")
|
||||||
end
|
end
|
||||||
|
|
||||||
def configure_networks(networks)
|
|
||||||
# Remove any previous host only network additions to the interface file
|
|
||||||
vm.communicate.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/conf.d/net > /tmp/vagrant-network-interfaces")
|
|
||||||
vm.communicate.sudo("cat /tmp/vagrant-network-interfaces > /etc/conf.d/net")
|
|
||||||
vm.communicate.sudo("rm /tmp/vagrant-network-interfaces")
|
|
||||||
|
|
||||||
# Configure each network interface
|
|
||||||
networks.each do |network|
|
|
||||||
entry = TemplateRenderer.render("guests/gentoo/network_#{network[:type]}",
|
|
||||||
:options => network)
|
|
||||||
|
|
||||||
# Upload the entry to a temporary location
|
|
||||||
temp = Tempfile.new("vagrant")
|
|
||||||
temp.binmode
|
|
||||||
temp.write(entry)
|
|
||||||
temp.close
|
|
||||||
|
|
||||||
vm.communicate.upload(temp.path, "/tmp/vagrant-network-entry")
|
|
||||||
|
|
||||||
# Configure the interface
|
|
||||||
vm.communicate.sudo("ln -fs /etc/init.d/net.lo /etc/init.d/net.eth#{network[:interface]}")
|
|
||||||
vm.communicate.sudo("/etc/init.d/net.eth#{network[:interface]} stop 2> /dev/null")
|
|
||||||
vm.communicate.sudo("cat /tmp/vagrant-network-entry >> /etc/conf.d/net")
|
|
||||||
vm.communicate.sudo("rm /tmp/vagrant-network-entry")
|
|
||||||
vm.communicate.sudo("/etc/init.d/net.eth#{network[:interface]} start")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def change_host_name(name)
|
|
||||||
if !vm.communicate.test("sudo hostname --fqdn | grep '#{name}'")
|
|
||||||
vm.communicate.sudo("echo 'hostname=#{name.split('.')[0]}' > /etc/conf.d/hostname")
|
|
||||||
vm.communicate.sudo("sed -i 's@^\\(127[.]0[.]0[.]1[[:space:]]\\+\\)@\\1#{name} #{name.split('.')[0]} @' /etc/hosts")
|
|
||||||
vm.communicate.sudo("hostname #{name.split('.')[0]}")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,6 +10,16 @@ module VagrantPlugins
|
||||||
require File.expand_path("../guest", __FILE__)
|
require File.expand_path("../guest", __FILE__)
|
||||||
Guest
|
Guest
|
||||||
end
|
end
|
||||||
|
|
||||||
|
guest_capability("gentoo", "change_host_name") do
|
||||||
|
require_relative "cap/change_host_name"
|
||||||
|
Cap::ChangeHostName
|
||||||
|
end
|
||||||
|
|
||||||
|
guest_capability("gentoo", "configure_networks") do
|
||||||
|
require_relative "cap/configure_networks"
|
||||||
|
Cap::ConfigureNetworks
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
module VagrantPlugins
|
||||||
|
module GuestOpenBSD
|
||||||
|
module Cap
|
||||||
|
class Halt
|
||||||
|
def self.halt(machine)
|
||||||
|
begin
|
||||||
|
machine.communicate.sudo("shutdown -p -h now")
|
||||||
|
rescue IOError
|
||||||
|
# Do nothing, because it probably means the machine shut down
|
||||||
|
# and SSH connection was lost.
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,18 +1,12 @@
|
||||||
require "vagrant"
|
require "vagrant"
|
||||||
|
|
||||||
require Vagrant.source_root.join("plugins/guests/linux/guest")
|
|
||||||
|
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
module GuestOpenBSD
|
module GuestOpenBSD
|
||||||
class Guest < VagrantPlugins::GuestLinux::Guest
|
class Guest < Vagrant.plugin("2", :guest)
|
||||||
def detect?(machine)
|
def detect?(machine)
|
||||||
# TODO: OpenBSD detection
|
# TODO: OpenBSD detection
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
def halt
|
|
||||||
vm.communicate.sudo("shutdown -p -h now")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,6 +10,11 @@ module VagrantPlugins
|
||||||
require File.expand_path("../guest", __FILE__)
|
require File.expand_path("../guest", __FILE__)
|
||||||
Guest
|
Guest
|
||||||
end
|
end
|
||||||
|
|
||||||
|
guest_capability("openbsd", "halt") do
|
||||||
|
require_relative "cap/halt"
|
||||||
|
Cap::Halt
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
module VagrantPlugins
|
||||||
|
module GuestPld
|
||||||
|
module Cap
|
||||||
|
class NetworkScriptsDir
|
||||||
|
def self.network_scripts_dir(machine)
|
||||||
|
"/etc/sysconfig/interfaces"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,17 +1,11 @@
|
||||||
require "vagrant"
|
require "vagrant"
|
||||||
|
|
||||||
require Vagrant.source_root.join("plugins/guests/redhat/guest")
|
|
||||||
|
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
module GuestPld
|
module GuestPld
|
||||||
class Guest < VagrantPlugins::GuestRedHat::Guest
|
class Guest < Vagrant.plugin("2", :guest)
|
||||||
def detect?(machine)
|
def detect?(machine)
|
||||||
machine.communicate.test("cat /etc/pld-release")
|
machine.communicate.test("cat /etc/pld-release")
|
||||||
end
|
end
|
||||||
|
|
||||||
def network_scripts_dir
|
|
||||||
'/etc/sysconfig/interfaces/'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,6 +10,11 @@ module VagrantPlugins
|
||||||
require File.expand_path("../guest", __FILE__)
|
require File.expand_path("../guest", __FILE__)
|
||||||
Guest
|
Guest
|
||||||
end
|
end
|
||||||
|
|
||||||
|
guest_capability("pld", "network_scripts_dir") do
|
||||||
|
require_relative "cap/network_scripts_dir"
|
||||||
|
Cap::NetworkScriptsDir
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
module GuestFedora
|
module GuestRedHat
|
||||||
module Cap
|
module Cap
|
||||||
class ChangeHostName
|
class ChangeHostName
|
||||||
def self.change_host_name(machine, name)
|
def self.change_host_name(machine, name)
|
|
@ -0,0 +1,55 @@
|
||||||
|
require "set"
|
||||||
|
require "tempfile"
|
||||||
|
|
||||||
|
require "vagrant/util/template_renderer"
|
||||||
|
|
||||||
|
module VagrantPlugins
|
||||||
|
module GuestRedHat
|
||||||
|
module Cap
|
||||||
|
class ConfigureNetworks
|
||||||
|
extend Vagrant::Util
|
||||||
|
|
||||||
|
def self.configure_networks(machine, networks)
|
||||||
|
network_scripts_dir = machine.guest.capability("network_scripts_dir")
|
||||||
|
|
||||||
|
# Accumulate the configurations to add to the interfaces file as
|
||||||
|
# well as what interfaces we're actually configuring since we use that
|
||||||
|
# later.
|
||||||
|
interfaces = Set.new
|
||||||
|
networks.each do |network|
|
||||||
|
interfaces.add(network[:interface])
|
||||||
|
|
||||||
|
# Remove any previous vagrant configuration in this network interface's
|
||||||
|
# configuration files.
|
||||||
|
machine.communicate.sudo("touch #{network_scripts_dir}/ifcfg-eth#{network[:interface]}")
|
||||||
|
machine.communicate.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' #{network_scripts_dir}/ifcfg-eth#{network[:interface]} > /tmp/vagrant-ifcfg-eth#{network[:interface]}")
|
||||||
|
machine.communicate.sudo("cat /tmp/vagrant-ifcfg-eth#{network[:interface]} > #{network_scripts_dir}/ifcfg-eth#{network[:interface]}")
|
||||||
|
machine.communicate.sudo("rm /tmp/vagrant-ifcfg-eth#{network[:interface]}")
|
||||||
|
|
||||||
|
# Render and upload the network entry file to a deterministic
|
||||||
|
# temporary location.
|
||||||
|
entry = TemplateRenderer.render("guests/redhat/network_#{network[:type]}",
|
||||||
|
:options => network)
|
||||||
|
|
||||||
|
temp = Tempfile.new("vagrant")
|
||||||
|
temp.binmode
|
||||||
|
temp.write(entry)
|
||||||
|
temp.close
|
||||||
|
|
||||||
|
machine.communicate.upload(temp.path, "/tmp/vagrant-network-entry_#{network[:interface]}")
|
||||||
|
end
|
||||||
|
|
||||||
|
# Bring down all the interfaces we're reconfiguring. By bringing down
|
||||||
|
# each specifically, we avoid reconfiguring eth0 (the NAT interface) so
|
||||||
|
# SSH never dies.
|
||||||
|
interfaces.each do |interface|
|
||||||
|
machine.communicate.sudo("/sbin/ifdown eth#{interface} 2> /dev/null", :error_check => false)
|
||||||
|
machine.communicate.sudo("cat /tmp/vagrant-network-entry_#{interface} >> #{network_scripts_dir}/ifcfg-eth#{interface}")
|
||||||
|
machine.communicate.sudo("rm /tmp/vagrant-network-entry_#{interface}")
|
||||||
|
machine.communicate.sudo("/sbin/ifup eth#{interface} 2> /dev/null")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,11 @@
|
||||||
|
module VagrantPlugins
|
||||||
|
module GuestRedHat
|
||||||
|
module Cap
|
||||||
|
class NetworkScriptsDir
|
||||||
|
def self.network_scripts_dir(machine)
|
||||||
|
"/etc/sysconfig/network-scripts"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,78 +1,11 @@
|
||||||
require 'set'
|
|
||||||
require 'tempfile'
|
|
||||||
|
|
||||||
require "vagrant"
|
require "vagrant"
|
||||||
require 'vagrant/util/template_renderer'
|
|
||||||
|
|
||||||
require Vagrant.source_root.join("plugins/guests/linux/guest")
|
|
||||||
|
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
module GuestRedHat
|
module GuestRedHat
|
||||||
class Guest < VagrantPlugins::GuestLinux::Guest
|
class Guest < Vagrant.plugin("2", :guest)
|
||||||
# Make the TemplateRenderer top-level
|
|
||||||
include Vagrant::Util
|
|
||||||
|
|
||||||
def detect?(machine)
|
def detect?(machine)
|
||||||
machine.communicate.test("cat /etc/redhat-release")
|
machine.communicate.test("cat /etc/redhat-release")
|
||||||
end
|
end
|
||||||
|
|
||||||
def configure_networks(networks)
|
|
||||||
# Accumulate the configurations to add to the interfaces file as
|
|
||||||
# well as what interfaces we're actually configuring since we use that
|
|
||||||
# later.
|
|
||||||
interfaces = Set.new
|
|
||||||
networks.each do |network|
|
|
||||||
interfaces.add(network[:interface])
|
|
||||||
|
|
||||||
# Remove any previous vagrant configuration in this network interface's
|
|
||||||
# configuration files.
|
|
||||||
vm.communicate.sudo("touch #{network_scripts_dir}/ifcfg-eth#{network[:interface]}")
|
|
||||||
vm.communicate.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' #{network_scripts_dir}/ifcfg-eth#{network[:interface]} > /tmp/vagrant-ifcfg-eth#{network[:interface]}")
|
|
||||||
vm.communicate.sudo("cat /tmp/vagrant-ifcfg-eth#{network[:interface]} > #{network_scripts_dir}/ifcfg-eth#{network[:interface]}")
|
|
||||||
vm.communicate.sudo("rm /tmp/vagrant-ifcfg-eth#{network[:interface]}")
|
|
||||||
|
|
||||||
# Render and upload the network entry file to a deterministic
|
|
||||||
# temporary location.
|
|
||||||
entry = TemplateRenderer.render("guests/redhat/network_#{network[:type]}",
|
|
||||||
:options => network)
|
|
||||||
|
|
||||||
temp = Tempfile.new("vagrant")
|
|
||||||
temp.binmode
|
|
||||||
temp.write(entry)
|
|
||||||
temp.close
|
|
||||||
|
|
||||||
vm.communicate.upload(temp.path, "/tmp/vagrant-network-entry_#{network[:interface]}")
|
|
||||||
end
|
|
||||||
|
|
||||||
# Bring down all the interfaces we're reconfiguring. By bringing down
|
|
||||||
# each specifically, we avoid reconfiguring eth0 (the NAT interface) so
|
|
||||||
# SSH never dies.
|
|
||||||
interfaces.each do |interface|
|
|
||||||
vm.communicate.sudo("/sbin/ifdown eth#{interface} 2> /dev/null", :error_check => false)
|
|
||||||
vm.communicate.sudo("cat /tmp/vagrant-network-entry_#{interface} >> #{network_scripts_dir}/ifcfg-eth#{interface}")
|
|
||||||
vm.communicate.sudo("rm /tmp/vagrant-network-entry_#{interface}")
|
|
||||||
vm.communicate.sudo("/sbin/ifup eth#{interface} 2> /dev/null")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# The path to the directory with the network configuration scripts.
|
|
||||||
# This is pulled out into its own directory since there are other
|
|
||||||
# operating systems (SuSE) which behave similarly but with a different
|
|
||||||
# path to the network scripts.
|
|
||||||
def network_scripts_dir
|
|
||||||
'/etc/sysconfig/network-scripts'
|
|
||||||
end
|
|
||||||
|
|
||||||
def change_host_name(name)
|
|
||||||
vm.communicate.tap do |comm|
|
|
||||||
# Only do this if the hostname is not already set
|
|
||||||
if !comm.test("sudo hostname | grep '#{name}'")
|
|
||||||
comm.sudo("sed -i 's/\\(HOSTNAME=\\).*/\\1#{name}/' /etc/sysconfig/network")
|
|
||||||
comm.sudo("hostname #{name}")
|
|
||||||
comm.sudo("sed -i 's@^\\(127[.]0[.]0[.]1[[:space:]]\\+\\)@\\1#{name} #{name.split('.')[0]} @' /etc/hosts")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,6 +10,21 @@ module VagrantPlugins
|
||||||
require File.expand_path("../guest", __FILE__)
|
require File.expand_path("../guest", __FILE__)
|
||||||
Guest
|
Guest
|
||||||
end
|
end
|
||||||
|
|
||||||
|
guest_capability("redhat", "change_host_name") do
|
||||||
|
require_relative "cap/change_host_name"
|
||||||
|
Cap::ChangeHostName
|
||||||
|
end
|
||||||
|
|
||||||
|
guest_capability("redhat", "configure_networks") do
|
||||||
|
require_relative "cap/configure_networks"
|
||||||
|
Cap::ConfigureNetworks
|
||||||
|
end
|
||||||
|
|
||||||
|
guest_capability("redhat", "network_scripts_dir") do
|
||||||
|
require_relative "cap/network_scripts_dir"
|
||||||
|
Cap::NetworkScriptsDir
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue