Skip to content
This repository has been archived by the owner on Mar 20, 2021. It is now read-only.

Big cookbook refactoring #101

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .foodcritic
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
~FC057
~FC007
50 changes: 29 additions & 21 deletions .kitchen.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
driver_plugin: vagrant
driver_config:
require_chef_omnibus: 12.4.1
require_chef_omnibus: 12.16.42
network:
- ["forwarded_port", {guest: 8080, host: 8080, auto_correct: true}]

Expand All @@ -15,10 +15,10 @@ platforms:
- name: ubuntu-16.04
run_list:
- recipe[apt]
- name: centos-6.4
- name: centos-6.8
driver_config:
box: opscode-centos-6.4
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_centos-6.4_provisionerless.box
box: opscode-centos-6.8
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-6.8_chef-provisionerless.box
attributes:
yum:
epel:
Expand All @@ -28,29 +28,21 @@ platforms:
- name: centos-7.2

suites:
- name: kibana3_apache
- name: default
run_list:
- 'recipe[netstat]'
- 'recipe[apache2]'
- 'recipe[kibana]'
- 'recipe[kibana::apache]'
attributes: {}
- name: kibana3_nginx
run_list:
- 'recipe[netstat]'
- 'recipe[chef_nginx]'
- 'recipe[kibana]'
- 'recipe[kibana::nginx]'
attributes: {}
- name: kibana3_source
attributes:
kibana:
version: '4.6.3'
- name: tarball_default
run_list:
- 'recipe[netstat]'
- 'recipe[apache2]'
- 'recipe[kibana]'
- 'recipe[kibana::apache]'
attributes:
kibana:
install_method: 'source'
version: '4.6.3'
install_method: 'tarball'
service:
bin_path: 'kibana/bin'
- name: kibana4_apache
run_list:
- 'recipe[netstat]'
Expand Down Expand Up @@ -120,3 +112,19 @@ suites:
listen_http: 8080
java:
jdk_version: '8'

- name: kibana5
run_list:
- 'recipe[kibana]'
attributes:
kibana:
version: '5.1.1'
- name: tarball_kibana5
run_list:
- 'recipe[kibana]'
attributes:
kibana:
version: '5.1.1'
install_method: 'tarball'
service:
bin_path: 'kibana/bin'
28 changes: 26 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,35 @@ AllCops:

BlockComments:
Enabled: false
BlockLength:
Enabled: false

Style/RescueModifier:
Exclude:
- 'Rakefile'
- 'libraries/helpers.rb'

LeadingCommentSpace:
Enabled: false

LineLength:
Enabled: false

# Longer classes are okay.
Metrics/MethodLength:
Max: 30
Metrics/ModuleLength:
Max: 150

# We're not against complexity.
Metrics/AbcSize:
Max: 55
Metrics/CyclomaticComplexity:
Max: 20
Metrics/PerceivedComplexity:
Max: 20

# Mixlib::ShellOut is nice to have as an older hash syntax
Style/HashSyntax:
Enabled: false

Style/ClassAndModuleChildren:
Enabled: false
14 changes: 0 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,6 @@ env:
- TESTS="unit"
- TESTS="rubocop"
- TESTS="foodcritic"
- TESTS="integration:docker[kibana3-apache-ubuntu-1404]"
- TESTS="integration:docker[kibana3-nginx-ubuntu-1404]"
- TESTS="integration:docker[kibana4-apache-ubuntu-1404]"
- TESTS="integration:docker[kibana4-nginx-ubuntu-1404]"
- TESTS="integration:docker[kibana4-apache-package-ubuntu-1404]"
- TESTS="integration:docker[kibana4-apache-ubuntu-1604]"
- TESTS="integration:docker[kibana4-nginx-ubuntu-1604]"
- TESTS="integration:docker[kibana4-apache-package-ubuntu-1604]"
- TESTS="integration:docker[kibana3-apache-centos-64]"
- TESTS="integration:docker[kibana3-nginx-centos-64]"
- TESTS="integration:docker[kibana4-apache-centos-64]"
- TESTS="integration:docker[kibana4-nginx-centos-64]"
- TESTS="integration:docker[kibana4-apache-centos-72]"
- TESTS="integration:docker[kibana4-nginx-centos-72]"

before_install: curl -L https://www.getchef.com/chef/install.sh | sudo bash -s -- -P chefdk
install: chef exec bundle install --jobs=3 --retry=3 --without='vagrant'
Expand Down
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ A cookbook that installs [Kibana](https://github.com/elastic/kibana).

Kibana requires ElasticSearch index to be configured to work as per logstash requirements.

[Kibana](https://www.elastic.co/products/kibana) - This cookbook is being written and tested to support Kibana 5.x and greater. If you must have a cookbook that works with older versions of Kibana, please test and then pin to a specific, older major.minor version of this cookbook and only leave the patch release to float. Older versions can be found via Git tags or on Chef Supermarket.

# Requirements

* Chef 11+
Expand All @@ -26,22 +28,19 @@ Kibana requires ElasticSearch index to be configured to work as per logstash req

# Attributes

* `node['kibana']['version']` - Kibana version. Defaults to `3`.
* `node['kibana']['kibana3_version']` - Kibana3 exact version. Defaults to `3.0.0`.
* `node['kibana']['kibana4_version']` - Kibana4 exact version. Defaults to `4.2.0`.
* `node['kibana']['version']` - Kibana version. Defaults to `5.1.1`.
* `node['kibana']['base_dir']` - The base directory of kibana. Defaults to `/opt/kibana`.
* `node['kibana']['user']` - The user under which Kibana is installed. Defaults to `kibana`.
* `node['kibana']['group']` - The group under which Kibana is installed. Defaults to `kibana`.
* `node['kibana']['install_method']` - Install method. Can be source or release. Defaults to `release`.
* `node['kibana']['url']` - Url of tarball. Defaults to `https://download.elasticsearch.org/kibana/kibana/kibana-#{node['kibana']['kibana3_version']}.tar.gz`.
* `node['kibana']['checksum']` - Checksum of the tarball. Defaults to `df25bc0cc02385edcac446ef8cbd83b896cdc910a0fa1b0a7bd2a958164593a8`.
* `node['kibana']['kibana4_checksum']` - Checksum of the tarball. Defaults to `67d586e43a35652adeb6780eaa785d3d785ce60cc74fbf3b6a9a53b753c8f985`.
* `node['kibana']['install_method']` - Install method. Can be tarball or package. Defaults to `package`.
* `node['kibana']['repository_url']` - Url of package. Defaults to `https://arifacts.elastic.co/packages/5.x/[apt|yum]` (depending on OS family).
* `node['kibana']['checksum']['4.6.3']['tar']` - Checksum of the kibana 4.6.3 tarball. Defaults to `67d586e43a35652adeb6780eaa785d3d785ce60cc74fbf3b6a9a53b753c8f985`.
* `node['kibana']['checksum']['5.1.1']['tar']` - Checksum of the kibana 5.1.1 tarball. Defaults to `da0383be8a12936c7d2a0a145e7bf0eb15abf972e585e0115ed8742032c79245`.
* `node['kibana']['git']['url']` - The URL to Kibana repository. Defaults to `https://github.com/elasticsearch/kibana.git`.
* `node['kibana']['git']['reference']` - The git reference in the Kibana repository. Defaults to `'v' + node['kibana']['kibana3_version']`.
* `node['kibana']['rubyversion']` - The version of Ruby and Gems to use for Kibana. Defaults to `1.9.1`.
* `node['kibana']['interface']` - The interface on which to bind. Defaults to `127.0.0.1`.
* `node['kibana']['port']` - The port on which to bind. Defaults to `5601`.
* `node['kibana']['elasticsearch']['hosts']` - An Array of the elasticsearch service hosts. Defaults to `['127.0.0.1']`.
* `node['kibana']['elasticsearch']['port']` - The port of the elasticsearch http service. Defaults to `9200`.
* `node['kibana']['default_fields']` - The which fields are shown by default. Defaults to `["@message"]`.
* `node['kibana']['default_operator']` - The operator used if no explicit operator is specified. Defaults to `OR`.
Expand Down Expand Up @@ -77,9 +76,7 @@ Kibana requires ElasticSearch index to be configured to work as per logstash req

* [kibana::apache](#kibanaapache) - Setup vhost for apache that rewrites to Kibana.
* [kibana::default](#kibanadefault) - Install Kibana.
* kibana::kibana3
* kibana::kibana4
* kibana::nginx
* [kibana::nginx](#kibananginx) - Setup Nginx configuration to act as a reverse proxy to Kibana

## kibana::apache

Expand All @@ -89,6 +86,10 @@ Setup vhost for apache that rewrites to Kibana.

Install Kibana.

## kibana::nginx

Install & configure Nginx to act as a reverse proxy to Kibana.

# License and Maintainers

Maintainers:: Peter Donald (<[email protected]>), Dimitry Ryobryshkin (@cyberflow), Scott Nelson Windels (<[email protected]>)
Expand Down
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ end

desc 'Foodcritic linter'
task :foodcritic do
sh 'foodcritic -f any -t ~FC007 .'
sh 'foodcritic -f any .'
end

desc 'Run Test Kitchen integration tests'
Expand Down Expand Up @@ -44,7 +44,7 @@ desc 'Run chefspec unit tests'
RSpec::Core::RakeTask.new(:unit) do |t|
t.rspec_opts = [].tap do |a|
a.push('--color')
a.push('--format progress')
a.push('--format documentation')
end.join(' ')
t.pattern = 'test/unit/spec/*_spec.rb'
end
Expand Down
82 changes: 18 additions & 64 deletions attributes/default.rb
Original file line number Diff line number Diff line change
@@ -1,74 +1,28 @@
# Encoding: utf-8

#<> Kibana major version
default['kibana']['version'] = '3'
#<> Kibana3 exact version
default['kibana']['kibana3_version'] = '3.0.0'
#<> Kibana4 exact version
default['kibana']['kibana4_version'] = '4.2.0'
#<> The base directory of kibana.
default['kibana']['base_dir'] = '/opt/kibana'
#<> The user under which Kibana is installed.
default['kibana']['user'] = 'kibana'
#<> The group under which Kibana is installed.
default['kibana']['group'] = 'kibana'
#<> Install method. Can be source, release or package
default['kibana']['install_method'] = 'release'
default['kibana']['version'] = '5.1.1'
#<> Install method. Can be tarball or package
default['kibana']['install_method'] = 'package'
#<> Kibana repository url for package method install
default['kibana']['repository_url'] = 'http://packages.elastic.co/kibana/4.5/debian'
#<> Kibana repository Public Signing Key
default['kibana']['repository_key'] = 'https://packages.elastic.co/GPG-KEY-elasticsearch'

url_version = node['kibana']["kibana#{node['kibana']['version']}_version"] || node['kibana']['version']
#<> Url of tarball
default['kibana']['url'] = Kibana::Url.new(node, url_version).get
#<> Checksum of the tarball
default['kibana']['checksum'] = 'df25bc0cc02385edcac446ef8cbd83b896cdc910a0fa1b0a7bd2a958164593a8'
#<> Checksum of the tarball (for Kibana4)
default['kibana']['kibana4_checksum'] = '67d586e43a35652adeb6780eaa785d3d785ce60cc74fbf3b6a9a53b753c8f985'

#<> The URL to Kibana repository.
default['kibana']['git']['url'] = 'https://github.com/elasticsearch/kibana.git'

#<> The git reference in the Kibana repository.
default['kibana']['git']['reference'] = 'v' + node['kibana']['kibana3_version']

#<> The version of Ruby and Gems to use for Kibana.
case node['platform_family']
when 'debian'
default['kibana']['rubyversion'] = '1.9.1'
when 'rhel'
default['kibana']['rubyversion'] = nil
end
# default['kibana']['repository_url'] = 'http://packages.elastic.co/kibana/4.5/debian'
default['kibana']['repository_url'] = if node['platform_family'] == 'debian'
'https://artifacts.elastic.co/packages/5.x/apt'
elsif node['platform_family'] == 'rhel'
'https://artifacts.elastic.co/packages/5.x/yum'
else
''
end
#<> Checksum of the tarball (for Kibana4/5)
default['kibana']['checksum']['4.6.3']['tar'] = '483d49d7d03052f4885c88d905b602f3fa432cb12e2c2cbdab82bb0d259d00c7'
default['kibana']['checksum']['5.1.1']['tar'] = 'da0383be8a12936c7d2a0a145e7bf0eb15abf972e585e0115ed8742032c79245'

#<> The interface on which to bind.
default['kibana']['interface'] = '127.0.0.1'

#<> The port on which to bind.
default['kibana']['port'] = 5601
#<> An Array of the elasticsearch service hosts.
default['kibana']['elasticsearch']['hosts'] = ['127.0.0.1']
#<> The port of the elasticsearch http service.
default['kibana']['elasticsearch']['port'] = 9200

default['kibana']['index'] = if node['kibana']['version'] > '3'
'.kibana'
else
'kibana-int'
end

#<> The which fields are shown by default.
default['kibana']['default_fields'] = '["@message"]'
#<> The operator used if no explicit operator is specified.
default['kibana']['default_operator'] = 'OR'
#<> The cookbook from which configuration template is taken
default['kibana']['config']['cookbook'] = nil
#<> The template from which configuration is generated from
default['kibana']['config']['source'] = nil
#<> Fields specifiers which default to @message (may need to be changed for newer logstash)
default['kibana']['highlighted_field'] = '@message'
default['kibana']['primary_field'] = '@message'
default['kibana']['default_index'] = '@message'
default['kibana']['elasticsearch']['port'] = 9200 # used in apache recipe

#<> The host to create apache vhost for.
default['kibana']['apache']['host'] = node['fqdn']
Expand Down Expand Up @@ -126,7 +80,7 @@
default['kibana']['nginx']['server_name'] = 'kibana'

#<> The nginx configuration source
default['kibana']['nginx']['source'] = node['kibana']['version'] == '4' ? 'nginx4.conf.erb' : 'nginx.conf.erb'
default['kibana']['nginx']['source'] = node['kibana']['version'] =~ /^4/ ? 'nginx4.conf.erb' : 'nginx5.conf.erb'
default['kibana']['nginx']['cookbook'] = 'kibana'

#<> Redirect requests to kibana service
Expand All @@ -137,7 +91,7 @@

# kibana service configurations - defaults to settings for Ubuntu 14.04
case node['platform']
when 'centos'
when 'centos', 'redhat'
if node['platform_version'] < '6.9'
default['kibana']['service']['provider'] = Chef::Provider::Service::Init::Redhat
default['kibana']['service']['source'] = 'initd.kibana.erb'
Expand All @@ -160,7 +114,7 @@
end
end
default['kibana']['service']['cookbook'] = 'kibana'
default['kibana']['service']['bin_path'] = 'current/bin'
default['kibana']['service']['bin_path'] = 'bin'
default['kibana']['service']['options'] = ''

#<> The kibana 4 default application on load
Expand Down
1 change: 1 addition & 0 deletions chefignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ test/*
features/*
Guardfile
Procfile
test

# SCM #
#######
Expand Down
Loading