Last active
August 1, 2019 17:17
-
-
Save lukebigum/1a8b9735f604493da38d7b1d924ba4bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class profile::statistics::collection_server( | |
$apache_listen_ip = undef, | |
$logical_volume_size = '100G', | |
$volume_group = 'vg_os', | |
$physical_volume = undef, | |
$extra_proxy_pass = [], | |
$extra_docroot_index_links = {}, | |
$influxdb_index_version = 'inmem', | |
$cache_max_memory_size = 1048576000, | |
) inherits profile { | |
include ::lmax_pulp::repo::statistics | |
$common_docroot_index_links = { 'Grafana' => '/stats', 'Chronograf' => '/chronograf' } | |
class { '::grafana': | |
manage_package_repo => false, | |
install_method => 'repo', | |
version => 'present', | |
require => Class[::lmax_pulp], | |
cfg => { | |
server => { | |
root_url => '%(protocol)s://%(domain)s:%(http_port)s/stats/', | |
}, | |
security => { disable_gravatar => true, }, | |
users => { allow_sign_up => false, }, | |
'auth.anonymous' => { enabled => true, }, | |
}, | |
} | |
package { 'chronograf': | |
ensure => present, | |
require => Class[::lmax_pulp], | |
} | |
#for apache proxy-path | |
file { '/etc/default/chronograf': | |
ensure => file, | |
content => "CHRONOGRAF_OPTS=\"--basepath /chronograf\"\n", | |
} | |
service { 'chronograf': | |
ensure => running, | |
enable => true, | |
hasstatus => true, | |
hasrestart => true, | |
require => [ Package['chronograf'], File['/etc/default/chronograf'], ], | |
} | |
grafana_datasource { 'telegraf': | |
grafana_url => 'http://localhost:3000', | |
grafana_user => 'admin', | |
type => 'influxdb', | |
user => 'telegraf', | |
database => 'telegraf', | |
url => 'http://localhost:8086', | |
access_mode => 'proxy', | |
is_default => true, | |
require => Class[influxdb], | |
} | |
lmax_lvm::volume { 'influxdb': | |
location => '/var/lib', | |
size => $logical_volume_size, | |
fstype => 'ext4', | |
group => 'influxdb', | |
owner => 'influxdb', | |
mode => '0755', | |
vg => $volume_group, | |
pv => $physical_volume, | |
require => Class[::influxdb::install], | |
before => Class[::influxdb::service], | |
} | |
$data_config = { | |
'dir' => '/var/lib/influxdb/data', | |
'wal-dir' => '/var/lib/influxdb/wal', | |
'trace-logging-enabled' => false, | |
'query-log-enabled' => true, | |
'cache-max-memory-size' => $cache_max_memory_size, | |
'cache-snapshot-memory-size' => 26214400, | |
'cache-snapshot-write-cold-duration' => '10m', | |
'compact-full-write-cold-duration' => '4h', | |
'max-series-per-database' => 0, | |
'max-values-per-tag' => 0, | |
'index-version' => $influxdb_index_version, | |
} | |
class { '::influxdb': | |
manage_repos => false, | |
data_config => $data_config, | |
require => Class[::lmax_pulp], | |
} | |
#LB: use apache as the Proxy engine | |
class { '::apache': | |
default_vhost => false, | |
} | |
#Parse order issue, sub modules must be after main apache class | |
include ::apache::mod::headers | |
include ::apache::mod::proxy | |
include ::apache::mod::proxy_http | |
$base_proxy_pass = [ | |
{ | |
'path' => '/stats', | |
'url' => 'http://localhost:3000', | |
'reverse_urls' => 'http://localhost:3000', | |
}, | |
{ | |
'path' => '/chronograf', | |
'url' => 'http://localhost:8888/chronograf', | |
'reverse_urls' => 'http://localhost:8888/chronograf', | |
}, | |
] | |
apache::vhost { "${::fqdn} non-ssl": | |
port => 80, | |
servername => $::fqdn, | |
docroot => '/var/www/html', | |
rewrites => [ | |
{ | |
comment => 'Rewrite non-SSL to SSL', | |
rewrite_cond => '%{HTTPS} !=on', | |
rewrite_rule => '^/?(.*)$ https://%{SERVER_NAME}/$1 [R=301,L]', | |
}, | |
], | |
} | |
apache::vhost { "${::fqdn} ssl": | |
ip => $apache_listen_ip, | |
port => 443, | |
ssl => true, | |
servername => $::fqdn, | |
docroot => '/var/www/html', | |
proxy_preserve_host => true, | |
proxy_pass => concat($base_proxy_pass, $extra_proxy_pass), | |
ssl_cert => "/etc/pki/tls/certs/${::fqdn}.crt", | |
ssl_chain => "/etc/pki/tls/certs/${::fqdn}.crt", | |
ssl_key => "/etc/pki/tls/private/${::fqdn}.key", | |
} | |
$docroot_index_links = merge($common_docroot_index_links, $extra_docroot_index_links) | |
file { '/var/www/html/index.html': | |
ensure => file, | |
content => template("${module_name}/statistics/index.html.erb"), | |
} | |
::nagios::host::service::fast { 'influxdb_http': | |
service_description => 'InfluxDB HTTP API', | |
notes => 'InfluxDBHTTPAPI', | |
check_command => 'port_open!8086', | |
servicegroups => [ 'InfluxDB', ], | |
} | |
::nagios::host::service::fast { 'grafana_server': | |
service_description => 'Grafana Process', | |
notes => 'GrafanaProcess', | |
check_command => 'check_nrpe_args!check_single_process!grafana-server', | |
servicegroups => [ 'Grafana', ], | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment