Refactor kibana-ruby specific bits to kibana::ruby

Move all of the resources specific to the ruby version of kibana to
kibana::ruby.

Change-Id: I93a4b0f103b4259f356e93fe025e0a649c79b75b
This commit is contained in:
K Jonathan Harker 2015-06-02 16:07:17 -07:00
parent 8423c1ae96
commit 3e95d92cfc
2 changed files with 88 additions and 58 deletions

View File

@ -15,7 +15,8 @@
# Class to install kibana frontend to logstash. # Class to install kibana frontend to logstash.
# #
class kibana ( class kibana (
$discover_nodes = ['localhost:9200'] $discover_nodes = ['localhost:9200'],
$version = 'ruby',
) { ) {
group { 'kibana': group { 'kibana':
@ -41,64 +42,12 @@ class kibana (
require => User['kibana'], require => User['kibana'],
} }
vcsrepo { '/opt/kibana/kibana': case $version {
ensure => latest, 'ruby': {
provider => git, include ::kibana::ruby
source => 'https://github.com/rashidkpc/Kibana2.git',
revision => 'v0.2.0',
require => File['/opt/kibana'],
}
package { 'bundler':
ensure => latest,
provider => 'gem',
}
if $::osfamily == 'Debian' {
package { 'ruby-dev':
ensure => installed,
before => Exec['install_kibana'],
} }
package { 'build-essential': default: {
ensure => installed, fail("Unknown version: ${version}")
before => Exec['install_kibana'],
} }
} }
exec { 'install_kibana':
command => 'bundle install',
path => ['/usr/bin', '/usr/local/bin'],
cwd => '/opt/kibana/kibana',
logoutput => true,
refreshonly => true,
subscribe => Vcsrepo['/opt/kibana/kibana'],
require => [
User['kibana'],
Package['bundler'],
],
}
file { '/opt/kibana/kibana/KibanaConfig.rb':
ensure => present,
content => template('kibana/config.rb.erb'),
replace => true,
owner => 'kibana',
group => 'kibana',
require => Vcsrepo['/opt/kibana/kibana'],
}
file { '/etc/init/kibana.conf':
ensure => present,
source => 'puppet:///modules/kibana/kibana.init',
}
service { 'kibana':
ensure => running,
require => [
File['/etc/init/kibana.conf'],
File['/opt/kibana/kibana/KibanaConfig.rb'],
Exec['install_kibana'],
],
}
} }

81
manifests/ruby.pp Normal file
View File

@ -0,0 +1,81 @@
# Copyright 2015 Hewlett-Packard Development Company, L.P.
#
# 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.
#
# Class to install kibana frontend to logstash.
#
class kibana::ruby (
$git_revision = 'v0.2.0',
) {
vcsrepo { '/opt/kibana/kibana':
ensure => latest,
provider => git,
source => 'https://github.com/rashidkpc/Kibana2.git',
revision => $git_revision,
require => File['/opt/kibana'],
}
package { 'bundler':
ensure => latest,
provider => 'gem',
}
if $::osfamily == 'Debian' {
package { 'ruby-dev':
ensure => installed,
before => Exec['install_kibana'],
}
package { 'build-essential':
ensure => installed,
before => Exec['install_kibana'],
}
}
exec { 'install_kibana':
command => 'bundle install',
path => ['/usr/bin', '/usr/local/bin'],
cwd => '/opt/kibana/kibana',
logoutput => true,
refreshonly => true,
subscribe => Vcsrepo['/opt/kibana/kibana'],
require => [
User['kibana'],
Package['bundler'],
],
}
file { '/opt/kibana/kibana/KibanaConfig.rb':
ensure => present,
content => template('kibana/config.rb.erb'),
replace => true,
owner => 'kibana',
group => 'kibana',
require => Vcsrepo['/opt/kibana/kibana'],
}
file { '/etc/init/kibana.conf':
ensure => present,
source => 'puppet:///modules/kibana/kibana.init',
}
service { 'kibana':
ensure => running,
require => [
File['/etc/init/kibana.conf'],
File['/opt/kibana/kibana/KibanaConfig.rb'],
Exec['install_kibana'],
],
}
}