fixed-vagrant 0.7.4.dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +15 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +272 -0
- data/Gemfile +21 -0
- data/LICENSE +21 -0
- data/README.md +75 -0
- data/Rakefile +22 -0
- data/bin/vagrant +22 -0
- data/config/default.rb +39 -0
- data/contrib/README.md +12 -0
- data/contrib/emacs/vagrant.el +8 -0
- data/contrib/vim/vagrantfile.vim +9 -0
- data/keys/README.md +17 -0
- data/keys/vagrant +27 -0
- data/keys/vagrant.ppk +26 -0
- data/keys/vagrant.pub +1 -0
- data/lib/vagrant.rb +42 -0
- data/lib/vagrant/action.rb +134 -0
- data/lib/vagrant/action/box.rb +11 -0
- data/lib/vagrant/action/box/destroy.rb +21 -0
- data/lib/vagrant/action/box/download.rb +72 -0
- data/lib/vagrant/action/box/package.rb +19 -0
- data/lib/vagrant/action/box/unpackage.rb +55 -0
- data/lib/vagrant/action/box/verify.rb +23 -0
- data/lib/vagrant/action/builder.rb +124 -0
- data/lib/vagrant/action/builtin.rb +104 -0
- data/lib/vagrant/action/env.rb +7 -0
- data/lib/vagrant/action/env/set.rb +18 -0
- data/lib/vagrant/action/environment.rb +50 -0
- data/lib/vagrant/action/general.rb +8 -0
- data/lib/vagrant/action/general/package.rb +109 -0
- data/lib/vagrant/action/general/validate.rb +19 -0
- data/lib/vagrant/action/vm.rb +31 -0
- data/lib/vagrant/action/vm/boot.rb +48 -0
- data/lib/vagrant/action/vm/check_box.rb +28 -0
- data/lib/vagrant/action/vm/check_guest_additions.rb +30 -0
- data/lib/vagrant/action/vm/clean_machine_folder.rb +43 -0
- data/lib/vagrant/action/vm/clear_forwarded_ports.rb +39 -0
- data/lib/vagrant/action/vm/clear_nfs_exports.rb +20 -0
- data/lib/vagrant/action/vm/clear_shared_folders.rb +32 -0
- data/lib/vagrant/action/vm/customize.rb +21 -0
- data/lib/vagrant/action/vm/destroy.rb +19 -0
- data/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb +30 -0
- data/lib/vagrant/action/vm/discard_state.rb +22 -0
- data/lib/vagrant/action/vm/export.rb +52 -0
- data/lib/vagrant/action/vm/forward_ports.rb +134 -0
- data/lib/vagrant/action/vm/forward_ports_helpers.rb +28 -0
- data/lib/vagrant/action/vm/halt.rb +29 -0
- data/lib/vagrant/action/vm/host_name.rb +21 -0
- data/lib/vagrant/action/vm/import.rb +35 -0
- data/lib/vagrant/action/vm/match_mac_address.rb +21 -0
- data/lib/vagrant/action/vm/network.rb +139 -0
- data/lib/vagrant/action/vm/nfs.rb +159 -0
- data/lib/vagrant/action/vm/nfs_helpers.rb +11 -0
- data/lib/vagrant/action/vm/package.rb +23 -0
- data/lib/vagrant/action/vm/package_vagrantfile.rb +33 -0
- data/lib/vagrant/action/vm/provision.rb +41 -0
- data/lib/vagrant/action/vm/resume.rb +20 -0
- data/lib/vagrant/action/vm/share_folders.rb +70 -0
- data/lib/vagrant/action/vm/suspend.rb +20 -0
- data/lib/vagrant/action/warden.rb +79 -0
- data/lib/vagrant/box.rb +90 -0
- data/lib/vagrant/box_collection.rb +53 -0
- data/lib/vagrant/cli.rb +55 -0
- data/lib/vagrant/command.rb +25 -0
- data/lib/vagrant/command/base.rb +106 -0
- data/lib/vagrant/command/box.rb +33 -0
- data/lib/vagrant/command/destroy.rb +17 -0
- data/lib/vagrant/command/group_base.rb +107 -0
- data/lib/vagrant/command/halt.rb +18 -0
- data/lib/vagrant/command/helpers.rb +33 -0
- data/lib/vagrant/command/init.rb +14 -0
- data/lib/vagrant/command/named_base.rb +14 -0
- data/lib/vagrant/command/package.rb +41 -0
- data/lib/vagrant/command/provision.rb +17 -0
- data/lib/vagrant/command/reload.rb +17 -0
- data/lib/vagrant/command/resume.rb +17 -0
- data/lib/vagrant/command/ssh.rb +42 -0
- data/lib/vagrant/command/ssh_config.rb +26 -0
- data/lib/vagrant/command/status.rb +22 -0
- data/lib/vagrant/command/suspend.rb +17 -0
- data/lib/vagrant/command/up.rb +19 -0
- data/lib/vagrant/command/upgrade_to_060.rb +45 -0
- data/lib/vagrant/command/version.rb +13 -0
- data/lib/vagrant/config.rb +123 -0
- data/lib/vagrant/config/base.rb +85 -0
- data/lib/vagrant/config/error_recorder.rb +19 -0
- data/lib/vagrant/config/nfs.rb +10 -0
- data/lib/vagrant/config/package.rb +9 -0
- data/lib/vagrant/config/ssh.rb +33 -0
- data/lib/vagrant/config/top.rb +61 -0
- data/lib/vagrant/config/vagrant.rb +16 -0
- data/lib/vagrant/config/vm.rb +137 -0
- data/lib/vagrant/config/vm/provisioner.rb +56 -0
- data/lib/vagrant/config/vm/sub_vm.rb +17 -0
- data/lib/vagrant/data_store.rb +70 -0
- data/lib/vagrant/downloaders.rb +7 -0
- data/lib/vagrant/downloaders/base.rb +23 -0
- data/lib/vagrant/downloaders/file.rb +22 -0
- data/lib/vagrant/downloaders/http.rb +64 -0
- data/lib/vagrant/environment.rb +392 -0
- data/lib/vagrant/errors.rb +332 -0
- data/lib/vagrant/hosts.rb +8 -0
- data/lib/vagrant/hosts/arch.rb +27 -0
- data/lib/vagrant/hosts/base.rb +78 -0
- data/lib/vagrant/hosts/bsd.rb +52 -0
- data/lib/vagrant/hosts/linux.rb +47 -0
- data/lib/vagrant/plugin.rb +57 -0
- data/lib/vagrant/provisioners.rb +9 -0
- data/lib/vagrant/provisioners/base.rb +63 -0
- data/lib/vagrant/provisioners/chef.rb +130 -0
- data/lib/vagrant/provisioners/chef_server.rb +103 -0
- data/lib/vagrant/provisioners/chef_solo.rb +142 -0
- data/lib/vagrant/provisioners/puppet.rb +137 -0
- data/lib/vagrant/provisioners/puppet_server.rb +55 -0
- data/lib/vagrant/provisioners/shell.rb +52 -0
- data/lib/vagrant/ssh.rb +173 -0
- data/lib/vagrant/ssh/session.rb +125 -0
- data/lib/vagrant/systems.rb +11 -0
- data/lib/vagrant/systems/base.rb +87 -0
- data/lib/vagrant/systems/debian.rb +36 -0
- data/lib/vagrant/systems/freebsd.rb +84 -0
- data/lib/vagrant/systems/gentoo.rb +27 -0
- data/lib/vagrant/systems/linux.rb +83 -0
- data/lib/vagrant/systems/linux/config.rb +21 -0
- data/lib/vagrant/systems/linux/error.rb +9 -0
- data/lib/vagrant/systems/redhat.rb +39 -0
- data/lib/vagrant/systems/solaris.rb +62 -0
- data/lib/vagrant/systems/ubuntu.rb +17 -0
- data/lib/vagrant/test_helpers.rb +128 -0
- data/lib/vagrant/ui.rb +69 -0
- data/lib/vagrant/util.rb +13 -0
- data/lib/vagrant/util/busy.rb +59 -0
- data/lib/vagrant/util/hash_with_indifferent_access.rb +63 -0
- data/lib/vagrant/util/plain_logger.rb +25 -0
- data/lib/vagrant/util/platform.rb +65 -0
- data/lib/vagrant/util/resource_logger.rb +63 -0
- data/lib/vagrant/util/retryable.rb +25 -0
- data/lib/vagrant/util/stacked_proc_runner.rb +35 -0
- data/lib/vagrant/util/template_renderer.rb +83 -0
- data/lib/vagrant/version.rb +6 -0
- data/lib/vagrant/vm.rb +177 -0
- data/templates/chef_server_client.erb +18 -0
- data/templates/chef_solo_solo.erb +19 -0
- data/templates/commands/init/Vagrantfile.erb +82 -0
- data/templates/config/validation_failed.erb +7 -0
- data/templates/locales/en.yml +535 -0
- data/templates/network_entry_debian.erb +8 -0
- data/templates/network_entry_gentoo.erb +5 -0
- data/templates/network_entry_redhat.erb +8 -0
- data/templates/nfs/exports.erb +5 -0
- data/templates/nfs/exports_linux.erb +5 -0
- data/templates/package_Vagrantfile.erb +11 -0
- data/templates/ssh_config.erb +9 -0
- data/test/locales/en.yml +8 -0
- data/test/test_helper.rb +26 -0
- data/test/vagrant/action/box/destroy_test.rb +18 -0
- data/test/vagrant/action/box/download_test.rb +125 -0
- data/test/vagrant/action/box/package_test.rb +25 -0
- data/test/vagrant/action/box/unpackage_test.rb +84 -0
- data/test/vagrant/action/box/verify_test.rb +30 -0
- data/test/vagrant/action/builder_test.rb +203 -0
- data/test/vagrant/action/env/set_test.rb +24 -0
- data/test/vagrant/action/environment_test.rb +27 -0
- data/test/vagrant/action/general/package_test.rb +268 -0
- data/test/vagrant/action/general/validate_test.rb +31 -0
- data/test/vagrant/action/vm/boot_test.rb +66 -0
- data/test/vagrant/action/vm/check_box_test.rb +56 -0
- data/test/vagrant/action/vm/check_guest_additions_test.rb +9 -0
- data/test/vagrant/action/vm/clean_machine_folder_test.rb +84 -0
- data/test/vagrant/action/vm/clear_forwarded_ports_test.rb +72 -0
- data/test/vagrant/action/vm/clear_nfs_exports_test.rb +22 -0
- data/test/vagrant/action/vm/clear_shared_folders_test.rb +49 -0
- data/test/vagrant/action/vm/customize_test.rb +30 -0
- data/test/vagrant/action/vm/destroy_test.rb +25 -0
- data/test/vagrant/action/vm/destroy_unused_network_interfaces_test.rb +49 -0
- data/test/vagrant/action/vm/discard_state_test.rb +45 -0
- data/test/vagrant/action/vm/export_test.rb +107 -0
- data/test/vagrant/action/vm/forward_ports_helpers_test.rb +70 -0
- data/test/vagrant/action/vm/forward_ports_test.rb +194 -0
- data/test/vagrant/action/vm/halt_test.rb +79 -0
- data/test/vagrant/action/vm/host_name_test.rb +36 -0
- data/test/vagrant/action/vm/import_test.rb +66 -0
- data/test/vagrant/action/vm/match_mac_address_test.rb +36 -0
- data/test/vagrant/action/vm/network_test.rb +286 -0
- data/test/vagrant/action/vm/nfs_helpers_test.rb +26 -0
- data/test/vagrant/action/vm/nfs_test.rb +260 -0
- data/test/vagrant/action/vm/package_test.rb +25 -0
- data/test/vagrant/action/vm/package_vagrantfile_test.rb +46 -0
- data/test/vagrant/action/vm/provision_test.rb +90 -0
- data/test/vagrant/action/vm/resume_test.rb +35 -0
- data/test/vagrant/action/vm/share_folders_test.rb +139 -0
- data/test/vagrant/action/vm/suspend_test.rb +35 -0
- data/test/vagrant/action/warden_test.rb +119 -0
- data/test/vagrant/action_test.rb +89 -0
- data/test/vagrant/box_collection_test.rb +45 -0
- data/test/vagrant/box_test.rb +74 -0
- data/test/vagrant/cli_test.rb +35 -0
- data/test/vagrant/command/base_test.rb +23 -0
- data/test/vagrant/command/group_base_test.rb +15 -0
- data/test/vagrant/command/helpers_test.rb +88 -0
- data/test/vagrant/command/package_test.rb +27 -0
- data/test/vagrant/config/base_test.rb +52 -0
- data/test/vagrant/config/error_recorder_test.rb +18 -0
- data/test/vagrant/config/ssh_test.rb +12 -0
- data/test/vagrant/config/vagrant_test.rb +35 -0
- data/test/vagrant/config/vm/provisioner_test.rb +92 -0
- data/test/vagrant/config/vm_test.rb +86 -0
- data/test/vagrant/config_test.rb +162 -0
- data/test/vagrant/data_store_test.rb +77 -0
- data/test/vagrant/downloaders/base_test.rb +28 -0
- data/test/vagrant/downloaders/file_test.rb +48 -0
- data/test/vagrant/downloaders/http_test.rb +80 -0
- data/test/vagrant/environment_test.rb +508 -0
- data/test/vagrant/errors_test.rb +42 -0
- data/test/vagrant/hosts/base_test.rb +46 -0
- data/test/vagrant/hosts/bsd_test.rb +53 -0
- data/test/vagrant/hosts/linux_test.rb +54 -0
- data/test/vagrant/plugin_test.rb +9 -0
- data/test/vagrant/provisioners/base_test.rb +63 -0
- data/test/vagrant/provisioners/chef_server_test.rb +188 -0
- data/test/vagrant/provisioners/chef_solo_test.rb +219 -0
- data/test/vagrant/provisioners/chef_test.rb +179 -0
- data/test/vagrant/provisioners/puppet_server_test.rb +68 -0
- data/test/vagrant/provisioners/puppet_test.rb +182 -0
- data/test/vagrant/provisioners/shell_test.rb +68 -0
- data/test/vagrant/ssh/session_test.rb +40 -0
- data/test/vagrant/ssh_test.rb +342 -0
- data/test/vagrant/systems/base_test.rb +18 -0
- data/test/vagrant/systems/linux_test.rb +114 -0
- data/test/vagrant/ui_test.rb +29 -0
- data/test/vagrant/util/busy_test.rb +106 -0
- data/test/vagrant/util/hash_with_indifferent_access_test.rb +39 -0
- data/test/vagrant/util/plain_logger_test.rb +17 -0
- data/test/vagrant/util/platform_test.rb +18 -0
- data/test/vagrant/util/resource_logger_test.rb +78 -0
- data/test/vagrant/util/retryable_test.rb +50 -0
- data/test/vagrant/util/stacked_proc_runner_test.rb +43 -0
- data/test/vagrant/util/template_renderer_test.rb +145 -0
- data/test/vagrant/vm_test.rb +291 -0
- data/vagrant.gemspec +36 -0
- metadata +514 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# These can't be autoloaded because they have to register functionality
|
|
2
|
+
# with Vagrant core.
|
|
3
|
+
require 'vagrant/systems/base'
|
|
4
|
+
require 'vagrant/systems/freebsd'
|
|
5
|
+
require 'vagrant/systems/linux'
|
|
6
|
+
require 'vagrant/systems/solaris'
|
|
7
|
+
|
|
8
|
+
require 'vagrant/systems/debian'
|
|
9
|
+
require 'vagrant/systems/gentoo'
|
|
10
|
+
require 'vagrant/systems/redhat'
|
|
11
|
+
require 'vagrant/systems/ubuntu'
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
module Vagrant
|
|
2
|
+
module Systems
|
|
3
|
+
# The base class for a "system." A system represents an installed
|
|
4
|
+
# operating system on a given box. There are some portions of
|
|
5
|
+
# Vagrant which are fairly OS-specific (such as mounting shared
|
|
6
|
+
# folders) and while the number is few, this abstraction allows
|
|
7
|
+
# more obscure operating systems to be installed without having
|
|
8
|
+
# to directly modify Vagrant internals.
|
|
9
|
+
#
|
|
10
|
+
# Subclasses of the system base class are expected to implement
|
|
11
|
+
# all the methods. These methods are described in the comments
|
|
12
|
+
# above their definition.
|
|
13
|
+
#
|
|
14
|
+
# **This is by no means a complete specification. The methods
|
|
15
|
+
# required by systems can and will change at any time. Any
|
|
16
|
+
# changes will be noted on release notes.**
|
|
17
|
+
class Base
|
|
18
|
+
class BaseError < Errors::VagrantError
|
|
19
|
+
error_namespace("vagrant.systems.base")
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
include Vagrant::Util
|
|
23
|
+
|
|
24
|
+
# The VM which this system is tied to.
|
|
25
|
+
attr_reader :vm
|
|
26
|
+
|
|
27
|
+
# Initializes the system. Any subclasses MUST make sure this
|
|
28
|
+
# method is called on the parent. Therefore, if a subclass overrides
|
|
29
|
+
# `initialize`, then you must call `super`.
|
|
30
|
+
def initialize(vm)
|
|
31
|
+
@vm = vm
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# This method is automatically called when the system is available (when
|
|
35
|
+
# Vagrant can successfully SSH into the machine) to give the system a chance
|
|
36
|
+
# to determine the distro and return a distro-specific system.
|
|
37
|
+
#
|
|
38
|
+
# **Warning:** If a return value which subclasses from {Base} is
|
|
39
|
+
# returned, Vagrant will use it as the new system instance for the
|
|
40
|
+
# class.
|
|
41
|
+
def distro_dispatch; end
|
|
42
|
+
|
|
43
|
+
# Halt the machine. This method should gracefully shut down the
|
|
44
|
+
# operating system. This method will cause `vagrant halt` and associated
|
|
45
|
+
# commands to _block_, meaning that if the machine doesn't halt
|
|
46
|
+
# in a reasonable amount of time, this method should just return.
|
|
47
|
+
#
|
|
48
|
+
# If when this method returns, the machine's state isn't "powered_off,"
|
|
49
|
+
# Vagrant will proceed to forcefully shut the machine down.
|
|
50
|
+
def halt; end
|
|
51
|
+
|
|
52
|
+
# Mounts a shared folder. This method is called by the shared
|
|
53
|
+
# folder action with an open SSH session (passed in as `ssh`).
|
|
54
|
+
# This method should create, mount, and properly set permissions
|
|
55
|
+
# on the shared folder. This method should also properly
|
|
56
|
+
# adhere to any configuration values such as `shared_folder_uid`
|
|
57
|
+
# on `config.vm`.
|
|
58
|
+
#
|
|
59
|
+
# @param [Object] ssh The Net::SSH session.
|
|
60
|
+
# @param [String] name The name of the shared folder.
|
|
61
|
+
# @param [String] guestpath The path on the machine which the user
|
|
62
|
+
# wants the folder mounted.
|
|
63
|
+
def mount_shared_folder(ssh, name, guestpath); end
|
|
64
|
+
|
|
65
|
+
# Mounts a shared folder via NFS. This assumes that the exports
|
|
66
|
+
# via the host are already done.
|
|
67
|
+
def mount_nfs(ip, folders); end
|
|
68
|
+
|
|
69
|
+
# Prepares the system for host only networks. This is called
|
|
70
|
+
# once prior to any `enable_host_only_network` calls.
|
|
71
|
+
def prepare_host_only_network(net_options=nil)
|
|
72
|
+
raise BaseError, :_key => :unsupported_host_only
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Setup the system by adding a new host only network. This
|
|
76
|
+
# method should configure and bring up the interface for the
|
|
77
|
+
# given options.
|
|
78
|
+
#
|
|
79
|
+
# @param [Hash] net_options The options for the network.
|
|
80
|
+
def enable_host_only_network(net_options); end
|
|
81
|
+
|
|
82
|
+
def change_host_name(name)
|
|
83
|
+
raise BaseError, :_key => :unsupported_host_name
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module Vagrant
|
|
2
|
+
module Systems
|
|
3
|
+
class Debian < Linux
|
|
4
|
+
def prepare_host_only_network(net_options=nil)
|
|
5
|
+
# Remove any previous host only network additions to the
|
|
6
|
+
# interface file.
|
|
7
|
+
vm.ssh.execute do |ssh|
|
|
8
|
+
# Clear out any previous entries
|
|
9
|
+
ssh.exec!("sudo sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/network/interfaces > /tmp/vagrant-network-interfaces")
|
|
10
|
+
ssh.exec!("sudo su -c 'cat /tmp/vagrant-network-interfaces > /etc/network/interfaces'")
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def enable_host_only_network(net_options)
|
|
15
|
+
entry = TemplateRenderer.render('network_entry_debian', :net_options => net_options)
|
|
16
|
+
vm.ssh.upload!(StringIO.new(entry), "/tmp/vagrant-network-entry")
|
|
17
|
+
|
|
18
|
+
vm.ssh.execute do |ssh|
|
|
19
|
+
ssh.exec!("sudo /sbin/ifdown eth#{net_options[:adapter]} 2> /dev/null")
|
|
20
|
+
ssh.exec!("sudo su -c 'cat /tmp/vagrant-network-entry >> /etc/network/interfaces'")
|
|
21
|
+
ssh.exec!("sudo /sbin/ifup eth#{net_options[:adapter]}")
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def change_host_name(name)
|
|
26
|
+
vm.ssh.execute do |ssh|
|
|
27
|
+
if !ssh.test?("sudo hostname | grep '#{name}'")
|
|
28
|
+
ssh.exec!("sudo sed -i 's@^\\(127[.]0[.]1[.]1[[:space:]]\\+\\)@\\1#{name} #{name.split('.')[0]} @' /etc/hosts")
|
|
29
|
+
ssh.exec!("sudo sed -i 's/.*$/#{name}/' /etc/hostname")
|
|
30
|
+
ssh.exec!("sudo hostname -F /etc/hostname")
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
module Vagrant
|
|
2
|
+
module Systems
|
|
3
|
+
# A general Vagrant system implementation for "freebsd".
|
|
4
|
+
#
|
|
5
|
+
# Contributed by Kenneth Vestergaard <kvs@binarysolutions.dk>
|
|
6
|
+
class FreeBSD < Base
|
|
7
|
+
# A custom config class which will be made accessible via `config.freebsd`
|
|
8
|
+
# This is not necessary for all system implementers, of course. However,
|
|
9
|
+
# generally, Vagrant tries to make almost every aspect of its execution
|
|
10
|
+
# configurable, and this assists that goal.
|
|
11
|
+
class FreeBSDConfig < Vagrant::Config::Base
|
|
12
|
+
configures :freebsd
|
|
13
|
+
|
|
14
|
+
attr_accessor :halt_timeout
|
|
15
|
+
attr_accessor :halt_check_interval
|
|
16
|
+
|
|
17
|
+
def initialize
|
|
18
|
+
@halt_timeout = 30
|
|
19
|
+
@halt_check_interval = 1
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Here for whenever it may be used.
|
|
24
|
+
class FreeBSDError < Errors::VagrantError
|
|
25
|
+
error_namespace("vagrant.systems.freebsd")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def halt
|
|
29
|
+
vm.env.ui.info I18n.t("vagrant.systems.freebsd.attempting_halt")
|
|
30
|
+
vm.ssh.execute do |ssh|
|
|
31
|
+
ssh.exec!("sudo shutdown -p now")
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Wait until the VM's state is actually powered off. If this doesn't
|
|
35
|
+
# occur within a reasonable amount of time (15 seconds by default),
|
|
36
|
+
# then simply return and allow Vagrant to kill the machine.
|
|
37
|
+
count = 0
|
|
38
|
+
while vm.vm.state != :powered_off
|
|
39
|
+
count += 1
|
|
40
|
+
|
|
41
|
+
return if count >= vm.env.config.freebsd.halt_timeout
|
|
42
|
+
sleep vm.env.config.freebsd.halt_check_interval
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# TODO: Error/warning about this.
|
|
47
|
+
# def mount_shared_folder(ssh, name, guestpath)
|
|
48
|
+
# ssh.exec!("sudo mkdir -p #{guestpath}")
|
|
49
|
+
# # Using a custom mount method here; could use improvement.
|
|
50
|
+
# ssh.exec!("sudo mount -t vboxfs v-root #{guestpath}")
|
|
51
|
+
# ssh.exec!("sudo chown #{vm.env.config.ssh.username} #{guestpath}")
|
|
52
|
+
# end
|
|
53
|
+
|
|
54
|
+
def mount_nfs(ip, folders)
|
|
55
|
+
folders.each do |name, opts|
|
|
56
|
+
vm.ssh.execute do |ssh|
|
|
57
|
+
ssh.exec!("sudo mkdir -p #{opts[:guestpath]}")
|
|
58
|
+
ssh.exec!("sudo mount #{ip}:#{opts[:hostpath]} #{opts[:guestpath]}")
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def prepare_host_only_network(net_options=nil)
|
|
64
|
+
# Remove any previous host only network additions to the
|
|
65
|
+
# interface file.
|
|
66
|
+
vm.ssh.execute do |ssh|
|
|
67
|
+
# Clear out any previous entries
|
|
68
|
+
ssh.exec!("sudo sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/rc.conf > /tmp/rc.conf")
|
|
69
|
+
ssh.exec!("sudo mv /tmp/rc.conf /etc/rc.conf")
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def enable_host_only_network(net_options)
|
|
74
|
+
entry = "#VAGRANT-BEGIN\nifconfig_em#{net_options[:adapter]}=\"inet #{net_options[:ip]} netmask #{net_options[:netmask]}\"\n#VAGRANT-END\n"
|
|
75
|
+
vm.ssh.upload!(StringIO.new(entry), "/tmp/vagrant-network-entry")
|
|
76
|
+
|
|
77
|
+
vm.ssh.execute do |ssh|
|
|
78
|
+
ssh.exec!("sudo su -m root -c 'cat /tmp/vagrant-network-entry >> /etc/rc.conf'")
|
|
79
|
+
ssh.exec!("sudo ifconfig em#{net_options[:adapter]} inet #{net_options[:ip]} netmask #{net_options[:netmask]}")
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module Vagrant
|
|
2
|
+
module Systems
|
|
3
|
+
class Gentoo < Linux
|
|
4
|
+
def prepare_host_only_network(net_options=nil)
|
|
5
|
+
# Remove any previous host only network additions to the
|
|
6
|
+
# interface file.
|
|
7
|
+
vm.ssh.execute do |ssh|
|
|
8
|
+
# Clear out any previous entries
|
|
9
|
+
ssh.exec!("sudo sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/conf.d/net > /tmp/vagrant-network-interfaces")
|
|
10
|
+
ssh.exec!("sudo su -c 'cat /tmp/vagrant-network-interfaces > /etc/conf.d/net'")
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def enable_host_only_network(net_options)
|
|
15
|
+
entry = TemplateRenderer.render('network_entry_gentoo', :net_options => net_options)
|
|
16
|
+
vm.ssh.upload!(StringIO.new(entry), "/tmp/vagrant-network-entry")
|
|
17
|
+
|
|
18
|
+
vm.ssh.execute do |ssh|
|
|
19
|
+
ssh.exec!("sudo ln -fs /etc/init.d/net.lo /etc/init.d/net.eth#{net_options[:adapter]}")
|
|
20
|
+
ssh.exec!("sudo /etc/init.d/net.eth#{net_options[:adapter]} stop 2> /dev/null")
|
|
21
|
+
ssh.exec!("sudo su -c 'cat /tmp/vagrant-network-entry >> /etc/conf.d/net'")
|
|
22
|
+
ssh.exec!("sudo /etc/init.d/net.eth#{net_options[:adapter]} start")
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
require 'vagrant/systems/linux/error'
|
|
2
|
+
require 'vagrant/systems/linux/config'
|
|
3
|
+
|
|
4
|
+
module Vagrant
|
|
5
|
+
module Systems
|
|
6
|
+
class Linux < Base
|
|
7
|
+
def distro_dispatch
|
|
8
|
+
vm.ssh.execute do |ssh|
|
|
9
|
+
if ssh.test?("cat /etc/debian_version")
|
|
10
|
+
return :debian if ssh.test?("cat /proc/version | grep 'Debian'")
|
|
11
|
+
return :ubuntu if ssh.test?("cat /proc/version | grep 'Ubuntu'")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
return :gentoo if ssh.test?("cat /etc/gentoo-release")
|
|
15
|
+
return :redhat if ssh.test?("cat /etc/redhat-release")
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Can't detect the distro, assume vanilla linux
|
|
19
|
+
nil
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def halt
|
|
23
|
+
vm.env.ui.info I18n.t("vagrant.systems.linux.attempting_halt")
|
|
24
|
+
vm.ssh.execute do |ssh|
|
|
25
|
+
ssh.exec!("sudo halt")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Wait until the VM's state is actually powered off. If this doesn't
|
|
29
|
+
# occur within a reasonable amount of time (15 seconds by default),
|
|
30
|
+
# then simply return and allow Vagrant to kill the machine.
|
|
31
|
+
count = 0
|
|
32
|
+
while vm.vm.state != :powered_off
|
|
33
|
+
count += 1
|
|
34
|
+
|
|
35
|
+
return if count >= vm.env.config.linux.halt_timeout
|
|
36
|
+
sleep vm.env.config.linux.halt_check_interval
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def mount_shared_folder(ssh, name, guestpath)
|
|
41
|
+
ssh.exec!("sudo mkdir -p #{guestpath}")
|
|
42
|
+
mount_folder(ssh, name, guestpath)
|
|
43
|
+
ssh.exec!("sudo chown #{vm.env.config.ssh.username} #{guestpath}")
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def mount_nfs(ip, folders)
|
|
47
|
+
# TODO: Maybe check for nfs support on the guest, since its often
|
|
48
|
+
# not installed by default
|
|
49
|
+
folders.each do |name, opts|
|
|
50
|
+
vm.ssh.execute do |ssh|
|
|
51
|
+
ssh.exec!("sudo mkdir -p #{opts[:guestpath]}")
|
|
52
|
+
ssh.exec!("sudo mount #{ip}:'#{opts[:hostpath]}' #{opts[:guestpath]}", :_error_class => LinuxError, :_key => :mount_nfs_fail)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
#-------------------------------------------------------------------
|
|
58
|
+
# "Private" methods which assist above methods
|
|
59
|
+
#-------------------------------------------------------------------
|
|
60
|
+
def mount_folder(ssh, name, guestpath, sleeptime=5)
|
|
61
|
+
# Determine the permission string to attach to the mount command
|
|
62
|
+
perms = []
|
|
63
|
+
perms << "uid=`id -u #{vm.env.config.vm.shared_folder_uid}`"
|
|
64
|
+
perms << "gid=`id -g #{vm.env.config.vm.shared_folder_gid}`"
|
|
65
|
+
perms = " -o #{perms.join(",")}" if !perms.empty?
|
|
66
|
+
|
|
67
|
+
attempts = 0
|
|
68
|
+
while true
|
|
69
|
+
result = ssh.exec!("sudo mount -t vboxsf#{perms} #{name} #{guestpath}") do |ch, type, data|
|
|
70
|
+
# net/ssh returns the value in ch[:result] (based on looking at source)
|
|
71
|
+
ch[:result] = !!(type == :stderr && data =~ /No such device/i)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
break unless result
|
|
75
|
+
|
|
76
|
+
attempts += 1
|
|
77
|
+
raise LinuxError, :mount_fail if attempts >= 10
|
|
78
|
+
sleep sleeptime
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Vagrant
|
|
2
|
+
module Systems
|
|
3
|
+
class Linux < Vagrant::Systems::Base
|
|
4
|
+
# A custom config class which will be made accessible via `config.linux`
|
|
5
|
+
# This is not necessary for all system implementers, of course. However,
|
|
6
|
+
# generally, Vagrant tries to make almost every aspect of its execution
|
|
7
|
+
# configurable, and this assists that goal.
|
|
8
|
+
class LinuxConfig < Vagrant::Config::Base
|
|
9
|
+
configures :linux
|
|
10
|
+
|
|
11
|
+
attr_accessor :halt_timeout
|
|
12
|
+
attr_accessor :halt_check_interval
|
|
13
|
+
|
|
14
|
+
def initialize
|
|
15
|
+
@halt_timeout = 30
|
|
16
|
+
@halt_check_interval = 1
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module Vagrant
|
|
2
|
+
module Systems
|
|
3
|
+
class Redhat < Linux
|
|
4
|
+
def prepare_host_only_network(net_options)
|
|
5
|
+
# Remove any previous host only network additions to the
|
|
6
|
+
# interface file.
|
|
7
|
+
vm.ssh.execute do |ssh|
|
|
8
|
+
# Clear out any previous entries
|
|
9
|
+
ssh.exec!("sudo sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/sysconfig/network-scripts/ifcfg-eth#{net_options[:adapter]} > /tmp/vagrant-ifcfg-eth#{net_options[:adapter]}")
|
|
10
|
+
ssh.exec!("sudo su -c 'cat /tmp/vagrant-ifcfg-eth#{net_options[:adapter]} > /etc/sysconfig/network-scripts/ifcfg-eth#{net_options[:adapter]}'")
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def enable_host_only_network(net_options)
|
|
15
|
+
entry = TemplateRenderer.render('network_entry_redhat', :net_options => net_options)
|
|
16
|
+
|
|
17
|
+
vm.ssh.upload!(StringIO.new(entry), "/tmp/vagrant-network-entry")
|
|
18
|
+
|
|
19
|
+
vm.ssh.execute do |ssh|
|
|
20
|
+
interface_up = ssh.test?("/sbin/ifconfig eth#{net_options[:adapter]} | grep 'inet addr:'")
|
|
21
|
+
ssh.exec!("sudo /sbin/ifdown eth#{net_options[:adapter]} 2> /dev/null") if interface_up
|
|
22
|
+
ssh.exec!("sudo su -c 'cat /tmp/vagrant-network-entry >> /etc/sysconfig/network-scripts/ifcfg-eth#{net_options[:adapter]}'")
|
|
23
|
+
ssh.exec!("sudo /sbin/ifup eth#{net_options[:adapter]}")
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def change_host_name(name)
|
|
28
|
+
vm.ssh.execute do |ssh|
|
|
29
|
+
# Only do this if the hostname is not already set
|
|
30
|
+
if !ssh.test?("sudo hostname | grep '#{name}'")
|
|
31
|
+
ssh.exec!("sudo sed -i 's/\\(HOSTNAME=\\).*/\\1#{name}/' /etc/sysconfig/network")
|
|
32
|
+
ssh.exec!("sudo hostname #{name}")
|
|
33
|
+
ssh.exec!("sudo sed -i 's@^\\(127[.]0[.]0[.]1[[:space:]]\\+\\)@\\1#{name} @' /etc/hosts")
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
module Vagrant
|
|
2
|
+
module Systems
|
|
3
|
+
# A general Vagrant system implementation for "solaris".
|
|
4
|
+
#
|
|
5
|
+
# Contributed by Blake Irvin <b.irvin@modcloth.com>
|
|
6
|
+
class Solaris < Base
|
|
7
|
+
# A custom config class which will be made accessible via `config.solaris`
|
|
8
|
+
# This is not necessary for all system implementers, of course. However,
|
|
9
|
+
# generally, Vagrant tries to make almost every aspect of its execution
|
|
10
|
+
# configurable, and this assists that goal.
|
|
11
|
+
class SolarisConfig < Vagrant::Config::Base
|
|
12
|
+
configures :solaris
|
|
13
|
+
|
|
14
|
+
attr_accessor :halt_timeout
|
|
15
|
+
attr_accessor :halt_check_interval
|
|
16
|
+
# This sets the command to use to execute items as a superuser. sudo is default
|
|
17
|
+
attr_accessor :suexec_cmd
|
|
18
|
+
|
|
19
|
+
def initialize
|
|
20
|
+
@halt_timeout = 30
|
|
21
|
+
@halt_check_interval = 1
|
|
22
|
+
@suexec_cmd = 'sudo'
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Here for whenever it may be used.
|
|
27
|
+
class SolarisError < Errors::VagrantError
|
|
28
|
+
error_namespace("vagrant.systems.solaris")
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# There should be an exception raised if the line
|
|
32
|
+
#
|
|
33
|
+
# vagrant::::profiles=Primary Administrator
|
|
34
|
+
#
|
|
35
|
+
# does not exist in /etc/user_attr. TODO
|
|
36
|
+
def halt
|
|
37
|
+
vm.env.ui.info I18n.t("vagrant.systems.solaris.attempting_halt")
|
|
38
|
+
vm.ssh.execute do |ssh|
|
|
39
|
+
ssh.exec!("#{vm.env.config.solaris.suexec_cmd} /usr/sbin/poweroff")
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Wait until the VM's state is actually powered off. If this doesn't
|
|
43
|
+
# occur within a reasonable amount of time (15 seconds by default),
|
|
44
|
+
# then simply return and allow Vagrant to kill the machine.
|
|
45
|
+
count = 0
|
|
46
|
+
while vm.vm.state != :powered_off
|
|
47
|
+
count += 1
|
|
48
|
+
|
|
49
|
+
return if count >= vm.env.config.solaris.halt_timeout
|
|
50
|
+
sleep vm.env.config.solaris.halt_check_interval
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def mount_shared_folder(ssh, name, guestpath)
|
|
55
|
+
ssh.exec!("#{vm.env.config.solaris.suexec_cmd} mkdir -p #{guestpath}")
|
|
56
|
+
# Using a custom mount method here; could use improvement.
|
|
57
|
+
ssh.exec!("#{vm.env.config.solaris.suexec_cmd} /sbin/mount -F vboxfs #{name} #{guestpath}")
|
|
58
|
+
ssh.exec!("#{vm.env.config.solaris.suexec_cmd} chown #{vm.env.config.ssh.username} #{guestpath}")
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|