Merge https://github.com/mitchellh/vagrant into salty-vagrant-provisoner

This commit is contained in:
Raadad Elsleiman 2013-05-19 03:03:11 +10:00
commit 017baa1ddb
33 changed files with 571 additions and 258 deletions

View File

@ -1,8 +1,61 @@
## 1.2.2 (unreleased) ## 1.2.3 (unreleased)
FEATURES:
- Puppet provisioner now supports Hiera by specifying a `hiera_config_path`.
- Added a `working_directory` configuration option to the Puppet apply
provisioner so you can specify the working directory when `puppet` is
called, making it friendly to Hiera data and such. [GH-1670]
IMPROVEMENTS:
- Setting hostnames works properly on OmniOS. [GH-1672]
- Better VBoxManage error detection on Windows systems. This avoids
some major issues where Vagrant would sometimes "lose" your VM. [GH-1669]
- Better detection of missing VirtualBox kernel drivers on Linux
systems. [GH-1671]
- More precise detection of Ubuntu/Debian guests so that running Vagrant
within an LXC container works properly now.
- Allow strings in addition to symbols to more places in V1 configuration
as well as V2 configuration.
BUG FIXES:
- Ignore "guest not ready" errors when attempting to graceful halt and
carry on checks whether the halt succeeded. [GH-1679]
- Handle the case where a roles path for Chef solo isn't properly
defined. [GH-1665]
- Finding V1 boxes now works properly again to avoid "box not found"
errors. [GH-1691]
## 1.2.2 (April 23, 2013)
FEATURES:
- New `DestroyConfirm` built-in middleware for providers so they can
more easily conform to the `destroy` action.
IMPROVEMENTS:
- No longer an error if the Chef run list is empty. It is now
a warning. [GH-1620]
- Better locking around handling the `box_url` parameter for
parallel providers.
- Solaris guest is now properly detected on SmartOS, OmniOS, etc. [GH-1639]
- Guest addition version detection is more robust, attempting other
routes to get the version, and also retrying a few times. [GH-1575]
BUG FIXES: BUG FIXES:
- `vagrant package --base` works again. [GH-1615] - `vagrant package --base` works again. [GH-1615]
- Box overrides specified in provider config overrides no longer
fail to detect the box. [GH-1617]
- In a multi-machine environment, a box not found won't be downloaded
multiple times. [GH-1467]
- `vagrant box add` with a file path now works correctly on Windows
when a drive letter is specified.
- DOS line endings are converted to Unix line endings for the
shell provisioner automatically. [GH-1495]
## 1.2.1 (April 17, 2013) ## 1.2.1 (April 17, 2013)
@ -36,6 +89,8 @@ BACKWARDS INCOMPATIBILITIES:
To work around this, either set `VAGRANT_HOME` to your Cygwin ".vagrant.d" To work around this, either set `VAGRANT_HOME` to your Cygwin ".vagrant.d"
folder or move your ".vagrant.d" folder to `USERPROFILE`. The latter is folder or move your ".vagrant.d" folder to `USERPROFILE`. The latter is
recommended for long-term support. recommended for long-term support.
- The constant `Vagrant::Environment::VAGRANT_HOME` was removed in favor of
`Vagrant::Environment#default_vagrant_home`.
FEATURES: FEATURES:

View File

@ -12,6 +12,7 @@ module Vagrant
autoload :Call, "vagrant/action/builtin/call" autoload :Call, "vagrant/action/builtin/call"
autoload :Confirm, "vagrant/action/builtin/confirm" autoload :Confirm, "vagrant/action/builtin/confirm"
autoload :ConfigValidate, "vagrant/action/builtin/config_validate" autoload :ConfigValidate, "vagrant/action/builtin/config_validate"
autoload :DestroyConfirm, "vagrant/action/builtin/destroy_confirm"
autoload :EnvSet, "vagrant/action/builtin/env_set" autoload :EnvSet, "vagrant/action/builtin/env_set"
autoload :GracefulHalt, "vagrant/action/builtin/graceful_halt" autoload :GracefulHalt, "vagrant/action/builtin/graceful_halt"
autoload :HandleBoxUrl, "vagrant/action/builtin/handle_box_url" autoload :HandleBoxUrl, "vagrant/action/builtin/handle_box_url"

View File

@ -19,8 +19,8 @@ module Vagrant
@logger.info("Downloading box to: #{@temp_path}") @logger.info("Downloading box to: #{@temp_path}")
url = env[:box_url] url = env[:box_url]
if url !~ /^[a-z0-9]+:.*$/i if File.file?(url) || url !~ /^[a-z0-9]+:.*$/i
@logger.info("No protocol found on box URL, assuming file:") @logger.info("URL is a file or protocol not found and assuming file.")
file_path = File.expand_path(url) file_path = File.expand_path(url)
file_path = Util::Platform.cygwin_windows_path(file_path) file_path = Util::Platform.cygwin_windows_path(file_path)
url = "file:#{file_path}" url = "file:#{file_path}"

View File

@ -0,0 +1,21 @@
require_relative "confirm"
module Vagrant
module Action
module Builtin
# This class asks the user to confirm the destruction of a machine
# that Vagrant manages. This is provided as a built-in on top of
# {Confirm} because it sets up the proper keys and such so that
# `vagrant destroy -f` works properly.
class DestroyConfirm < Confirm
def initialize(app, env)
force_key = :force_confirm_destroy
message = I18n.t("vagrant.commands.destroy.confirmation",
:name => env[:machine].name)
super(app, env, message, force_key)
end
end
end
end
end

View File

@ -44,7 +44,12 @@ module Vagrant
# checked above. # checked above.
if graceful if graceful
env[:ui].info I18n.t("vagrant.actions.vm.halt.graceful") env[:ui].info I18n.t("vagrant.actions.vm.halt.graceful")
env[:machine].guest.capability(:halt)
begin
env[:machine].guest.capability(:halt)
rescue Errors::MachineGuestNotReady
@logger.info("Machine guest not ready while attempting to halt. Ignoring.")
end
@logger.debug("Waiting for target graceful halt state: #{@target_state}") @logger.debug("Waiting for target graceful halt state: #{@target_state}")
count = 0 count = 0

View File

@ -1,3 +1,5 @@
require "thread"
module Vagrant module Vagrant
module Action module Action
module Builtin module Builtin
@ -6,29 +8,61 @@ module Vagrant
# sequence for a provider after configuration validation but before # sequence for a provider after configuration validation but before
# you attempt to use any box. # you attempt to use any box.
class HandleBoxUrl class HandleBoxUrl
@@big_lock = Mutex.new
@@handle_box_url_locks = Hash.new { |h,k| h[k] = Mutex.new }
def initialize(app, env) def initialize(app, env)
@app = app @app = app
end end
def call(env) def call(env)
if !env[:machine].box if !env[:machine].box
# Get a "big lock" to make sure that our more fine grained
# lock access is thread safe.
lock = nil
@@big_lock.synchronize do
lock = @@handle_box_url_locks[env[:machine].config.vm.box]
end
# We can assume a box URL is set because the Vagrantfile # We can assume a box URL is set because the Vagrantfile
# validation should do this for us. If not, though, we do # validation should do this for us. If not, though, we do
# raise a terrible runtime error. # raise a terrible runtime error.
box_name = env[:machine].config.vm.box box_name = env[:machine].config.vm.box
box_url = env[:machine].config.vm.box_url box_url = env[:machine].config.vm.box_url
# Add the box then reload the box collection so that it becomes lock.synchronize do
# aware of it. # First see if we actually have the box now.
env[:ui].info I18n.t( has_box = false
"vagrant.actions.vm.check_box.not_found",
:name => box_name, formats = env[:machine].provider_options[:box_format] ||
:provider => env[:machine].provider_name) env[:machine].provider_name
env[:action_runner].run(Vagrant::Action.action_box_add, { [formats].flatten.each do |format|
:box_name => box_name, if env[:box_collection].find(box_name, format)
:box_provider => env[:machine].provider_name, has_box = true
:box_url => box_url break
}) end
end
if !has_box
# Add the box then reload the box collection so that it becomes
# aware of it.
env[:ui].info I18n.t(
"vagrant.actions.vm.check_box.not_found",
:name => box_name,
:provider => env[:machine].provider_name)
begin
env[:action_runner].run(Vagrant::Action.action_box_add, {
:box_name => box_name,
:box_provider => env[:machine].provider_name,
:box_url => box_url
})
rescue Errors::BoxAlreadyExists
# Just ignore this, since it means the next part will succeed!
# This can happen in a multi-threaded environment.
end
end
end
# Reload the environment and set the VM to be the new loaded VM. # Reload the environment and set the VM to be the new loaded VM.
env[:machine] = env[:machine].env.machine( env[:machine] = env[:machine].env.machine(

View File

@ -1,4 +1,5 @@
require "digest/sha1" require "digest/sha1"
require "thread"
require "tmpdir" require "tmpdir"
require "log4r" require "log4r"
@ -43,6 +44,7 @@ module Vagrant
options ||= {} options ||= {}
@directory = directory @directory = directory
@lock = Mutex.new
@temp_root = options[:temp_dir_root] @temp_root = options[:temp_dir_root]
@logger = Log4r::Logger.new("vagrant::box_collection") @logger = Log4r::Logger.new("vagrant::box_collection")
end end
@ -69,97 +71,99 @@ module Vagrant
# @param [Boolean] force If true, any existing box with the same name # @param [Boolean] force If true, any existing box with the same name
# and provider will be replaced. # and provider will be replaced.
def add(path, name, provider=nil, force=false) def add(path, name, provider=nil, force=false)
# A helper to check if a box exists. We store this in a variable with_collection_lock do
# since we call it multiple times. # A helper to check if a box exists. We store this in a variable
check_box_exists = lambda do |box_provider| # since we call it multiple times.
box = find(name, box_provider) check_box_exists = lambda do |box_provider|
next if !box box = find(name, box_provider)
next if !box
if !force if !force
@logger.error("Box already exists, can't add: #{name} #{box_provider}") @logger.error("Box already exists, can't add: #{name} #{box_provider}")
raise Errors::BoxAlreadyExists, :name => name, :provider => box_provider raise Errors::BoxAlreadyExists, :name => name, :provider => box_provider
end
# We're forcing, so just delete the old box
@logger.info("Box already exists, but forcing so removing: #{name} #{box_provider}")
box.destroy!
end end
# We're forcing, so just delete the old box log_provider = provider ? provider : "any provider"
@logger.info("Box already exists, but forcing so removing: #{name} #{box_provider}") @logger.debug("Adding box: #{name} (#{log_provider}) from #{path}")
box.destroy!
end
log_provider = provider ? provider : "any provider" # Verify the box doesn't exist early if we're given a provider. This
@logger.debug("Adding box: #{name} (#{log_provider}) from #{path}") # can potentially speed things up considerably since we don't need
# to unpack any files.
check_box_exists.call(provider) if provider
# Verify the box doesn't exist early if we're given a provider. This # Verify that a V1 box doesn't exist. If it does, then we signal
# can potentially speed things up considerably since we don't need # to the user that we need an upgrade.
# to unpack any files. raise Errors::BoxUpgradeRequired, :name => name if v1_box?(@directory.join(name))
check_box_exists.call(provider) if provider
# Verify that a V1 box doesn't exist. If it does, then we signal # Create a temporary directory since we're not sure at this point if
# to the user that we need an upgrade. # the box we're unpackaging already exists (if no provider was given)
raise Errors::BoxUpgradeRequired, :name => name if v1_box?(@directory.join(name)) with_temp_dir do |temp_dir|
# Extract the box into a temporary directory.
@logger.debug("Unpacking box into temporary directory: #{temp_dir}")
result = Util::Subprocess.execute(
"bsdtar", "-v", "-x", "-m", "-C", temp_dir.to_s, "-f", path.to_s)
raise Errors::BoxUnpackageFailure, :output => result.stderr.to_s if result.exit_code != 0
# Create a temporary directory since we're not sure at this point if # If we get a V1 box, we want to update it in place
# the box we're unpackaging already exists (if no provider was given) if v1_box?(temp_dir)
with_temp_dir do |temp_dir| @logger.debug("Added box is a V1 box. Upgrading in place.")
# Extract the box into a temporary directory. temp_dir = v1_upgrade(temp_dir)
@logger.debug("Unpacking box into temporary directory: #{temp_dir}") end
result = Util::Subprocess.execute(
"bsdtar", "-v", "-x", "-m", "-C", temp_dir.to_s, "-f", path.to_s)
raise Errors::BoxUnpackageFailure, :output => result.stderr.to_s if result.exit_code != 0
# If we get a V1 box, we want to update it in place # We re-wrap ourselves in the safety net in case we upgraded.
if v1_box?(temp_dir) # If we didn't upgrade, then this is still safe because the
@logger.debug("Added box is a V1 box. Upgrading in place.") # helper will only delete the directory if it exists
temp_dir = v1_upgrade(temp_dir) with_temp_dir(temp_dir) do |final_temp_dir|
end # Get an instance of the box we just added before it is finalized
# in the system so we can inspect and use its metadata.
box = Box.new(name, provider, final_temp_dir)
# We re-wrap ourselves in the safety net in case we upgraded. # Get the provider, since we'll need that to at the least add it
# If we didn't upgrade, then this is still safe because the # to the system or check that it matches what is given to us.
# helper will only delete the directory if it exists box_provider = box.metadata["provider"]
with_temp_dir(temp_dir) do |final_temp_dir|
# Get an instance of the box we just added before it is finalized
# in the system so we can inspect and use its metadata.
box = Box.new(name, provider, final_temp_dir)
# Get the provider, since we'll need that to at the least add it if provider
# to the system or check that it matches what is given to us. # Verify that the given provider matches what the box has.
box_provider = box.metadata["provider"] if box_provider.to_sym != provider
@logger.error("Added box provider doesnt match expected: #{box_provider}")
raise Errors::BoxProviderDoesntMatch, :expected => provider, :actual => box_provider
end
else
# We weren't given a provider, so store this one.
provider = box_provider.to_sym
if provider # Verify the box doesn't already exist
# Verify that the given provider matches what the box has. check_box_exists.call(provider)
if box_provider.to_sym != provider
@logger.error("Added box provider doesnt match expected: #{box_provider}")
raise Errors::BoxProviderDoesntMatch, :expected => provider, :actual => box_provider
end end
else
# We weren't given a provider, so store this one.
provider = box_provider.to_sym
# Verify the box doesn't already exist # Create the directory for this box, not including the provider
check_box_exists.call(provider) box_dir = @directory.join(name)
end box_dir.mkpath
@logger.debug("Box directory: #{box_dir}")
# Create the directory for this box, not including the provider # This is the final directory we'll move it to
box_dir = @directory.join(name) final_dir = box_dir.join(provider.to_s)
box_dir.mkpath if final_dir.exist?
@logger.debug("Box directory: #{box_dir}") @logger.debug("Removing existing provider directory...")
final_dir.rmtree
end
# This is the final directory we'll move it to # Move to final destination
final_dir = box_dir.join(provider.to_s) final_dir.mkpath
if final_dir.exist?
@logger.debug("Removing existing provider directory...")
final_dir.rmtree
end
# Move to final destination # Go through each child and copy them one-by-one. This avoids
final_dir.mkpath # an issue where on Windows cross-device directory copies are
# failing for some reason. [GH-1424]
# Go through each child and copy them one-by-one. This avoids final_temp_dir.children(true).each do |f|
# an issue where on Windows cross-device directory copies are destination = final_dir.join(f.basename)
# failing for some reason. [GH-1424] @logger.debug("Moving: #{f} => #{destination}")
final_temp_dir.children(true).each do |f| FileUtils.mv(f, destination)
destination = final_dir.join(f.basename) end
@logger.debug("Moving: #{f} => #{destination}")
FileUtils.mv(f, destination)
end end
end end
end end
@ -177,33 +181,35 @@ module Vagrant
def all def all
results = [] results = []
@logger.debug("Finding all boxes in: #{@directory}") with_collection_lock do
@directory.children(true).each do |child| @logger.debug("Finding all boxes in: #{@directory}")
# Ignore non-directories, since files are not interesting to @directory.children(true).each do |child|
# us in our folder structure. # Ignore non-directories, since files are not interesting to
next if !child.directory? # us in our folder structure.
next if !child.directory?
box_name = child.basename.to_s box_name = child.basename.to_s
# If this is a V1 box, we still return that name, but specify # If this is a V1 box, we still return that name, but specify
# that the box is a V1 box. # that the box is a V1 box.
if v1_box?(child) if v1_box?(child)
@logger.debug("V1 box found: #{box_name}") @logger.debug("V1 box found: #{box_name}")
results << [box_name, :virtualbox, :v1] results << [box_name, :virtualbox, :v1]
next next
end end
# Otherwise, traverse the subdirectories and see what providers # Otherwise, traverse the subdirectories and see what providers
# we have. # we have.
child.children(true).each do |provider| child.children(true).each do |provider|
# Verify this is a potentially valid box. If it looks # Verify this is a potentially valid box. If it looks
# correct enough then include it. # correct enough then include it.
if provider.directory? && provider.join("metadata.json").file? if provider.directory? && provider.join("metadata.json").file?
provider_name = provider.basename.to_s.to_sym provider_name = provider.basename.to_s.to_sym
@logger.debug("Box: #{box_name} (#{provider_name})") @logger.debug("Box: #{box_name} (#{provider_name})")
results << [box_name, provider_name] results << [box_name, provider_name]
else else
@logger.debug("Invalid box, ignoring: #{provider}") @logger.debug("Invalid box, ignoring: #{provider}")
end
end end
end end
end end
@ -217,29 +223,31 @@ module Vagrant
# @Param [String] provider Provider that the box implements. # @Param [String] provider Provider that the box implements.
# @return [Box] The box found, or `nil` if not found. # @return [Box] The box found, or `nil` if not found.
def find(name, provider) def find(name, provider)
# First look directly for the box we're asking for. with_collection_lock do
box_directory = @directory.join(name, provider.to_s, "metadata.json") # First look directly for the box we're asking for.
@logger.info("Searching for box: #{name} (#{provider}) in #{box_directory}") box_directory = @directory.join(name, provider.to_s, "metadata.json")
if box_directory.file? @logger.info("Searching for box: #{name} (#{provider}) in #{box_directory}")
@logger.info("Box found: #{name} (#{provider})") if box_directory.file?
return Box.new(name, provider, box_directory.dirname) @logger.info("Box found: #{name} (#{provider})")
end return Box.new(name, provider, box_directory.dirname)
end
# If we're looking for a VirtualBox box, then we check if there is # If we're looking for a VirtualBox box, then we check if there is
# a V1 box. # a V1 box.
if provider == :virtualbox if provider.to_sym == :virtualbox
# Check if a V1 version of this box exists, and if so, raise an # Check if a V1 version of this box exists, and if so, raise an
# exception notifying the caller that the box exists but needs # exception notifying the caller that the box exists but needs
# to be upgraded. We don't do the upgrade here because it can be # to be upgraded. We don't do the upgrade here because it can be
# a fairly intensive activity and don't want to immediately degrade # a fairly intensive activity and don't want to immediately degrade
# user performance on a find. # user performance on a find.
# #
# To determine if it is a V1 box we just do a simple heuristic # To determine if it is a V1 box we just do a simple heuristic
# based approach. # based approach.
@logger.info("Searching for V1 box: #{name}") @logger.info("Searching for V1 box: #{name}")
if v1_box?(@directory.join(name)) if v1_box?(@directory.join(name))
@logger.warn("V1 box found: #{name}") @logger.warn("V1 box found: #{name}")
raise Errors::BoxUpgradeRequired, :name => name raise Errors::BoxUpgradeRequired, :name => name
end
end end
end end
@ -255,21 +263,23 @@ module Vagrant
# #
# @return [Boolean] `true` otherwise an exception is raised. # @return [Boolean] `true` otherwise an exception is raised.
def upgrade(name) def upgrade(name)
@logger.debug("Upgrade request for box: #{name}") with_collection_lock do
box_dir = @directory.join(name) @logger.debug("Upgrade request for box: #{name}")
box_dir = @directory.join(name)
# If the box doesn't exist at all, raise an exception # If the box doesn't exist at all, raise an exception
raise Errors::BoxNotFound, :name => name if !box_dir.directory? raise Errors::BoxNotFound, :name => name if !box_dir.directory?
if v1_box?(box_dir) if v1_box?(box_dir)
@logger.debug("V1 box #{name} found. Upgrading!") @logger.debug("V1 box #{name} found. Upgrading!")
# First we actually perform the upgrade # First we actually perform the upgrade
temp_dir = v1_upgrade(box_dir) temp_dir = v1_upgrade(box_dir)
# Rename the temporary directory to the provider. # Rename the temporary directory to the provider.
FileUtils.mv(temp_dir.to_s, box_dir.join("virtualbox").to_s) FileUtils.mv(temp_dir.to_s, box_dir.join("virtualbox").to_s)
@logger.info("Box '#{name}' upgraded from V1 to V2.") @logger.info("Box '#{name}' upgraded from V1 to V2.")
end
end end
# We did it! Or the v1 box didn't exist so it doesn't matter. # We did it! Or the v1 box didn't exist so it doesn't matter.
@ -330,6 +340,24 @@ module Vagrant
temp_dir temp_dir
end end
# This locks the region given by the block with a lock on this
# collection.
def with_collection_lock
lock = @lock
begin
lock.synchronize {}
rescue ThreadError
# If we already hold the lock, just create a new lock so
# we definitely don't block and don't get an error.
lock = Mutex.new
end
lock.synchronize do
return yield
end
end
# This is a helper that makes sure that our temporary directories # This is a helper that makes sure that our temporary directories
# are cleaned up no matter what. # are cleaned up no matter what.
# #

View File

@ -328,58 +328,65 @@ module Vagrant
config, config_warnings, config_errors = \ config, config_warnings, config_errors = \
@config_loader.load([:default, :home, :root, vm_config_key]) @config_loader.load([:default, :home, :root, vm_config_key])
# Determine the possible box formats for any boxes and find the box
box_formats = provider_options[:box_format] || provider
box = nil box = nil
if config.vm.box
# Determine the box formats we support
formats = provider_options[:box_format]
formats ||= provider
formats = [formats] if !formats.is_a?(Array)
@logger.info("Provider-supported box formats: #{formats.inspect}") # Set this variable in order to keep track of if the box changes
formats.each do |format| # too many times.
begin original_box = config.vm.box
box = boxes.find(config.vm.box, format.to_s) box_changed = false
rescue Errors::BoxUpgradeRequired
# Upgrade the box if we must
@logger.info("Upgrading box during config load: #{config.vm.box}")
boxes.upgrade(config.vm.box)
retry
end
# If a box was found, we exit load_box_and_overrides = lambda do
if box box = find_box(config.vm.box, box_formats) if config.vm.box
@logger.info("Box found with format: #{format}")
break # If a box was found, then we attempt to load the Vagrantfile for
# that box. We don't require a box since we allow providers to download
# boxes and so on.
if box
box_vagrantfile = find_vagrantfile(box.directory)
if box_vagrantfile
# The box has a custom Vagrantfile, so we load that into the config
# as well.
@logger.info("Box exists with Vagrantfile. Reloading machine config.")
box_config_key = "box_#{box.name}_#{box.provider}".to_sym
@config_loader.set(box_config_key, box_vagrantfile)
config, config_warnings, config_errors = \
@config_loader.load([:default, box_config_key, :home, :root, vm_config_key])
end end
end end
end
# If a box was found, then we attempt to load the Vagrantfile for # If there are provider overrides for the machine, then we run
# that box. We don't require a box since we allow providers to download # those as well.
# boxes and so on. provider_overrides = config.vm.get_provider_overrides(provider)
if box if provider_overrides.length > 0
box_vagrantfile = find_vagrantfile(box.directory) @logger.info("Applying #{provider_overrides.length} provider overrides. Reloading config.")
if box_vagrantfile provider_override_key = "vm_#{name}_#{config.vm.box}_#{provider}".to_sym
# The box has a custom Vagrantfile, so we load that into the config @config_loader.set(provider_override_key, provider_overrides)
# as well.
@logger.info("Box exists with Vagrantfile. Reloading machine config.")
box_config_key = "box_#{box.name}_#{box.provider}".to_sym
@config_loader.set(box_config_key, box_vagrantfile)
config, config_warnings, config_errors = \ config, config_warnings, config_errors = \
@config_loader.load([:default, box_config_key, :home, :root, vm_config_key]) @config_loader.load([:default, box_config_key, :home, :root, vm_config_key, provider_override_key])
end
if config.vm.box && original_box != config.vm.box
if box_changed
# We already changed boxes once, so report an error that a
# box is attempting to change boxes again.
raise Errors::BoxConfigChangingBox
end
# The box changed, probably due to the provider override. Let's
# run the configuration one more time with the new box.
@logger.info("Box changed to: #{config.vm.box}. Reloading configurations.")
original_box = config.vm.box
box_changed = true
# Recurse so that we reload all the configurations
load_box_and_overrides.call
end end
end end
# If there are provider overrides for the machine, then we run # Load the box and overrides configuration
# those as well. load_box_and_overrides.call
provider_overrides = config.vm.get_provider_overrides(provider)
if provider_overrides.length > 0
@logger.info("Applying #{provider_overrides.length} provider overrides. Reloading config.")
provider_override_key = "vm_#{name}_#{config.vm.box}_#{provider}".to_sym
@config_loader.set(provider_override_key, provider_overrides)
config, config_warnings, config_errors = \
@config_loader.load([:default, box_config_key, :home, :root, vm_config_key, provider_override_key])
end
# Get the provider configuration from the final loaded configuration # Get the provider configuration from the final loaded configuration
provider_config = config.vm.get_provider_config(provider) provider_config = config.vm.get_provider_config(provider)
@ -398,11 +405,11 @@ module Vagrant
"config/messages", "config/messages",
:warnings => config_warnings, :warnings => config_warnings,
:errors => config_errors).chomp :errors => config_errors).chomp
@ui.send(level, I18n.t("vagrant.general.config_upgrade_messages", @ui.send(level, I18n.t("vagrant.general.config_upgrade_messages",
:output => output)) :output => output))
# If we had errors, then we bail # If we had errors, then we bail
raise Errors::ConfigUpgradeErrors if !config_errors.empty? raise Errors::ConfigUpgradeErrors if !config_errors.empty?
end end
# Create the machine and cache it for future calls. This will also # Create the machine and cache it for future calls. This will also
@ -686,6 +693,39 @@ module Vagrant
Pathname.new(path) Pathname.new(path)
end end
# This finds a box for the given name and formats, or returns nil
# if the box isn't found.
#
# @param [String] name Name of the box
# @param [Array<Symbol>] formats The formats to search for the box.
# @return [Box]
def find_box(name, formats)
# Determine the box formats we support
formats = [formats] if !formats.is_a?(Array)
@logger.info("Provider-supported box formats: #{formats.inspect}")
formats.each do |format|
box = nil
begin
box = boxes.find(name, format.to_s)
rescue Errors::BoxUpgradeRequired
# Upgrade the box if we must
@logger.info("Upgrading box during config load: #{name}")
boxes.upgrade(name)
retry
end
# If a box was found, we exit
if box
@logger.info("Box found with format: #{format}")
return box
end
end
nil
end
# Finds the Vagrantfile in the given directory. # Finds the Vagrantfile in the given directory.
# #
# @param [Pathname] path Path to search in. # @param [Pathname] path Path to search in.
@ -797,7 +837,7 @@ module Vagrant
# Upgrade complete! Let the user know # Upgrade complete! Let the user know
@ui.info(I18n.t("vagrant.general.upgraded_v1_dotfile", @ui.info(I18n.t("vagrant.general.upgraded_v1_dotfile",
:backup_path => backup_file.to_s)) :backup_path => backup_file.to_s))
end end
end end
end end

View File

@ -103,6 +103,10 @@ module Vagrant
error_key(:already_exists, "vagrant.actions.box.unpackage") error_key(:already_exists, "vagrant.actions.box.unpackage")
end end
class BoxConfigChangingBox < VagrantError
error_key(:box_config_changing_box)
end
class BoxMetadataFileNotFound < VagrantError class BoxMetadataFileNotFound < VagrantError
error_key(:box_metadata_file_not_found) error_key(:box_metadata_file_not_found)
end end

View File

@ -193,6 +193,8 @@ module Vagrant
# #
# @param [String] value The ID. # @param [String] value The ID.
def id=(value) def id=(value)
@logger.info("New machine ID: #{value.inspect}")
# The file that will store the id if we have one. This allows the # The file that will store the id if we have one. This allows the
# ID to persist across Vagrant runs. # ID to persist across Vagrant runs.
id_file = @data_dir.join("id") id_file = @data_dir.join("id")

View File

@ -2,5 +2,5 @@ module Vagrant
# This will always be up to date with the current version of Vagrant, # This will always be up to date with the current version of Vagrant,
# since it is used to generate the gemspec and is also the source of # since it is used to generate the gemspec and is also the source of
# the version for `vagrant -v` # the version for `vagrant -v`
VERSION = "1.2.2.dev" VERSION = "1.2.3.dev"
end end

View File

@ -194,7 +194,12 @@ module VagrantPlugins
:verbose => :debug :verbose => :debug
}) })
@logger.info("Attempting to connect to SSH: #{ssh_info[:host]}:#{ssh_info[:port]}") @logger.info("Attempting to connect to SSH...")
@logger.info(" - Host: #{ssh_info[:host]}")
@logger.info(" - Port: #{ssh_info[:port]}")
@logger.info(" - Username: #{ssh_info[:username]}")
@logger.info(" - Key Path: #{ssh_info[:private_key_path]}")
Net::SSH.start(ssh_info[:host], ssh_info[:username], connect_opts) Net::SSH.start(ssh_info[:host], ssh_info[:username], connect_opts)
ensure ensure
# Make sure we output the connection log # Make sure we output the connection log

View File

@ -2,7 +2,7 @@ module VagrantPlugins
module GuestDebian module GuestDebian
class Guest < Vagrant.plugin("2", :guest) class Guest < Vagrant.plugin("2", :guest)
def detect?(machine) def detect?(machine)
machine.communicate.test("cat /proc/version | grep 'Debian'") machine.communicate.test("cat /etc/issue | grep 'Debian'")
end end
end end
end end

View File

@ -0,0 +1,17 @@
module VagrantPlugins
module GuestOmniOS
module Cap
class ChangeHostName
def self.change_host_name(machine, name)
su_cmd = machine.config.solaris.suexec_cmd
# Only do this if the hostname is not already set
if !machine.communicate.test("#{su_cmd} hostname | grep '#{name}'")
machine.communicate.execute("#{su_cmd} sh -c \"echo '#{name}' > /etc/nodename\"")
machine.communicate.execute("#{su_cmd} hostname #{name}")
end
end
end
end
end
end

View File

@ -0,0 +1,11 @@
require "vagrant"
module VagrantPlugins
module GuestOmniOS
class Guest < Vagrant.plugin("2", :guest)
def detect?(machine)
machine.communicate.test("cat /etc/release | grep -i OmniOS")
end
end
end
end

View File

@ -0,0 +1,20 @@
require "vagrant"
module VagrantPlugins
module GuestOmniOS
class Plugin < Vagrant.plugin("2")
name "OmniOS guest."
description "OmniOS guest support."
guest("omnios", "solaris") do
require File.expand_path("../guest", __FILE__)
Guest
end
guest_capability("omnios", "change_host_name") do
require_relative "cap/change_host_name"
Cap::ChangeHostName
end
end
end
end

View File

@ -7,7 +7,7 @@ module VagrantPlugins
# Contributed by Blake Irvin <b.irvin@modcloth.com> # Contributed by Blake Irvin <b.irvin@modcloth.com>
class Guest < Vagrant.plugin("2", :guest) class Guest < Vagrant.plugin("2", :guest)
def detect?(machine) def detect?(machine)
machine.communicate.test("grep 'Solaris' /etc/release") machine.communicate.test("uname -o | grep Solaris")
end end
end end
end end

View File

@ -6,7 +6,7 @@ module VagrantPlugins
module GuestUbuntu module GuestUbuntu
class Guest < VagrantPlugins::GuestDebian::Guest class Guest < VagrantPlugins::GuestDebian::Guest
def detect?(machine) def detect?(machine)
machine.communicate.test("cat /proc/version | grep 'Ubuntu'") machine.communicate.test("cat /etc/issue | grep 'Ubuntu'")
end end
def mount_shared_folder(name, guestpath, options) def mount_shared_folder(name, guestpath, options)

View File

@ -53,6 +53,9 @@ module VagrantPlugins
end end
def network(type, *args) def network(type, *args)
# Convert to symbol so we can allow most anything...
type = type.to_sym if type
if type == :hostonly if type == :hostonly
@networks << [:private_network, args] @networks << [:private_network, args]
elsif type == :bridged elsif type == :bridged
@ -110,8 +113,8 @@ module VagrantPlugins
# VirtualBox provider on the new VM. # VirtualBox provider on the new VM.
if !self.customizations.empty? if !self.customizations.empty?
warnings << "`config.vm.customize` calls are VirtualBox-specific. If you're\n" + warnings << "`config.vm.customize` calls are VirtualBox-specific. If you're\n" +
"using any other provider, you'll have to find provider-specific configuration\n" + "using any other provider, you'll have to use config.vm.provider in a\n" +
"to translate to manually in your Vagrantfile." "v2 configuration block."
new.vm.provider :virtualbox do |vb| new.vm.provider :virtualbox do |vb|
self.customizations.each do |customization| self.customizations.each do |customization|

View File

@ -31,12 +31,12 @@ module VagrantPlugins
# Internal state # Internal state
@__compiled_provider_configs = {} @__compiled_provider_configs = {}
@__compiled_provider_overrides = {}
@__defined_vm_keys = [] @__defined_vm_keys = []
@__defined_vms = {} @__defined_vms = {}
@__finalized = false @__finalized = false
@__networks = {} @__networks = {}
@__providers = {} @__providers = {}
@__provider_overrides = {}
@__synced_folders = {} @__synced_folders = {}
end end
@ -80,6 +80,14 @@ module VagrantPlugins
new_providers[key] += blocks new_providers[key] += blocks
end end
# Merge the provider overrides by appending them...
other_overrides = other.instance_variable_get(:@__provider_overrides)
new_overrides = @__provider_overrides.dup
other_overrides.each do |key, blocks|
new_overrides[key] ||= []
new_overrides[key] += blocks
end
# Merge synced folders. # Merge synced folders.
other_folders = other.instance_variable_get(:@__synced_folders) other_folders = other.instance_variable_get(:@__synced_folders)
new_folders = @__synced_folders.dup new_folders = @__synced_folders.dup
@ -91,6 +99,7 @@ module VagrantPlugins
result.instance_variable_set(:@__defined_vm_keys, new_defined_vm_keys) result.instance_variable_set(:@__defined_vm_keys, new_defined_vm_keys)
result.instance_variable_set(:@__defined_vms, new_defined_vms) result.instance_variable_set(:@__defined_vms, new_defined_vms)
result.instance_variable_set(:@__providers, new_providers) result.instance_variable_set(:@__providers, new_providers)
result.instance_variable_set(:@__provider_overrides, new_overrides)
result.instance_variable_set(:@__synced_folders, new_folders) result.instance_variable_set(:@__synced_folders, new_folders)
end end
end end
@ -165,7 +174,17 @@ module VagrantPlugins
def provider(name, &block) def provider(name, &block)
name = name.to_sym name = name.to_sym
@__providers[name] ||= [] @__providers[name] ||= []
@__providers[name] << block if block_given? @__provider_overrides[name] ||= []
if block_given?
@__providers[name] << block if block_given?
# If this block takes two arguments, then we curry it and store
# the configuration override for use later.
if block.arity == 2
@__provider_overrides[name] << block.curry[Vagrant::Config::V2::DummyConfig.new]
end
end
end end
def provision(name, options=nil, &block) def provision(name, options=nil, &block)
@ -223,23 +242,15 @@ module VagrantPlugins
# Load it up # Load it up
config = config_class.new config = config_class.new
overrides = []
blocks.each do |b| blocks.each do |b|
b.call(config, Vagrant::Config::V2::DummyConfig.new) b.call(config, Vagrant::Config::V2::DummyConfig.new)
# If the block takes two arguments, then we store the second
# one away for overrides later.
if b.arity == 2
overrides << b.curry[Vagrant::Config::V2::DummyConfig.new]
end
end end
config.finalize! config.finalize!
# Store it for retrieval later # Store it for retrieval later
@__compiled_provider_configs[name] = config @__compiled_provider_configs[name] = config
@__compiled_provider_overrides[name] = overrides
end end
# Flag that we finalized # Flag that we finalized
@ -274,7 +285,7 @@ module VagrantPlugins
# @param [Symbol] name Name of the provider # @param [Symbol] name Name of the provider
# @return [Array<Proc>] # @return [Array<Proc>]
def get_provider_overrides(name) def get_provider_overrides(name)
(@__compiled_provider_overrides[name] || []).map do |p| (@__provider_overrides[name] || []).map do |p|
["2", p] ["2", p]
end end
end end

View File

@ -16,7 +16,6 @@ module VagrantPlugins
autoload :Created, File.expand_path("../action/created", __FILE__) autoload :Created, File.expand_path("../action/created", __FILE__)
autoload :Customize, File.expand_path("../action/customize", __FILE__) autoload :Customize, File.expand_path("../action/customize", __FILE__)
autoload :Destroy, File.expand_path("../action/destroy", __FILE__) autoload :Destroy, File.expand_path("../action/destroy", __FILE__)
autoload :DestroyConfirm, File.expand_path("../action/destroy_confirm", __FILE__)
autoload :DestroyUnusedNetworkInterfaces, File.expand_path("../action/destroy_unused_network_interfaces", __FILE__) autoload :DestroyUnusedNetworkInterfaces, File.expand_path("../action/destroy_unused_network_interfaces", __FILE__)
autoload :DiscardState, File.expand_path("../action/discard_state", __FILE__) autoload :DiscardState, File.expand_path("../action/discard_state", __FILE__)
autoload :Export, File.expand_path("../action/export", __FILE__) autoload :Export, File.expand_path("../action/export", __FILE__)

View File

@ -1,17 +0,0 @@
require "vagrant/action/builtin/confirm"
module VagrantPlugins
module ProviderVirtualBox
module Action
class DestroyConfirm < Vagrant::Action::Builtin::Confirm
def initialize(app, env)
force_key = :force_confirm_destroy
message = I18n.t("vagrant.commands.destroy.confirmation",
:name => env[:machine].name)
super(app, env, message, force_key)
end
end
end
end
end

View File

@ -303,7 +303,16 @@ module VagrantPlugins
# Sometimes, VBoxManage fails but doesn't actual return a non-zero # Sometimes, VBoxManage fails but doesn't actual return a non-zero
# exit code. For this we inspect the output and determine if an error # exit code. For this we inspect the output and determine if an error
# occurred. # occurred.
if r.stderr =~ /VBoxManage: error:/
if r.stderr =~ /failed to open \/dev\/vboxnetctl/i
# This catches an error message that only shows when kernel
# drivers aren't properly installed.
@logger.error("Error message about unable to open vboxnetctl")
raise Vagrant::Errors::VirtualBoxKernelModuleNotLoaded
end
if r.stderr =~ /VBoxManage([.a-z]+?): error:/
# This catches the generic VBoxManage error case.
@logger.info("VBoxManage error text found, assuming error.") @logger.info("VBoxManage error text found, assuming error.")
errored = true errored = true
end end

View File

@ -264,6 +264,13 @@ module VagrantPlugins
return value.split("_").first return value.split("_").first
end end
# If we can't get the guest additions version by guest property, try
# to get it from the VM info itself.
info = execute("showvminfo", @uuid, "--machinereadable", :retryable => true)
info.split("\n").each do |line|
return $1.to_s if line =~ /^GuestAdditionsVersion="(.+?)"$/
end
return nil return nil
end end

View File

@ -34,16 +34,12 @@ module VagrantPlugins
@chef_server_url = nil if @chef_server_url == UNSET_VALUE @chef_server_url = nil if @chef_server_url == UNSET_VALUE
@client_key_path = "/etc/chef/client.pem" if @client_key_path == UNSET_VALUE @client_key_path = "/etc/chef/client.pem" if @client_key_path == UNSET_VALUE
@encrypted_data_bag_secret_key_path = nil if @encrypted_data_bag_secret_key_path == UNSET_VALUE @encrypted_data_bag_secret_key_path = nil if @encrypted_data_bag_secret_key_path == UNSET_VALUE
@encrypted_data_bag_secret = nil if @encrypted_data_bag_secret == UNSET_VALUE @encrypted_data_bag_secret = "/tmp/encrypted_data_bag_secret" if @encrypted_data_bag_secret == UNSET_VALUE
@environment = nil if @environment == UNSET_VALUE @environment = nil if @environment == UNSET_VALUE
@file_backup_path = "/srv/chef/cache" if @file_backup_path == UNSET_VALUE @file_backup_path = "/srv/chef/cache" if @file_backup_path == UNSET_VALUE
@file_cache_path = "/srv/chef/file_store" if @file_cache_path == UNSET_VALUE @file_cache_path = "/srv/chef/file_store" if @file_cache_path == UNSET_VALUE
@validation_client_name = "chef-validator" if @validation_client_name == UNSET_VALUE @validation_client_name = "chef-validator" if @validation_client_name == UNSET_VALUE
@validation_key_path = nil if @validation_key_path == UNSET_VALUE @validation_key_path = nil if @validation_key_path == UNSET_VALUE
if @encrypted_data_bag_secret == UNSET_VALUE
@encrypted_data_bag_secret = "/tmp/encrypted_data_bag_secret"
end
end end
def validate(machine) def validate(machine)
@ -52,8 +48,6 @@ module VagrantPlugins
!chef_server_url || chef_server_url.strip == "" !chef_server_url || chef_server_url.strip == ""
errors << I18n.t("vagrant.config.chef.validation_key_path") if \ errors << I18n.t("vagrant.config.chef.validation_key_path") if \
!validation_key_path !validation_key_path
errors << I18n.t("vagrant.config.chef.run_list_empty") if \
@run_list && @run_list.empty?
{ "chef client provisioner" => errors } { "chef client provisioner" => errors }
end end

View File

@ -61,8 +61,6 @@ module VagrantPlugins
errors = _detected_errors errors = _detected_errors
errors << I18n.t("vagrant.config.chef.cookbooks_path_empty") if \ errors << I18n.t("vagrant.config.chef.cookbooks_path_empty") if \
!cookbooks_path || [cookbooks_path].flatten.empty? !cookbooks_path || [cookbooks_path].flatten.empty?
errors << I18n.t("vagrant.config.chef.run_list_empty") if \
!run_list || run_list.empty?
{ "chef solo provisioner" => errors } { "chef solo provisioner" => errors }
end end

View File

@ -58,6 +58,10 @@ module VagrantPlugins
end end
def run_chef_client def run_chef_client
if @config.run_list && @config.run_list.empty?
@machine.ui.warn(I18n.t("vagrant.chef_run_list_empty"))
end
command_env = @config.binary_env ? "#{@config.binary_env} " : "" command_env = @config.binary_env ? "#{@config.binary_env} " : ""
command_args = @config.arguments ? " #{@config.arguments}" : "" command_args = @config.arguments ? " #{@config.arguments}" : ""
command = "#{command_env}#{chef_binary_path("chef-client")} -c #{@config.provisioning_path}/client.rb -j #{@config.provisioning_path}/dna.json #{command_args}" command = "#{command_env}#{chef_binary_path("chef-client")} -c #{@config.provisioning_path}/client.rb -j #{@config.provisioning_path}/dna.json #{command_args}"

View File

@ -135,6 +135,10 @@ module VagrantPlugins
end end
def run_chef_solo def run_chef_solo
if @config.run_list && @config.run_list.empty?
@machine.ui.warn(I18n.t("vagrant.chef_run_list_empty"))
end
command_env = @config.binary_env ? "#{@config.binary_env} " : "" command_env = @config.binary_env ? "#{@config.binary_env} " : ""
command_args = @config.arguments ? " #{@config.arguments}" : "" command_args = @config.arguments ? " #{@config.arguments}" : ""
command = "#{command_env}#{chef_binary_path("chef-solo")} -c #{@config.provisioning_path}/solo.rb -j #{@config.provisioning_path}/dna.json #{command_args}" command = "#{command_env}#{chef_binary_path("chef-solo")} -c #{@config.provisioning_path}/solo.rb -j #{@config.provisioning_path}/dna.json #{command_args}"

View File

@ -2,18 +2,38 @@ module VagrantPlugins
module Puppet module Puppet
module Config module Config
class Puppet < Vagrant.plugin("2", :config) class Puppet < Vagrant.plugin("2", :config)
attr_accessor :facter
attr_accessor :hiera_config_path
attr_accessor :manifest_file attr_accessor :manifest_file
attr_accessor :manifests_path attr_accessor :manifests_path
attr_accessor :module_path attr_accessor :module_path
attr_accessor :pp_path
attr_accessor :options attr_accessor :options
attr_accessor :facter attr_accessor :temp_dir
attr_accessor :working_directory
def manifest_file; @manifest_file || "default.pp"; end def initialize
def manifests_path; @manifests_path || "manifests"; end super
def pp_path; @pp_path || "/tmp/vagrant-puppet"; end
def options; @options ||= []; end @hiera_config_path = UNSET_VALUE
def facter; @facter ||= {}; end @manifest_file = UNSET_VALUE
@manifests_path = UNSET_VALUE
@module_path = UNSET_VALUE
@options = []
@facter = {}
@temp_dir = UNSET_VALUE
@working_directory = UNSET_VALUE
end
def finalize!
super
@hiera_config_path = nil if @hiera_config_path == UNSET_VALUE
@manifest_file = "default.pp" if @manifest_file == UNSET_VALUE
@manifests_path = "manifests" if @manifests_path == UNSET_VALUE
@module_path = nil if @module_path == UNSET_VALUE
@temp_dir = "/tmp/vagrant-puppet" if @temp_dir == UNSET_VALUE
@working_directory = nil if @working_directory == UNSET_VALUE
end
# Returns the manifests path expanded relative to the root path of the # Returns the manifests path expanded relative to the root path of the
# environment. # environment.

View File

@ -19,12 +19,12 @@ module VagrantPlugins
root_path = @machine.env.root_path root_path = @machine.env.root_path
@expanded_manifests_path = @config.expanded_manifests_path(root_path) @expanded_manifests_path = @config.expanded_manifests_path(root_path)
@expanded_module_paths = @config.expanded_module_paths(root_path) @expanded_module_paths = @config.expanded_module_paths(root_path)
@manifest_file = @config.manifest_file @manifest_file = File.join(manifests_guest_path, @config.manifest_file)
# Setup the module paths # Setup the module paths
@module_paths = [] @module_paths = []
@expanded_module_paths.each_with_index do |path, i| @expanded_module_paths.each_with_index do |path, i|
@module_paths << [path, File.join(config.pp_path, "modules-#{i}")] @module_paths << [path, File.join(config.temp_dir, "modules-#{i}")]
end end
# Share the manifests directory with the guest # Share the manifests directory with the guest
@ -52,11 +52,26 @@ module VagrantPlugins
# Verify Puppet is installed and run it # Verify Puppet is installed and run it
verify_binary("puppet") verify_binary("puppet")
# Make sure the temporary directory is properly set up
@machine.communicate.tap do |comm|
comm.sudo("mkdir -p #{config.temp_dir}")
comm.sudo("chmod 0777 #{config.temp_dir}")
end
# Upload Hiera configuration if we have it
@hiera_config_path = nil
if config.hiera_config_path
local_hiera_path = File.expand_path(config.hiera_config_path, @machine.env.root_path)
@hiera_config_path = File.join(config.temp_dir, "hiera.yaml")
@machine.communicate.upload(local_hiera_path, @hiera_config_path)
end
run_puppet_apply run_puppet_apply
end end
def manifests_guest_path def manifests_guest_path
File.join(config.pp_path, "manifests") File.join(config.temp_dir, "manifests")
end end
def verify_binary(binary) def verify_binary(binary)
@ -78,6 +93,11 @@ module VagrantPlugins
options << "--modulepath '#{module_paths.join(':')}'" options << "--modulepath '#{module_paths.join(':')}'"
end end
if @hiera_config_path
options << "--hiera_config=#{@hiera_config_path}"
end
options << "--detailed-exitcodes"
options << @manifest_file options << @manifest_file
options = options.join(" ") options = options.join(" ")
@ -92,10 +112,13 @@ module VagrantPlugins
facter = "#{facts.join(" ")} " facter = "#{facts.join(" ")} "
end end
command = "cd #{manifests_guest_path} && #{facter}puppet apply #{options} --detailed-exitcodes || [ $? -eq 2 ]" command = "#{facter}puppet apply #{options} || [ $? -eq 2 ]"
if config.working_directory
command = "cd #{config.working_directory} && #{command}"
end
@machine.env.ui.info I18n.t("vagrant.provisioners.puppet.running_puppet", @machine.env.ui.info I18n.t("vagrant.provisioners.puppet.running_puppet",
:manifest => @manifest_file) :manifest => config.manifest_file)
@machine.communicate.sudo(command) do |type, data| @machine.communicate.sudo(command) do |type, data|
data.chomp! data.chomp!

View File

@ -48,13 +48,20 @@ module VagrantPlugins
# on the remote server. This method will properly clean up the # on the remote server. This method will properly clean up the
# script file if needed. # script file if needed.
def with_script_file def with_script_file
script = nil
if config.path if config.path
# Just yield the path to that file... # Just yield the path to that file...
root_path = @machine.env.root_path root_path = @machine.env.root_path
yield Pathname.new(config.path).expand_path(root_path) script = Pathname.new(config.path).expand_path(root_path).read
return else
# The script is just the inline code...
script = config.inline
end end
# Replace Windows line endings with Unix ones
script.gsub!(/\r\n?$/, "\n")
# Otherwise we have an inline script, we need to Tempfile it, # Otherwise we have an inline script, we need to Tempfile it,
# and handle it specially... # and handle it specially...
file = Tempfile.new('vagrant-shell') file = Tempfile.new('vagrant-shell')
@ -65,7 +72,7 @@ module VagrantPlugins
file.binmode file.binmode
begin begin
file.write(config.inline) file.write(script)
file.fsync file.fsync
file.close file.close
yield file.path yield file.path

View File

@ -25,6 +25,8 @@ en:
CFEngine running in "single run" mode. Will execute one file. CFEngine running in "single run" mode. Will execute one file.
cfengine_single_run_execute: |- cfengine_single_run_execute: |-
Executing run file for CFEngine... Executing run file for CFEngine...
chef_run_list_empty: |-
Warning: Chef solo run list is empty. This may not be what you want.
cfengine_config: cfengine_config:
classes_array: |- classes_array: |-
@ -118,6 +120,11 @@ en:
Any errors that occurred are shown below. Any errors that occurred are shown below.
%{message} %{message}
box_config_changing_box: |-
While loading the Vagrantfile, the provider override specified
a new box. This box, in turn, specified a different box. This isn't
allowed, as it could lead to infinite recursion of Vagrant configuration
loading. Please fix this.
box_metadata_file_not_found: |- box_metadata_file_not_found: |-
The "metadata.json" file for the box '%{name}' was not found. The "metadata.json" file for the box '%{name}' was not found.
Boxes require this file in order for Vagrant to determine the Boxes require this file in order for Vagrant to determine the
@ -521,8 +528,8 @@ en:
%{supported_versions} %{supported_versions}
virtualbox_kernel_module_not_loaded: |- virtualbox_kernel_module_not_loaded: |-
VirtualBox is complaining that the kernel module is not loaded. Please VirtualBox is complaining that the kernel module is not loaded. Please
run `VBoxManage --version` to see the error message which should contain run `VBoxManage --version` or open the VirtualBox GUI to see the error
instructions on how to fix this error. message which should contain instructions on how to fix this error.
virtualbox_install_incomplete: |- virtualbox_install_incomplete: |-
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
@ -569,7 +576,6 @@ en:
cookbooks_path_empty: "Must specify a cookbooks path for chef solo." cookbooks_path_empty: "Must specify a cookbooks path for chef solo."
cookbooks_path_missing: |- cookbooks_path_missing: |-
Cookbook path doesn't exist: %{path} Cookbook path doesn't exist: %{path}
run_list_empty: "Run list must not be empty."
server_url_empty: "Chef server URL must be populated." server_url_empty: "Chef server URL must be populated."
validation_key_path: "Validation key path must be valid path to your chef server validation key." validation_key_path: "Validation key path must be valid path to your chef server validation key."
loader: loader:

View File

@ -3,7 +3,9 @@ node_name "<%= node_name %>"
<% end %> <% end %>
file_cache_path "<%= provisioning_path %>" file_cache_path "<%= provisioning_path %>"
cookbook_path <%= cookbooks_path.inspect %> cookbook_path <%= cookbooks_path.inspect %>
<% if roles_path %>
role_path <%= roles_path.inspect %> role_path <%= roles_path.inspect %>
<% end %>
log_level <%= log_level.inspect %> log_level <%= log_level.inspect %>
encrypted_data_bag_secret "<%= encrypted_data_bag_secret %>" encrypted_data_bag_secret "<%= encrypted_data_bag_secret %>"