Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class stackdriver::config{
# OS Family specific configuration
class { $::stackdriver::cclass:
apikey => $::stackdriver::apikey,
}
contain $::stackdriver::cclass
}
6 changes: 2 additions & 4 deletions manifests/config/debian.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
# - Stackdriver configuration file
#
class stackdriver::config::debian(

$apikey,
$sysconfig = '/etc/default/stackdriver-agent',

) inherits stackdriver {
) {

validate_string ( $sysconfig )

Expand All @@ -28,7 +27,6 @@
group => 'root',
mode => '0440', # secure API key
content => template("stackdriver/${::kernel}/${sysconfig}.erb"),
notify => Service[$svc],
}

}
8 changes: 2 additions & 6 deletions manifests/config/redhat.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
# - Stackdriver configuration file
#
class stackdriver::config::redhat(

$apikey,
$sysconfig = '/etc/sysconfig/stackdriver',

) inherits stackdriver {

) {
validate_string ( $sysconfig )

file { $sysconfig:
Expand All @@ -28,8 +26,6 @@
group => 'root',
mode => '0440', # secure API key
content => template("stackdriver/${::kernel}/${sysconfig}.erb"),
notify => Service[$svc],
}

}

48 changes: 13 additions & 35 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -23,57 +23,35 @@
# apikey => "OMGBECKYLOOKATHERBUTTITSJUSTSOROUND"
# }
#
class stackdriver (

$apikey = undef,
$ensure = 'present',
class stackdriver(
$apikey = undef,
$ensure = 'present',
$service_ensure = 'running',
$service_enable = true,

$plugins = [],
$svc = $::osfamily ? {
'RedHat' => [ 'stackdriver-agent', 'stackdriver-extractor' ],
'Debian' => [ 'stackdriver-agent', 'stackdriver-extractor' ],
default => undef,
},

$iclass = "::stackdriver::install::${::osfamily}",
$cclass = "::stackdriver::config::${::osfamily}",
) {

validate_string ( $apikey )
validate_array ( $svc )

# Runtime class definitions
$iclass = "${name}::install::${::osfamily}"
$cclass = "${name}::config::${::osfamily}"
$sclass = "${name}::service"


# OS Family specific installation
class { "::${iclass}":
ensure => $ensure,
notify => Class[$sclass],
}
contain $iclass
contain stackdriver::install
contain stackdriver::config
contain stackdriver::service


# OS Family specific configuration
class { "::${cclass}": require => Class[$iclass]; }
contain $cclass


# Service
class { "::${sclass}":
service_ensure => $service_ensure,
service_enable => $service_enable,
require => Class[$cclass],
}
include $sclass

# Array of Plugins to load (optional)
$plugins = hiera_array("${name}::plugins", [])
Class['::stackdriver::install'] -> Class['::stackdriver::config']
Class['::stackdriver::install'] ~> Class['::stackdriver::service']
Class['::stackdriver::config'] ~> Class['::stackdriver::service']

if ! empty($plugins) {
stackdriver::plugin { $plugins: }
}


}

7 changes: 7 additions & 0 deletions manifests/install.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class stackdriver::install{
# OS Family specific installation
class { $::stackdriver::iclass:
ensure => $stackdriver::ensure,
}
contain $::stackdriver::iclass
}
2 changes: 1 addition & 1 deletion manifests/install/redhat.pp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#
class stackdriver::install::redhat(

$pkg = [ 'stackdriver-agent', 'stackdriver-extractor' ],
$pkg = [ 'stackdriver-extractor','stackdriver-agent'],
$ensure = 'present',

$repo = {
Expand Down
29 changes: 4 additions & 25 deletions manifests/plugin.pp
Original file line number Diff line number Diff line change
@@ -1,31 +1,10 @@
# vim: tabstop=2 expandtab shiftwidth=2 softtabstop=2 foldmethod=marker
#
# == Define: stackdriver::plugin
#
# Loads a Plugin for the Stackdriver Agent
#
# NOTE: plugin configuration parameters should be defined via Hiera
#
# === Parameters
# ---
#
# [*name*]
# - Default - NONE (REQUIRED)
# - Stackdriver plugin name
#
# == Examples:
#
# stackdriver::plugin { 'elasticsearch': }
#
define stackdriver::plugin() {

define stackdriver::plugin(){
$pclass = "::stackdriver::plugin::${name}"

if ! defined($pclass) {
fail("Unknown Stackdriver Agent plugin ${name}")
}

include $pclass
} else {
contain $pclass

}
}

12 changes: 4 additions & 8 deletions manifests/plugin/apache.pp
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,22 @@
# - 'apache'
#
class stackdriver::plugin::apache(

$config = '/opt/stackdriver/collectd/etc/collectd.d/apache.conf',

$url = 'http://127.0.0.1/mod_status?auto',
$user = undef,
$password = undef,

) {

Class['stackdriver'] -> Class[$name]

validate_string ( $config )
validate_string ( $url )
if $user { validate_string ( $user ) }
if $password { validate_string ( $password ) }

#contain "${name}::install"

#class { "::${name}::config": require => Class["::${name}::install"] }
contain "${name}::config"

Class['::stackdriver::config'] ->
Class["::${name}::config"] ~>
Class['::stackdriver::service']

}

14 changes: 4 additions & 10 deletions manifests/plugin/elasticsearch.pp
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +42,24 @@
# - 'elasticsearch'
#
class stackdriver::plugin::elasticsearch(

$pkg = $::osfamily ? {
/(?i:Debian)/ => 'libyajl1',
/(?i:RedHat)/ => 'yajl',
default => undef,
},

$config = '/opt/stackdriver/collectd/etc/collectd.d/elasticsearch.conf',

$host = 'localhost',
$port = 9200,

) {

Class['stackdriver'] -> Class[$name]

if $pkg { validate_string ( $pkg ) }
validate_string ( $config )


contain "${name}::install"

class { "::${name}::config": require => Class["::${name}::install"] }
contain "${name}::config"

Class['::stackdriver::config'] ->
Class["::${name}::install"] ->
Class["::${name}::config"] ~>
Class['::stackdriver::service']
}

6 changes: 4 additions & 2 deletions manifests/plugin/memcached.pp
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@

) {

Class['stackdriver'] -> Class[$name]

validate_string ( $config )
validate_string ( $host )

contain "${name}::config"

Class['::stackdriver::config'] ->
Class["::${name}::config"] ~>
Class['::stackdriver::service']

}

12 changes: 4 additions & 8 deletions manifests/plugin/mongo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,23 @@
# - 'mongo'
#
class stackdriver::plugin::mongo(

$config = '/opt/stackdriver/collectd/etc/collectd.d/mongo.conf',

$host = 'localhost',
$port = 27017,
$user = 'stackdriver',
$password = 'ahzae8aiLiKoe',

) {

Class['stackdriver'] -> Class[$name]

validate_string ( $config )
validate_string ( $host )
validate_string ( $user )
validate_string ( $password )

#contain "${name}::install"

#class { "::${name}::config": require => Class["::${name}::install"] }
contain "${name}::config"

Class['::stackdriver::config'] ->
Class["::${name}::config"] ~>
Class['::stackdriver::service']

}

9 changes: 4 additions & 5 deletions manifests/plugin/nginx.pp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@

) {

Class['stackdriver'] -> Class[$name]

validate_absolute_path ( $config )
validate_string ( $url )

Expand All @@ -75,10 +73,11 @@
if $verifyhost != undef { validate_bool ( $verifyhost ) }
if $cacert != undef { validate_absolute_path ( $cacert ) }

#contain "${name}::install"

#class { "::${name}::config": require => Class["::${name}::install"] }
contain "${name}::config"

Class['::stackdriver::config'] ->
Class["::${name}::config"] ~>
Class['::stackdriver::service']

}

3 changes: 0 additions & 3 deletions manifests/plugin/nginx/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
# Configures Nginx Agent Plugin for Stackdriver Agent
#
class stackdriver::plugin::nginx::config(


) inherits stackdriver::plugin::nginx {

file { $config:
Expand All @@ -15,7 +13,6 @@
owner => 'root',
group => 'root',
mode => '0440', # secure
notify => Service[$::stackdriver::svc],
}

}
Expand Down
12 changes: 4 additions & 8 deletions manifests/plugin/postgres.pp
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,22 @@
# - 'postgres'
#
class stackdriver::plugin::postgres(

$config = '/opt/stackdriver/collectd/etc/collectd.d/postgres.conf',

$dbname = undef, # REQUIRED Param
$user = 'stackdriver',
$password = 'xoiboov9Pai5e',

) {

Class['stackdriver'] -> Class[$name]

validate_string ( $config )
validate_string ( $dbname )
validate_string ( $user )
validate_string ( $password )

#contain "${name}::install"

#class { "::${name}::config": require => Class["::${name}::install"] }
contain "${name}::config"

Class['::stackdriver::config'] ->
Class["::${name}::config"] ~>
Class['::stackdriver::service']

}

5 changes: 4 additions & 1 deletion manifests/plugin/rabbitmq.pp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@

) {

Class['stackdriver'] -> Class[$name]

validate_array ( $queues )

Expand All @@ -71,5 +70,9 @@
'ensure' => 'present',
})

Class['::stackdriver::config'] ->
Class["::${name}::config"] ~>
Class['::stackdriver::service']

}

2 changes: 0 additions & 2 deletions manifests/plugin/rabbitmq/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
# Configures RabbitMQ Agent Plugin for Stackdriver Agent
#
class stackdriver::plugin::rabbitmq::config(


) inherits stackdriver::plugin::rabbitmq {

file { $config:
Expand Down
Loading