Skip to content

Commit

Permalink
Added plugin feature anuriq#5
Browse files Browse the repository at this point in the history
  • Loading branch information
Vrinceanu Catalin committed Feb 8, 2018
1 parent 070b634 commit c926357
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 1.4.0 (8 Feb, 2018)
- Add plugin resource;

## 1.3.2 (8 Feb, 2018)
- Add version 5.6.7 of Kibana;

Expand Down
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
license 'Apache-2.0'
description 'Installs/Configures kibana 5'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '1.3.2'
version '1.4.0'
issues_url 'https://github.com/anuriq/chef-kibana5/issues' if respond_to?(:issues_url)
source_url 'https://github.com/anuriq/chef-kibana5' if respond_to?(:source_url)

Expand Down
57 changes: 57 additions & 0 deletions resources/plugins.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#
# Cookbook:: kibana5
# Resource:: kibana5_plugins
#
# Copyright:: 2017, Parallels International GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

resource_name :kibana5_plugins

property :name, String, name_property: true
property :install_type, String, default: 'native'
property :url, String, default: ''

default_action :install

action :install do

service 'kibana' do
action :nothing
end

case new_resource.install_type
when 'native'
ex = execute "Install #{new_resource.name} Kibana plugin" do
command "./kibana-plugin install #{new_resource.name}"
user node['kibana5']['service_user']
group node['kibana5']['service_group']
cwd "/opt/kibana/#{node['kibana5']['version']}/current/bin"
notifies :restart, "service[kibana]"
not_if "/opt/kibana/#{node['kibana5']['version']}/current/bin/kibana-plugin list | grep #{new_resource.name}"
end
new_resource.updated_by_last_action(ex.updated_by_last_action?)
when 'url'
ex = execute "Install #{new_resource.name} Kibana plugin" do
command "./kibana-plugin install #{new_resource.url}"
user node['kibana5']['service_user']
group node['kibana5']['service_group']
cwd "/opt/kibana/#{node['kibana5']['version']}/current/bin"
notifies :restart, "service[kibana]"
not_if "/opt/kibana/#{node['kibana5']['version']}/current/bin/kibana-plugin list | grep #{new_resource.name}"
end
new_resource.updated_by_last_action(ex.updated_by_last_action?)
else
Chef::Application.fatal!("Unknown install type: #{new_resource.install_type}")
end
end

0 comments on commit c926357

Please sign in to comment.