commit
1277f19251
|
@ -780,6 +780,14 @@ module Vagrant
|
||||||
error_key(:virtualbox_no_name)
|
error_key(:virtualbox_no_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class VirtualBoxMountFailed < VagrantError
|
||||||
|
error_key(:virtualbox_mount_failed)
|
||||||
|
end
|
||||||
|
|
||||||
|
class VirtualBoxMountNotSupportedBSD < VagrantError
|
||||||
|
error_key(:virtualbox_mount_not_supported_bsd)
|
||||||
|
end
|
||||||
|
|
||||||
class VirtualBoxNameExists < VagrantError
|
class VirtualBoxNameExists < VagrantError
|
||||||
error_key(:virtualbox_name_exists)
|
error_key(:virtualbox_name_exists)
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,19 +5,22 @@ module VagrantPlugins
|
||||||
def self.change_host_name(machine, name)
|
def self.change_host_name(machine, name)
|
||||||
comm = machine.communicate
|
comm = machine.communicate
|
||||||
|
|
||||||
if !comm.test("hostname | grep -w '#{name}'")
|
if !comm.test("hostname -f | grep '^#{name}$'", sudo: false)
|
||||||
basename = name.split(".", 2)[0]
|
basename = name.split(".", 2)[0]
|
||||||
comm.sudo <<-EOH
|
comm.sudo <<-EOH.gsub(/^ {14}/, "")
|
||||||
hostnamectl set-hostname '#{name}'
|
set -e
|
||||||
|
|
||||||
# Remove comments and blank lines from /etc/hosts
|
# Set hostname
|
||||||
sed -i'' -e 's/#.*$//' -e '/^$/d' /etc/hosts
|
hostnamectl set-hostname '#{basename}'
|
||||||
|
|
||||||
# Prepend ourselves to /etc/hosts
|
# Remove comments and blank lines from /etc/hosts
|
||||||
grep -w '#{name}' /etc/hosts || {
|
sed -i'' -e 's/#.*$//' -e '/^$/d' /etc/hosts
|
||||||
sed -i'' '1i 127.0.0.1\\t#{name}\\t#{basename}' /etc/hosts
|
|
||||||
}
|
# Prepend ourselves to /etc/hosts
|
||||||
EOH
|
grep -w '#{name}' /etc/hosts || {
|
||||||
|
sed -i'' '1i 127.0.0.1\\t#{name}\\t#{basename}' /etc/hosts
|
||||||
|
}
|
||||||
|
EOH
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
require "ipaddr"
|
||||||
|
require "socket"
|
||||||
require "tempfile"
|
require "tempfile"
|
||||||
|
|
||||||
require_relative "../../../../lib/vagrant/util/template_renderer"
|
require_relative "../../../../lib/vagrant/util/template_renderer"
|
||||||
|
@ -11,18 +13,19 @@ module VagrantPlugins
|
||||||
def self.configure_networks(machine, networks)
|
def self.configure_networks(machine, networks)
|
||||||
comm = machine.communicate
|
comm = machine.communicate
|
||||||
|
|
||||||
commands = []
|
commands = ["set -e"]
|
||||||
interfaces = []
|
interfaces = machine.guest.capability(:network_interfaces)
|
||||||
|
|
||||||
# The result will be something like:
|
|
||||||
# eth0\nenp0s8\nenp0s9
|
|
||||||
comm.sudo("ip -o -0 addr | grep -v LOOPBACK | awk '{print $2}' | sed 's/://'") do |_, stdout|
|
|
||||||
interfaces = stdout.split("\n")
|
|
||||||
end
|
|
||||||
|
|
||||||
networks.each.with_index do |network, i|
|
networks.each.with_index do |network, i|
|
||||||
network[:device] = interfaces[network[:interface]]
|
network[:device] = interfaces[network[:interface]]
|
||||||
|
|
||||||
|
# Arch expects netmasks to be in the "24" or "64", but users may
|
||||||
|
# specify IPV4 netmasks like "255.255.255.0". This magic converts
|
||||||
|
# the netmask to the proper value.
|
||||||
|
if network[:netmask] && network[:netmask].to_s.include?(".")
|
||||||
|
network[:netmask] = (32-Math.log2((IPAddr.new(network[:netmask], Socket::AF_INET).to_i^0xffffffff)+1)).to_i
|
||||||
|
end
|
||||||
|
|
||||||
entry = TemplateRenderer.render("guests/arch/network_#{network[:type]}",
|
entry = TemplateRenderer.render("guests/arch/network_#{network[:type]}",
|
||||||
options: network,
|
options: network,
|
||||||
)
|
)
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
module VagrantPlugins
|
||||||
|
module GuestArch
|
||||||
|
module Cap
|
||||||
|
class NFS
|
||||||
|
def self.nfs_client_installed(machine)
|
||||||
|
machine.communicate.test("pacman -Q nfs-utils")
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.nfs_pre(machine)
|
||||||
|
comm = machine.communicate
|
||||||
|
|
||||||
|
# There is a bug in NFS where the rpcbind functionality is not started
|
||||||
|
# and it's not a dependency of nfs-utils. Read more here:
|
||||||
|
#
|
||||||
|
# https://bbs.archlinux.org/viewtopic.php?id=193410
|
||||||
|
#
|
||||||
|
comm.sudo <<-EOH.gsub(/^ {12}/, "")
|
||||||
|
set -e
|
||||||
|
systemctl enable rpcbind
|
||||||
|
systemctl start rpcbind
|
||||||
|
EOH
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.nfs_client_install(machine)
|
||||||
|
comm = machine.communicate
|
||||||
|
comm.sudo <<-EOH.gsub(/^ {12}/, "")
|
||||||
|
set -e
|
||||||
|
pacman --noconfirm -Syy
|
||||||
|
pacman --noconfirm -S nfs-utils ntp
|
||||||
|
EOH
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -20,6 +20,21 @@ module VagrantPlugins
|
||||||
require_relative "cap/configure_networks"
|
require_relative "cap/configure_networks"
|
||||||
Cap::ConfigureNetworks
|
Cap::ConfigureNetworks
|
||||||
end
|
end
|
||||||
|
|
||||||
|
guest_capability(:arch, :nfs_client_install) do
|
||||||
|
require_relative "cap/nfs"
|
||||||
|
Cap::NFS
|
||||||
|
end
|
||||||
|
|
||||||
|
guest_capability(:arch, :nfs_client_installed) do
|
||||||
|
require_relative "cap/nfs"
|
||||||
|
Cap::NFS
|
||||||
|
end
|
||||||
|
|
||||||
|
guest_capability(:arch, :nfs_pre) do
|
||||||
|
require_relative "cap/nfs"
|
||||||
|
Cap::NFS
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,19 +5,22 @@ module VagrantPlugins
|
||||||
def self.change_host_name(machine, name)
|
def self.change_host_name(machine, name)
|
||||||
comm = machine.communicate
|
comm = machine.communicate
|
||||||
|
|
||||||
if !comm.test("hostname | grep -w '#{name}'")
|
if !comm.test("hostname -f | grep '^#{name}$'", sudo: false)
|
||||||
basename = name.split(".", 2)[0]
|
basename = name.split(".", 2)[0]
|
||||||
comm.sudo <<-EOH
|
comm.sudo <<-EOH.gsub(/^ {14}/, "")
|
||||||
hostnamectl set-hostname '#{name}'
|
set -e
|
||||||
|
|
||||||
# Remove comments and blank lines from /etc/hosts
|
# Set hostname
|
||||||
sed -i'' -e 's/#.*$//' -e '/^$/d' /etc/hosts
|
hostnamectl set-hostname '#{basename}'
|
||||||
|
|
||||||
# Prepend ourselves to /etc/hosts
|
# Remove comments and blank lines from /etc/hosts
|
||||||
grep -w '#{name}' /etc/hosts || {
|
sed -i'' -e 's/#.*$//' -e '/^$/d' /etc/hosts
|
||||||
sed -i'' '1i 127.0.0.1\\t#{name}\\t#{basename}' /etc/hosts
|
|
||||||
}
|
# Prepend ourselves to /etc/hosts
|
||||||
EOH
|
grep -w '#{name}' /etc/hosts || {
|
||||||
|
sed -i'' '1i 127.0.0.1\\t#{name}\\t#{basename}' /etc/hosts
|
||||||
|
}
|
||||||
|
EOH
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,7 +4,7 @@ module VagrantPlugins
|
||||||
class Halt
|
class Halt
|
||||||
def self.halt(machine)
|
def self.halt(machine)
|
||||||
begin
|
begin
|
||||||
machine.communicate.sudo("/sbin/shutdown -p -h now", shell: "sh")
|
machine.communicate.sudo("/sbin/shutdown -p now", shell: "sh")
|
||||||
rescue IOError
|
rescue IOError
|
||||||
# Do nothing, because it probably means the machine shut down
|
# Do nothing, because it probably means the machine shut down
|
||||||
# and SSH connection was lost.
|
# and SSH connection was lost.
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
module VagrantPlugins
|
||||||
|
module GuestBSD
|
||||||
|
module Cap
|
||||||
|
class VirtualBox
|
||||||
|
# BSD-based guests do not currently support VirtualBox synced folders.
|
||||||
|
# Instead of raising an error about a missing capability, this defines
|
||||||
|
# the capability and then provides a more detailed error message,
|
||||||
|
# linking to sources on the Internet where the problem is
|
||||||
|
# better-described.
|
||||||
|
def self.mount_virtualbox_shared_folder(machine, name, guestpath, options)
|
||||||
|
raise Vagrant::Errors::VirtualBoxMountNotSupportedBSD
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -26,6 +26,11 @@ module VagrantPlugins
|
||||||
Cap::NFS
|
Cap::NFS
|
||||||
end
|
end
|
||||||
|
|
||||||
|
guest_capability(:bsd, :mount_virtualbox_shared_folder) do
|
||||||
|
require_relative "cap/virtualbox"
|
||||||
|
Cap::VirtualBox
|
||||||
|
end
|
||||||
|
|
||||||
guest_capability(:bsd, :remove_public_key) do
|
guest_capability(:bsd, :remove_public_key) do
|
||||||
require_relative "cap/public_key"
|
require_relative "cap/public_key"
|
||||||
Cap::PublicKey
|
Cap::PublicKey
|
||||||
|
|
|
@ -5,7 +5,7 @@ module VagrantPlugins
|
||||||
def self.change_host_name(machine, name)
|
def self.change_host_name(machine, name)
|
||||||
comm = machine.communicate
|
comm = machine.communicate
|
||||||
|
|
||||||
if !comm.test("hostname --fqdn | grep -w '#{name}'")
|
if !comm.test("hostname -f | grep '^#{name}$'", sudo: false)
|
||||||
basename = name.split(".", 2)[0]
|
basename = name.split(".", 2)[0]
|
||||||
comm.sudo("hostname '#{basename}'")
|
comm.sudo("hostname '#{basename}'")
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,13 @@ module VagrantPlugins
|
||||||
def self.change_host_name(machine, name)
|
def self.change_host_name(machine, name)
|
||||||
comm = machine.communicate
|
comm = machine.communicate
|
||||||
|
|
||||||
if !comm.test("hostname -f | grep -w '#{name}' || hostname -s | grep -w '#{name}'")
|
if !comm.test("hostname -f | grep '^#{name}$'", sudo: false)
|
||||||
basename = name.split(".", 2)[0]
|
basename = name.split(".", 2)[0]
|
||||||
|
|
||||||
comm.sudo <<-EOH.gsub(/^ {14}/, '')
|
comm.sudo <<-EOH.gsub(/^ {14}/, '')
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Set hostname
|
||||||
scutil --set ComputerName '#{name}'
|
scutil --set ComputerName '#{name}'
|
||||||
scutil --set HostName '#{name}'
|
scutil --set HostName '#{name}'
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
require "shellwords"
|
||||||
|
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
module GuestDarwin
|
module GuestDarwin
|
||||||
module Cap
|
module Cap
|
||||||
|
@ -11,9 +13,8 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.rsync_pre(machine, opts)
|
def self.rsync_pre(machine, opts)
|
||||||
machine.communicate.tap do |comm|
|
guest_path = Shellwords.escape(opts[:guestpath])
|
||||||
comm.sudo("mkdir -p '#{opts[:guestpath]}'")
|
machine.communicate.sudo("mkdir -p #{guest_path}")
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.rsync_post(machine, opts)
|
def self.rsync_post(machine, opts)
|
||||||
|
@ -21,8 +22,10 @@ module VagrantPlugins
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
guest_path = Shellwords.escape(opts[:guestpath])
|
||||||
|
|
||||||
machine.communicate.sudo(
|
machine.communicate.sudo(
|
||||||
"find '#{opts[:guestpath]}' '(' ! -user #{opts[:owner]} -or ! -group #{opts[:group]} ')' -print0 | " +
|
"find #{guest_path} '(' ! -user #{opts[:owner]} -or ! -group #{opts[:group]} ')' -print0 | " +
|
||||||
"xargs -0 chown #{opts[:owner]}:#{opts[:group]}")
|
"xargs -0 chown #{opts[:owner]}:#{opts[:group]}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,20 +2,23 @@ module VagrantPlugins
|
||||||
module GuestDebian
|
module GuestDebian
|
||||||
module Cap
|
module Cap
|
||||||
class ChangeHostName
|
class ChangeHostName
|
||||||
# For more information, please see:
|
|
||||||
#
|
|
||||||
# https://wiki.debian.org/HowTo/ChangeHostname
|
|
||||||
#
|
|
||||||
def self.change_host_name(machine, name)
|
def self.change_host_name(machine, name)
|
||||||
comm = machine.communicate
|
comm = machine.communicate
|
||||||
|
|
||||||
if !comm.test("hostname -f | grep -w '#{name}'")
|
if !comm.test("hostname -f | grep '^#{name}$'", sudo: false)
|
||||||
basename = name.split(".", 2)[0]
|
basename = name.split(".", 2)[0]
|
||||||
comm.sudo <<-EOH.gsub(/^ {14}/, '')
|
comm.sudo <<-EOH.gsub(/^ {14}/, '')
|
||||||
|
# Ensure exit on command error
|
||||||
|
set -e
|
||||||
|
|
||||||
# Set the hostname
|
# Set the hostname
|
||||||
echo '#{name}' > /etc/hostname
|
echo '#{basename}' > /etc/hostname
|
||||||
hostname -F /etc/hostname
|
hostname -F /etc/hostname
|
||||||
|
|
||||||
|
if command -v hostnamectl; then
|
||||||
|
hostnamectl set-hostname '#{basename}'
|
||||||
|
fi
|
||||||
|
|
||||||
# Remove comments and blank lines from /etc/hosts
|
# Remove comments and blank lines from /etc/hosts
|
||||||
sed -i'' -e 's/#.*$//' -e '/^$/d' /etc/hosts
|
sed -i'' -e 's/#.*$//' -e '/^$/d' /etc/hosts
|
||||||
|
|
||||||
|
@ -27,17 +30,13 @@ module VagrantPlugins
|
||||||
# Update mailname
|
# Update mailname
|
||||||
echo '#{name}' > /etc/mailname
|
echo '#{name}' > /etc/mailname
|
||||||
|
|
||||||
# Restart networking and force new DHCP
|
# Restart hostname services
|
||||||
if [ test -f /etc/init.d/hostname.sh ]; then
|
if test -f /etc/init.d/hostname; then
|
||||||
invoke-rc.d hostname.sh start
|
/etc/init.d/hostname start || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ test -f /etc/init.d/networking ]; then
|
if test -f /etc/init.d/hostname.sh; then
|
||||||
invoke-rc.d networking force-reload
|
/etc/init.d/hostname.sh start || true
|
||||||
fi
|
|
||||||
|
|
||||||
if [ test -f /etc/init.d/network-manager ]; then
|
|
||||||
invoke-rc.d network-manager force-reload
|
|
||||||
fi
|
fi
|
||||||
EOH
|
EOH
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,13 +11,9 @@ module VagrantPlugins
|
||||||
def self.configure_networks(machine, networks)
|
def self.configure_networks(machine, networks)
|
||||||
comm = machine.communicate
|
comm = machine.communicate
|
||||||
|
|
||||||
commands = []
|
commands = ["set -e"]
|
||||||
entries = []
|
entries = []
|
||||||
interfaces = []
|
interfaces = machine.guest.capability(:network_interfaces)
|
||||||
|
|
||||||
comm.sudo("ip -o -0 addr | grep -v LOOPBACK | awk '{print $2}' | sed 's/://'") do |_, stdout|
|
|
||||||
interfaces = stdout.split("\n")
|
|
||||||
end
|
|
||||||
|
|
||||||
networks.each do |network|
|
networks.each do |network|
|
||||||
network[:device] = interfaces[network[:interface]]
|
network[:device] = interfaces[network[:interface]]
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
module GuestDebian
|
module GuestDebian
|
||||||
module Cap
|
module Cap
|
||||||
class NFSClient
|
class NFS
|
||||||
def self.nfs_client_install(machine)
|
def self.nfs_client_install(machine)
|
||||||
comm = machine.communicate
|
comm = machine.communicate
|
||||||
comm.sudo <<-EOH.gsub(/^ {12}/, '')
|
comm.sudo <<-EOH.gsub(/^ {12}/, '')
|
||||||
|
set -e
|
||||||
apt-get -yqq update
|
apt-get -yqq update
|
||||||
apt-get -yqq install nfs-common portmap
|
apt-get -yqq install nfs-common portmap
|
||||||
EOH
|
EOH
|
|
@ -4,12 +4,11 @@ module VagrantPlugins
|
||||||
class RSync
|
class RSync
|
||||||
def self.rsync_install(machine)
|
def self.rsync_install(machine)
|
||||||
comm = machine.communicate
|
comm = machine.communicate
|
||||||
if !comm.test("command -v rsync")
|
comm.sudo <<-EOH.gsub(/^ {14}/, '')
|
||||||
comm.sudo <<-EOH.gsub(/^ {14}/, '')
|
set -e
|
||||||
apt-get -yqq update
|
apt-get -yqq update
|
||||||
apt-get -yqq install rsync
|
apt-get -yqq install rsync
|
||||||
EOH
|
EOH
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,8 +22,8 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
guest_capability(:debian, :nfs_client_install) do
|
guest_capability(:debian, :nfs_client_install) do
|
||||||
require_relative "cap/nfs_client"
|
require_relative "cap/nfs"
|
||||||
Cap::NFSClient
|
Cap::NFS
|
||||||
end
|
end
|
||||||
|
|
||||||
guest_capability(:debian, :rsync_install) do
|
guest_capability(:debian, :rsync_install) do
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
module VagrantPlugins
|
|
||||||
module GuestFedora
|
|
||||||
module Cap
|
|
||||||
class ChangeHostName
|
|
||||||
def self.change_host_name(machine, name)
|
|
||||||
comm = machine.communicate
|
|
||||||
|
|
||||||
if !comm.test("hostname | grep -w '#{name}'")
|
|
||||||
basename = name.split(".", 2)[0]
|
|
||||||
comm.sudo <<-EOH
|
|
||||||
echo '#{name}' > /etc/hostname
|
|
||||||
hostname -F /etc/hostname
|
|
||||||
hostnamectl set-hostname --static '#{name}'
|
|
||||||
hostnamectl set-hostname --transient '#{name}'
|
|
||||||
|
|
||||||
# Remove comments and blank lines from /etc/hosts
|
|
||||||
sed -i'' -e 's/#.*$//' -e '/^$/d' /etc/hosts
|
|
||||||
|
|
||||||
# Prepend ourselves to /etc/hosts
|
|
||||||
grep -w '#{name}' /etc/hosts || {
|
|
||||||
sed -i'' '1i 127.0.0.1\\t#{name}\\t#{basename}' /etc/hosts
|
|
||||||
}
|
|
||||||
EOH
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,135 +0,0 @@
|
||||||
require "set"
|
|
||||||
require "tempfile"
|
|
||||||
|
|
||||||
require_relative "../../../../lib/vagrant/util/retryable"
|
|
||||||
require_relative "../../../../lib/vagrant/util/template_renderer"
|
|
||||||
|
|
||||||
module VagrantPlugins
|
|
||||||
module GuestFedora
|
|
||||||
module Cap
|
|
||||||
class ConfigureNetworks
|
|
||||||
extend Vagrant::Util::Retryable
|
|
||||||
include Vagrant::Util
|
|
||||||
|
|
||||||
def self.configure_networks(machine, networks)
|
|
||||||
network_scripts_dir = machine.guest.capability("network_scripts_dir")
|
|
||||||
|
|
||||||
virtual = false
|
|
||||||
interface_names = Array.new
|
|
||||||
interface_names_by_slot = Array.new
|
|
||||||
machine.communicate.sudo("/usr/sbin/biosdevname &>/dev/null; echo $?") do |_, result|
|
|
||||||
# The above command returns:
|
|
||||||
# - '4' if /usr/sbin/biosdevname detects it is running in a virtual machine
|
|
||||||
# - '127' if /usr/sbin/biosdevname doesn't exist
|
|
||||||
virtual = true if ['4', '127'].include? result.chomp
|
|
||||||
end
|
|
||||||
|
|
||||||
if virtual
|
|
||||||
machine.communicate.sudo("ls -v /sys/class/net | egrep -v lo\\|docker") do |_, result|
|
|
||||||
interface_names = result.split("\n")
|
|
||||||
end
|
|
||||||
|
|
||||||
interface_names_by_slot = networks.map do |network|
|
|
||||||
"#{interface_names[network[:interface]]}"
|
|
||||||
end
|
|
||||||
else
|
|
||||||
machine.communicate.sudo("/usr/sbin/biosdevname -d | grep Kernel | cut -f2 -d: | sed -e 's/ //;'") do |_, result|
|
|
||||||
interface_names = result.split("\n")
|
|
||||||
end
|
|
||||||
|
|
||||||
interface_name_pairs = Array.new
|
|
||||||
interface_names.each do |interface_name|
|
|
||||||
machine.communicate.sudo("/usr/sbin/biosdevname --policy=all_ethN -i #{interface_name}") do |_, result|
|
|
||||||
interface_name_pairs.push([interface_name, result.gsub("\n", "")])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
setting_interface_names = networks.map do |network|
|
|
||||||
"eth#{network[:interface]}"
|
|
||||||
end
|
|
||||||
|
|
||||||
interface_names_by_slot = interface_names.dup
|
|
||||||
interface_name_pairs.each do |interface_name, previous_interface_name|
|
|
||||||
if setting_interface_names.index(previous_interface_name) == nil
|
|
||||||
interface_names_by_slot.delete(interface_name)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Read interface MAC addresses for later matching
|
|
||||||
mac_addresses = Array.new(interface_names.length)
|
|
||||||
interface_names.each_with_index do |ifname, index|
|
|
||||||
machine.communicate.sudo("cat /sys/class/net/#{ifname}/address") do |_, result|
|
|
||||||
mac_addresses[index] = result.strip
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# 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|
|
|
||||||
interface = nil
|
|
||||||
if network[:mac_address]
|
|
||||||
found_idx = mac_addresses.find_index(network[:mac_address])
|
|
||||||
# Ignore network if requested MAC address could not be found
|
|
||||||
next if found_idx.nil?
|
|
||||||
interface = interface_names[found_idx]
|
|
||||||
else
|
|
||||||
ifname_by_slot = interface_names_by_slot[network[:interface]-1]
|
|
||||||
# Don't overwrite if interface was already matched via MAC address
|
|
||||||
next if interfaces.include?(ifname_by_slot)
|
|
||||||
interface = ifname_by_slot
|
|
||||||
end
|
|
||||||
|
|
||||||
interfaces.add(interface)
|
|
||||||
network[:device] = interface
|
|
||||||
|
|
||||||
# Remove any previous vagrant configuration in this network
|
|
||||||
# interface's configuration files.
|
|
||||||
machine.communicate.sudo("touch #{network_scripts_dir}/ifcfg-#{interface}")
|
|
||||||
machine.communicate.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' #{network_scripts_dir}/ifcfg-#{interface} > /tmp/vagrant-ifcfg-#{interface}")
|
|
||||||
machine.communicate.sudo("cat /tmp/vagrant-ifcfg-#{interface} > #{network_scripts_dir}/ifcfg-#{interface}")
|
|
||||||
machine.communicate.sudo("rm -f /tmp/vagrant-ifcfg-#{interface}")
|
|
||||||
|
|
||||||
# Render and upload the network entry file to a deterministic
|
|
||||||
# temporary location.
|
|
||||||
entry = TemplateRenderer.render("guests/fedora/network_#{network[:type]}",
|
|
||||||
options: network)
|
|
||||||
|
|
||||||
Tempfile.open("vagrant-fedora-configure-networks") do |f|
|
|
||||||
f.binmode
|
|
||||||
f.write(entry)
|
|
||||||
f.fsync
|
|
||||||
f.close
|
|
||||||
machine.communicate.upload(f.path, "/tmp/vagrant-network-entry_#{interface}")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Bring down all the interfaces we're reconfiguring. By bringing down
|
|
||||||
# each specifically, we avoid reconfiguring p7p (the NAT interface) so
|
|
||||||
# SSH never dies.
|
|
||||||
interfaces.each do |interface|
|
|
||||||
retryable(on: Vagrant::Errors::VagrantError, tries: 3, sleep: 2) do
|
|
||||||
machine.communicate.sudo(<<-SCRIPT, error_check: true)
|
|
||||||
cat /tmp/vagrant-network-entry_#{interface} >> #{network_scripts_dir}/ifcfg-#{interface}
|
|
||||||
|
|
||||||
if command -v nmcli &>/dev/null; then
|
|
||||||
if command -v systemctl &>/dev/null && systemctl -q is-enabled NetworkManager &>/dev/null; then
|
|
||||||
nmcli c reload #{interface}
|
|
||||||
elif command -v service &>/dev/null && service NetworkManager status &>/dev/null; then
|
|
||||||
nmcli c reload #{interface}
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
/sbin/ifdown #{interface}
|
|
||||||
/sbin/ifup #{interface}
|
|
||||||
|
|
||||||
rm -f /tmp/vagrant-network-entry_#{interface}
|
|
||||||
SCRIPT
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -14,7 +14,7 @@ module VagrantPlugins
|
||||||
if version.nil?
|
if version.nil?
|
||||||
return :fedora
|
return :fedora
|
||||||
else
|
else
|
||||||
return "fedora_#{version}".to_sym
|
return :"fedora_#{version}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
module VagrantPlugins
|
|
||||||
module GuestFedora
|
|
||||||
module Cap
|
|
||||||
class NetworkScriptsDir
|
|
||||||
# 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 self.network_scripts_dir(machine)
|
|
||||||
"/etc/sysconfig/network-scripts"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -11,21 +11,6 @@ module VagrantPlugins
|
||||||
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
|
|
||||||
require_relative "cap/configure_networks"
|
|
||||||
Cap::ConfigureNetworks
|
|
||||||
end
|
|
||||||
|
|
||||||
guest_capability(:fedora, :network_scripts_dir) do
|
|
||||||
require_relative "cap/network_scripts_dir"
|
|
||||||
Cap::NetworkScriptsDir
|
|
||||||
end
|
|
||||||
|
|
||||||
guest_capability(:fedora, :flavor) do
|
guest_capability(:fedora, :flavor) do
|
||||||
require_relative "cap/flavor"
|
require_relative "cap/flavor"
|
||||||
Cap::Flavor
|
Cap::Flavor
|
||||||
|
|
|
@ -3,10 +3,9 @@ module VagrantPlugins
|
||||||
module Cap
|
module Cap
|
||||||
class ChangeHostName
|
class ChangeHostName
|
||||||
def self.change_host_name(machine, name)
|
def self.change_host_name(machine, name)
|
||||||
options = { shell: "sh" }
|
|
||||||
comm = machine.communicate
|
comm = machine.communicate
|
||||||
|
|
||||||
if !comm.test("hostname -f | grep -w '#{name}' || hostname -s | grep -w '#{name}'", options)
|
if !comm.test("hostname -f | grep '^#{name}$'", sudo: false, shell: "sh")
|
||||||
basename = name.split(".", 2)[0]
|
basename = name.split(".", 2)[0]
|
||||||
command = <<-EOH.gsub(/^ {14}/, '')
|
command = <<-EOH.gsub(/^ {14}/, '')
|
||||||
# Set the hostname
|
# Set the hostname
|
||||||
|
@ -23,7 +22,7 @@ module VagrantPlugins
|
||||||
mv /tmp/tmp-hosts /etc/hosts
|
mv /tmp/tmp-hosts /etc/hosts
|
||||||
}
|
}
|
||||||
EOH
|
EOH
|
||||||
comm.sudo(command, options)
|
comm.sudo(command, shell: "sh")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
require "shellwords"
|
||||||
|
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
module GuestFreeBSD
|
module GuestFreeBSD
|
||||||
module Cap
|
module Cap
|
||||||
|
@ -15,9 +17,8 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.rsync_pre(machine, opts)
|
def self.rsync_pre(machine, opts)
|
||||||
machine.communicate.tap do |comm|
|
guest_path = Shellwords.escape(opts[:guestpath])
|
||||||
comm.sudo("mkdir -p '#{opts[:guestpath]}'")
|
machine.communicate.sudo("mkdir -p #{guest_path}")
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.rsync_post(machine, opts)
|
def self.rsync_post(machine, opts)
|
||||||
|
@ -25,8 +26,10 @@ module VagrantPlugins
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
guest_path = Shellwords.escape(opts[:guestpath])
|
||||||
|
|
||||||
machine.communicate.sudo(
|
machine.communicate.sudo(
|
||||||
"find '#{opts[:guestpath]}' '(' ! -user #{opts[:owner]} -or ! -group #{opts[:group]} ')' -print0 | " +
|
"find #{guest_path} '(' ! -user #{opts[:owner]} -or ! -group #{opts[:group]} ')' -print0 | " +
|
||||||
"xargs -0 -r chown #{opts[:owner]}:#{opts[:group]}")
|
"xargs -0 -r chown #{opts[:owner]}:#{opts[:group]}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
module VagrantPlugins
|
|
||||||
module GuestFuntoo
|
|
||||||
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
|
|
|
@ -6,16 +6,11 @@ module VagrantPlugins
|
||||||
name "Funtoo guest"
|
name "Funtoo guest"
|
||||||
description "Funtoo guest support."
|
description "Funtoo guest support."
|
||||||
|
|
||||||
guest(:funtoo, :linux) do
|
guest(:funtoo, :gentoo) do
|
||||||
require_relative "guest"
|
require_relative "guest"
|
||||||
Guest
|
Guest
|
||||||
end
|
end
|
||||||
|
|
||||||
guest_capability(:funtoo, :change_host_name) do
|
|
||||||
require_relative "cap/change_host_name"
|
|
||||||
Cap::ChangeHostName
|
|
||||||
end
|
|
||||||
|
|
||||||
guest_capability(:funtoo, :configure_networks) do
|
guest_capability(:funtoo, :configure_networks) do
|
||||||
require_relative "cap/configure_networks"
|
require_relative "cap/configure_networks"
|
||||||
Cap::ConfigureNetworks
|
Cap::ConfigureNetworks
|
||||||
|
|
|
@ -3,12 +3,27 @@ module VagrantPlugins
|
||||||
module Cap
|
module Cap
|
||||||
class ChangeHostName
|
class ChangeHostName
|
||||||
def self.change_host_name(machine, name)
|
def self.change_host_name(machine, name)
|
||||||
machine.communicate.tap do |comm|
|
comm = machine.communicate
|
||||||
if !comm.test("sudo hostname --fqdn | grep '#{name}'")
|
|
||||||
comm.sudo("echo 'hostname=#{name.split('.')[0]}' > /etc/conf.d/hostname")
|
if !comm.test("hostname -f | grep '^#{name}$'", sudo: false)
|
||||||
comm.sudo("sed -i 's@^\\(127[.]0[.]0[.]1[[:space:]]\\+\\)@\\1#{name} #{name.split('.')[0]} @' /etc/hosts")
|
basename = name.split(".", 2)[0]
|
||||||
comm.sudo("hostname #{name.split('.')[0]}")
|
comm.sudo <<-EOH.gsub(/^ {14}/, "")
|
||||||
end
|
set -e
|
||||||
|
|
||||||
|
# Set the hostname
|
||||||
|
hostname '#{basename}'
|
||||||
|
echo "hostname=#{basename}" > /etc/conf.d/hostname
|
||||||
|
|
||||||
|
# Remove comments and blank lines from /etc/hosts
|
||||||
|
sed -i'' -e 's/#.*$//' /etc/hosts
|
||||||
|
sed -i'' -e '/^$/d' /etc/hosts
|
||||||
|
|
||||||
|
# Prepend ourselves to /etc/hosts
|
||||||
|
grep -w '#{name}' /etc/hosts || {
|
||||||
|
echo -e '127.0.0.1\\t#{name}\\t#{basename}' | cat - /etc/hosts > /tmp/tmp-hosts
|
||||||
|
mv /tmp/tmp-hosts /etc/hosts
|
||||||
|
}
|
||||||
|
EOH
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,34 +9,43 @@ module VagrantPlugins
|
||||||
include Vagrant::Util
|
include Vagrant::Util
|
||||||
|
|
||||||
def self.configure_networks(machine, networks)
|
def self.configure_networks(machine, networks)
|
||||||
machine.communicate.tap do |comm|
|
comm = machine.communicate
|
||||||
# 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 -f /tmp/vagrant-network-interfaces")
|
|
||||||
|
|
||||||
# Configure each network interface
|
commands = []
|
||||||
networks.each do |network|
|
interfaces = machine.guest.capability(:network_interfaces, "/bin/ip")
|
||||||
entry = TemplateRenderer.render("guests/gentoo/network_#{network[:type]}",
|
|
||||||
options: network)
|
|
||||||
|
|
||||||
# Upload the entry to a temporary location
|
# Remove any previous network additions to the configuration file.
|
||||||
Tempfile.open("vagrant-gentoo-configure-networks") do |f|
|
commands << "sed -i'' -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/conf.d/net"
|
||||||
f.binmode
|
|
||||||
f.write(entry)
|
|
||||||
f.fsync
|
|
||||||
f.close
|
|
||||||
comm.upload(f.path, "/tmp/vagrant-network-entry")
|
|
||||||
end
|
|
||||||
|
|
||||||
# Configure the interface
|
networks.each_with_index do |network, i|
|
||||||
comm.sudo("ln -fs /etc/init.d/net.lo /etc/init.d/net.eth#{network[:interface]}")
|
network[:device] = interfaces[network[:interface]]
|
||||||
comm.sudo("/etc/init.d/net.eth#{network[:interface]} stop")
|
|
||||||
comm.sudo("cat /tmp/vagrant-network-entry >> /etc/conf.d/net")
|
entry = TemplateRenderer.render("guests/gentoo/network_#{network[:type]}",
|
||||||
comm.sudo("rm -f /tmp/vagrant-network-entry")
|
options: network,
|
||||||
comm.sudo("/etc/init.d/net.eth#{network[:interface]} start")
|
)
|
||||||
|
|
||||||
|
remote_path = "/tmp/vagrant-network-#{network[:device]}-#{Time.now.to_i}-#{i}"
|
||||||
|
|
||||||
|
Tempfile.open("vagrant-gentoo-configure-networks") do |f|
|
||||||
|
f.binmode
|
||||||
|
f.write(entry)
|
||||||
|
f.fsync
|
||||||
|
f.close
|
||||||
|
comm.upload(f.path, remote_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
commands << <<-EOH.gsub(/^ {14}/, '')
|
||||||
|
ln -sf /etc/init.d/net.lo /etc/init.d/net.#{network[:device]}
|
||||||
|
/etc/init.d/net.#{network[:device]} stop || true
|
||||||
|
|
||||||
|
cat '#{remote_path}' >> /etc/conf.d/net
|
||||||
|
rm -f '#{remote_path}'
|
||||||
|
|
||||||
|
/etc/init.d/net.#{network[:device]} start
|
||||||
|
EOH
|
||||||
end
|
end
|
||||||
|
|
||||||
|
comm.sudo(commands.join("\n"))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,13 +6,12 @@ module VagrantPlugins
|
||||||
comm = machine.communicate
|
comm = machine.communicate
|
||||||
|
|
||||||
possible.each do |ip|
|
possible.each do |ip|
|
||||||
command = "ping -c1 -w1 -W1 #{ip}"
|
if comm.test("ping -c1 -w1 -W1 #{ip}")
|
||||||
if comm.test(command)
|
|
||||||
return ip
|
return ip
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
nil
|
return nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
module VagrantPlugins
|
|
||||||
module GuestLinux
|
|
||||||
module Cap
|
|
||||||
class InsertPublicKey
|
|
||||||
def self.insert_public_key(machine, contents)
|
|
||||||
comm = machine.communicate
|
|
||||||
contents = contents.strip << "\n"
|
|
||||||
|
|
||||||
remote_path = "/tmp/vagrant-authorized-keys-#{Time.now.to_i}"
|
|
||||||
Tempfile.open("vagrant-linux-insert-public-key") do |f|
|
|
||||||
f.binmode
|
|
||||||
f.write(contents)
|
|
||||||
f.fsync
|
|
||||||
f.close
|
|
||||||
comm.upload(f.path, remote_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
comm.execute <<-EOH.gsub(/^ {12}/, '')
|
|
||||||
mkdir -p ~/.ssh
|
|
||||||
chmod 0700 ~/.ssh
|
|
||||||
cat '#{remote_path}' >> ~/.ssh/authorized_keys
|
|
||||||
chmod 0600 ~/.ssh/authorized_keys
|
|
||||||
|
|
||||||
# Remove the temporary file
|
|
||||||
rm -f '#{remote_path}'
|
|
||||||
EOH
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,12 +1,17 @@
|
||||||
|
require "shellwords"
|
||||||
|
|
||||||
|
require "vagrant/util/retryable"
|
||||||
|
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
module GuestLinux
|
module GuestLinux
|
||||||
module Cap
|
module Cap
|
||||||
class MountVirtualBoxSharedFolder
|
class MountVirtualBoxSharedFolder
|
||||||
def self.mount_virtualbox_shared_folder(machine, name, guestpath, options)
|
extend Vagrant::Util::Retryable
|
||||||
expanded_guest_path = machine.guest.capability(
|
|
||||||
:shell_expand_guest_path, guestpath)
|
|
||||||
|
|
||||||
mount_commands = []
|
def self.mount_virtualbox_shared_folder(machine, name, guestpath, options)
|
||||||
|
guest_path = Shellwords.escape(guestpath)
|
||||||
|
|
||||||
|
mount_commands = ["set -e"]
|
||||||
|
|
||||||
if options[:owner].is_a? Integer
|
if options[:owner].is_a? Integer
|
||||||
mount_uid = options[:owner]
|
mount_uid = options[:owner]
|
||||||
|
@ -25,73 +30,54 @@ module VagrantPlugins
|
||||||
# First mount command uses getent to get the group
|
# First mount command uses getent to get the group
|
||||||
mount_options = "-o uid=#{mount_uid},gid=#{mount_gid}"
|
mount_options = "-o uid=#{mount_uid},gid=#{mount_gid}"
|
||||||
mount_options += ",#{options[:mount_options].join(",")}" if options[:mount_options]
|
mount_options += ",#{options[:mount_options].join(",")}" if options[:mount_options]
|
||||||
mount_commands << "mount -t vboxsf #{mount_options} #{name} #{expanded_guest_path}"
|
mount_commands << "mount -t vboxsf #{mount_options} #{name} #{guest_path}"
|
||||||
|
|
||||||
# Second mount command uses the old style `id -g`
|
# Second mount command uses the old style `id -g`
|
||||||
mount_options = "-o uid=#{mount_uid},gid=#{mount_gid_old}"
|
mount_options = "-o uid=#{mount_uid},gid=#{mount_gid_old}"
|
||||||
mount_options += ",#{options[:mount_options].join(",")}" if options[:mount_options]
|
mount_options += ",#{options[:mount_options].join(",")}" if options[:mount_options]
|
||||||
mount_commands << "mount -t vboxsf #{mount_options} #{name} #{expanded_guest_path}"
|
mount_commands << "mount -t vboxsf #{mount_options} #{name} #{guest_path}"
|
||||||
|
|
||||||
# Create the guest path if it doesn't exist
|
# Create the guest path if it doesn't exist
|
||||||
machine.communicate.sudo("mkdir -p #{expanded_guest_path}")
|
machine.communicate.sudo("mkdir -p #{guest_path}")
|
||||||
|
|
||||||
# Attempt to mount the folder. We retry here a few times because
|
# Attempt to mount the folder. We retry here a few times because
|
||||||
# it can fail early on.
|
# it can fail early on.
|
||||||
attempts = 0
|
command = mount_commands.join("\n")
|
||||||
while true
|
stderr = ""
|
||||||
success = true
|
retryable(on: Vagrant::Errors::VirtualBoxMountFailed, tries: 3, sleep: 5) do
|
||||||
|
machine.communicate.sudo(command,
|
||||||
stderr = ""
|
error_class: Vagrant::Errors::VirtualBoxMountFailed,
|
||||||
mount_commands.each do |command|
|
error_key: :virtualbox_mount_failed,
|
||||||
no_such_device = false
|
command: command,
|
||||||
stderr = ""
|
output: stderr,
|
||||||
status = machine.communicate.sudo(command, error_check: false) do |type, data|
|
) { |type, data| stderr = data if type == :stderr }
|
||||||
if type == :stderr
|
|
||||||
no_such_device = true if data =~ /No such device/i
|
|
||||||
stderr += data.to_s
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
success = status == 0 && !no_such_device
|
|
||||||
break if success
|
|
||||||
end
|
|
||||||
|
|
||||||
break if success
|
|
||||||
|
|
||||||
attempts += 1
|
|
||||||
if attempts > 10
|
|
||||||
raise Vagrant::Errors::LinuxMountFailed,
|
|
||||||
command: mount_commands.join("\n"),
|
|
||||||
output: stderr
|
|
||||||
end
|
|
||||||
|
|
||||||
sleep(2*attempts)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Chown the directory to the proper user. We skip this if the
|
# Chown the directory to the proper user. We skip this if the
|
||||||
# mount options contained a readonly flag, because it won't work.
|
# mount options contained a readonly flag, because it won't work.
|
||||||
if !options[:mount_options] || !options[:mount_options].include?("ro")
|
if !options[:mount_options] || !options[:mount_options].include?("ro")
|
||||||
chown_commands = []
|
chown_commands = []
|
||||||
chown_commands << "chown #{mount_uid}:#{mount_gid} #{expanded_guest_path}"
|
chown_commands << "chown #{mount_uid}:#{mount_gid} #{guest_path}"
|
||||||
chown_commands << "chown #{mount_uid}:#{mount_gid_old} #{expanded_guest_path}"
|
chown_commands << "chown #{mount_uid}:#{mount_gid_old} #{guest_path}"
|
||||||
|
|
||||||
exit_status = machine.communicate.sudo(chown_commands[0], error_check: false)
|
exit_status = machine.communicate.sudo(chown_commands[0], error_check: false)
|
||||||
machine.communicate.sudo(chown_commands[1]) if exit_status != 0
|
machine.communicate.sudo(chown_commands[1]) if exit_status != 0
|
||||||
end
|
end
|
||||||
|
|
||||||
# Emit an upstart event if we can
|
# Emit an upstart event if we can
|
||||||
machine.communicate.sudo <<-SCRIPT
|
machine.communicate.sudo <<-EOH.gsub(/^ {12}/, "")
|
||||||
if command -v /sbin/init && /sbin/init --version | grep upstart; then
|
if command -v /sbin/init && /sbin/init --version | grep upstart; then
|
||||||
/sbin/initctl emit --no-wait vagrant-mounted MOUNTPOINT='#{expanded_guest_path}'
|
/sbin/initctl emit --no-wait vagrant-mounted MOUNTPOINT=#{guest_path}
|
||||||
fi
|
fi
|
||||||
SCRIPT
|
EOH
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.unmount_virtualbox_shared_folder(machine, guestpath, options)
|
def self.unmount_virtualbox_shared_folder(machine, guestpath, options)
|
||||||
result = machine.communicate.sudo(
|
guest_path = Shellwords.escape(guestpath)
|
||||||
"umount #{guestpath}", error_check: false)
|
|
||||||
|
result = machine.communicate.sudo("umount #{guest_path}", error_check: false)
|
||||||
if result == 0
|
if result == 0
|
||||||
machine.communicate.sudo("rmdir #{guestpath}", error_check: false)
|
machine.communicate.sudo("rmdir #{guest_path}", error_check: false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
module VagrantPlugins
|
||||||
|
module GuestLinux
|
||||||
|
module Cap
|
||||||
|
class NetworkInterfaces
|
||||||
|
# Get network interfaces as a list. The result will be something like:
|
||||||
|
#
|
||||||
|
# eth0\nenp0s8\nenp0s9
|
||||||
|
#
|
||||||
|
# @return [Array<String>]
|
||||||
|
def self.network_interfaces(machine, path = "/sbin/ip")
|
||||||
|
s = ""
|
||||||
|
machine.communicate.sudo("#{path} -o -0 addr | grep -v LOOPBACK | awk '{print $2}' | sed 's/://'") do |type, data|
|
||||||
|
s << data if type == :stdout
|
||||||
|
end
|
||||||
|
s.split("\n")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -3,9 +3,13 @@ require "vagrant/util/retryable"
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
module GuestLinux
|
module GuestLinux
|
||||||
module Cap
|
module Cap
|
||||||
class MountNFS
|
class NFS
|
||||||
extend Vagrant::Util::Retryable
|
extend Vagrant::Util::Retryable
|
||||||
|
|
||||||
|
def self.nfs_client_installed(machine)
|
||||||
|
machine.communicate.test("test -x /sbin/mount.nfs")
|
||||||
|
end
|
||||||
|
|
||||||
def self.mount_nfs_folder(machine, ip, folders)
|
def self.mount_nfs_folder(machine, ip, folders)
|
||||||
comm = machine.communicate
|
comm = machine.communicate
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
module VagrantPlugins
|
|
||||||
module GuestLinux
|
|
||||||
module Cap
|
|
||||||
class NFSClient
|
|
||||||
def self.nfs_client_installed(machine)
|
|
||||||
machine.communicate.test("test -x /sbin/mount.nfs")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
require "tempfile"
|
||||||
|
|
||||||
|
require "vagrant/util/shell_quote"
|
||||||
|
|
||||||
|
module VagrantPlugins
|
||||||
|
module GuestLinux
|
||||||
|
module Cap
|
||||||
|
class PublicKey
|
||||||
|
def self.insert_public_key(machine, contents)
|
||||||
|
comm = machine.communicate
|
||||||
|
contents = contents.strip << "\n"
|
||||||
|
|
||||||
|
remote_path = "/tmp/vagrant-insert-pubkey-#{Time.now.to_i}"
|
||||||
|
Tempfile.open("vagrant-linux-insert-public-key") do |f|
|
||||||
|
f.binmode
|
||||||
|
f.write(contents)
|
||||||
|
f.fsync
|
||||||
|
f.close
|
||||||
|
comm.upload(f.path, remote_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Use execute (not sudo) because we want to execute this as the SSH
|
||||||
|
# user (which is "vagrant" by default).
|
||||||
|
comm.execute <<-EOH.gsub(/^ {12}/, "")
|
||||||
|
set -e
|
||||||
|
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
chmod 0700 ~/.ssh
|
||||||
|
cat '#{remote_path}' >> ~/.ssh/authorized_keys
|
||||||
|
chmod 0600 ~/.ssh/authorized_keys
|
||||||
|
|
||||||
|
rm -f '#{remote_path}'
|
||||||
|
EOH
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.remove_public_key(machine, contents)
|
||||||
|
comm = machine.communicate
|
||||||
|
contents = contents.strip << "\n"
|
||||||
|
|
||||||
|
remote_path = "/tmp/vagrant-remove-pubkey-#{Time.now.to_i}"
|
||||||
|
Tempfile.open("vagrant-bsd-remove-public-key") do |f|
|
||||||
|
f.binmode
|
||||||
|
f.write(contents)
|
||||||
|
f.fsync
|
||||||
|
f.close
|
||||||
|
comm.upload(f.path, remote_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Use execute (not sudo) because we want to execute this as the SSH
|
||||||
|
# user (which is "vagrant" by default).
|
||||||
|
comm.execute <<-EOH.sub(/^ {12}/, "")
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if test -f ~/.ssh/authorized_keys; then
|
||||||
|
grep -v -x -f '#{remote_path}' ~/.ssh/authorized_keys > ~/.ssh/authorized_keys.tmp
|
||||||
|
mv ~/.ssh/authorized_keys.tmp ~/.ssh/authorized_keys
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -f '#{remote_path}'
|
||||||
|
EOH
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,24 +0,0 @@
|
||||||
require "vagrant/util/shell_quote"
|
|
||||||
|
|
||||||
module VagrantPlugins
|
|
||||||
module GuestLinux
|
|
||||||
module Cap
|
|
||||||
class RemovePublicKey
|
|
||||||
def self.remove_public_key(machine, contents)
|
|
||||||
contents = contents.chomp
|
|
||||||
contents = Vagrant::Util::ShellQuote.escape(contents, "'")
|
|
||||||
|
|
||||||
machine.communicate.tap do |comm|
|
|
||||||
if comm.test("test -f ~/.ssh/authorized_keys")
|
|
||||||
comm.execute(<<SCRIPT)
|
|
||||||
sed -e '/^.*#{contents}.*$/d' ~/.ssh/authorized_keys > ~/.ssh/authorized_keys.new
|
|
||||||
mv ~/.ssh/authorized_keys.new ~/.ssh/authorized_keys
|
|
||||||
chmod 600 ~/.ssh/authorized_keys
|
|
||||||
SCRIPT
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
require "shellwords"
|
||||||
|
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
module GuestLinux
|
module GuestLinux
|
||||||
module Cap
|
module Cap
|
||||||
|
@ -11,9 +13,8 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.rsync_pre(machine, opts)
|
def self.rsync_pre(machine, opts)
|
||||||
machine.communicate.tap do |comm|
|
guest_path = Shellwords.escape(opts[:guestpath])
|
||||||
comm.sudo("mkdir -p '#{opts[:guestpath]}'")
|
machine.communicate.sudo("mkdir -p #{guest_path}")
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.rsync_post(machine, opts)
|
def self.rsync_post(machine, opts)
|
||||||
|
@ -21,8 +22,10 @@ module VagrantPlugins
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
guest_path = Shellwords.escape(opts[:guestpath])
|
||||||
|
|
||||||
machine.communicate.sudo(
|
machine.communicate.sudo(
|
||||||
"find '#{opts[:guestpath]}' " +
|
"find #{guest_path} " +
|
||||||
"'!' -type l -a " +
|
"'!' -type l -a " +
|
||||||
"'(' ! -user #{opts[:owner]} -or ! -group #{opts[:group]} ')' -print0 | " +
|
"'(' ! -user #{opts[:owner]} -or ! -group #{opts[:group]} ')' -print0 | " +
|
||||||
"xargs -0 -r chown #{opts[:owner]}:#{opts[:group]}")
|
"xargs -0 -r chown #{opts[:owner]}:#{opts[:group]}")
|
||||||
|
|
|
@ -22,8 +22,8 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
guest_capability(:linux, :insert_public_key) do
|
guest_capability(:linux, :insert_public_key) do
|
||||||
require_relative "cap/insert_public_key"
|
require_relative "cap/public_key"
|
||||||
Cap::InsertPublicKey
|
Cap::PublicKey
|
||||||
end
|
end
|
||||||
|
|
||||||
guest_capability(:linux, :shell_expand_guest_path) do
|
guest_capability(:linux, :shell_expand_guest_path) do
|
||||||
|
@ -32,8 +32,8 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
guest_capability(:linux, :mount_nfs_folder) do
|
guest_capability(:linux, :mount_nfs_folder) do
|
||||||
require_relative "cap/mount_nfs"
|
require_relative "cap/nfs"
|
||||||
Cap::MountNFS
|
Cap::NFS
|
||||||
end
|
end
|
||||||
|
|
||||||
guest_capability(:linux, :mount_smb_shared_folder) do
|
guest_capability(:linux, :mount_smb_shared_folder) do
|
||||||
|
@ -46,9 +46,14 @@ module VagrantPlugins
|
||||||
Cap::MountVirtualBoxSharedFolder
|
Cap::MountVirtualBoxSharedFolder
|
||||||
end
|
end
|
||||||
|
|
||||||
|
guest_capability(:linux, :network_interfaces) do
|
||||||
|
require_relative "cap/network_interfaces"
|
||||||
|
Cap::NetworkInterfaces
|
||||||
|
end
|
||||||
|
|
||||||
guest_capability(:linux, :nfs_client_installed) do
|
guest_capability(:linux, :nfs_client_installed) do
|
||||||
require_relative "cap/nfs_client"
|
require_relative "cap/nfs"
|
||||||
Cap::NFSClient
|
Cap::NFS
|
||||||
end
|
end
|
||||||
|
|
||||||
# For the Docker provider
|
# For the Docker provider
|
||||||
|
@ -63,8 +68,8 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
guest_capability(:linux, :remove_public_key) do
|
guest_capability(:linux, :remove_public_key) do
|
||||||
require_relative "cap/remove_public_key"
|
require_relative "cap/public_key"
|
||||||
Cap::RemovePublicKey
|
Cap::PublicKey
|
||||||
end
|
end
|
||||||
|
|
||||||
guest_capability(:linux, :rsync_installed) do
|
guest_capability(:linux, :rsync_installed) do
|
||||||
|
|
|
@ -5,7 +5,7 @@ module VagrantPlugins
|
||||||
def self.change_host_name(machine, name)
|
def self.change_host_name(machine, name)
|
||||||
comm = machine.communicate
|
comm = machine.communicate
|
||||||
|
|
||||||
if !comm.test("hostname | grep -w '#{name}'", sudo: false)
|
if !comm.test("hostname -f | grep '^#{name}$'", sudo: false)
|
||||||
basename = name.split(".", 2)[0]
|
basename = name.split(".", 2)[0]
|
||||||
comm.sudo <<-EOH.gsub(/^ {14}/, '')
|
comm.sudo <<-EOH.gsub(/^ {14}/, '')
|
||||||
# Set hostname
|
# Set hostname
|
||||||
|
|
|
@ -3,9 +3,27 @@ module VagrantPlugins
|
||||||
module Cap
|
module Cap
|
||||||
class ChangeHostName
|
class ChangeHostName
|
||||||
def self.change_host_name(machine, name)
|
def self.change_host_name(machine, name)
|
||||||
if !machine.communicate.test("hostname | grep '^#{name}$'")
|
comm = machine.communicate
|
||||||
machine.communicate.sudo("sh -c \"echo '#{name}' > /etc/myname\"")
|
|
||||||
machine.communicate.sudo("hostname #{name}")
|
if !comm.test("hostname -f | grep '^#{name}$'", sudo: false, shell: "sh")
|
||||||
|
basename = name.split(".", 2)[0]
|
||||||
|
command = <<-EOH.gsub(/^ {14}/, '')
|
||||||
|
# Set the hostname
|
||||||
|
hostname '#{name}'
|
||||||
|
sed -i'' 's/^hostname=.*$/hostname=\"#{name}\"/' /etc/rc.conf
|
||||||
|
echo '#{name}' > /etc/myname
|
||||||
|
|
||||||
|
# Remove comments and blank lines from /etc/hosts
|
||||||
|
sed -i'' -e 's/#.*$//' /etc/hosts
|
||||||
|
sed -i'' -e '/^$/d' /etc/hosts
|
||||||
|
|
||||||
|
# Prepend ourselves to /etc/hosts
|
||||||
|
grep -w '#{name}' /etc/hosts || {
|
||||||
|
echo -e '127.0.0.1\\t#{name}\\t#{basename}' | cat - /etc/hosts > /tmp/tmp-hosts
|
||||||
|
mv /tmp/tmp-hosts /etc/hosts
|
||||||
|
}
|
||||||
|
EOH
|
||||||
|
comm.sudo(command, shell: "sh")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ module VagrantPlugins
|
||||||
def self.change_host_name(machine, name)
|
def self.change_host_name(machine, name)
|
||||||
comm = machine.communicate
|
comm = machine.communicate
|
||||||
|
|
||||||
if !comm.test("hostname -f | grep -w '#{name}'", sudo: false)
|
if !comm.test("hostname -f | grep '^#{name}$'", sudo: false)
|
||||||
basename = name.split(".", 2)[0]
|
basename = name.split(".", 2)[0]
|
||||||
comm.sudo <<-EOH.gsub(/^ {14}/, '')
|
comm.sudo <<-EOH.gsub(/^ {14}/, '')
|
||||||
# Set the hostname
|
# Set the hostname
|
||||||
|
|
|
@ -5,7 +5,7 @@ module VagrantPlugins
|
||||||
def self.change_host_name(machine, name)
|
def self.change_host_name(machine, name)
|
||||||
comm = machine.communicate
|
comm = machine.communicate
|
||||||
|
|
||||||
if !comm.test("hostname | grep -w '#{name}'", sudo: false)
|
if !comm.test("hostname -f | grep '^#{name}$'", sudo: false)
|
||||||
basename = name.split(".", 2)[0]
|
basename = name.split(".", 2)[0]
|
||||||
comm.sudo <<-EOH.gsub(/^ {14}/, '')
|
comm.sudo <<-EOH.gsub(/^ {14}/, '')
|
||||||
hostname '#{name}'
|
hostname '#{name}'
|
||||||
|
|
|
@ -5,7 +5,7 @@ module VagrantPlugins
|
||||||
def self.change_host_name(machine, name)
|
def self.change_host_name(machine, name)
|
||||||
comm = machine.communicate
|
comm = machine.communicate
|
||||||
|
|
||||||
if !comm.test("hostname -f | grep -w '#{name}'", sudo: false)
|
if !comm.test("hostname -f | grep '^#{name}$'", sudo: false)
|
||||||
basename = name.split('.', 2)[0]
|
basename = name.split('.', 2)[0]
|
||||||
comm.sudo <<-EOH.gsub(/^ {14}/, '')
|
comm.sudo <<-EOH.gsub(/^ {14}/, '')
|
||||||
# Update sysconfig
|
# Update sysconfig
|
||||||
|
@ -17,9 +17,10 @@ module VagrantPlugins
|
||||||
# Set the hostname - use hostnamectl if available
|
# Set the hostname - use hostnamectl if available
|
||||||
echo '#{name}' > /etc/hostname
|
echo '#{name}' > /etc/hostname
|
||||||
if command -v hostnamectl; then
|
if command -v hostnamectl; then
|
||||||
hostnamectl set-hostname '#{name}'
|
hostnamectl set-hostname --static '#{name}'
|
||||||
|
hostnamectl set-hostname --transient '#{name}'
|
||||||
else
|
else
|
||||||
hostname '#{name}'
|
hostname -F /etc/hostname
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove comments and blank lines from /etc/hosts
|
# Remove comments and blank lines from /etc/hosts
|
||||||
|
|
|
@ -1,43 +1,20 @@
|
||||||
require "tempfile"
|
require "tempfile"
|
||||||
|
|
||||||
require_relative "../../../../lib/vagrant/util/retryable"
|
|
||||||
require_relative "../../../../lib/vagrant/util/template_renderer"
|
require_relative "../../../../lib/vagrant/util/template_renderer"
|
||||||
|
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
module GuestRedHat
|
module GuestRedHat
|
||||||
module Cap
|
module Cap
|
||||||
class ConfigureNetworks
|
class ConfigureNetworks
|
||||||
extend Vagrant::Util::Retryable
|
|
||||||
include Vagrant::Util
|
include Vagrant::Util
|
||||||
|
|
||||||
def self.configure_networks(machine, networks)
|
def self.configure_networks(machine, networks)
|
||||||
case machine.guest.capability(:flavor)
|
|
||||||
when :rhel_7
|
|
||||||
configure_networks_rhel7(machine, networks)
|
|
||||||
else
|
|
||||||
configure_networks_default(machine, networks)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.configure_networks_rhel7(machine, networks)
|
|
||||||
# This is kind of jank but the configure networks is the same as
|
|
||||||
# Fedora at this point.
|
|
||||||
require_relative "../../fedora/cap/configure_networks"
|
|
||||||
::VagrantPlugins::GuestFedora::Cap::ConfigureNetworks
|
|
||||||
.configure_networks(machine, networks)
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.configure_networks_default(machine, networks)
|
|
||||||
comm = machine.communicate
|
comm = machine.communicate
|
||||||
|
|
||||||
network_scripts_dir = machine.guest.capability(:network_scripts_dir)
|
network_scripts_dir = machine.guest.capability(:network_scripts_dir)
|
||||||
|
|
||||||
interfaces = []
|
|
||||||
commands = []
|
commands = []
|
||||||
|
interfaces = machine.guest.capability(:network_interfaces)
|
||||||
comm.sudo("/sbin/ip -o -0 addr | grep -v LOOPBACK | awk '{print $2}' | sed 's/://'") do |_, stdout|
|
|
||||||
interfaces = stdout.split("\n")
|
|
||||||
end
|
|
||||||
|
|
||||||
networks.each.with_index do |network, i|
|
networks.each.with_index do |network, i|
|
||||||
network[:device] = interfaces[network[:interface]]
|
network[:device] = interfaces[network[:interface]]
|
||||||
|
|
|
@ -5,7 +5,7 @@ module VagrantPlugins
|
||||||
def self.change_host_name(machine, name)
|
def self.change_host_name(machine, name)
|
||||||
comm = machine.communicate
|
comm = machine.communicate
|
||||||
|
|
||||||
if !comm.test("hostname -f | grep -w '#{name}'", sudo: false)
|
if !comm.test("hostname -f | grep '^#{name}$'", sudo: false)
|
||||||
basename = name.split(".", 2)[0]
|
basename = name.split(".", 2)[0]
|
||||||
comm.sudo <<-EOH.gsub(/^ {14}/, '')
|
comm.sudo <<-EOH.gsub(/^ {14}/, '')
|
||||||
# Set the hostname
|
# Set the hostname
|
||||||
|
|
|
@ -12,11 +12,7 @@ module VagrantPlugins
|
||||||
comm = machine.communicate
|
comm = machine.communicate
|
||||||
|
|
||||||
commands = []
|
commands = []
|
||||||
interfaces = []
|
interfaces = machine.guest.capability(:network_interfaces)
|
||||||
|
|
||||||
comm.sudo("ip -o -0 addr | grep -v LOOPBACK | awk '{print $2}' | sed 's/://'") do |_, result|
|
|
||||||
interfaces = result.split("\n")
|
|
||||||
end
|
|
||||||
|
|
||||||
# Remove any previous configuration
|
# Remove any previous configuration
|
||||||
commands << "sed -i'' -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/rc.d/rc.inet1.conf"
|
commands << "sed -i'' -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/rc.d/rc.inet1.conf"
|
||||||
|
|
|
@ -5,7 +5,7 @@ module VagrantPlugins
|
||||||
def self.change_host_name(machine, name)
|
def self.change_host_name(machine, name)
|
||||||
comm = machine.communicate
|
comm = machine.communicate
|
||||||
|
|
||||||
if !comm.test("hostname -f | grep -w '#{name}'", sudo: false)
|
if !comm.test("hostname -f | grep '^#{name}$'", sudo: false)
|
||||||
basename = name.split(".", 2)[0]
|
basename = name.split(".", 2)[0]
|
||||||
comm.sudo <<-EOH.gsub(/^ {14}/, '')
|
comm.sudo <<-EOH.gsub(/^ {14}/, '')
|
||||||
echo '#{name}' > /etc/HOSTNAME
|
echo '#{name}' > /etc/HOSTNAME
|
||||||
|
|
|
@ -15,11 +15,7 @@ module VagrantPlugins
|
||||||
network_scripts_dir = machine.guest.capability(:network_scripts_dir)
|
network_scripts_dir = machine.guest.capability(:network_scripts_dir)
|
||||||
|
|
||||||
commands = []
|
commands = []
|
||||||
interfaces = []
|
interfaces = machine.guest.capability(:network_interfaces)
|
||||||
|
|
||||||
comm.sudo("ip -o -0 addr | grep -v LOOPBACK | awk '{print $2}' | sed 's/://'") do |_, stdout|
|
|
||||||
interfaces = stdout.split("\n")
|
|
||||||
end
|
|
||||||
|
|
||||||
networks.each.with_index do |network, i|
|
networks.each.with_index do |network, i|
|
||||||
network[:device] = interfaces[network[:interface]]
|
network[:device] = interfaces[network[:interface]]
|
||||||
|
|
|
@ -1,52 +0,0 @@
|
||||||
module VagrantPlugins
|
|
||||||
module GuestUbuntu
|
|
||||||
module Cap
|
|
||||||
class ChangeHostName
|
|
||||||
def self.change_host_name(machine, name)
|
|
||||||
comm = machine.communicate
|
|
||||||
|
|
||||||
if !comm.test("hostname -f | grep -w '#{name}'")
|
|
||||||
basename = name.split(".", 2)[0]
|
|
||||||
comm.sudo <<-EOH.gsub(/^ {14}/, '')
|
|
||||||
# Set the hostname
|
|
||||||
echo '#{name}' > /etc/hostname
|
|
||||||
hostname -F /etc/hostname
|
|
||||||
|
|
||||||
if command -v hostnamectl; then
|
|
||||||
hostnamectl set-hostname '#{name}'
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Remove comments and blank lines from /etc/hosts
|
|
||||||
sed -i'' -e 's/#.*$//' -e '/^$/d' /etc/hosts
|
|
||||||
|
|
||||||
# Prepend ourselves to /etc/hosts
|
|
||||||
grep -w '#{name}' /etc/hosts || {
|
|
||||||
sed -i'' '1i 127.0.0.1\\t#{name}\\t#{basename}' /etc/hosts
|
|
||||||
}
|
|
||||||
|
|
||||||
# Update mailname
|
|
||||||
echo '#{name}' > /etc/mailname
|
|
||||||
|
|
||||||
# Restart networking and force new DHCP
|
|
||||||
if [ test -f /etc/init.d/hostname ]; then
|
|
||||||
/etc/init.d/hostname start || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ test -f /etc/init.d/hostname.sh ]; then
|
|
||||||
/etc/init.d/hostname.sh start || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ test -f /etc/init.d/networking ]; then
|
|
||||||
/etc/init.d/networking force-reload
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ test -f /etc/init.d/network-manager ]; then
|
|
||||||
/etc/init.d/network-manager force-reload
|
|
||||||
fi
|
|
||||||
EOH
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -10,11 +10,6 @@ module VagrantPlugins
|
||||||
require_relative "guest"
|
require_relative "guest"
|
||||||
Guest
|
Guest
|
||||||
end
|
end
|
||||||
|
|
||||||
guest_capability(:ubuntu, :change_host_name) do
|
|
||||||
require_relative "cap/change_host_name"
|
|
||||||
Cap::ChangeHostName
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -101,8 +101,16 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
# Mount them!
|
# Mount them!
|
||||||
machine.guest.capability(
|
if machine.guest.capability?(:nfs_pre)
|
||||||
:mount_nfs_folder, nfsopts[:nfs_host_ip], mount_folders)
|
machine.guest.capability(:nfs_pre)
|
||||||
|
end
|
||||||
|
|
||||||
|
machine.guest.capability(:mount_nfs_folder,
|
||||||
|
nfsopts[:nfs_host_ip], mount_folders)
|
||||||
|
|
||||||
|
if machine.guest.capability?(:nfs_post)
|
||||||
|
machine.guest.capability(:nfs_post)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def cleanup(machine, opts)
|
def cleanup(machine, opts)
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
require "shellwords"
|
||||||
|
|
||||||
require "vagrant/util/platform"
|
require "vagrant/util/platform"
|
||||||
require "vagrant/util/subprocess"
|
require "vagrant/util/subprocess"
|
||||||
|
|
||||||
|
@ -43,6 +45,9 @@ module VagrantPlugins
|
||||||
guestpath = machine.guest.capability(:rsync_scrub_guestpath, opts)
|
guestpath = machine.guest.capability(:rsync_scrub_guestpath, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Shellescape
|
||||||
|
guestpath = Shellwords.escape(guestpath)
|
||||||
|
|
||||||
if Vagrant::Util::Platform.windows?
|
if Vagrant::Util::Platform.windows?
|
||||||
# rsync for Windows expects cygwin style paths, always.
|
# rsync for Windows expects cygwin style paths, always.
|
||||||
hostpath = Vagrant::Util::Platform.cygwin_path(hostpath)
|
hostpath = Vagrant::Util::Platform.cygwin_path(hostpath)
|
||||||
|
|
|
@ -2,7 +2,7 @@ Connection=ethernet
|
||||||
Description='A basic static ethernet connection'
|
Description='A basic static ethernet connection'
|
||||||
Interface=<%= options[:device] %>
|
Interface=<%= options[:device] %>
|
||||||
IP=static
|
IP=static
|
||||||
Address=('<%= options[:ip]%>/24')
|
Address=('<%= options[:ip]%>/<%= options[:netmask] %>')
|
||||||
<% if options[:gateway] %>
|
<% if options[:gateway] -%>
|
||||||
Gateway='<%= options[:gateway] %>'
|
Gateway='<%= options[:gateway] %>'
|
||||||
<% end %>
|
<% end -%>
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
Connection=ethernet
|
||||||
|
Description='A basic IPv6 ethernet connection'
|
||||||
|
Interface=<%= options[:device] %>
|
||||||
|
IP6=static
|
||||||
|
Address6=('<%= options[:ip]%>/<%= options[:netmask] %>')
|
||||||
|
<% if options[:gateway] -%>
|
||||||
|
Gateway6='<%= options[:gateway] %>'
|
||||||
|
<% end -%>
|
|
@ -1,6 +0,0 @@
|
||||||
#VAGRANT-BEGIN
|
|
||||||
# The contents below are automatically generated by Vagrant. Do not modify.
|
|
||||||
BOOTPROTO=dhcp
|
|
||||||
ONBOOT=yes
|
|
||||||
DEVICE=<%= options[:device] %>
|
|
||||||
#VAGRANT-END
|
|
|
@ -1,16 +0,0 @@
|
||||||
#VAGRANT-BEGIN
|
|
||||||
# The contents below are automatically generated by Vagrant. Do not modify.
|
|
||||||
NM_CONTROLLED=no
|
|
||||||
BOOTPROTO=none
|
|
||||||
ONBOOT=yes
|
|
||||||
IPADDR=<%= options[:ip] %>
|
|
||||||
NETMASK=<%= options[:netmask] %>
|
|
||||||
DEVICE=<%= options[:device] %>
|
|
||||||
<% if options[:gateway] %>
|
|
||||||
GATEWAY=<%= options[:gateway] %>
|
|
||||||
<% end %>
|
|
||||||
<% if options[:mac_address] %>
|
|
||||||
HWADDR=<%= options[:mac_address] %>
|
|
||||||
<% end %>
|
|
||||||
PEERDNS=no
|
|
||||||
#VAGRANT-END
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
#VAGRANT-BEGIN
|
||||||
|
ifconfig_<%= options[:device] %>_ipv6="inet6 <%= options[:ip] %> prefixlen <%= options[:netmask] %>"
|
||||||
|
<% if options[:gateway] %>
|
||||||
|
ipv6_default_router="<%= options[:gateway] %>"
|
||||||
|
<% end %>
|
||||||
|
#VAGRANT-END
|
|
@ -0,0 +1,9 @@
|
||||||
|
#VAGRANT-BEGIN
|
||||||
|
template='interface'
|
||||||
|
ipaddr='<%= options[:ip] %>/<%= options[:netmask] %>'
|
||||||
|
<% [:gateway, :nameservers, :domain, :route, :gateway6, :route6, :mtu].each do |key| %>
|
||||||
|
<% if options[key] %>
|
||||||
|
<%= key %>='<%= options[key] %>'
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
#VAGRANT-END
|
|
@ -1,4 +1,4 @@
|
||||||
#VAGRANT-BEGIN
|
#VAGRANT-BEGIN
|
||||||
# The contents below are automatically generated by Vagrant. Do not modify.
|
# The contents below are automatically generated by Vagrant. Do not modify.
|
||||||
config_eth<%= options[:interface] %>="dhcp"
|
config_<%= options[:device] %>="dhcp"
|
||||||
#VAGRANT-END
|
#VAGRANT-END
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#VAGRANT-BEGIN
|
#VAGRANT-BEGIN
|
||||||
# The contents below are automatically generated by Vagrant. Do not modify.
|
# The contents below are automatically generated by Vagrant. Do not modify.
|
||||||
config_eth<%= options[:interface] %>=("<%= options[:ip] %> netmask <%= options[:netmask] %>")
|
config_<%= options[:device] %>=("<%= options[:ip] %> netmask <%= options[:netmask] %>")
|
||||||
<% if options[:gateway] %>
|
<% if options[:gateway] -%>
|
||||||
gateways_eth<%= options[:interface] %>="<%= options[:gateway] %>"
|
gateways_<%= options[:device] %>="<%= options[:gateway] %>"
|
||||||
<% end %>
|
<% end -%>
|
||||||
#VAGRANT-END
|
#VAGRANT-END
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
#VAGRANT-BEGIN
|
||||||
|
# The contents below are automatically generated by Vagrant. Do not modify.
|
||||||
|
config_<%= options[:device] %>="<%= options[:ip] %>/<%= options[:netmask] %>"
|
||||||
|
<% if options[:gateway] -%>
|
||||||
|
gateways_<%= options[:device] %>="<%= options[:gateway] %>"
|
||||||
|
<% end -%>
|
||||||
|
#VAGRANT-END
|
|
@ -2,5 +2,5 @@
|
||||||
# The contents below are automatically generated by Vagrant. Do not modify.
|
# The contents below are automatically generated by Vagrant. Do not modify.
|
||||||
BOOTPROTO=dhcp
|
BOOTPROTO=dhcp
|
||||||
ONBOOT=yes
|
ONBOOT=yes
|
||||||
DEVICE=eth<%= options[:interface] %>
|
DEVICE=<%= options[:device] %>
|
||||||
#VAGRANT-END
|
#VAGRANT-END
|
||||||
|
|
|
@ -5,9 +5,12 @@ BOOTPROTO=none
|
||||||
ONBOOT=yes
|
ONBOOT=yes
|
||||||
IPADDR=<%= options[:ip] %>
|
IPADDR=<%= options[:ip] %>
|
||||||
NETMASK=<%= options[:netmask] %>
|
NETMASK=<%= options[:netmask] %>
|
||||||
DEVICE=eth<%= options[:interface] %>
|
DEVICE=<%= options[:device] %>
|
||||||
<% if options[:gateway] %>
|
<% if options[:gateway] %>
|
||||||
GATEWAY=<%= options[:gateway] %>
|
GATEWAY=<%= options[:gateway] %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% if options[:mac_address] %>
|
||||||
|
HWADDR=<%= options[:mac_address] %>
|
||||||
|
<% end %>
|
||||||
PEERDNS=no
|
PEERDNS=no
|
||||||
#VAGRANT-END
|
#VAGRANT-END
|
||||||
|
|
|
@ -3,7 +3,10 @@
|
||||||
NM_CONTROLLED=no
|
NM_CONTROLLED=no
|
||||||
BOOTPROTO=static
|
BOOTPROTO=static
|
||||||
ONBOOT=yes
|
ONBOOT=yes
|
||||||
IPV6INIT=yes
|
|
||||||
IPV6ADDR=<%= options[:ip] %>
|
|
||||||
DEVICE=<%= options[:device] %>
|
DEVICE=<%= options[:device] %>
|
||||||
|
IPV6INIT=yes
|
||||||
|
IPV6ADDR=<%= options[:ip] %>/<%= options[:netmask] %>
|
||||||
|
<% if options[:gateway] -%>
|
||||||
|
IPV6_DEFAULTGW=<%= options[:gateway] %>
|
||||||
|
<% end %>
|
||||||
#VAGRANT-END
|
#VAGRANT-END
|
|
@ -1342,6 +1342,38 @@ en:
|
||||||
VirtualBox is complaining that the installation is incomplete. Please
|
VirtualBox is complaining that the installation is incomplete. Please
|
||||||
run `VBoxManage --version` to see the error message which should contain
|
run `VBoxManage --version` to see the error message which should contain
|
||||||
instructions on how to fix this error.
|
instructions on how to fix this error.
|
||||||
|
virtualbox_mount_failed: |-
|
||||||
|
Vagrant was unable to mount VirtualBox shared folders. This is usually
|
||||||
|
because the filesystem "vboxsf" is not available. This filesystem is
|
||||||
|
made available via the VirtualBox Guest Additions and kernel module.
|
||||||
|
Please verify that these guest additions are properly installed in the
|
||||||
|
guest. This is not a bug in Vagrant and is usually caused by a faulty
|
||||||
|
Vagrant box. For context, the command attemped was:
|
||||||
|
|
||||||
|
%{command}
|
||||||
|
|
||||||
|
The error output from the command was:
|
||||||
|
|
||||||
|
%{output}
|
||||||
|
virtualbox_mount_not_supported_bsd: |-
|
||||||
|
Vagrant is not able to mount VirtualBox shared folders on BSD-based
|
||||||
|
guests. BSD-based guests do not support the VirtualBox filesystem at
|
||||||
|
this time.
|
||||||
|
|
||||||
|
To change the type of the default synced folder, specify the type as
|
||||||
|
rsync or nfs:
|
||||||
|
|
||||||
|
config.vm.synced_folder ".", "/vagrant", type: "nfs" # or "rsync"
|
||||||
|
|
||||||
|
Alternatively, if you do not need to mount the default synced folder,
|
||||||
|
you can also disable it entirely:
|
||||||
|
|
||||||
|
config.vm.synced_folder ".", "/vagrant", disabled: true
|
||||||
|
|
||||||
|
You can read more about Vagrant's synced folder types and the various
|
||||||
|
configuration options on the Vagrant website.
|
||||||
|
|
||||||
|
This is not a bug in Vagrant.
|
||||||
virtualbox_name_exists: |-
|
virtualbox_name_exists: |-
|
||||||
The name of your virtual machine couldn't be set because VirtualBox
|
The name of your virtual machine couldn't be set because VirtualBox
|
||||||
is reporting another VM with that name already exists. Most of the
|
is reporting another VM with that name already exists. Most of the
|
||||||
|
|
|
@ -20,18 +20,18 @@ describe "VagrantPlugins::GuestArch::Cap::ChangeHostName" do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe ".change_host_name" do
|
describe ".change_host_name" do
|
||||||
let(:hostname) { "banana-rama.example.com" }
|
let(:name) { "banana-rama.example.com" }
|
||||||
|
|
||||||
it "sets the hostname" do
|
it "sets the hostname" do
|
||||||
comm.stub_command("hostname | grep -w '#{hostname}'", exit_code: 1)
|
comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 1)
|
||||||
|
|
||||||
described_class.change_host_name(machine, hostname)
|
described_class.change_host_name(machine, name)
|
||||||
expect(comm.received_commands[1]).to match(/hostnamectl set-hostname '#{hostname}'/)
|
expect(comm.received_commands[1]).to match(/hostnamectl set-hostname 'banana-rama'/)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not change the hostname if already set" do
|
it "does not change the hostname if already set" do
|
||||||
comm.stub_command("hostname | grep -w '#{hostname}'", exit_code: 0)
|
comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 0)
|
||||||
described_class.change_host_name(machine, hostname)
|
described_class.change_host_name(machine, name)
|
||||||
expect(comm.received_commands.size).to eq(1)
|
expect(comm.received_commands.size).to eq(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,20 +1,18 @@
|
||||||
require_relative "../../../../base"
|
require_relative "../../../../base"
|
||||||
|
|
||||||
describe "VagrantPlugins::GuestArch::Cap::ConfigureNetworks" do
|
describe "VagrantPlugins::GuestArch::Cap::ConfigureNetworks" do
|
||||||
let(:described_class) do
|
let(:caps) do
|
||||||
VagrantPlugins::GuestArch::Plugin
|
VagrantPlugins::GuestArch::Plugin
|
||||||
.components
|
.components
|
||||||
.guest_capabilities[:arch]
|
.guest_capabilities[:arch]
|
||||||
.get(:configure_networks)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:machine) { double("machine") }
|
let(:guest) { double("guest") }
|
||||||
|
let(:machine) { double("machine", guest: guest) }
|
||||||
let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) }
|
let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(machine).to receive(:communicate).and_return(comm)
|
allow(machine).to receive(:communicate).and_return(comm)
|
||||||
comm.stub_command("ip -o -0 addr | grep -v LOOPBACK | awk '{print $2}' | sed 's/://'",
|
|
||||||
stdout: "eth1\neth2")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
|
@ -22,6 +20,13 @@ describe "VagrantPlugins::GuestArch::Cap::ConfigureNetworks" do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe ".configure_networks" do
|
describe ".configure_networks" do
|
||||||
|
let(:cap) { caps.get(:configure_networks) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
allow(guest).to receive(:capability).with(:network_interfaces)
|
||||||
|
.and_return(["eth1", "eth2"])
|
||||||
|
end
|
||||||
|
|
||||||
let(:network_1) do
|
let(:network_1) do
|
||||||
{
|
{
|
||||||
interface: 0,
|
interface: 0,
|
||||||
|
@ -40,16 +45,16 @@ describe "VagrantPlugins::GuestArch::Cap::ConfigureNetworks" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "creates and starts the networks" do
|
it "creates and starts the networks" do
|
||||||
described_class.configure_networks(machine, [network_1, network_2])
|
cap.configure_networks(machine, [network_1, network_2])
|
||||||
expect(comm.received_commands[1]).to match(/mv (.+) '\/etc\/netctl\/eth1'/)
|
expect(comm.received_commands[0]).to match(/mv (.+) '\/etc\/netctl\/eth1'/)
|
||||||
expect(comm.received_commands[1]).to match(/ip link set 'eth1' down/)
|
expect(comm.received_commands[0]).to match(/ip link set 'eth1' down/)
|
||||||
expect(comm.received_commands[1]).to match(/netctl restart 'eth1'/)
|
expect(comm.received_commands[0]).to match(/netctl restart 'eth1'/)
|
||||||
expect(comm.received_commands[1]).to match(/netctl enable 'eth1'/)
|
expect(comm.received_commands[0]).to match(/netctl enable 'eth1'/)
|
||||||
|
|
||||||
expect(comm.received_commands[1]).to match(/mv (.+) '\/etc\/netctl\/eth2'/)
|
expect(comm.received_commands[0]).to match(/mv (.+) '\/etc\/netctl\/eth2'/)
|
||||||
expect(comm.received_commands[1]).to match(/ip link set 'eth2' down/)
|
expect(comm.received_commands[0]).to match(/ip link set 'eth2' down/)
|
||||||
expect(comm.received_commands[1]).to match(/netctl restart 'eth2'/)
|
expect(comm.received_commands[0]).to match(/netctl restart 'eth2'/)
|
||||||
expect(comm.received_commands[1]).to match(/netctl enable 'eth2'/)
|
expect(comm.received_commands[0]).to match(/netctl enable 'eth2'/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
require_relative "../../../../base"
|
require_relative "../../../../base"
|
||||||
|
|
||||||
describe "VagrantPlugins::GuestAtomic::Cap::ChangeHostName" do
|
describe "VagrantPlugins::GuestAtomic::Cap::ChangeHostName" do
|
||||||
let(:described_class) do
|
let(:caps) do
|
||||||
VagrantPlugins::GuestAtomic::Plugin
|
VagrantPlugins::GuestAtomic::Plugin
|
||||||
.components
|
.components
|
||||||
.guest_capabilities[:atomic]
|
.guest_capabilities[:atomic]
|
||||||
.get(:change_host_name)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:machine) { double("machine") }
|
let(:machine) { double("machine") }
|
||||||
|
@ -20,18 +19,20 @@ describe "VagrantPlugins::GuestAtomic::Cap::ChangeHostName" do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe ".change_host_name" do
|
describe ".change_host_name" do
|
||||||
let(:hostname) { "banana-rama.example.com" }
|
let(:cap) { caps.get(:change_host_name) }
|
||||||
|
|
||||||
|
let(:name) { "banana-rama.example.com" }
|
||||||
|
|
||||||
it "sets the hostname" do
|
it "sets the hostname" do
|
||||||
comm.stub_command("hostname | grep -w '#{hostname}'", exit_code: 1)
|
comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 1)
|
||||||
|
|
||||||
described_class.change_host_name(machine, hostname)
|
cap.change_host_name(machine, name)
|
||||||
expect(comm.received_commands[1]).to match(/hostnamectl set-hostname '#{hostname}'/)
|
expect(comm.received_commands[1]).to match(/hostnamectl set-hostname 'banana-rama'/)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not change the hostname if already set" do
|
it "does not change the hostname if already set" do
|
||||||
comm.stub_command("hostname | grep -w '#{hostname}'", exit_code: 0)
|
comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 0)
|
||||||
described_class.change_host_name(machine, hostname)
|
cap.change_host_name(machine, name)
|
||||||
expect(comm.received_commands.size).to eq(1)
|
expect(comm.received_commands.size).to eq(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,12 +22,12 @@ describe "VagrantPlugins::GuestBSD::Cap::Halt" do
|
||||||
let(:cap) { caps.get(:halt) }
|
let(:cap) { caps.get(:halt) }
|
||||||
|
|
||||||
it "runs the shutdown command" do
|
it "runs the shutdown command" do
|
||||||
comm.expect_command("/sbin/shutdown -p -h now")
|
comm.expect_command("/sbin/shutdown -p now")
|
||||||
cap.halt(machine)
|
cap.halt(machine)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "ignores an IOError" do
|
it "ignores an IOError" do
|
||||||
comm.stub_command("/sbin/shutdown -p -h now", raise: IOError)
|
comm.stub_command("/sbin/shutdown -p now", raise: IOError)
|
||||||
expect {
|
expect {
|
||||||
cap.halt(machine)
|
cap.halt(machine)
|
||||||
}.to_not raise_error
|
}.to_not raise_error
|
||||||
|
|
|
@ -20,17 +20,17 @@ describe "VagrantPlugins::GuestCoreOS::Cap::ChangeHostName" do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe ".change_host_name" do
|
describe ".change_host_name" do
|
||||||
let(:hostname) { "banana-rama.example.com" }
|
let(:name) { "banana-rama.example.com" }
|
||||||
|
|
||||||
it "sets the hostname" do
|
it "sets the hostname" do
|
||||||
comm.stub_command("hostname --fqdn | grep -w '#{hostname}'", exit_code: 1)
|
comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 1)
|
||||||
comm.expect_command("hostname 'banana-rama'")
|
comm.expect_command("hostname 'banana-rama'")
|
||||||
described_class.change_host_name(machine, hostname)
|
described_class.change_host_name(machine, name)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not change the hostname if already set" do
|
it "does not change the hostname if already set" do
|
||||||
comm.stub_command("hostname --fqdn | grep -w '#{hostname}'", exit_code: 0)
|
comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 0)
|
||||||
described_class.change_host_name(machine, hostname)
|
described_class.change_host_name(machine, name)
|
||||||
expect(comm.received_commands.size).to eq(1)
|
expect(comm.received_commands.size).to eq(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,11 +20,11 @@ describe "VagrantPlugins::GuestDarwin::Cap::ChangeHostName" do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe ".change_host_name" do
|
describe ".change_host_name" do
|
||||||
let(:hostname) { "banana-rama.example.com" }
|
let(:name) { "banana-rama.example.com" }
|
||||||
|
|
||||||
it "sets the hostname" do
|
it "sets the hostname" do
|
||||||
comm.stub_command("hostname -f | grep -w '#{hostname}' || hostname -s | grep -w '#{hostname}'", exit_code: 1)
|
comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 1)
|
||||||
described_class.change_host_name(machine, hostname)
|
described_class.change_host_name(machine, name)
|
||||||
expect(comm.received_commands[1]).to match(/scutil --set ComputerName 'banana-rama.example.com'/)
|
expect(comm.received_commands[1]).to match(/scutil --set ComputerName 'banana-rama.example.com'/)
|
||||||
expect(comm.received_commands[1]).to match(/scutil --set HostName 'banana-rama.example.com'/)
|
expect(comm.received_commands[1]).to match(/scutil --set HostName 'banana-rama.example.com'/)
|
||||||
expect(comm.received_commands[1]).to match(/scutil --set LocalHostName 'banana-rama'/)
|
expect(comm.received_commands[1]).to match(/scutil --set LocalHostName 'banana-rama'/)
|
||||||
|
@ -32,8 +32,8 @@ describe "VagrantPlugins::GuestDarwin::Cap::ChangeHostName" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not change the hostname if already set" do
|
it "does not change the hostname if already set" do
|
||||||
comm.stub_command("hostname -f | grep -w '#{hostname}' || hostname -s | grep -w '#{hostname}'", exit_code: 0)
|
comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 0)
|
||||||
described_class.change_host_name(machine, hostname)
|
described_class.change_host_name(machine, name)
|
||||||
expect(comm.received_commands.size).to eq(1)
|
expect(comm.received_commands.size).to eq(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,16 +24,14 @@ describe "VagrantPlugins::GuestDebian::Cap::ChangeHostName" do
|
||||||
let(:name) { 'banana-rama.example.com' }
|
let(:name) { 'banana-rama.example.com' }
|
||||||
|
|
||||||
it "sets the hostname if not set" do
|
it "sets the hostname if not set" do
|
||||||
comm.stub_command("hostname -f | grep -w '#{name}'", exit_code: 1)
|
comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 1)
|
||||||
cap.change_host_name(machine, name)
|
cap.change_host_name(machine, name)
|
||||||
expect(comm.received_commands[1]).to match(/hostname -F \/etc\/hostname/)
|
expect(comm.received_commands[1]).to match(/hostname -F \/etc\/hostname/)
|
||||||
expect(comm.received_commands[1]).to match(/invoke-rc.d hostname.sh start/)
|
expect(comm.received_commands[1]).to match(/hostname.sh start/)
|
||||||
expect(comm.received_commands[1]).to match(/invoke-rc.d networking force-reload/)
|
|
||||||
expect(comm.received_commands[1]).to match(/invoke-rc.d network-manager force-reload/)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not set the hostname if unset" do
|
it "does not set the hostname if unset" do
|
||||||
comm.stub_command("hostname -f | grep -w '#{name}'", exit_code: 0)
|
comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 0)
|
||||||
cap.change_host_name(machine, name)
|
cap.change_host_name(machine, name)
|
||||||
expect(comm.received_commands.size).to eq(1)
|
expect(comm.received_commands.size).to eq(1)
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,13 +7,12 @@ describe "VagrantPlugins::GuestDebian::Cap::ConfigureNetworks" do
|
||||||
.guest_capabilities[:debian]
|
.guest_capabilities[:debian]
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:machine) { double("machine") }
|
let(:guest) { double("guest") }
|
||||||
|
let(:machine) { double("machine", guest: guest) }
|
||||||
let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) }
|
let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(machine).to receive(:communicate).and_return(comm)
|
allow(machine).to receive(:communicate).and_return(comm)
|
||||||
comm.stub_command("ip -o -0 addr | grep -v LOOPBACK | awk '{print $2}' | sed 's/://'",
|
|
||||||
stdout: "eth1\neth2")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
|
@ -23,6 +22,11 @@ describe "VagrantPlugins::GuestDebian::Cap::ConfigureNetworks" do
|
||||||
describe ".configure_networks" do
|
describe ".configure_networks" do
|
||||||
let(:cap) { caps.get(:configure_networks) }
|
let(:cap) { caps.get(:configure_networks) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
allow(guest).to receive(:capability).with(:network_interfaces)
|
||||||
|
.and_return(["eth1", "eth2"])
|
||||||
|
end
|
||||||
|
|
||||||
let(:network_0) do
|
let(:network_0) do
|
||||||
{
|
{
|
||||||
interface: 0,
|
interface: 0,
|
||||||
|
@ -43,12 +47,12 @@ describe "VagrantPlugins::GuestDebian::Cap::ConfigureNetworks" do
|
||||||
it "creates and starts the networks" do
|
it "creates and starts the networks" do
|
||||||
cap.configure_networks(machine, [network_0, network_1])
|
cap.configure_networks(machine, [network_0, network_1])
|
||||||
|
|
||||||
expect(comm.received_commands[1]).to match("/sbin/ifdown 'eth1' || true")
|
expect(comm.received_commands[0]).to match("/sbin/ifdown 'eth1' || true")
|
||||||
expect(comm.received_commands[1]).to match("/sbin/ip addr flush dev 'eth1'")
|
expect(comm.received_commands[0]).to match("/sbin/ip addr flush dev 'eth1'")
|
||||||
expect(comm.received_commands[1]).to match("/sbin/ifdown 'eth2' || true")
|
expect(comm.received_commands[0]).to match("/sbin/ifdown 'eth2' || true")
|
||||||
expect(comm.received_commands[1]).to match("/sbin/ip addr flush dev 'eth2'")
|
expect(comm.received_commands[0]).to match("/sbin/ip addr flush dev 'eth2'")
|
||||||
expect(comm.received_commands[1]).to match("/sbin/ifup 'eth1'")
|
expect(comm.received_commands[0]).to match("/sbin/ifup 'eth1'")
|
||||||
expect(comm.received_commands[1]).to match("/sbin/ifup 'eth2'")
|
expect(comm.received_commands[0]).to match("/sbin/ifup 'eth2'")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,19 +20,11 @@ describe "VagrantPlugins::GuestDebian::Cap:RSync" do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe ".rsync_install" do
|
describe ".rsync_install" do
|
||||||
it "installs rsync when not installed" do
|
it "installs rsync" do
|
||||||
comm.stub_command("command -v rsync", exit_code: 1)
|
|
||||||
described_class.rsync_install(machine)
|
described_class.rsync_install(machine)
|
||||||
|
|
||||||
expect(comm.received_commands[1]).to match(/apt-get -yqq update/)
|
expect(comm.received_commands[0]).to match(/apt-get -yqq update/)
|
||||||
expect(comm.received_commands[1]).to match(/apt-get -yqq install rsync/)
|
expect(comm.received_commands[0]).to match(/apt-get -yqq install rsync/)
|
||||||
end
|
|
||||||
|
|
||||||
it "does not install rsync when installed" do
|
|
||||||
comm.stub_command("command -v rsync", exit_code: 0)
|
|
||||||
described_class.rsync_install(machine)
|
|
||||||
|
|
||||||
expect(comm.received_commands.join("")).to_not match(/update/)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,7 +23,7 @@ describe "VagrantPlugins::GuestFreeBSD::Cap::ChangeHostName" do
|
||||||
let(:name) { "banana-rama.example.com" }
|
let(:name) { "banana-rama.example.com" }
|
||||||
|
|
||||||
it "sets the hostname and /etc/hosts" do
|
it "sets the hostname and /etc/hosts" do
|
||||||
comm.stub_command("hostname -f | grep -w '#{name}' || hostname -s | grep -w '#{name}'", exit_code: 1)
|
comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 1)
|
||||||
described_class.change_host_name(machine, name)
|
described_class.change_host_name(machine, name)
|
||||||
|
|
||||||
expect(comm.received_commands[1]).to match(/hostname '#{name}'/)
|
expect(comm.received_commands[1]).to match(/hostname '#{name}'/)
|
||||||
|
@ -32,7 +32,7 @@ describe "VagrantPlugins::GuestFreeBSD::Cap::ChangeHostName" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does nothing if the hostname is already set" do
|
it "does nothing if the hostname is already set" do
|
||||||
comm.stub_command("hostname -f | grep -w '#{name}' || hostname -s | grep -w '#{name}'", exit_code: 0)
|
comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 0)
|
||||||
described_class.change_host_name(machine, name)
|
described_class.change_host_name(machine, name)
|
||||||
expect(comm.received_commands.size).to eq(1)
|
expect(comm.received_commands.size).to eq(1)
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,7 +24,7 @@ describe "VagrantPlugins::GuestOmniOS::Cap:RSync" do
|
||||||
let(:name) { "banana-rama.example.com" }
|
let(:name) { "banana-rama.example.com" }
|
||||||
|
|
||||||
it "sets the hostname if unset" do
|
it "sets the hostname if unset" do
|
||||||
comm.stub_command("hostname | grep -w '#{name}'", exit_code: 1)
|
comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 1)
|
||||||
cap.change_host_name(machine, name)
|
cap.change_host_name(machine, name)
|
||||||
|
|
||||||
expect(comm.received_commands[1]).to match(/echo '#{name}' > \/etc\/nodename/)
|
expect(comm.received_commands[1]).to match(/echo '#{name}' > \/etc\/nodename/)
|
||||||
|
@ -32,7 +32,7 @@ describe "VagrantPlugins::GuestOmniOS::Cap:RSync" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not set the hostname if set" do
|
it "does not set the hostname if set" do
|
||||||
comm.stub_command("hostname | grep -w '#{name}'", exit_code: 0)
|
comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 0)
|
||||||
cap.change_host_name(machine, name)
|
cap.change_host_name(machine, name)
|
||||||
|
|
||||||
expect(comm.received_commands.size).to eq(1)
|
expect(comm.received_commands.size).to eq(1)
|
||||||
|
|
|
@ -26,7 +26,7 @@ describe "VagrantPlugins::GuestPhoton::Cap::ChangeHostName" do
|
||||||
let(:name) { "banana-rama.example.com" }
|
let(:name) { "banana-rama.example.com" }
|
||||||
|
|
||||||
it "sets the hostname" do
|
it "sets the hostname" do
|
||||||
comm.stub_command("hostname -f | grep -w '#{name}'", exit_code: 1)
|
comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 1)
|
||||||
|
|
||||||
cap.change_host_name(machine, name)
|
cap.change_host_name(machine, name)
|
||||||
expect(comm.received_commands[1]).to match(/echo '#{name}' > \/etc\/hostname/)
|
expect(comm.received_commands[1]).to match(/echo '#{name}' > \/etc\/hostname/)
|
||||||
|
@ -34,7 +34,7 @@ describe "VagrantPlugins::GuestPhoton::Cap::ChangeHostName" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not change the hostname if already set" do
|
it "does not change the hostname if already set" do
|
||||||
comm.stub_command("hostname -f | grep -w '#{name}'", exit_code: 0)
|
comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 0)
|
||||||
cap.change_host_name(machine, name)
|
cap.change_host_name(machine, name)
|
||||||
expect(comm.received_commands.size).to eq(1)
|
expect(comm.received_commands.size).to eq(1)
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,14 +24,14 @@ describe "VagrantPlugins::GuestPld::Cap::ChangeHostName" do
|
||||||
let(:name) { "banana-rama.example.com" }
|
let(:name) { "banana-rama.example.com" }
|
||||||
|
|
||||||
it "sets the hostname" do
|
it "sets the hostname" do
|
||||||
comm.stub_command("hostname | grep -w '#{name}'", exit_code: 1)
|
comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 1)
|
||||||
|
|
||||||
cap.change_host_name(machine, name)
|
cap.change_host_name(machine, name)
|
||||||
expect(comm.received_commands[1]).to match(/hostname '#{name}'/)
|
expect(comm.received_commands[1]).to match(/hostname '#{name}'/)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not change the hostname if already set" do
|
it "does not change the hostname if already set" do
|
||||||
comm.stub_command("hostname | grep -w '#{name}'", exit_code: 0)
|
comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 0)
|
||||||
cap.change_host_name(machine, name)
|
cap.change_host_name(machine, name)
|
||||||
expect(comm.received_commands.size).to eq(1)
|
expect(comm.received_commands.size).to eq(1)
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,17 +24,18 @@ describe "VagrantPlugins::GuestRedHat::Cap::ChangeHostName" do
|
||||||
let(:name) { "banana-rama.example.com" }
|
let(:name) { "banana-rama.example.com" }
|
||||||
|
|
||||||
it "sets the hostname" do
|
it "sets the hostname" do
|
||||||
comm.stub_command("hostname -f | grep -w '#{name}'", exit_code: 1)
|
comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 1)
|
||||||
|
|
||||||
cap.change_host_name(machine, name)
|
cap.change_host_name(machine, name)
|
||||||
expect(comm.received_commands[1]).to match(/\/etc\/sysconfig\/network/)
|
expect(comm.received_commands[1]).to match(/\/etc\/sysconfig\/network/)
|
||||||
expect(comm.received_commands[1]).to match(/\/etc\/sysconfig\/network-scripts\/ifcfg/)
|
expect(comm.received_commands[1]).to match(/\/etc\/sysconfig\/network-scripts\/ifcfg/)
|
||||||
expect(comm.received_commands[1]).to match(/hostnamectl set-hostname '#{name}'/)
|
expect(comm.received_commands[1]).to match(/hostnamectl set-hostname --static '#{name}'/)
|
||||||
|
expect(comm.received_commands[1]).to match(/hostnamectl set-hostname --transient '#{name}'/)
|
||||||
expect(comm.received_commands[1]).to match(/service network restart/)
|
expect(comm.received_commands[1]).to match(/service network restart/)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not change the hostname if already set" do
|
it "does not change the hostname if already set" do
|
||||||
comm.stub_command("hostname -f | grep -w '#{name}'", exit_code: 0)
|
comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 0)
|
||||||
cap.change_host_name(machine, name)
|
cap.change_host_name(machine, name)
|
||||||
expect(comm.received_commands.size).to eq(1)
|
expect(comm.received_commands.size).to eq(1)
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,13 +7,12 @@ describe "VagrantPlugins::GuestRedHat::Cap::ConfigureNetworks" do
|
||||||
.guest_capabilities[:redhat]
|
.guest_capabilities[:redhat]
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:machine) { double("machine") }
|
let(:guest) { double("guest") }
|
||||||
|
let(:machine) { double("machine", guest: guest) }
|
||||||
let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) }
|
let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(machine).to receive(:communicate).and_return(comm)
|
allow(machine).to receive(:communicate).and_return(comm)
|
||||||
comm.stub_command("/sbin/ip -o -0 addr | grep -v LOOPBACK | awk '{print $2}' | sed 's/://'",
|
|
||||||
stdout: "eth1\neth2")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
|
@ -23,6 +22,16 @@ describe "VagrantPlugins::GuestRedHat::Cap::ConfigureNetworks" do
|
||||||
describe ".configure_networks" do
|
describe ".configure_networks" do
|
||||||
let(:cap) { caps.get(:configure_networks) }
|
let(:cap) { caps.get(:configure_networks) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
allow(guest).to receive(:capability)
|
||||||
|
.with(:network_scripts_dir)
|
||||||
|
.and_return("/scripts")
|
||||||
|
|
||||||
|
allow(guest).to receive(:capability)
|
||||||
|
.with(:network_interfaces)
|
||||||
|
.and_return(["eth1", "eth2"])
|
||||||
|
end
|
||||||
|
|
||||||
let(:network_1) do
|
let(:network_1) do
|
||||||
{
|
{
|
||||||
interface: 0,
|
interface: 0,
|
||||||
|
@ -40,41 +49,16 @@ describe "VagrantPlugins::GuestRedHat::Cap::ConfigureNetworks" do
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:network_scripts_dir) { "/" }
|
|
||||||
|
|
||||||
let(:capability) { double("capability") }
|
|
||||||
|
|
||||||
before do
|
|
||||||
allow(machine).to receive(:guest).and_return(capability)
|
|
||||||
allow(capability).to receive(:capability)
|
|
||||||
.with(:network_scripts_dir)
|
|
||||||
.and_return(network_scripts_dir)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "uses fedora for rhel7 configuration" do
|
|
||||||
require_relative "../../../../../../plugins/guests/fedora/cap/configure_networks"
|
|
||||||
|
|
||||||
allow(capability).to receive(:capability)
|
|
||||||
.with(:flavor)
|
|
||||||
.and_return(:rhel_7)
|
|
||||||
allow(VagrantPlugins::GuestFedora::Cap::ConfigureNetworks)
|
|
||||||
.to receive(:configure_networks)
|
|
||||||
|
|
||||||
expect(VagrantPlugins::GuestFedora::Cap::ConfigureNetworks)
|
|
||||||
.to receive(:configure_networks).once
|
|
||||||
cap.configure_networks(machine, [network_1, network_2])
|
|
||||||
end
|
|
||||||
|
|
||||||
it "creates and starts the networks" do
|
it "creates and starts the networks" do
|
||||||
allow(capability).to receive(:capability)
|
allow(guest).to receive(:capability)
|
||||||
.with(:flavor)
|
.with(:flavor)
|
||||||
.and_return(:rhel)
|
.and_return(:rhel)
|
||||||
|
|
||||||
cap.configure_networks(machine, [network_1, network_2])
|
cap.configure_networks(machine, [network_1, network_2])
|
||||||
expect(comm.received_commands[1]).to match(/\/sbin\/ifdown 'eth1'/)
|
expect(comm.received_commands[0]).to match(/\/sbin\/ifdown 'eth1'/)
|
||||||
expect(comm.received_commands[1]).to match(/\/sbin\/ifup 'eth1'/)
|
expect(comm.received_commands[0]).to match(/\/sbin\/ifup 'eth1'/)
|
||||||
expect(comm.received_commands[1]).to match(/\/sbin\/ifdown 'eth2'/)
|
expect(comm.received_commands[0]).to match(/\/sbin\/ifdown 'eth2'/)
|
||||||
expect(comm.received_commands[1]).to match(/\/sbin\/ifup 'eth2'/)
|
expect(comm.received_commands[0]).to match(/\/sbin\/ifup 'eth2'/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,7 +24,7 @@ describe "VagrantPlugins::GuestSlackware::Cap::ChangeHostName" do
|
||||||
let(:name) { "banana-rama.example.com" }
|
let(:name) { "banana-rama.example.com" }
|
||||||
|
|
||||||
it "sets the hostname" do
|
it "sets the hostname" do
|
||||||
comm.stub_command("hostname -f | grep -w '#{name}'", exit_code: 1)
|
comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 1)
|
||||||
|
|
||||||
cap.change_host_name(machine, name)
|
cap.change_host_name(machine, name)
|
||||||
expect(comm.received_commands[1]).to match(/echo '#{name}' > \/etc\/hostname/)
|
expect(comm.received_commands[1]).to match(/echo '#{name}' > \/etc\/hostname/)
|
||||||
|
@ -32,7 +32,7 @@ describe "VagrantPlugins::GuestSlackware::Cap::ChangeHostName" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not change the hostname if already set" do
|
it "does not change the hostname if already set" do
|
||||||
comm.stub_command("hostname -f | grep -w '#{name}'", exit_code: 0)
|
comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 0)
|
||||||
cap.change_host_name(machine, name)
|
cap.change_host_name(machine, name)
|
||||||
expect(comm.received_commands.size).to eq(1)
|
expect(comm.received_commands.size).to eq(1)
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,13 +7,12 @@ describe "VagrantPlugins::GuestSlackware::Cap::ConfigureNetworks" do
|
||||||
.guest_capabilities[:slackware]
|
.guest_capabilities[:slackware]
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:machine) { double("machine") }
|
let(:guest) { double("guest") }
|
||||||
|
let(:machine) { double("machine", guest: guest) }
|
||||||
let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) }
|
let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(machine).to receive(:communicate).and_return(comm)
|
allow(machine).to receive(:communicate).and_return(comm)
|
||||||
comm.stub_command("ip -o -0 addr | grep -v LOOPBACK | awk '{print $2}' | sed 's/://'",
|
|
||||||
stdout: "eth1\neth2")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
|
@ -23,6 +22,11 @@ describe "VagrantPlugins::GuestSlackware::Cap::ConfigureNetworks" do
|
||||||
describe ".configure_networks" do
|
describe ".configure_networks" do
|
||||||
let(:cap) { caps.get(:configure_networks) }
|
let(:cap) { caps.get(:configure_networks) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
allow(guest).to receive(:capability).with(:network_interfaces)
|
||||||
|
.and_return(["eth1", "eth2"])
|
||||||
|
end
|
||||||
|
|
||||||
let(:network_1) do
|
let(:network_1) do
|
||||||
{
|
{
|
||||||
interface: 0,
|
interface: 0,
|
||||||
|
@ -42,7 +46,7 @@ describe "VagrantPlugins::GuestSlackware::Cap::ConfigureNetworks" do
|
||||||
|
|
||||||
it "creates and starts the networks" do
|
it "creates and starts the networks" do
|
||||||
cap.configure_networks(machine, [network_1, network_2])
|
cap.configure_networks(machine, [network_1, network_2])
|
||||||
expect(comm.received_commands[1]).to match(/\/etc\/rc.d\/rc.inet1/)
|
expect(comm.received_commands[0]).to match(/\/etc\/rc.d\/rc.inet1/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,7 +24,7 @@ describe "VagrantPlugins::GuestSUSE::Cap::ChangeHostName" do
|
||||||
let(:name) { "banana-rama.example.com" }
|
let(:name) { "banana-rama.example.com" }
|
||||||
|
|
||||||
it "sets the hostname" do
|
it "sets the hostname" do
|
||||||
comm.stub_command("hostname -f | grep -w '#{name}'", exit_code: 1)
|
comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 1)
|
||||||
|
|
||||||
cap.change_host_name(machine, name)
|
cap.change_host_name(machine, name)
|
||||||
expect(comm.received_commands[1]).to match(/echo '#{name}' > \/etc\/HOSTNAME/)
|
expect(comm.received_commands[1]).to match(/echo '#{name}' > \/etc\/HOSTNAME/)
|
||||||
|
@ -32,7 +32,7 @@ describe "VagrantPlugins::GuestSUSE::Cap::ChangeHostName" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not change the hostname if already set" do
|
it "does not change the hostname if already set" do
|
||||||
comm.stub_command("hostname -f | grep -w '#{name}'", exit_code: 0)
|
comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 0)
|
||||||
cap.change_host_name(machine, name)
|
cap.change_host_name(machine, name)
|
||||||
expect(comm.received_commands.size).to eq(1)
|
expect(comm.received_commands.size).to eq(1)
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,13 +7,12 @@ describe "VagrantPlugins::GuestSUSE::Cap::ConfigureNetworks" do
|
||||||
.guest_capabilities[:suse]
|
.guest_capabilities[:suse]
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:machine) { double("machine") }
|
let(:guest) { double("guest") }
|
||||||
|
let(:machine) { double("machine", guest: guest) }
|
||||||
let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) }
|
let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(machine).to receive(:communicate).and_return(comm)
|
allow(machine).to receive(:communicate).and_return(comm)
|
||||||
comm.stub_command("ip -o -0 addr | grep -v LOOPBACK | awk '{print $2}' | sed 's/://'",
|
|
||||||
stdout: "eth1\neth2")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
|
@ -23,6 +22,13 @@ describe "VagrantPlugins::GuestSUSE::Cap::ConfigureNetworks" do
|
||||||
describe ".configure_networks" do
|
describe ".configure_networks" do
|
||||||
let(:cap) { caps.get(:configure_networks) }
|
let(:cap) { caps.get(:configure_networks) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
allow(guest).to receive(:capability).with(:network_scripts_dir)
|
||||||
|
.and_return("/scripts")
|
||||||
|
allow(guest).to receive(:capability).with(:network_interfaces)
|
||||||
|
.and_return(["eth1", "eth2"])
|
||||||
|
end
|
||||||
|
|
||||||
let(:network_1) do
|
let(:network_1) do
|
||||||
{
|
{
|
||||||
interface: 0,
|
interface: 0,
|
||||||
|
@ -40,21 +46,12 @@ describe "VagrantPlugins::GuestSUSE::Cap::ConfigureNetworks" do
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:guest) { double("guest") }
|
|
||||||
|
|
||||||
before do
|
|
||||||
allow(machine).to receive(:guest).and_return(guest)
|
|
||||||
allow(guest).to receive(:capability)
|
|
||||||
.with(:network_scripts_dir)
|
|
||||||
.and_return("/scripts")
|
|
||||||
end
|
|
||||||
|
|
||||||
it "creates and starts the networks" do
|
it "creates and starts the networks" do
|
||||||
cap.configure_networks(machine, [network_1, network_2])
|
cap.configure_networks(machine, [network_1, network_2])
|
||||||
expect(comm.received_commands[1]).to match(/\/sbin\/ifdown 'eth1'/)
|
expect(comm.received_commands[0]).to match(/\/sbin\/ifdown 'eth1'/)
|
||||||
expect(comm.received_commands[1]).to match(/\/sbin\/ifup 'eth1'/)
|
expect(comm.received_commands[0]).to match(/\/sbin\/ifup 'eth1'/)
|
||||||
expect(comm.received_commands[1]).to match(/\/sbin\/ifdown 'eth2'/)
|
expect(comm.received_commands[0]).to match(/\/sbin\/ifdown 'eth2'/)
|
||||||
expect(comm.received_commands[1]).to match(/\/sbin\/ifup 'eth2'/)
|
expect(comm.received_commands[0]).to match(/\/sbin\/ifup 'eth2'/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
require_relative "../../../../base"
|
|
||||||
|
|
||||||
describe "VagrantPlugins::GuestUbuntu::Cap::ChangeHostName" do
|
|
||||||
let(:caps) do
|
|
||||||
VagrantPlugins::GuestUbuntu::Plugin
|
|
||||||
.components
|
|
||||||
.guest_capabilities[:ubuntu]
|
|
||||||
end
|
|
||||||
|
|
||||||
let(:machine) { double("machine") }
|
|
||||||
let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) }
|
|
||||||
|
|
||||||
before do
|
|
||||||
allow(machine).to receive(:communicate).and_return(comm)
|
|
||||||
end
|
|
||||||
|
|
||||||
after do
|
|
||||||
comm.verify_expectations!
|
|
||||||
end
|
|
||||||
|
|
||||||
describe ".change_host_name" do
|
|
||||||
let(:cap) { caps.get(:change_host_name) }
|
|
||||||
|
|
||||||
let(:name) { 'banana-rama.example.com' }
|
|
||||||
|
|
||||||
it "sets the hostname if not set" do
|
|
||||||
comm.stub_command("hostname -f | grep -w '#{name}'", exit_code: 1)
|
|
||||||
cap.change_host_name(machine, name)
|
|
||||||
expect(comm.received_commands[1]).to match(/hostname -F \/etc\/hostname/)
|
|
||||||
expect(comm.received_commands[1]).to match(/\/etc\/init.d\/hostname.sh start/)
|
|
||||||
expect(comm.received_commands[1]).to match(/\/etc\/init.d\/hostname start/)
|
|
||||||
expect(comm.received_commands[1]).to match(/\/etc\/init.d\/networking force-reload/)
|
|
||||||
expect(comm.received_commands[1]).to match(/\/etc\/init.d\/network-manager force-reload/)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "does not set the hostname if unset" do
|
|
||||||
comm.stub_command("hostname -f | grep -w '#{name}'", exit_code: 0)
|
|
||||||
cap.change_host_name(machine, name)
|
|
||||||
expect(comm.received_commands.size).to eq(1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -7,8 +7,9 @@ describe "templates/guests/arch/network_static" do
|
||||||
|
|
||||||
it "renders the template" do
|
it "renders the template" do
|
||||||
result = Vagrant::Util::TemplateRenderer.render(template, options: {
|
result = Vagrant::Util::TemplateRenderer.render(template, options: {
|
||||||
device: "eth1",
|
device: "eth1",
|
||||||
ip: "1.1.1.1",
|
ip: "1.1.1.1",
|
||||||
|
netmask: "24",
|
||||||
})
|
})
|
||||||
expect(result).to eq <<-EOH.gsub(/^ {6}/, "")
|
expect(result).to eq <<-EOH.gsub(/^ {6}/, "")
|
||||||
Connection=ethernet
|
Connection=ethernet
|
||||||
|
@ -24,6 +25,7 @@ describe "templates/guests/arch/network_static" do
|
||||||
device: "eth1",
|
device: "eth1",
|
||||||
ip: "1.1.1.1",
|
ip: "1.1.1.1",
|
||||||
gateway: "1.2.3.4",
|
gateway: "1.2.3.4",
|
||||||
|
netmask: "24",
|
||||||
})
|
})
|
||||||
expect(result).to eq <<-EOH.gsub(/^ {6}/, "")
|
expect(result).to eq <<-EOH.gsub(/^ {6}/, "")
|
||||||
Connection=ethernet
|
Connection=ethernet
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
require_relative "../../../base"
|
|
||||||
|
|
||||||
require "vagrant/util/template_renderer"
|
|
||||||
|
|
||||||
describe "templates/guests/fedora/network_dhcp" do
|
|
||||||
let(:template) { "guests/fedora/network_dhcp" }
|
|
||||||
|
|
||||||
it "renders the template" do
|
|
||||||
result = Vagrant::Util::TemplateRenderer.render(template, options: {
|
|
||||||
device: "en0",
|
|
||||||
})
|
|
||||||
expect(result).to eq <<-EOH.gsub(/^ {6}/, "")
|
|
||||||
#VAGRANT-BEGIN
|
|
||||||
# The contents below are automatically generated by Vagrant. Do not modify.
|
|
||||||
BOOTPROTO=dhcp
|
|
||||||
ONBOOT=yes
|
|
||||||
DEVICE=en0
|
|
||||||
#VAGRANT-END
|
|
||||||
EOH
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,25 +0,0 @@
|
||||||
require_relative "../../../base"
|
|
||||||
|
|
||||||
require "vagrant/util/template_renderer"
|
|
||||||
|
|
||||||
describe "templates/guests/fedora/network_static6" do
|
|
||||||
let(:template) { "guests/fedora/network_static6" }
|
|
||||||
|
|
||||||
it "renders the template" do
|
|
||||||
result = Vagrant::Util::TemplateRenderer.render(template, options: {
|
|
||||||
device: "en0",
|
|
||||||
ip: "fc00::10/64"
|
|
||||||
})
|
|
||||||
expect(result).to eq <<-EOH.gsub(/^ {6}/, "")
|
|
||||||
#VAGRANT-BEGIN
|
|
||||||
# The contents below are automatically generated by Vagrant. Do not modify.
|
|
||||||
NM_CONTROLLED=no
|
|
||||||
BOOTPROTO=static
|
|
||||||
ONBOOT=yes
|
|
||||||
IPV6INIT=yes
|
|
||||||
IPV6ADDR=fc00::10/64
|
|
||||||
DEVICE=en0
|
|
||||||
#VAGRANT-END
|
|
||||||
EOH
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,71 +0,0 @@
|
||||||
require_relative "../../../base"
|
|
||||||
|
|
||||||
require "vagrant/util/template_renderer"
|
|
||||||
|
|
||||||
describe "templates/guests/fedora/network_static" do
|
|
||||||
let(:template) { "guests/fedora/network_static" }
|
|
||||||
|
|
||||||
it "renders the template" do
|
|
||||||
result = Vagrant::Util::TemplateRenderer.render(template, options: {
|
|
||||||
device: "en0",
|
|
||||||
ip: "1.1.1.1",
|
|
||||||
netmask: "255.255.0.0",
|
|
||||||
})
|
|
||||||
expect(result).to eq <<-EOH.gsub(/^ {6}/, "")
|
|
||||||
#VAGRANT-BEGIN
|
|
||||||
# The contents below are automatically generated by Vagrant. Do not modify.
|
|
||||||
NM_CONTROLLED=no
|
|
||||||
BOOTPROTO=none
|
|
||||||
ONBOOT=yes
|
|
||||||
IPADDR=1.1.1.1
|
|
||||||
NETMASK=255.255.0.0
|
|
||||||
DEVICE=en0
|
|
||||||
PEERDNS=no
|
|
||||||
#VAGRANT-END
|
|
||||||
EOH
|
|
||||||
end
|
|
||||||
|
|
||||||
it "includes the gateway" do
|
|
||||||
result = Vagrant::Util::TemplateRenderer.render(template, options: {
|
|
||||||
device: "en0",
|
|
||||||
ip: "1.1.1.1",
|
|
||||||
netmask: "255.255.0.0",
|
|
||||||
gateway: "1.2.3.4",
|
|
||||||
})
|
|
||||||
expect(result).to eq <<-EOH.gsub(/^ {6}/, "")
|
|
||||||
#VAGRANT-BEGIN
|
|
||||||
# The contents below are automatically generated by Vagrant. Do not modify.
|
|
||||||
NM_CONTROLLED=no
|
|
||||||
BOOTPROTO=none
|
|
||||||
ONBOOT=yes
|
|
||||||
IPADDR=1.1.1.1
|
|
||||||
NETMASK=255.255.0.0
|
|
||||||
DEVICE=en0
|
|
||||||
GATEWAY=1.2.3.4
|
|
||||||
PEERDNS=no
|
|
||||||
#VAGRANT-END
|
|
||||||
EOH
|
|
||||||
end
|
|
||||||
|
|
||||||
it "includes the mac_address" do
|
|
||||||
result = Vagrant::Util::TemplateRenderer.render(template, options: {
|
|
||||||
device: "en0",
|
|
||||||
ip: "1.1.1.1",
|
|
||||||
netmask: "255.255.0.0",
|
|
||||||
mac_address: "abcd1234",
|
|
||||||
})
|
|
||||||
expect(result).to eq <<-EOH.gsub(/^ {6}/, "")
|
|
||||||
#VAGRANT-BEGIN
|
|
||||||
# The contents below are automatically generated by Vagrant. Do not modify.
|
|
||||||
NM_CONTROLLED=no
|
|
||||||
BOOTPROTO=none
|
|
||||||
ONBOOT=yes
|
|
||||||
IPADDR=1.1.1.1
|
|
||||||
NETMASK=255.255.0.0
|
|
||||||
DEVICE=en0
|
|
||||||
HWADDR=abcd1234
|
|
||||||
PEERDNS=no
|
|
||||||
#VAGRANT-END
|
|
||||||
EOH
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -7,12 +7,12 @@ describe "templates/guests/gentoo/network_dhcp" do
|
||||||
|
|
||||||
it "renders the template" do
|
it "renders the template" do
|
||||||
result = Vagrant::Util::TemplateRenderer.render(template, options: {
|
result = Vagrant::Util::TemplateRenderer.render(template, options: {
|
||||||
interface: "en0",
|
device: "en0",
|
||||||
})
|
})
|
||||||
expect(result).to eq <<-EOH.gsub(/^ {6}/, "")
|
expect(result).to eq <<-EOH.gsub(/^ {6}/, "")
|
||||||
#VAGRANT-BEGIN
|
#VAGRANT-BEGIN
|
||||||
# The contents below are automatically generated by Vagrant. Do not modify.
|
# The contents below are automatically generated by Vagrant. Do not modify.
|
||||||
config_ethen0="dhcp"
|
config_en0="dhcp"
|
||||||
#VAGRANT-END
|
#VAGRANT-END
|
||||||
EOH
|
EOH
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,30 +7,30 @@ describe "templates/guests/gentoo/network_static" do
|
||||||
|
|
||||||
it "renders the template" do
|
it "renders the template" do
|
||||||
result = Vagrant::Util::TemplateRenderer.render(template, options: {
|
result = Vagrant::Util::TemplateRenderer.render(template, options: {
|
||||||
interface: "en0",
|
device: "en0",
|
||||||
ip: "1.1.1.1",
|
ip: "1.1.1.1",
|
||||||
netmask: "255.255.0.0",
|
netmask: "255.255.0.0",
|
||||||
})
|
})
|
||||||
expect(result).to eq <<-EOH.gsub(/^ {6}/, "")
|
expect(result).to eq <<-EOH.gsub(/^ {6}/, "")
|
||||||
#VAGRANT-BEGIN
|
#VAGRANT-BEGIN
|
||||||
# The contents below are automatically generated by Vagrant. Do not modify.
|
# The contents below are automatically generated by Vagrant. Do not modify.
|
||||||
config_ethen0=("1.1.1.1 netmask 255.255.0.0")
|
config_en0=("1.1.1.1 netmask 255.255.0.0")
|
||||||
#VAGRANT-END
|
#VAGRANT-END
|
||||||
EOH
|
EOH
|
||||||
end
|
end
|
||||||
|
|
||||||
it "includes the gateway" do
|
it "includes the gateway" do
|
||||||
result = Vagrant::Util::TemplateRenderer.render(template, options: {
|
result = Vagrant::Util::TemplateRenderer.render(template, options: {
|
||||||
interface: "en0",
|
device: "en0",
|
||||||
ip: "1.1.1.1",
|
ip: "1.1.1.1",
|
||||||
netmask: "255.255.0.0",
|
netmask: "255.255.0.0",
|
||||||
gateway: "1.2.3.4",
|
gateway: "1.2.3.4",
|
||||||
})
|
})
|
||||||
expect(result).to eq <<-EOH.gsub(/^ {6}/, "")
|
expect(result).to eq <<-EOH.gsub(/^ {6}/, "")
|
||||||
#VAGRANT-BEGIN
|
#VAGRANT-BEGIN
|
||||||
# The contents below are automatically generated by Vagrant. Do not modify.
|
# The contents below are automatically generated by Vagrant. Do not modify.
|
||||||
config_ethen0=("1.1.1.1 netmask 255.255.0.0")
|
config_en0=("1.1.1.1 netmask 255.255.0.0")
|
||||||
gateways_ethen0="1.2.3.4"
|
gateways_en0="1.2.3.4"
|
||||||
#VAGRANT-END
|
#VAGRANT-END
|
||||||
EOH
|
EOH
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,14 +7,14 @@ describe "templates/guests/redhat/network_dhcp" do
|
||||||
|
|
||||||
it "renders the template" do
|
it "renders the template" do
|
||||||
result = Vagrant::Util::TemplateRenderer.render(template, options: {
|
result = Vagrant::Util::TemplateRenderer.render(template, options: {
|
||||||
interface: "en0",
|
device: "en0",
|
||||||
})
|
})
|
||||||
expect(result).to eq <<-EOH.gsub(/^ {6}/, "")
|
expect(result).to eq <<-EOH.gsub(/^ {6}/, "")
|
||||||
#VAGRANT-BEGIN
|
#VAGRANT-BEGIN
|
||||||
# The contents below are automatically generated by Vagrant. Do not modify.
|
# The contents below are automatically generated by Vagrant. Do not modify.
|
||||||
BOOTPROTO=dhcp
|
BOOTPROTO=dhcp
|
||||||
ONBOOT=yes
|
ONBOOT=yes
|
||||||
DEVICE=ethen0
|
DEVICE=en0
|
||||||
#VAGRANT-END
|
#VAGRANT-END
|
||||||
EOH
|
EOH
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,9 +7,9 @@ describe "templates/guests/redhat/network_static" do
|
||||||
|
|
||||||
it "renders the template" do
|
it "renders the template" do
|
||||||
result = Vagrant::Util::TemplateRenderer.render(template, options: {
|
result = Vagrant::Util::TemplateRenderer.render(template, options: {
|
||||||
interface: "en0",
|
device: "en0",
|
||||||
ip: "1.1.1.1",
|
ip: "1.1.1.1",
|
||||||
netmask: "255.255.0.0",
|
netmask: "255.255.0.0",
|
||||||
})
|
})
|
||||||
expect(result).to eq <<-EOH.gsub(/^ {6}/, "")
|
expect(result).to eq <<-EOH.gsub(/^ {6}/, "")
|
||||||
#VAGRANT-BEGIN
|
#VAGRANT-BEGIN
|
||||||
|
@ -19,7 +19,7 @@ describe "templates/guests/redhat/network_static" do
|
||||||
ONBOOT=yes
|
ONBOOT=yes
|
||||||
IPADDR=1.1.1.1
|
IPADDR=1.1.1.1
|
||||||
NETMASK=255.255.0.0
|
NETMASK=255.255.0.0
|
||||||
DEVICE=ethen0
|
DEVICE=en0
|
||||||
PEERDNS=no
|
PEERDNS=no
|
||||||
#VAGRANT-END
|
#VAGRANT-END
|
||||||
EOH
|
EOH
|
||||||
|
@ -27,10 +27,10 @@ describe "templates/guests/redhat/network_static" do
|
||||||
|
|
||||||
it "includes the gateway" do
|
it "includes the gateway" do
|
||||||
result = Vagrant::Util::TemplateRenderer.render(template, options: {
|
result = Vagrant::Util::TemplateRenderer.render(template, options: {
|
||||||
interface: "en0",
|
device: "en0",
|
||||||
ip: "1.1.1.1",
|
ip: "1.1.1.1",
|
||||||
gateway: "1.2.3.4",
|
gateway: "1.2.3.4",
|
||||||
netmask: "255.255.0.0",
|
netmask: "255.255.0.0",
|
||||||
})
|
})
|
||||||
expect(result).to eq <<-EOH.gsub(/^ {6}/, "")
|
expect(result).to eq <<-EOH.gsub(/^ {6}/, "")
|
||||||
#VAGRANT-BEGIN
|
#VAGRANT-BEGIN
|
||||||
|
@ -40,7 +40,7 @@ describe "templates/guests/redhat/network_static" do
|
||||||
ONBOOT=yes
|
ONBOOT=yes
|
||||||
IPADDR=1.1.1.1
|
IPADDR=1.1.1.1
|
||||||
NETMASK=255.255.0.0
|
NETMASK=255.255.0.0
|
||||||
DEVICE=ethen0
|
DEVICE=en0
|
||||||
GATEWAY=1.2.3.4
|
GATEWAY=1.2.3.4
|
||||||
PEERDNS=no
|
PEERDNS=no
|
||||||
#VAGRANT-END
|
#VAGRANT-END
|
||||||
|
|
Loading…
Reference in New Issue