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 systemd_service "kibana@" do
67 description "Kibana server"
68 after "network.target"
70 exec_start "/opt/kibana-#{version}/bin/kibana -c /etc/kibana/%i.yml"
74 node[:kibana][:sites].each do |name, details|
75 file "/etc/kibana/#{name}.yml" do
76 content YAML.dump(YAML.safe_load(File.read("/opt/kibana-#{version}/config/kibana.yml")).merge(
77 "port" => details[:port],
78 "host" => "127.0.0.1",
79 "elasticsearch_url" => details[:elasticsearch_url],
80 "pid_file" => "/var/run/kibana/#{name}.pid",
81 "log_file" => "/var/log/kibana/#{name}.log"
86 notifies :restart, "service[kibana@#{name}]"
89 service "kibana@#{name}" do
90 action [:enable, :start]
91 supports :status => true, :restart => true, :reload => false
94 apache_site details[:site] do
96 variables details.merge(:passwd => "/etc/kibana/#{name}.passwd")