From 2104abc62682c8772aba2f4b55f29958a33aebdf Mon Sep 17 00:00:00 2001 From: sraguram Date: Thu, 2 Feb 2012 20:47:20 -0800 Subject: [PATCH 1/4] adding recipe to install with mysql --- recipes/mysql.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 recipes/mysql.rb diff --git a/recipes/mysql.rb b/recipes/mysql.rb new file mode 100644 index 0000000..f6aac71 --- /dev/null +++ b/recipes/mysql.rb @@ -0,0 +1,27 @@ +# +# Cookbook Name:: sonar +# Recipe:: mysql +# +# Copyright 2011, Srinivasan Raguraman +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Database settings +# @see conf/sonar.properties for examples for different databases +override['sonar']['jdbc_url'] = "jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8" +override['sonar']['jdbc_driverClassName'] = "com.mysql.jdbc.Driver" +override['sonar']['jdbc_validationQuery'] = "select 1" + +include "default" +include "database_mysql" From 5223489a95faa6b33126cc362a5dba390611817a Mon Sep 17 00:00:00 2001 From: sraguram Date: Thu, 2 Feb 2012 22:50:51 -0800 Subject: [PATCH 2/4] fixing to work with mysql --- recipes/default.rb | 8 ++++++++ recipes/mysql.rb | 10 +++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/recipes/default.rb b/recipes/default.rb index f859443..7012bac 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -36,6 +36,14 @@ to "/opt/sonar-#{node['sonar']['version']}" end +file "/etc/init.d/sonar" do + path "/opt/sonar/bin/#{node['sonar']['os_kernel']}/sonar.sh" + owner "root" + group "root" + mode "0755" + action :create +end + service "sonar" do stop_command "sh /opt/sonar/bin/#{node['sonar']['os_kernel']}/sonar.sh stop" start_command "sh /opt/sonar/bin/#{node['sonar']['os_kernel']}/sonar.sh start" diff --git a/recipes/mysql.rb b/recipes/mysql.rb index f6aac71..ba84eaa 100644 --- a/recipes/mysql.rb +++ b/recipes/mysql.rb @@ -19,9 +19,9 @@ # Database settings # @see conf/sonar.properties for examples for different databases -override['sonar']['jdbc_url'] = "jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8" -override['sonar']['jdbc_driverClassName'] = "com.mysql.jdbc.Driver" -override['sonar']['jdbc_validationQuery'] = "select 1" +node.default['sonar']['jdbc_url'] = "jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8" +node.default['sonar']['jdbc_driverClassName'] = "com.mysql.jdbc.Driver" +node.default['sonar']['jdbc_validationQuery'] = "select 1" -include "default" -include "database_mysql" +include_recipe "sonar::default" +include_recipe "sonar::database_mysql" From c45e89a9754bdbfa84bfbeaed2a7cf995d6099c1 Mon Sep 17 00:00:00 2001 From: sraguram Date: Fri, 3 Feb 2012 02:48:00 -0800 Subject: [PATCH 3/4] enables as service, so gets booted up on server start --- recipes/default.rb | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/recipes/default.rb b/recipes/default.rb index 7012bac..264a498 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -36,20 +36,13 @@ to "/opt/sonar-#{node['sonar']['version']}" end -file "/etc/init.d/sonar" do - path "/opt/sonar/bin/#{node['sonar']['os_kernel']}/sonar.sh" - owner "root" - group "root" - mode "0755" - action :create +link "/etc/init.d/sonar" do + to "/opt/sonar/bin/#{node['sonar']['os_kernel']}/sonar.sh" end service "sonar" do - stop_command "sh /opt/sonar/bin/#{node['sonar']['os_kernel']}/sonar.sh stop" - start_command "sh /opt/sonar/bin/#{node['sonar']['os_kernel']}/sonar.sh start" - status_command "sh /opt/sonar/bin/#{node['sonar']['os_kernel']}/sonar.sh status" - restart_command "sh /opt/sonar/bin/#{node['sonar']['os_kernel']}/sonar.sh restart" - action :start + supports :status => true, :restart => true + action :enable end template "sonar.properties" do From 70ec2aa31d987ae34c074eea31d596ac71555576 Mon Sep 17 00:00:00 2001 From: sraguram Date: Fri, 3 Feb 2012 03:17:17 -0800 Subject: [PATCH 4/4] Introducing installation of sonar plugins updated sonar version --- attributes/default.rb | 4 +++- definitions/default.rb | 10 ++++++++++ recipes/plugins.rb | 5 +++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 definitions/default.rb create mode 100644 recipes/plugins.rb diff --git a/attributes/default.rb b/attributes/default.rb index c745c39..c030203 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -1,9 +1,11 @@ # General settings default['sonar']['dir'] = "/opt/sonar" -default['sonar']['version'] = "2.11" +default['sonar']['version'] = "2.13.1" default['sonar']['checksum'] = "9d05e25ca79c33d673004444d89c8770" default['sonar']['os_kernel'] = "linux-x86-32" default['sonar']['mirror'] = "http://dist.sonar.codehaus.org" +default['sonar']['plugins_repo'] = "http://repository.codehaus.org/org/codehaus/sonar-plugins" +default['sonar']['plugins_dir'] = "extensions/plugins" # Web settings # The default listen port is 9000, the default context path is / and Sonar listens by default to all network interfaces : '0.0.0.0'. diff --git a/definitions/default.rb b/definitions/default.rb new file mode 100644 index 0000000..8775dd3 --- /dev/null +++ b/definitions/default.rb @@ -0,0 +1,10 @@ +define :sonar_plugin, :version => "1.0" do + remote_file "#{node[:sonar][:dir]}/#{node[:sonar][:plugins_dir]}/#{params[:name]}-#{params[:version]}.jar" do + source "#{node[:sonar][:plugins_repo]}/#{params[:name]}/#{params[:version]}/#{params[:name]}-#{params[:version]}.jar" + owner "root" + group "root" + mode 0755 + notifies :restart, resources(:service => "sonar") + not_if "test -f #{node[:sonar][:dir]}/#{node[:sonar][:plugins_dir]}/#{params[:name]}-#{params[:version]}.jar" + end +end diff --git a/recipes/plugins.rb b/recipes/plugins.rb new file mode 100644 index 0000000..56afb2c --- /dev/null +++ b/recipes/plugins.rb @@ -0,0 +1,5 @@ +# installs common sonar plugins used enterprise wide +# + +sonar_plugin "sonar-build-breaker-plugin" +sonar_plugin "sonar-taglist-plugin"