module Vagrant module Notify class Plugin < Vagrant.plugin('2') name 'vagrant notify' description 'Forwards notify-send from guest to host machine' action_hook 'notify-provisioning-status', :provisioner_run do |hook| require_relative './action' hook.before :run_provisioner, Vagrant::Notify::Action::NotifyProvisioningStatus end # TODO: This should be generic, we don't want to hard code every single # possible provider action class that Vagrant might have start_server_hook = lambda do |hook| require_relative './action' hook.after VagrantPlugins::ProviderVirtualBox::Action::WaitForCommunicator, Vagrant::Notify::Action.action_start_server if defined?(Vagrant::LXC) require 'vagrant-lxc/action' hook.after Vagrant::LXC::Action::Boot, Vagrant::Notify::Action.action_start_server end end action_hook 'start-server-after-boot-on-machine-up', :machine_action_up, &start_server_hook action_hook 'start-server-after-boot-on-machine-reload', :machine_action_reload, &start_server_hook action_hook 'start-server-after-resume-on-machine', :machine_action_resume, &start_server_hook share_folder_hook = lambda do |hook| require_relative './action' hook.after Vagrant::Action::Builtin::Provision, Vagrant::Notify::Action::SetSharedFolder end action_hook 'set-shared-folder-and-start-notify-server-on-machine-up', :machine_action_up, &share_folder_hook action_hook 'set-shared-folder-and-start-notify-server-on-machine-reload', :machine_action_reload, &share_folder_hook action_hook 'stop-server-after-halt', :machine_action_halt do |hook| require_relative './action' hook.before Vagrant::Action::Builtin::GracefulHalt, Vagrant::Notify::Action.action_stop_server end # TODO: This should be generic, we don't want to hard code every single # possible provider action class that Vagrant might have action_hook 'stop-server-before-destroy', :machine_action_destroy do |hook| require_relative './action' hook.before VagrantPlugins::ProviderVirtualBox::Action::Destroy, Vagrant::Notify::Action.action_stop_server if defined?(Vagrant::LXC) require 'vagrant-lxc/action' hook.before Vagrant::LXC::Action::Destroy, Vagrant::Notify::Action.action_stop_server end end action_hook 'stop-server-after-suspend', :machine_action_suspend do |hook| require_relative './action' hook.before VagrantPlugins::ProviderVirtualBox::Action::Suspend, Vagrant::Notify::Action.action_stop_server end command(:notify) do require_relative 'command' Vagrant::Notify::Command end config(:notify) do require_relative 'config' Vagrant::Notify::Config end end end # Keep an eye on https://github.com/mitchellh/vagrant/wiki/Available-Vagrant-Plugins#wiki-providers # for more. CLOUD_PROVIDERS = %w( aws cloudstack digital_ocean hp joyent openstack rackspace softlayer proxmox managed azure brightbox cloudstack vcloud vsphere ) end