Skip to content
This repository was archived by the owner on Oct 22, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
d5bbde8
s/ssl_ca_path/ssl_ca_file
boinger Jul 1, 2013
30e3fc7
syntax cleanup (no functionality changes)
boinger Jul 1, 2013
7ebd13e
no depending on other modules! bad!
boinger Jul 1, 2013
5f59a37
must create the directory before we start making subdirectories (depe…
boinger Jul 1, 2013
d09cad0
correct references -- bad use of generic service names / patterns, mu…
boinger Jul 2, 2013
b46dcb7
change default behavior to restart on init file change
boinger Jul 2, 2013
76f8823
incorrect variable reference fixed
boinger Jul 2, 2013
5dfe783
wrap /etc/lumberjack creation in an if (!defined...) to allow multipl…
boinger Jul 2, 2013
6710f22
add file req before service is launched
boinger Jul 2, 2013
de2f5ca
add daemontools run templates
boinger Aug 7, 2013
fbeda29
add support for daemontools instead of crappy, crappy init.d
boinger Aug 7, 2013
5ef8acf
override type field
boinger Aug 8, 2013
722b913
override type field (correctly this time, I hope)
boinger Aug 9, 2013
807e804
override type field (correctly this time, I hope, take 2)
boinger Aug 9, 2013
81d5bdf
notify the Daemontools service when the run script changes (duh)
boinger Aug 9, 2013
c6ac396
refactor this a little to correct a syntax problem
boinger Aug 9, 2013
1f3d00b
attempting single-quoting to fix '=' being eaten
boinger Aug 9, 2013
9364834
revert
boinger Aug 9, 2013
b0daa39
using tail -F as an interface between log files and lumberjack. this …
Aug 9, 2013
d3db2d3
splitting tail and lumberjack into run and log/run to avoid orphaned …
Aug 12, 2013
2e0e603
add new lumberjack config file (not yet functional)
boinger Aug 12, 2013
2b550dc
overhauling lumberjack module to use latest version
boinger Aug 13, 2013
22336b4
make files arg required
boinger Aug 13, 2013
fa138bd
add the auto-joining of config pieces into a functional config
boinger Aug 13, 2013
6af3922
fix an errant comma
boinger Aug 13, 2013
ece424a
whitespace
boinger Aug 13, 2013
b712a36
split file paths by space
boinger Aug 13, 2013
0fc6f33
drop redundant mode
boinger Aug 13, 2013
b2a36ec
require the parent instance before adding file parts
boinger Aug 13, 2013
532bb25
make provider a param variable
boinger Aug 13, 2013
a807347
split service from instance
boinger Aug 13, 2013
1b63206
correct service name + add provider var
boinger Aug 13, 2013
e7f9a07
changed filepiece config triggers service restart
boinger Aug 13, 2013
221a01c
some syntax tuning to make json look like what lumberjack wants
boinger Aug 13, 2013
5cb25f7
trigger lumberjack to auto-upgrade
boinger Aug 13, 2013
bc1bbdb
update readme example
boinger Aug 14, 2013
0b6f569
drop timestamp, since lumberjack self-stamps
boinger Aug 14, 2013
3706cd2
lumberjack fields... if role is an array, join it into a space separa…
Oct 10, 2013
742ab22
syntax lumberjack.config.json-filepiece.erb
Oct 10, 2013
de60d35
typo lumberjack.config.json-filepiece.erb
Oct 10, 2013
120bc2b
reverting lumberjack.config.json-filepiece.erb and converting fields…
Oct 10, 2013
bf65b62
protecting lumberjack from field values that are arrays
Oct 10, 2013
368d7e6
lumberjack.config.json-filepiece.erb syntax
Oct 10, 2013
be6759e
push the field 'name' in if we don't set it explicitly
boinger Oct 11, 2013
0dc9399
change field['type'] to field['watcher'] to reduce the overuse of 'type'
boinger Oct 11, 2013
4c0cfca
just whitespace
boinger Oct 17, 2013
3b4a6e7
sort fields so that they don't keep re-generating the config when the…
boinger Oct 29, 2013
a1b8620
move the field sort earlier
boinger Oct 29, 2013
9c21ff9
take 3 on the array sort
boinger Oct 29, 2013
8df88b0
take 5 on sorting this damn fields hash
boinger Oct 29, 2013
936be3f
just whitespace
boinger Nov 12, 2013
42b81bb
ending newline
boinger Nov 21, 2013
c6b0797
pointing lumberjack to individual logstash servers
Dec 5, 2013
0221512
update logstash hosts to an array
boinger Dec 5, 2013
848827c
convert to logstash-forwarder package + dropping junk comments
boinger Mar 5, 2014
545b810
leverage service name from ::params
boinger Mar 5, 2014
664ce0b
convert to logstash-forwarder.sh
boinger Mar 6, 2014
4bbffb3
add (default) timeout flag
boinger Mar 6, 2014
0a07477
replacing the hash mutation in watcher.pp
Apr 10, 2014
a569d36
replacing the hash mutation in watcher.pp. keeping fields immutable
Apr 10, 2014
e161ade
replacing the hash mutation in watcher.pp. keeping fields immutable
Apr 10, 2014
370e329
replacing the hash mutation in watcher.pp. keeping fields immutable
Apr 10, 2014
2692280
replacing the hash mutation in watcher.pp. keeping fields immutable
Apr 10, 2014
9ec8890
trivial change to trigger a lumberjack restart
Apr 16, 2014
bb1dd39
restarting lumberjack instances
May 12, 2014
ba1bd00
triggering lumberjack restart
May 14, 2014
fa6b6b7
add support for runtime_opts var
boinger May 14, 2014
41de206
add support for runtime_opts var
boinger May 14, 2014
4f790e7
maybe I use the same variable name all the way through, no?
boinger May 14, 2014
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
37 changes: 23 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,33 @@ This module is puppet 3 tested

## Usage

Installation, make sure service is running and will be started at boot time:
### Set up a parent instance. This sets up the "framework" config to add individual file/file-group watchers that can be tagged with individual fields.

class { 'lumberjack':
host => 'logstashhost',
port => '1234',
files => ['/var/log/messages', '/var/log/secure'],
ssl_ca_path => "puppet:///path/to/ca.crt",
}
lumberjack::instance{
'core':
hosts => ['logstash.blah.com'],
port => '5005',
ssl_ca_file => 'puppet:///modules/conf/etc/ssl/certs/ca.crt',
provider => 'daemontools';
}

Removal/decommissioning:
### Add watchers that plug in to the intance you set up.
lumberjack::watcher {
'syslog':
part_of => 'core',
files => ["/var/log/secure", "/var/log/messages", "/var/log/*.log", ];

class { 'lumberjack':
ensure => 'absent',
}
'statsd':
part_of => 'core',
files => ["/data/log/statsd/statsd.log", ];

Install everything but disable service(s) afterwards:
'diamond':
part_of => 'core',
files => ["/data/log/diamond/diamond.log", ];
}

### Removal/decommissioning:

class { 'lumberjack':
status => 'disabled',
ensure => 'absent',
}

5 changes: 3 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
# String to set the specific version you want to install.
# Defaults to <tt>false</tt>.
#
# [*host*]
# Hostname to connect to
# [*hosts*]
# Array of Hostnames to connect to
#
# [*port*]
# Port to connect to
Expand Down Expand Up @@ -97,6 +97,7 @@
$autoupgrade = $lumberjack::params::autoupgrade,
$status = $lumberjack::params::status,
$restart_on_change = $lumberjack::params::restart_on_change,
$provider = $lumberjack::params::provider,
$version = false,
) inherits lumberjack::params {

Expand Down
159 changes: 42 additions & 117 deletions manifests/instance.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,22 @@
#
# === Parameters
#
# [*host*]
# Host name or IP address of the Logstash instance to connect to
# Value type is string
# Default value: undef
# This variable is optional
# [*hosts*]
# Host names or IP addresses of the Logstash instances to connect to
# Value type is array
#
# [*port*]
# Port number of the Logstash instance to connect to
# Value type is number
# Default value: undef
# This variable is optional
#
# [*files*]
# Array of files you wish to process
# Value type is array
# Default value: undef
# This variable is optional
#
# [*ssl_ca_file*]
# File to use for the SSL CA
# Value type is string
# This variable is mandatory
#
# [*fields*]
# Extra fields to send
# Value type is hash
# Default value: false
# This variable is optional
#
# [*run_as_service*]
# [*provider*]
# Set this to true if you want to run this as a service.
# Set to false if you only want to manage the ssl_ca_file
# Value type is boolean
Expand All @@ -43,124 +29,63 @@
# === Authors
#
# * Richard Pijnenburg <mailto:richard@ispavailability.com>
# * Modified by Jeff Vier <mailto:jeff@jeffvier.com>
#
define lumberjack::instance(
$ssl_ca_file,
$host = undef,
$hosts,
$port = undef,
$files = undef,
$fields = false,
$run_as_service = true,
$ensure = $logstash::ensure
$runtime_opts = '',
$provider = "daemontools",
) {

require lumberjack

File {
owner => 'root',
group => 'root',
mode => '0644'
owner => root,
group => root,
mode => 0644
}

if ($run_as_service == true ) {

# Input validation
validate_string($host)

if ! is_numeric($port) {
fail("\"${port}\" is not a valid port parameter value")
}

validate_array($files)
$logfiles = join($files,' ')

if $fields {
validate_hash($fields)
}

# Setup init file if running as a service
$notify_lumberjack = $lumberjack::restart_on_change ? {
true => Service["lumberjack-${name}"],
false => undef,
if ($provider != false ) {
lumberjack::service{
$name:
ssl_ca_file => $ssl_ca_file,
hosts => $hosts,
port => $port,
runtime_opts => $runtime_opts,
provider => $provider;
}
}

file { "/etc/init.d/lumberjack-${name}":
ensure => $ensure,
mode => '0755',
content => template("${module_name}/etc/init.d/lumberjack.erb"),
notify => $notify_lumberjack
}

#### Service management

# set params: in operation
if $lumberjack::ensure == 'present' {

case $lumberjack::status {
# make sure service is currently running, start it on boot
'enabled': {
$service_ensure = 'running'
$service_enable = true
}
# make sure service is currently stopped, do not start it on boot
'disabled': {
$service_ensure = 'stopped'
$service_enable = false
}
# make sure service is currently running, do not start it on boot
'running': {
$service_ensure = 'running'
$service_enable = false
}
# do not start service on boot, do not care whether currently running or not
'unmanaged': {
$service_ensure = undef
$service_enable = false
}
# unknown status
# note: don't forget to update the parameter check in init.pp if you
# add a new or change an existing status.
default: {
fail("\"${lumberjack::status}\" is an unknown service status value")
}
}

# set params: removal
} else {

# make sure the service is stopped and disabled (the removal itself will be
# done by package.pp)
$service_ensure = 'stopped'
$service_enable = false
if (!defined(File["/etc/lumberjack"])) {
file {
"/etc/lumberjack":
ensure => directory;
}

# action
service { "lumberjack-${name}":
ensure => $service_ensure,
enable => $service_enable,
name => $lumberjack::params::service_name,
hasstatus => $lumberjack::params::service_hasstatus,
hasrestart => $lumberjack::params::service_hasrestart,
pattern => $lumberjack::params::service_pattern,
}
if (!defined(File["/etc/lumberjack/${name}"])) {
file {
"/etc/lumberjack/${name}":
ensure => directory;
}

} else {

$notify_lumberjack = undef

}

file {
"/etc/lumberjack/${name}/pieces/header":
ensure => $ensure,
content => template("${module_name}/lumberjack.config.json-headerpiece.erb"),
notify => $notify_lumberjack;

file { "/etc/lumberjack/${name}":
ensure => directory,
}
"/etc/lumberjack/${name}/pieces/footer":
ensure => $ensure,
content => template("${module_name}/lumberjack.config.json-footerpiece.erb"),
notify => $notify_lumberjack;

# Setup certificate files
file { "/etc/lumberjack/${name}/ca.crt":
ensure => $ensure,
source => $ssl_ca_file,
require => File[ "/etc/lumberjack/${name}" ],
notify => $notify_lumberjack
"/etc/lumberjack/${name}/ca.crt":
ensure => $ensure,
source => $ssl_ca_file,
notify => $notify_lumberjack;
}

}
2 changes: 0 additions & 2 deletions manifests/package.pp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
#
class lumberjack::package {

#### Package management

# set params: in operation
if $lumberjack::ensure == 'present' {

Expand Down
36 changes: 11 additions & 25 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -28,56 +28,42 @@
# * Richard Pijnenburg <mailto:richard@ispavailability.com>
#
class lumberjack::params {

#### Default values for the parameters of the main module class, init.pp

# ensure
$ensure = 'present'

# autoupgrade
$autoupgrade = false

# service status
$autoupgrade = true
$status = 'enabled'

# Restart service on change
$restart_on_change = false

#### Internal module values
$restart_on_change = true
$provider = 'daemontools'

# packages
case $::operatingsystem {
'CentOS', 'Fedora', 'Scientific', 'OracleLinux', 'Amazon', 'RedHat': {
# main application
$package = [ 'lumberjack' ]
}
$package = [ 'logstash-forwarder' ]
}
'Debian', 'Ubuntu': {
# main application
$package = [ 'lumberjack' ]
}
$package = [ 'logstash-forwarder' ]
}
default: {
fail("\"${module_name}\" provides no package default value
for \"${::operatingsystem}\"")
}
}
}

# service parameters
case $::operatingsystem {
'CentOS', 'Fedora', 'Scientific', 'OracleLinux', 'Amazon', 'RedHat': {
$service_name = 'lumberjack'
$service_name = "lumberjack-${name}"
$service_hasrestart = true
$service_hasstatus = true
$service_pattern = $service_name
}
'Debian', 'Ubuntu': {
$service_name = 'lumberjack'
$service_name = "lumberjack-${name}"
$service_hasrestart = true
$service_hasstatus = true
$service_pattern = $service_name
}
default: {
fail("\"${module_name}\" provides no service parameters
for \"${::operatingsystem}\"")
fail("\"${module_name}\" doesn't know about OS \"${::operatingsystem}\"")
}
}

Expand Down
Loading