Extract plugin hooks and capabilities out to separate files
This commit is contained in:
parent
2dad88e275
commit
b8fcfb950f
3 changed files with 89 additions and 76 deletions
59
lib/vagrant-cachier/capabilities.rb
Normal file
59
lib/vagrant-cachier/capabilities.rb
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
module VagrantPlugins
|
||||||
|
module Cachier
|
||||||
|
class Plugin < Vagrant.plugin('2')
|
||||||
|
guest_capability 'linux', 'gemdir' do
|
||||||
|
require_relative 'cap/linux/gemdir'
|
||||||
|
Cap::Linux::Gemdir
|
||||||
|
end
|
||||||
|
|
||||||
|
guest_capability 'linux', 'rvm_path' do
|
||||||
|
require_relative 'cap/linux/rvm_path'
|
||||||
|
Cap::Linux::RvmPath
|
||||||
|
end
|
||||||
|
|
||||||
|
guest_capability 'linux', 'composer_path' do
|
||||||
|
require_relative 'cap/linux/composer_path'
|
||||||
|
Cap::Linux::ComposerPath
|
||||||
|
end
|
||||||
|
|
||||||
|
guest_capability 'linux', 'chef_file_cache_path' do
|
||||||
|
require_relative 'cap/linux/chef_file_cache_path'
|
||||||
|
Cap::Linux::ChefFileCachePath
|
||||||
|
end
|
||||||
|
|
||||||
|
guest_capability 'linux', 'npm_cache_dir' do
|
||||||
|
require_relative 'cap/linux/npm_cache_dir'
|
||||||
|
Cap::Linux::NpmCacheDir
|
||||||
|
end
|
||||||
|
|
||||||
|
guest_capability 'debian', 'apt_cache_dir' do
|
||||||
|
require_relative 'cap/debian/apt_cache_dir'
|
||||||
|
Cap::Debian::AptCacheDir
|
||||||
|
end
|
||||||
|
|
||||||
|
guest_capability 'debian', 'apt_cacher_dir' do
|
||||||
|
require_relative 'cap/debian/apt_cacher_dir'
|
||||||
|
Cap::Debian::AptCacherDir
|
||||||
|
end
|
||||||
|
|
||||||
|
guest_capability 'redhat', 'yum_cache_dir' do
|
||||||
|
require_relative 'cap/redhat/yum_cache_dir'
|
||||||
|
Cap::RedHat::YumCacheDir
|
||||||
|
end
|
||||||
|
|
||||||
|
guest_capability 'suse', 'yum_cache_dir' do
|
||||||
|
# Disable Yum on suse guests
|
||||||
|
end
|
||||||
|
|
||||||
|
guest_capability 'arch', 'pacman_cache_dir' do
|
||||||
|
require_relative 'cap/arch/pacman_cache_dir'
|
||||||
|
Cap::Arch::PacmanCacheDir
|
||||||
|
end
|
||||||
|
|
||||||
|
guest_capability 'suse', 'zypper_cache_dir' do
|
||||||
|
require_relative 'cap/suse/zypper_cache_dir'
|
||||||
|
Cap::SuSE::ZypperCacheDir
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
27
lib/vagrant-cachier/hooks.rb
Normal file
27
lib/vagrant-cachier/hooks.rb
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
module VagrantPlugins
|
||||||
|
module Cachier
|
||||||
|
class Plugin < Vagrant.plugin('2')
|
||||||
|
action_hook VagrantPlugins::Cachier::Plugin::ALL_ACTIONS do |hook|
|
||||||
|
require_relative 'action/configure_bucket_root'
|
||||||
|
require_relative 'action/install_buckets'
|
||||||
|
|
||||||
|
hook.before Vagrant::Action::Builtin::Provision, Action::ConfigureBucketRoot
|
||||||
|
# This will do the initial buckets installation
|
||||||
|
hook.after Vagrant::Action::Builtin::Provision, Action::InstallBuckets
|
||||||
|
end
|
||||||
|
|
||||||
|
# This ensure buckets are reconfigured after provisioners runs
|
||||||
|
action_hook :provisioner_run do |hook|
|
||||||
|
require_relative 'action/install_buckets'
|
||||||
|
hook.after :run_provisioner, Action::InstallBuckets
|
||||||
|
end
|
||||||
|
|
||||||
|
clean_action_hook = lambda do |hook|
|
||||||
|
require_relative 'action/clean'
|
||||||
|
hook.before Vagrant::Action::Builtin::GracefulHalt, Action::Clean
|
||||||
|
end
|
||||||
|
action_hook 'remove-guest-symlinks-on-halt', :machine_action_halt, &clean_action_hook
|
||||||
|
action_hook 'remove-guest-symlinks-on-package', :machine_action_package, &clean_action_hook
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -16,82 +16,9 @@ module VagrantPlugins
|
||||||
require_relative "config"
|
require_relative "config"
|
||||||
Config
|
Config
|
||||||
end
|
end
|
||||||
|
end
|
||||||
guest_capability 'linux', 'gemdir' do
|
end
|
||||||
require_relative 'cap/linux/gemdir'
|
|
||||||
Cap::Linux::Gemdir
|
|
||||||
end
|
end
|
||||||
|
|
||||||
guest_capability 'linux', 'rvm_path' do
|
require_relative "hooks"
|
||||||
require_relative 'cap/linux/rvm_path'
|
require_relative "capabilities"
|
||||||
Cap::Linux::RvmPath
|
|
||||||
end
|
|
||||||
|
|
||||||
guest_capability 'linux', 'composer_path' do
|
|
||||||
require_relative 'cap/linux/composer_path'
|
|
||||||
Cap::Linux::ComposerPath
|
|
||||||
end
|
|
||||||
|
|
||||||
guest_capability 'linux', 'chef_file_cache_path' do
|
|
||||||
require_relative 'cap/linux/chef_file_cache_path'
|
|
||||||
Cap::Linux::ChefFileCachePath
|
|
||||||
end
|
|
||||||
|
|
||||||
guest_capability 'linux', 'npm_cache_dir' do
|
|
||||||
require_relative 'cap/linux/npm_cache_dir'
|
|
||||||
Cap::Linux::NpmCacheDir
|
|
||||||
end
|
|
||||||
|
|
||||||
guest_capability 'debian', 'apt_cache_dir' do
|
|
||||||
require_relative 'cap/debian/apt_cache_dir'
|
|
||||||
Cap::Debian::AptCacheDir
|
|
||||||
end
|
|
||||||
|
|
||||||
guest_capability 'debian', 'apt_cacher_dir' do
|
|
||||||
require_relative 'cap/debian/apt_cacher_dir'
|
|
||||||
Cap::Debian::AptCacherDir
|
|
||||||
end
|
|
||||||
|
|
||||||
guest_capability 'redhat', 'yum_cache_dir' do
|
|
||||||
require_relative 'cap/redhat/yum_cache_dir'
|
|
||||||
Cap::RedHat::YumCacheDir
|
|
||||||
end
|
|
||||||
|
|
||||||
guest_capability 'suse', 'yum_cache_dir' do
|
|
||||||
# Disable Yum on suse guests
|
|
||||||
end
|
|
||||||
|
|
||||||
guest_capability 'arch', 'pacman_cache_dir' do
|
|
||||||
require_relative 'cap/arch/pacman_cache_dir'
|
|
||||||
Cap::Arch::PacmanCacheDir
|
|
||||||
end
|
|
||||||
|
|
||||||
guest_capability 'suse', 'zypper_cache_dir' do
|
|
||||||
require_relative 'cap/suse/zypper_cache_dir'
|
|
||||||
Cap::SuSE::ZypperCacheDir
|
|
||||||
end
|
|
||||||
|
|
||||||
clean_action_hook = lambda do |hook|
|
|
||||||
require_relative 'action/clean'
|
|
||||||
hook.before Vagrant::Action::Builtin::GracefulHalt, Action::Clean
|
|
||||||
end
|
|
||||||
action_hook 'remove-guest-symlinks-on-halt', :machine_action_halt, &clean_action_hook
|
|
||||||
action_hook 'remove-guest-symlinks-on-package', :machine_action_package, &clean_action_hook
|
|
||||||
|
|
||||||
action_hook ALL_ACTIONS do |hook|
|
|
||||||
require_relative 'action/configure_bucket_root'
|
|
||||||
require_relative 'action/install_buckets'
|
|
||||||
|
|
||||||
hook.before Vagrant::Action::Builtin::Provision, Action::ConfigureBucketRoot
|
|
||||||
# This will do the initial buckets installation
|
|
||||||
hook.after Vagrant::Action::Builtin::Provision, Action::InstallBuckets
|
|
||||||
end
|
|
||||||
|
|
||||||
# This ensure buckets are reconfigured after provisioners runs
|
|
||||||
action_hook :provisioner_run do |hook|
|
|
||||||
require_relative 'action/install_buckets'
|
|
||||||
hook.after :run_provisioner, Action::InstallBuckets
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
Loading…
Reference in a new issue