This repository has been archived by the owner on Dec 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 143
Add plugin provider #115
Closed
Closed
Add plugin provider #115
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2a754eb
Initial plugin provider support, adapted from logstash_plugin resource
davidski 31368f6
Warn on removal action. Minimal test fixture scaffolding
davidski 1949576
Update ruby to current ChefDK version for travis builds
davidski 7ab358e
Rubocop linting
davidski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
language: ruby | ||
rvm: | ||
- 1.9.3 | ||
- 2.1.6 | ||
env: | ||
- USE_SYSTEM_GECODE=1 | ||
before_install: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,3 +90,7 @@ Vagrantfile | |
# Travis # | ||
########## | ||
.travis.yml | ||
|
||
# Kitchen # | ||
########### | ||
.kitchen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# Encoding: utf-8 | ||
# Cookbook Name:: kibana | ||
# Resrouce/Provider:: plugins | ||
# Author:: John E. Vincent | ||
# Author:: Paul Czarkowski | ||
# License:: Apache 2.0 | ||
# | ||
# Copyright 2014, John E. Vincent | ||
|
||
class Chef | ||
class Resource::KibanaPlugin < Chef::Resource::LWRPBase | ||
provides :kibana_plugin | ||
actions(:create, :remove) | ||
default_action(:create) | ||
|
||
attribute(:name, kind_of: String, name_attribute: true) | ||
attribute(:base_directory, kind_of: String, default: lazy { node['kibana']['version'] }) | ||
attribute(:version, kind_of: String, default: lazy { node['kibana']['plugins_version'] }) | ||
attribute(:checksum, kind_of: String, default: lazy { node['kibana']['plugins_checksum'] }) | ||
attribute(:source_url, kind_of: String, default: lazy { node['kibana']['plugins_source_url'] }) | ||
attribute(:user, kind_of: String, default: lazy { node['kibana']['user'] }) | ||
attribute(:group, kind_of: String, default: lazy { node['kibana']['group'] }) | ||
attribute(:install_dir, kind_of: String, default: lazy { node['kibana']['install_dir'] }) | ||
attribute(:install_type, kind_of: String, default: lazy { node['kibana']['plugins_install_type'] }) | ||
attribute(:install_check, kind_of: String, default: lazy { node['kibana']['plugins_check_if_installed'] }) | ||
end | ||
|
||
class Provider::KibanaPlugin < Chef::Provider::LWRPBase # ~FC057, ~FC058 | ||
provides :kibana_plugin | ||
include Chef::DSL::Recipe # required under chef 12, see poise/poise #8 | ||
|
||
action :create do | ||
kb_args = kibana_resources | ||
|
||
case kb_args[:install_type] | ||
when 'native' | ||
ex = execute "bin/kibana plugin --install #{kb_args[:name]}" do | ||
command "bin/kibana plugin --install #{kb_args[:name]}" | ||
user kb_args[:user] | ||
group kb_args[:group] | ||
cwd "#{kb_args[:install_dir]}/kibana-#{kb_args[:base_directory]}" | ||
notifies :restart, 'service[kibana]' | ||
timeout 600 | ||
# this is a temp workaround to make the plugin command idempotent. | ||
not_if { ::File.exist?("#kb_args[:install_dir]}/#{kb_args[:install_check]}") } | ||
end | ||
new_resource.updated_by_last_action(ex.updated_by_last_action?) | ||
when 'tarball' | ||
@run_context.include_recipe 'ark::default' | ||
arkit = ark "#{kb_instance}_contrib" do | ||
name kb_args[:kb_instance] | ||
url kb_args[:kb_source_url] | ||
checksum kb_args[:kb_checksum] | ||
owner kb_args[:kb_user] | ||
group kb_args[:kb_group] | ||
mode 0755 | ||
version kb_args[:kb_version] | ||
path kb_args[:kb_basedir] | ||
action [:put] | ||
notifies :restart, 'service[kibana]' | ||
# this is a temp workaround to ensure idempotent. | ||
not_if { ::File.exist?("#{kb_args[:install_dir]}/#{kb_args[:install_check]}") } | ||
end | ||
new_resource.updated_by_last_action(arkit.updated_by_last_action?) | ||
else | ||
Chef::Application.fatal!("Unknown install type: #{kb_args[:install_type]}") | ||
end # case | ||
end # action | ||
|
||
action :remove do | ||
Chef::Log.warn('Kibana plugin removal is not supported!') | ||
end # action | ||
|
||
private | ||
|
||
def kibana_resources | ||
kb = { | ||
name: new_resource.name, | ||
user: new_resource.user, | ||
group: new_resource.group, | ||
install_dir: new_resource.install_dir, | ||
install_type: new_resource.install_type, | ||
base_directory: new_resource.base_directory, | ||
version: new_resource.version, | ||
checksum: new_resource.checksum | ||
} | ||
kb | ||
end # def | ||
end # end class | ||
end # end classes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should just be 'timelion' since that is the plugin name and directory name, right?
If we had a resource with the actual plugin name, we might be able to better finagle an uninstall action using that name and looking for a directory by the same name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @davidski -- any thoughts on having the resource name be the plugin name?