Permalink
Browse files

Initial commit of graylog2 module.

  • Loading branch information...
1 parent 7ad8d45 commit e0ab2c7b352e19f8ff6dc313e15f4716d6f31bd2 Peter Drake committed Jan 11, 2012
View
@@ -0,0 +1,12 @@
+name 'puppet-graylog2'
+version '0.0.1'
+author 'pdrakeweb'
+license 'GPL'
+summary 'Install graylog2 web interface and server.'
+description 'Install graylog2 web interface and server.'
+project_page 'https://github.com/pdrakeweb/puppet-graylog2'
+
+# Depends on a module called apache which installs apache2
+# dependency 'apache', '>= 1.2.0'
+# dependency 'apt', '>= 0.0.1'
+
View
15 README
@@ -0,0 +1,15 @@
+graylog2
+
+This is the graylog2 module.
+
+In order to install graylog2, the following files should be downloaded and places in the files directory:
+ 1. graylog2-server: https://github.com/Graylog2/graylog2-server/downloads (copy to modules/graylog2/files/graylog2-server-${glVersion}.tar.gz)
+ 2. graylog2-web-interface: https://github.com/Graylog2/graylog2-web-interface/downloads (copy to modules/graylog2/files/graylog2-web-interface-${glVersion}.tar.gz)
+
+Call graylog2 like:
+
+class role_prod_graylogserver {
+ class { graylog2: glVersion => "0.9.6" }
+ include graylog2::server
+ include graylog2::web
+}
@@ -0,0 +1,7 @@
+# gem_bin_path.rb
+
+Facter.add("gem_bin_path") do
+ setcode do
+ Facter::Util::Resolution.exec('ruby -r rubygems -e "puts Gem.path.collect{ |value| value + \'/bin\'}.join(\':\')"').chomp
+ end
+end
View
@@ -0,0 +1,36 @@
+# Class: graylog2
+#
+# This module manages graylog2
+#
+# Parameters:
+# glVersion - the version of graylog2 being installed (eg. 0.9.6)
+# glBasePath - the location to which graylog2 is being installed (eg. /var/graylog2)
+#
+# Actions:
+#
+# Requires:
+# java
+#
+# Sample Usage:
+# include graylog2 // note this is useless without including graylog2::server and/or graylog2::web
+#
+# [Remember: No empty lines between comments and class definition]
+class graylog2 ( $glVersion = "0.9.6", $glBasePath = "/var/graylog2") {
+
+ include java
+
+ file { "${glBasePath}":
+ ensure => "directory",
+ owner => "root",
+ group => "root",
+ mode => 755,
+ }
+
+ file { "${glBasePath}/src":
+ ensure => "directory",
+ owner => "root",
+ group => "root",
+ mode => 755,
+ }
+
+}
View
@@ -0,0 +1,73 @@
+# Class: graylog2::server
+#
+# This module manages graylog2::server
+#
+# Parameters:
+#
+# Actions:
+#
+# Requires:
+#
+# Sample Usage:
+# include graylog2::server
+#
+# [Remember: No empty lines between comments and class definition]
+class graylog2::server inherits graylog2 {
+
+ include mongodb
+ include elasticsearch
+
+ file { "${glBasePath}/src/graylog2-server-${glVersion}.tar.gz":
+ owner => root,
+ group => root,
+ mode => 644,
+ source => "puppet:///modules/graylog2/graylog2-server-${glVersion}.tar.gz",
+ }
+
+ exec { "graylog2-server-extract":
+ path => "/bin:/usr/bin:/usr/local/bin",
+ cwd => "${glBasePath}/src",
+ command => "tar -xzf graylog2-server-${glVersion}.tar.gz",
+ require => File["${glBasePath}/src/graylog2-server-${glVersion}.tar.gz"],
+ creates => "${glBasePath}/src/graylog2-server-${glVersion}",
+ }
+
+ file { "${glBasePath}/server":
+ ensure => link,
+ target => "${glBasePath}/src/graylog2-server-${glVersion}",
+ require => Exec["graylog2-server-extract"],
+ }
+
+ file { "/etc/graylog2.conf":
+ content => template("graylog2/graylog2.conf.erb"),
+ owner => root,
+ group => root,
+ mode => 644,
+ notify => Service["graylog2-server"],
+ }
+
+ file { "/etc/init/graylog2-server.conf":
+ content => template("graylog2/graylog2-server.conf.erb"),
+ owner => root,
+ group => root,
+ mode => 644,
+ }
+
+ file { "/etc/cron.d/graylog2-server":
+ content => template("graylog2/graylog2-server.cron.erb"),
+ owner => root,
+ group => root,
+ mode => 644,
+ }
+
+ service { "graylog2-server":
+ ensure => running,
+ hasstatus => false,
+ start => "start graylog2-server",
+ stop => "stop graylog2-server",
+ restart => "restart graylog2-server",
+ require => File["/etc/init/graylog2-server.conf"],
+ provider => "base",
+ }
+
+}
View
@@ -0,0 +1,103 @@
+# Class: graylog2::web
+#
+# This module manages graylog2::web
+#
+# Parameters:
+#
+# Actions:
+#
+# Requires:
+#
+# Sample Usage:
+# include graylog2::web
+#
+# [Remember: No empty lines between comments and class definition]
+class graylog2::web inherits graylog2 {
+
+ include apache
+
+ if !defined(Package["bundler"]) {
+ package { "bundler": ensure => latest, provider => gem }
+ }
+
+ if !defined(Package["libapache2-mod-passenger"]) {
+ package { "libapache2-mod-passenger": ensure => latest, }
+ }
+
+ file { "${glBasePath}/src/graylog2-web-interface-${glVersion}.tar.gz":
+ owner => root,
+ group => root,
+ mode => 644,
+ source => "puppet:///modules/graylog2/graylog2-web-interface-${glVersion}.tar.gz",
+ }
+
+ exec { "graylog2-web-extract":
+ path => "/bin:/usr/bin:/usr/local/bin",
+ cwd => "${glBasePath}/src",
+ command => "tar -xzf graylog2-web-interface-${glVersion}.tar.gz",
+ require => File["${glBasePath}/src/graylog2-web-interface-${glVersion}.tar.gz"],
+ creates => "${glBasePath}/src/graylog2-web-interface-${glVersion}",
+ }
+
+ file { "${glBasePath}/src/graylog2-web-interface-${glVersion}":
+ ensure => directory,
+ owner => www-data,
+ group => www-data,
+ mode => 755,
+ require => Exec["graylog2-web-extract"],
+ }
+
+ file { "${glBasePath}/src/graylog2-web-interface-${glVersion}/log":
+ ensure => directory,
+ owner => www-data,
+ group => www-data,
+ mode => 755,
+ require => File["${glBasePath}/src/graylog2-web-interface-${glVersion}"],
+ }
+
+ file { "${glBasePath}/src/graylog2-web-interface-${glVersion}/log/production.log":
+ owner => www-data,
+ group => www-data,
+ mode => 666,
+ replace => false,
+ content => "# graylog2 web interface log",
+ require => File["${glBasePath}/src/graylog2-web-interface-${glVersion}/log"],
+ }
+
+ file { "${glBasePath}/web":
+ ensure => link,
+ target => "${glBasePath}/src/graylog2-web-interface-${glVersion}",
+ require => Exec["graylog2-web-extract"],
+ }
+
+ exec { "mongoid-downgrade":
+ path => "/bin:/usr/bin:/usr/local/bin",
+ cwd => "${glBasePath}/web",
+ command => "cp Gemfile Gemfile.bak && sed 's/2\.3\.3/2\.2\.5/g' Gemfile.bak > Gemfile",
+ require => File[ "${glBasePath}/web" ],
+ creates => "${glBasePath}/src/graylog2-web-interface-${glVersion}/Gemfile.bak",
+ }
+
+ exec { "graylog2-web-install":
+ path => "/bin:/usr/bin:${gem_bin_path}",
+ cwd => "${glBasePath}/web",
+ command => "bundle install && touch bundle-installed",
+ require => [Package["bundler"], File["${glBasePath}/web"]],
+ creates => "${glBasePath}/web/bundle-installed",
+ }
+
+ file { "/etc/apache2/sites-available/graylog2":
+ content => template("graylog2/apache2-graylog2.erb"),
+ owner => root,
+ group => root,
+ mode => 644,
+ }
+
+ file { "/etc/apache2/sites-enabled/graylog2":
+ ensure => link,
+ target => "/etc/apache2/sites-available/graylog2",
+ require => Exec["graylog2-web-extract"],
+ notify => Exec["reload-apache2"],
+ }
+
+}
View
@@ -0,0 +1,12 @@
+/*
++-----------------------------------------------------------------------+
+| |
+| ==> DO NOT EDIT THIS FILE! <== |
+| |
+| You should edit the `Modulefile` and run `puppet-module build` |
+| to generate the `metadata.json` file for your releases. |
+| |
++-----------------------------------------------------------------------+
+*/
+
+{}
View
@@ -0,0 +1,6 @@
+--format
+s
+--colour
+--loadby
+mtime
+--backtrace
View
@@ -0,0 +1,18 @@
+require 'pathname'
+dir = Pathname.new(__FILE__).parent
+$LOAD_PATH.unshift(dir, dir + 'lib', dir + '../lib')
+
+require 'mocha'
+require 'puppet'
+gem 'rspec', '=1.2.9'
+require 'spec/autorun'
+
+Spec::Runner.configure do |config|
+ config.mock_with :mocha
+end
+
+# We need this because the RAL uses 'should' as a method. This
+# allows us the same behaviour but with a different method name.
+class Object
+ alias :must :should
+end
@@ -0,0 +1,20 @@
+#
+# Generated by Puppet, DO NOT TOUCH
+#
+Listen 80
+
+<VirtualHost *:80>
+ DocumentRoot <%= glBasePath %>/web/public
+ <Directory <%= glBasePath %>/web/public>
+ Allow from all
+ Options -MultiViews
+ SetEnv MONGOID_HOST localhost
+ SetEnv MONGOID_PORT 27017
+ SetEnv MONGOID_USERNAME
+ SetEnv MONGOID_PASSWORD
+ SetEnv MONGOID_DATABASE graylog2
+ </Directory>
+ ErrorLog /var/log/apache2/error.log
+ LogLevel warn
+ CustomLog /var/log/apache2/access.log combined
+</VirtualHost>
@@ -0,0 +1,15 @@
+description "graylog2 server"
+author "Peter J. Drake <pdrake@gmail.com>"
+
+start on runlevel [2345]
+stop on runlevel [06]
+
+# tell upstart we're creating a daemon
+# upstart manages PID creation for you.
+expect fork
+
+script
+ cd <%= glBasePath %>/server
+ exec sudo java -jar graylog2-server.jar &
+ emit graylog2-server_running
+end script
@@ -0,0 +1,4 @@
+# /etc/cron.d/graylog2: crontab fragment for graylog2
+
+# Send stream alarms and subscriptions every 15 minutes
+*/15 * * * * root cd <%= glBasePath %>/web && rake streamalarms:send && rake subscriptions:send
Oops, something went wrong.

0 comments on commit e0ab2c7

Please sign in to comment.