Commit c5669737 authored by Goh Choon Ming's avatar Goh Choon Ming Committed by GitHub

Merge pull request #17 from walterheck/walter/features/install_grafana_yum

Walter/features/install grafana yum
parents cce01c5e 35f9b575
......@@ -33,3 +33,4 @@ opstheater::profile::logstash::input_beats_type: 'logs'
opstheater::profile::logstash::output_codec: 'rubydebug'
opstheater::profile::logstash::output_elasticsearch_hosts:
- "elasticsearch:9200"
opstheater::profile::grafana::install_method: 'repo'
......@@ -4,14 +4,17 @@
class opstheater::profile::gitlab {
$gitlab_use_ssl = ( if hiera('opstheater::http_mode') == 'https' { true } else { false } )
$gitlab_url = hiera('opstheater::profile::gitlab::gitlab_url')
$gitlab_fqdn = hiera('opstheater::profile::gitlab::gitlab_fqdn')
$gitlab_ipaddress = hiera('opstheater::profile::gitlab::gitlab_ipaddress')
$gitlabci_url = hiera('opstheater::profile::gitlab::gitlab_url')
$gitlab_use_ssl = ( if hiera('opstheater::http_mode') == 'https' { true } else { false } )
$gitlab_url = hiera('opstheater::profile::gitlab::gitlab_url')
$gitlab_fqdn = hiera('opstheater::profile::gitlab::gitlab_fqdn')
$gitlab_ipaddress = hiera('opstheater::profile::gitlab::gitlab_ipaddress')
$gitlabci_url = hiera('opstheater::profile::gitlab::gitlab_url')
$gitlab_smtp_authentication = ( if hiera('opstheater::smtp::auth_type') in (['none','login','plain']) { hiera('opstheater::smtp::auth_type') } else { 'none' } )
$gitlab_enable_tls = ( if hiera('opstheater::smtp::ssl_type') in (['TLS','STARTTLS']) == true { true } else { false })
$gitlab_starttls_auto = ( if hiera('opstheater::smtp::ssl_type') == 'STARTTLS' { true } else { false } )
$email_smtp_username = ( if hiera('opstheater::smtp::auth_type') != false { hiera('opstheater::smtp::username') } else {''} )
$email_smtp_password = ( if hiera('opstheater::smtp::auth_type') != false { hiera('opstheater::smtp::password') } else {''} )
$github_oauth_enabled = hiera('opstheater::profile::gitlab::github_oauth_enabled')
$github_oauth_clientid = hiera('opstheater::profile::gitlab::github_oauth_clientid')
......@@ -22,14 +25,11 @@ class opstheater::profile::gitlab {
$mattermost_fqdn = hiera('opstheater::profile::gitlab::mattermost_fqdn')
$mattermost_connection_security = ( if hiera('opstheater::smtp::ssl_type') in (['TLS','STARTTLS']) { hiera('opstheater::smtp::ssl_type') } else { '' } )
$email_smtp_username = ( if hiera('opstheater::smtp::auth_type') != false { hiera('opstheater::smtp::username') } else {''} )
$email_smtp_password = ( if hiera('opstheater::smtp::auth_type') != false { hiera('opstheater::smtp::password') } else {''} )
$gitlab_api_endpoint = hiera('opstheater::profile::gitlab::api_endpoint')
$gitlab_api_user = hiera('opstheater::profile::gitlab::api_user')
$gitlab_api_password = hiera('opstheater::profile::gitlab::api_password')
$gitlab_ssl_cert = "/etc/gitlab/ssl/${gitlab_fqdn}.crt";
$gitlab_ssl_cert = "/etc/gitlab/ssl/${gitlab_fqdn}.crt";
$mattermost_ssl_cert = "/etc/gitlab/ssl/${mattermost_fqdn}.crt";
host { $mattermost_fqdn:
......
class opstheater::profile::grafana {
$grafanauser = hiera('opstheater::grafana::grafanauser')
$grafanapasswd = hiera('opstheater::grafana::grafanapasswd')
$grafanaurl = hiera('opstheater::grafana::url')
$user = hiera('opstheater::grafana::influxdb::user')
$password = hiera('opstheater::grafana::influxdb::password')
$grafanauser = hiera('opstheater::grafana::grafanauser')
$grafanapasswd = hiera('opstheater::grafana::grafanapasswd')
$grafanaurl = hiera('opstheater::grafana::url')
$elasticsearchurl = hiera('opstheater::elasticsearch::fqdn')
$install_method = hiera('opstheater::profile::grafana::install_method')
$domain = hiera('opstheater::domain')
$smtp_address = hiera('opstheater::smtp::fqdn'),
$smtp_port = hiera('opstheater::smtp::port'),
$smtp_user_name = hiera('opstheater::smtp::username'),
$smtp_password = hiera('opstheater::smtp::password'),
$smtp_openssl_verify_mode = hiera('opstheater::smtp::openssl_verify_mode'),
class { '::grafana': }
exec { 'elastic_datasource':
path => '/bin:/usr/bin:/sbin:/usr/sbin',
unless => "[ `curl --silent 'http://${grafanauser}:${grafanapasswd}@${grafanaurl}:3000/api/datasources' -X GET | tr ',' '\\n' | grep '\"name\":\"Elastic\"'` == '\"name\":\"Elastic\"' ]",
command => "sleep 10;curl 'http://${grafanauser}:${grafanapasswd}@${grafanaurl}:3000/api/datasources' -X POST -H 'Content-Type: application/json;charset=UTF-8\' --data-binary \'{\"name\":\"Elastic\",\"type\":\"elasticsearch\",\"url\":\"http://${grafanaurl}:9200\",\"access\":\"proxy\",\"isDefault\":true,\"database\":\"[logstash-]YYY.MM.DD\"'}",
require => Class[ 'grafana' ],
class { '::grafana':
install_method => $install_method,
cfg => {
server => {
http_port => 80,
},
smtp => {
enabled => true,
from_address => "grafana@${domain}",
host => "${smtp_address}:${smtp_port}",
user => $smtp_user_name,
password => $smtp_password,
skip_verify => $smtp_openssl_verify_mode,
}
}
}
class { 'influxdb::server' : }
exec { 'add_influxdb':
path => '/bin:/usr/bin:/sbin:/usr/sbin',
unless => '[ `influx -execute \'SHOW DATABASES\' |grep influxdb` == influxdb ]',
command => 'sleep 10 && curl -G http://localhost:8086/query --data-urlencode "q=CREATE DATABASE influxdb" && curl -G http://localhost:8086/query --data-urlencode "q=CREATE USER influxadmin WITH PASSWORD \'influxadmin\' WITH ALL PRIVILEGES"',
require => Class[ 'influxdb::server' ],
}
# curl http://admin:admin@localhost:3000/api/datasources -X POST -H 'Content-Type: application/json;charset=UTF-8' \
# --data '{"Name":"OpsTheater7","type":"elasticsearch","url":"http://elasticsearch.opstheater.vm:9200","access":"proxy","isDefault":true,"database":"[logstash-]YYYY.MM.DD","jsonData":{"timeField":"@timestamp", "esVersion": 2, "interval":"Daily"}}'
exec { 'influx_datasource':
path => '/bin:/usr/bin:/sbin:/usr/sbin',
unless => "[ `curl --silent 'http://${grafanauser}:${grafanapasswd}@${grafanaurl}:3000/api/datasources' -X GET | tr ',' '\\n' | grep '\"name\":\"Influx\"'` == '\"name\":\"Influx\"' ]",
command => "sleep 10;curl 'http://${grafanauser}:${grafanapasswd}@${grafanaurl}:3000/api/datasources' -X POST -H 'Content-Type: application/json;charset=UTF-8' --data-binary '{\"name\":\"Influx\",\"type\":\"influxdb\",\"url\":\"http://${grafanaurl}:8086\",\"access\":\"proxy\",\"isDefault\":true,\"database\":\"influxdb\",\"user\":\"${user}\",\"password\":\"${password}\"'}",
require => Class[ 'influxdb::server', 'grafana' ],
grafana_datasource { 'elastic':
grafana_url => "http://${grafanaurl}:3000",
grafana_user => $grafanauser,
grafana_password => $grafanapasswd,
url => "http://${elasticsearchurl}:9200",
type => elasticsearch,
access_mode => proxy,
is_default => true,
database => '[logstash-]YYYY.MM.DD',
json_data => {
timeField => '@timestamp',
esVersion => '2',
interval => 'Daily',
},
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment