Added rake tasks puppet:plugin:install and puppet:plugin:uninstall. These operate on a plug-in that already exists in the vendor/plugins directory, enabling and disabling its functionality and running the appropriate database migrations.
Paired-with: Jesse Wolfe <[email protected]> Signed-off-by: Paul Berry <[email protected]> --- Local-branch: maint/next/create_module_install_tasks .gitignore | 2 ++ lib/tasks/plugins.rake | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 0 deletions(-) create mode 100644 lib/tasks/plugins.rake diff --git a/.gitignore b/.gitignore index d389715..b05289f 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,5 @@ results/* certs vendor/plugins/puppet_* db/schema.rb +db/migrate/*_plugin__*.rb +config/installed_plugins diff --git a/lib/tasks/plugins.rake b/lib/tasks/plugins.rake new file mode 100644 index 0000000..06c1803 --- /dev/null +++ b/lib/tasks/plugins.rake @@ -0,0 +1,43 @@ +namespace :puppet do + namespace :plugin do + desc "Copy the migrations from a Puppet plugin into db/migrate" + task :copy_migration do + unless plugin_name = ENV['PLUGIN'] + raise "Must specify a plugin name using PLUGIN=..." + end + plugin_dir = File.join(Dir.pwd, 'vendor', 'plugins', plugin_name) + unless File.exists?(plugin_dir) + raise "Plugin #{plugin_name} not found in vendor/plugins." + end + Dir.glob(File.join(plugin_dir, 'db', 'migrate', '*.rb')) do |source_file| + if File.basename(source_file) =~ /^([0-9]+)_(.*)$/ + timestamp, migration_name = $1, $2 + destination_file = "db/migrate/#{timestamp}_plugin__#{plugin_name}__#{migration_name}" + FileUtils.cp source_file, destination_file + end + end + end + + desc "Install a Dashboard plug-in" + task :install => [:copy_migration, "db:migrate", :create_installed_semaphore] + + desc "Create the semaphore file to indicate that a plugin is installed" + task :create_installed_semaphore do + unless plugin_name = ENV['PLUGIN'] + raise "Must specify a plugin name using PLUGIN=..." + end + semaphore_file_name = "config/installed_plugins/#{plugin_name}" + FileUtils.mkdir_p('config/installed_plugins') + File.open(semaphore_file_name, 'w') do |file_handle| end + end + + desc "Uninstall a Dashboard plug-in" + task :uninstall do + unless plugin_name = ENV['PLUGIN'] + raise "Must specify a plugin name using PLUGIN=..." + end + semaphore_file_name = "config/installed_plugins/#{plugin_name}" + FileUtils.rm semaphore_file_name + end + end +end -- 1.7.2 -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
