Skip to content
Permalink
Browse files

feat: prepare initial working cookbook

Closes #2
  • Loading branch information...
rchukh committed Oct 11, 2014
1 parent 5b42b7b commit a91b26d2d6c08115196a38b65b117723c59da946
Showing with 374 additions and 16 deletions.
  1. +5 −6 .kitchen.yml
  2. +1 −1 .rubocop.yml
  3. +4 −0 Berksfile
  4. +2 −0 README.md
  5. +42 −5 attributes/default.rb
  6. +18 −2 metadata.rb
  7. +14 −0 recipes/_preconditions.rb
  8. +92 −2 recipes/default.rb
  9. +8 −0 recipes/dependencies.rb
  10. +168 −0 templates/default/kibana.init.erb
  11. +20 −0 templates/default/kibana.yml.erb
@@ -13,7 +13,7 @@ driver_config:
generic_buckets:
- ['chef', '/var/chef/cache']
network:
- ["forwarded_port", {guest: 80, host: 8080}]
# Kibana (should be the same as used for Kibana, defaults to 5601)
- ["forwarded_port", {guest: 5601, host: 8081}]
customize:
memory: 512
@@ -31,12 +31,11 @@ suites:
- name: default
run_list:
- recipe[java::default]
- recipe[elasticsearch::default]
- recipe[chamber-kibana::default]
attributes:
java:
jdk_version: '7'
kibana:
file:
url: 'https://download.elasticsearch.org/kibana/kibana/kibana-4.0.0-BETA1.1.tar.gz'
version: '4.0.0-BETA1.1'
checksum: '0010e467d598b67ba442c2edc5c6df196e8734f826044a58e0da3490a1bb587a'
elasticsearch:
version: '1.4.0.Beta1'
allocated_memory: '128m'
@@ -4,4 +4,4 @@ AllCops:
- metadata.rb

LineLength:
Max: 120
Max: 160
@@ -3,3 +3,7 @@ source "https://supermarket.getchef.com"
metadata

cookbook 'chef-sugar'
cookbook 'ark', '~> 0.9'
cookbook 'java', '~> 1.28.0'
cookbook 'elasticsearch', '~> 0.3.10'
cookbook 'logstash', '~> 0.9.2'
@@ -2,3 +2,5 @@ Chef cookbook for Kibana 4
==============

[![Build Status](https://travis-ci.org/rchukh/chamber-kibana.svg)](https://travis-ci.org/rchukh/chamber-kibana)

Heavily based on [ElasticSearch cookbook](https://github.com/elasticsearch/cookbook-elasticsearch/).
@@ -1,6 +1,43 @@
# Values to use for file method of installation
default['kibana']['file']['type'] = 'tar.gz' # zip | tar.gz
default['kibana']['file']['url'] = 'https://download.elasticsearch.org/kibana/kibana/kibana-4.0.0-BETA1.1.tar.gz'
default['kibana']['file']['version'] = '4.0.0-BETA1.1'
# === VERSION AND LOCATION
#
default['kibana']['version'] = '4.0.0-BETA1.1'
# sha256 ( shasum -a 256 FILENAME )
default['kibana']['file']['checksum'] = '0010e467d598b67ba442c2edc5c6df196e8734f826044a58e0da3490a1bb587a'
default['kibana']['checksum'] = '0010e467d598b67ba442c2edc5c6df196e8734f826044a58e0da3490a1bb587a'
default['kibana']['host'] = 'http://download.elasticsearch.org'
default['kibana']['repository'] = 'kibana/kibana'
default['kibana']['filename'] = "kibana-#{node['kibana']['version']}.tar.gz"
default['kibana']['download_url'] = [node['kibana']['host'], node['kibana']['repository'], node['kibana']['filename']].join('/')

# === NAMING
#
default['kibana']['node']['name'] = node.name

# === USER & PATHS
#
default['kibana']['dir'] = '/usr/local'
default['kibana']['bindir'] = '/usr/local/bin'
default['kibana']['user'] = 'kibana'
default['kibana']['uid'] = nil
default['kibana']['gid'] = nil

default['kibana']['path']['conf'] = '/usr/local/etc/kibana'
default['kibana']['path']['logs'] = '/usr/local/var/log/kibana'

default['kibana']['pid_path'] = '/usr/local/var/run'
default['kibana']['pid_file'] = "#{node['kibana']['pid_path']}/kibana-#{node['kibana']['node']['name'].to_s.gsub(/\W/, '_')}.pid"

default['kibana']['templates']['kibana_yml'] = 'kibana.yml.erb'

##
# Kibana instance configurations
##
# === PORT
#
default['kibana']['http']['port'] = 5601
# The Elasticsearch instance to use
default['kibana']['elasticsearch']['server'] = 'http://127.0.0.1:9200'
# Kibana uses an index in Elasticsearch to store saved searches, visualizations
# and dashboards. It will create an new index if it doesn't already exist.
default['kibana']['elasticsearch']['index'] = 'kibana-int'

# TODO: Add loaded and default applications support
@@ -2,10 +2,26 @@
maintainer 'Roman Chukh'
maintainer_email 'roman.chukh@gmail.com'
license 'Apache 2.0'
description 'Set of recipes for installing ... something'
description 'Set of recipes for installing Kibana 4'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.0.1'
version '0.0.2'

supports 'centos'

recipe "chamber-kibana::default", <<-EOH
Installs Kibana 4 (with or without dependencies).
See attributes for attribute-control of installed dependencies.
EOH
recipe "chamber-kibana::dependencies", <<-EOH
Installs Kibana 4 dependencies (without Kibana 4 itself).
See attributes for attribute-control of installed dependencies.
EOH

# Dependencies
depends 'chef-sugar', '~> 2.3'
depends 'ark', '~> 0.9'

# Optional dependencies
depends 'java', '~> 1.28.0'
depends 'elasticsearch', '~> 0.3.10'
recommends 'logstash', '~> 0.9.2'
@@ -0,0 +1,14 @@
#
# Cookbook Name:: chamber-kibana
# Recipe:: _preconditions.rb
#
include_recipe 'chef-sugar::default'
require 'chef/sugar/core_extensions'

unless centos?
Chef::Application.fatal!('Cookbook is incompatible with #{platform_family?}')
end

if node['kibana']['user'].blank?
Chef::Application.fatal!('Kibana user/group ownership attributes are missing')
end
@@ -1,5 +1,95 @@
#
# Cookbook Name:: boilerplate
# Cookbook Name:: chamber-kibana
# Recipe:: default
#
include_recipe 'chef-sugar::default'
include_recipe 'chamber-kibana::_preconditions'
include_recipe 'chamber-kibana::dependencies'
include_recipe 'ark'

# Create user and group
#
group node['kibana']['user'] do
gid node['kibana']['gid']
action :create
system true
end

user node['kibana']['user'] do
comment 'Kibana User'
home "#{node['kibana']['dir']}/kibana"
shell '/bin/bash'
uid node['kibana']['uid']
gid node['kibana']['user']
supports manage_home: false
action :create
system true
end

# Create ES directories
#
[node['kibana']['path']['conf'], node['kibana']['path']['logs']].each do |path|
directory path do
owner node['kibana']['user']
group node['kibana']['user']
mode 0755
recursive true
action :create
end
end

directory node['kibana']['pid_path'] do
mode 00755
recursive true
end

# Create service
#
template '/etc/init.d/kibana' do
source 'kibana.init.erb'
owner 'root'
mode 0755
end

service 'kibana' do
supports status: true, restart: true
action [:enable]
end

# Download, extract, symlink the kibana libraries and binaries
#
ark_prefix_root = node['kibana']['dir'] || node['ark']['prefix_root']
ark_prefix_home = node['kibana']['dir'] || node['ark']['prefix_home']

ark 'kibana' do
url node['kibana']['download_url']
owner node['kibana']['user']
group node['kibana']['user']
version node['kibana']['version']
has_binaries ['bin/kibana']
checksum node['kibana']['checksum']
prefix_root ark_prefix_root
prefix_home ark_prefix_home

notifies :start, 'service[kibana]' unless node['kibana']['skip_start']
notifies :restart, 'service[kibana]' unless node['kibana']['skip_restart']

not_if do
link = "#{node['kibana']['dir']}/kibana"
target = "#{node['kibana']['dir']}/kibana-#{node['kibana']['version']}"
binary = "#{target}/bin/kibana"

::File.directory?(link) && ::File.symlink?(link) && ::File.readlink(link) == target && ::File.exist?(binary)
end
end

# Create ES config file
#
template 'kibana.yml' do
path "#{node['kibana']['path']['conf']}/kibana.yml"
source node['kibana']['templates']['kibana_yml']
owner node['kibana']['user']
group node['kibana']['user']
mode 0755

notifies :restart, 'service[kibana]' unless node['kibana']['skip_restart']
end
@@ -0,0 +1,8 @@
#
# Cookbook Name:: chamber-kibana
# Recipe:: dependencies
#
# TODO: Add attribute for possibility to skip Java install
include_recipe 'java::default'
# TODO: Add attribute for possibility to skip ElasticSearch install
include_recipe 'elasticsearch::default'

0 comments on commit a91b26d

Please sign in to comment.
You can’t perform that action at this time.