3 # Cookbook Name:: kibana
6 # Copyright 2015, OpenStreetMap Foundation
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
12 # http://www.apache.org/licenses/LICENSE-2.0
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
23 include_recipe "apache::ssl"
25 apache_module "proxy_http"
27 version = node[:kibana][:version]
29 remote_file "#{Chef::Config[:file_cache_path]}/kibana-#{version}.tar.gz" do
30 source "https://download.elastic.co/kibana/kibana/kibana-4.1.1-linux-x64.tar.gz"
31 not_if { File.exist?("/opt/kibana-#{version}/bin/kibana") }
34 directory "/opt/kibana-#{version}" do
40 execute "unzip-kibana-#{version}" do
41 command "tar --gunzip --extract --strip-components=1 --file=#{Chef::Config[:file_cache_path]}/kibana-#{version}.tar.gz"
42 cwd "/opt/kibana-#{version}"
45 not_if { File.exist?("/opt/kibana-#{version}/bin/kibana") }
48 directory "/etc/kibana" do
54 directory "/var/run/kibana" do
60 directory "/var/log/kibana" do
66 node[:kibana][:sites].each do |name, details|
67 file "/etc/kibana/#{name}.yml" do
68 content YAML.dump(YAML.load(File.read("/opt/kibana-#{version}/config/kibana.yml")).merge(
69 "port" => details[:port],
70 "host" => "127.0.0.1",
71 "elasticsearch_url" => details[:elasticsearch_url],
72 "pid_file" => "/var/run/kibana/#{name}.pid",
73 "log_file" => "/var/log/kibana/#{name}.log"
78 notifies :restart, "service[kibana-#{name}]"
81 template "/etc/init/kibana-#{name}.conf" do
82 source "kibana.conf.erb"
86 variables :config => "/etc/kibana/#{name}.yml"
87 notifies :restart, "service[kibana-#{name}]"
90 service "kibana-#{name}" do
91 action [:enable, :start]
92 supports :status => true, :restart => true, :reload => false
95 apache_site details[:site] do
97 variables details.merge(:passwd => "/etc/kibana/#{name}.passwd")