5 # Copyright:: 2015, OpenStreetMap Foundation
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # https://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
22 include_recipe "accounts"
23 include_recipe "apache"
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-#{version}-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"
75 no_new_privileges true
79 node[:kibana][:sites].each do |name, details|
80 file "/etc/kibana/#{name}.yml" do
81 content YAML.dump(YAML.safe_load(File.read("/opt/kibana-#{version}/config/kibana.yml")).merge(
82 "port" => details[:port],
83 "host" => "127.0.0.1",
84 "elasticsearch_url" => details[:elasticsearch_url],
85 "pid_file" => "/var/run/kibana/#{name}.pid",
86 "log_file" => "/var/log/kibana/#{name}.log"
91 notifies :restart, "service[kibana@#{name}]"
94 service "kibana@#{name}" do
95 action [:enable, :start]
96 supports :status => true, :restart => true, :reload => false
97 subscribes :restart, "systemd_service[kibana@]"
100 ssl_certificate details[:site] do
101 domains details[:site]
102 notifies :reload, "service[apache2]"
105 apache_site details[:site] do
106 template "apache.erb"
107 variables details.merge(:passwd => "/etc/kibana/#{name}.passwd")