Sha256: e665d7e45292bab8ab9729e0bc46c86b1665393140dc349e15360e28388fa5de

Contents?: true

Size: 1.59 KB

Versions: 1

Compression:

Stored size: 1.59 KB

Contents

require_relative "BetterHosts"
require_relative "Action/BaseAction"
require_relative "Action/UpdateHosts"
require_relative "Action/RemoveHosts"

module VagrantPlugins
  module BetterHosts
    # Various Vagrant hooks
    class Plugin < Vagrant.plugin('2')
      name 'BetterHosts'
      description <<-DESC
        This plugin manages the /etc/hosts file for the host machine. An entry is
        created for the hostname attribute in the vm.config.
      DESC

      config(:betterhosts) do
        require_relative 'config'
        Config
      end

      action_hook(:betterhosts, :machine_action_up) do |hook|
        hook.append(Action::UpdateHosts)
      end

      action_hook(:betterhosts, :machine_action_boot) do |hook|
        hook.append(Action::UpdateHosts)
      end

      action_hook(:betterhosts, :machine_action_provision) do |hook|
        hook.before(Vagrant::Action::Builtin::Provision, Action::UpdateHosts)
      end

      action_hook(:betterhosts, :machine_action_halt) do |hook|
        hook.prepend(Action::RemoveHosts)
      end

      action_hook(:betterhosts, :machine_action_suspend) do |hook|
        hook.prepend(Action::RemoveHosts)
      end

      action_hook(:betterhosts, :machine_action_destroy) do |hook|
        hook.prepend(Action::RemoveHosts)
      end

      action_hook(:betterhosts, :machine_action_reload) do |hook|
        hook.prepend(Action::RemoveHosts)
        hook.append(Action::UpdateHosts)
      end

      action_hook(:betterhosts, :machine_action_resume) do |hook|
        hook.prepend(Action::RemoveHosts)
        hook.append(Action::UpdateHosts)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-betterhosts-1.1.6 lib/vagrant-betterhosts/plugin.rb