Sha256: 9fe07a394f43da948932119396f58a93e25ae45db559b456328966728843df4c

Contents?: true

Size: 1.75 KB

Versions: 2

Compression:

Stored size: 1.75 KB

Contents

module Berkshelf
  module Vagrant
    # @author Jamie Winsor <reset@riotgames.com>
    TESTED_CONSTRAINT="<= 1.2.1"
    class Plugin < ::Vagrant.plugin("2")
      class << self
        def provision(hook)
          hook.after(::Vagrant::Action::Builtin::Provision, Berkshelf::Vagrant::Action.upload)
          hook.after(::Vagrant::Action::Builtin::Provision, Berkshelf::Vagrant::Action.install)

          if ::VagrantPlugins.const_defined?(:AWS)
            hook.after(::VagrantPlugins::AWS::Action::TimedProvision, Berkshelf::Vagrant::Action.upload)
            hook.after(::VagrantPlugins::AWS::Action::TimedProvision, Berkshelf::Vagrant::Action.install)
          end

          hook.before(::Vagrant::Action::Builtin::ConfigValidate, Berkshelf::Vagrant::Action.setup)
        end
      end

      name "berkshelf"
      description <<-DESC
      Automatically make available cookbooks to virtual machines provisioned by Chef Solo
      or Chef Client using Berkshelf.
      DESC

      action_hook(:berkshelf_provision, :machine_action_up, &method(:provision))
      action_hook(:berkshelf_provision, :machine_action_reload, &method(:provision))
      action_hook(:berkshelf_provision, :machine_action_provision, &method(:provision))

      action_hook(:berkshelf_cleanup, :machine_action_destroy) do |hook|
        # @todo this should be appended to the middleware stack instead of hooked in after the
        #   Virtualbox specific destroy step but there is a bug in Vagrant (1.1.0) which
        #   causes appended middleware to run multiple times.
        hook.after(VagrantPlugins::ProviderVirtualBox::Action::DestroyUnusedNetworkInterfaces, Berkshelf::Vagrant::Action.clean)
      end

      config(:berkshelf) do
        Berkshelf::Vagrant::Config
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vagrant-berkshelf-1.3.2 lib/berkshelf/vagrant/plugin.rb
vagrant-berkshelf-1.2.0 lib/berkshelf/vagrant/plugin.rb