Skip to content

Commit

Permalink
Add support for Centos (fixes #28)
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanTron committed Nov 15, 2014
1 parent 7d5f7f4 commit 6844dbc
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 31 deletions.
60 changes: 48 additions & 12 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,67 @@ provisioner:

platforms:
- name: ubuntu-12.04
run_list:
- recipe[apt::default]
attributes:
java:
jdk_version: "7"
graphite:
listen_port: 8081
uwsgi:
listen_http: true
grafana:
graphite_port: 8081
webserver_aliases:
- grafana.dev
- name: debian-7.0
run_list:
- recipe[apt::default]
attributes:
java:
jdk_version: "7"
graphite:
listen_port: 8081
uwsgi:
listen_http: true
grafana:
graphite_port: 8081
webserver_aliases:
- grafana.dev
- name: centos-6.4
attributes:
java:
jdk_version: "7"
graphite:
listen_port: 8081
uwsgi:
listen_http: true
grafana:
graphite_port: 8081
webserver_aliases:
- grafana.dev
yum:
epel:
gpgkey: 'http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6'
mirrorlist: 'http://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch'

suites:
- name: default
attributes:
grafana:
webserver_port: 8080
nginx:
webserver_aliases: "grafana.dev"
run_list:
- recipe[apt::default]
- recipe[java::default]
- recipe[elasticsearch::default]
- recipe[graphite::default]
- recipe[graphite::carbon]
- recipe[graphite::web]
- recipe[graphite::uwsgi]
- recipe[grafana::default]
- name: git
attributes:
grafana:
install_type: git
webserver_port: 8080
nginx:
webserver_aliases: "grafana.dev"
run_list:
- recipe[apt::default]
- recipe[java::default]
- recipe[elasticsearch::default]
- recipe[graphite::default]
- recipe[graphite::carbon]
- recipe[graphite::web]
- recipe[graphite::uwsgi]
- recipe[grafana::default]
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

This file is used to list changes made in each version of grafana.

## 1.5.3:

* Add support for Centos[#28](https://github.com/JonathanTron/chef-grafana/issues/28)

## 1.5.2:

* Allow configuration of `default_route` via attributes (Miguel Landaeta) [#26](https://github.com/JonathanTron/chef-grafana/pull/26)
Expand Down
9 changes: 5 additions & 4 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
license 'Apache 2.0'
description 'Installs/Configures grafana'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '1.5.2'
version '1.5.3'

supports 'ubuntu'
supports 'debian'
supports 'centos'

depends 'git'
depends 'ark', '>= 0.7.2'
depends 'nginx'

supports 'ubuntu'
supports 'debian'
8 changes: 4 additions & 4 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
end
end

unless node['grafana']['webserver'].empty?
include_recipe "grafana::_#{node['grafana']['webserver']}"
end

directory node['grafana']['install_dir'] do
owner grafana_user
mode '0755'
Expand All @@ -46,7 +50,3 @@
mode '0644'
user grafana_user
end

unless node['grafana']['webserver'].empty?
include_recipe "grafana::_#{node['grafana']['webserver']}"
end
2 changes: 1 addition & 1 deletion spec/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
expect(chef_run).to include_recipe 'grafana::_install_file'
end

it 'generate grafana config file with use set to nginx user' do
it 'generate grafana config file with user set to nginx user' do
config_path = "#{chef_run.node['grafana']['web_dir']}/config.js"
expect(chef_run).to create_template(config_path).with(
mode: '0644',
Expand Down
43 changes: 35 additions & 8 deletions test/integration/default/serverspec/localhost/default_spec.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@

require 'spec_helper'

describe file('/srv/apps/grafana') do
let :owner do
if os[:family]=="redhat"
"nginx"
else
"www-data"
end
end
it { should be_directory }
it { should be_mode 755 }
it { should be_owned_by 'www-data' }
it { should be_owned_by owner }
it { should be_grouped_into 'root' }
end

describe file('/srv/apps/grafana/config.js') do
let :owner do
if os[:family]=="redhat"
"nginx"
else
"www-data"
end
end
it { should be_file }
it { should be_mode 644 }
it { should be_owned_by 'www-data' }
it { should be_owned_by owner }
it { should be_grouped_into 'root' }
it { should contain %Q{///// @scratch /configuration/config.js/1
// == Configuration
Expand All @@ -31,14 +44,15 @@
type: 'graphite',
url: window.location.protocol+"//"+window.location.hostname+":"+window.location.port+"/_graphite",
default: true
},
elasticsearch: {
type: 'elasticsearch',
url: window.location.protocol+"//"+window.location.hostname+":"+window.location.port,
index: 'grafana-index',
grafanaDB: true
}
},
// elasticsearch url
// used for storing and loading dashboards, optional
// For Basic authentication use: http://username:[email protected]:9200
elasticsearch: window.location.protocol+"//"+window.location.hostname+":"+window.location.port,
// default start dashboard
default_route: '/dashboard/file/default.json',
Expand All @@ -64,6 +78,19 @@
// Example: "1m", "1h"
playlist_timespan: "1m",
// If you want to specify password before saving, please specify it bellow
// The purpose of this password is not security, but to stop some users from accidentally changing dashboards
admin: {
password: ''
},
// Change window title prefix from 'Grafana - <dashboard title>'
window_title_prefix: "Grafana - ",
// specify the limit for dashboard search results
search: {
max_results: 20
},
// Add your own custom pannels
plugins: {
Expand Down
3 changes: 1 addition & 2 deletions test/integration/default/serverspec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require 'serverspec'

include SpecInfra::Helper::Exec
include SpecInfra::Helper::DetectOS
set :backend, :exec

RSpec.configure do |c|
if ENV['ASK_SUDO_PASSWORD']
Expand Down

0 comments on commit 6844dbc

Please sign in to comment.