Automatically determine names of local nodes

The user doesn't need any more to specify the node name when using a
local deployment of influxdb-grafana and elasticsearch-kibana plugins.

Change-Id: I6d3512bb182a70aa05269825b77c30f16a25b066
This commit is contained in:
Swann Croiset 2015-06-30 15:27:58 +02:00
parent a3217f47d5
commit cb6d6353bc
3 changed files with 17 additions and 55 deletions

View File

@ -21,11 +21,11 @@ $is_base_os = member($roles, 'base-os')
$current_node_name = hiera('user_node_name')
$elasticsearch_kibana = hiera('elasticsearch_kibana', false)
$es_node_name = $lma_collector['elasticsearch_node_name']
$es_node_name = $elasticsearch_kibana['node_name']
$es_nodes = filter_nodes(hiera('nodes'), 'user_node_name', $es_node_name)
$influxdb_grafana = hiera('influxdb_grafana', false)
$influxdb_node_name = $lma_collector['influxdb_node_name']
$influxdb_node_name = $influxdb_grafana['node_name']
$influxdb_nodes = filter_nodes(hiera('nodes'), 'user_node_name', $influxdb_node_name)
$tags = {
@ -57,9 +57,6 @@ case $elasticsearch_mode {
$es_server = $lma_collector['elasticsearch_address']
}
'local': {
if size($es_nodes) < 1 {
fail("Could not find node '${es_node_name}' in the environment")
}
$es_server = $es_nodes[0]['internal_address']
}
'disabled': {
@ -130,15 +127,8 @@ case $influxdb_mode {
$influxdb_password = $lma_collector['influxdb_password']
}
else {
if size($influxdb_nodes) < 1 {
fail("Could not find node '${influxdb_node_name}' in the environment")
}
if ! $influxdb_grafana {
fail('Could not get the InfluxDB parameters. The InfluxDB-Grafana plugin is probably not installed.')
}
elsif ! $influxdb_grafana['metadata']['enabled'] {
fail('Could not get the InfluxDB parameters. The InfluxDB-Grafana plugin is probably not enabled for this environment.')
}
# Note: we don't validate data inputs because another manifest
# is responsible to check their coherences.
$influxdb_server = $influxdb_nodes[0]['internal_address']
$influxdb_database = $influxdb_grafana['influxdb_dbname']
$influxdb_user = $influxdb_grafana['influxdb_username']
@ -146,13 +136,13 @@ case $influxdb_mode {
}
if $is_base_os {
if $current_node_name == $influxdb_grafana['node_name'] and $influxdb_mode == 'local' {
if $current_node_name == $influxdb_node_name and $influxdb_mode == 'local' {
$processes = ['hekad', 'collectd', 'influxdb']
} else {
$processes = ['hekad', 'collectd']
}
if $current_node_name == $elasticsearch_kibana['node_name'] and $elasticsearch_mode == 'local' {
if $current_node_name == $es_node_name and $elasticsearch_mode == 'local' {
# Elasticsearch is running on a JVM
$process_matches = [{name => 'elasticsearch', regex => 'java'}]
} else {

View File

@ -19,13 +19,6 @@ $lma_collector = hiera('lma_collector')
$elasticsearch_mode = $lma_collector['elasticsearch_mode']
if $elasticsearch_mode == 'local' {
# Check that the Elasticsearch-Kibana node exists in the environment
$es_node_name = $lma_collector['elasticsearch_node_name']
$es_nodes = filter_nodes(hiera('nodes'), 'user_node_name', $es_node_name)
if size($es_nodes) < 1 {
fail("Could not find node '${es_node_name}' in the environment")
}
# Check that the Elasticsearch-Kibana plugin is enabled for that environment
# and that the node names match
$elasticsearch_kibana = hiera('elasticsearch_kibana', false)
@ -35,20 +28,17 @@ if $elasticsearch_mode == 'local' {
elsif ! $elasticsearch_kibana['metadata']['enabled'] {
fail('Could not get the Elasticsearch parameters. The Elasticsearch-Kibana plugin is probably not enabled for this environment.')
}
elsif $elasticsearch_kibana['node_name'] != $es_node_name {
fail('Node name settings don\'t match between the LMA collector and Elasticsearch-Kibana plugins.')
# Check that the Elasticsearch-Kibana node exists in the environment
$es_node_name = $elasticsearch_kibana['node_name']
$es_nodes = filter_nodes(hiera('nodes'), 'user_node_name', $es_node_name)
if size($es_nodes) < 1 {
fail("Could not find node '${es_node_name}' in the environment")
}
}
$influxdb_mode = $lma_collector['influxdb_mode']
if $influxdb_mode == 'local' {
# Check that the InfluxDB-Grafana node exists in the environment
$influxdb_node_name = $lma_collector['influxdb_node_name']
$influxdb_nodes = filter_nodes(hiera('nodes'), 'user_node_name', $influxdb_node_name)
if size($influxdb_nodes) < 1 {
fail("Could not find node '${influxdb_node_name}' in the environment")
}
# Check that the InfluxDB-Grafana plugin is enabled for that environment
# and that the node names match
$influxdb_grafana = hiera('influxdb_grafana', false)
@ -58,7 +48,10 @@ if $influxdb_mode == 'local' {
elsif ! $influxdb_grafana['metadata']['enabled'] {
fail('Could not get the InfluxDB parameters. The InfluxDB-Grafana plugin is probably not enabled for this environment.')
}
elsif $influxdb_grafana['node_name'] != $influxdb_node_name {
fail('Node name settings don\'t match between the LMA collector and InfluxDB-Grafana plugins.')
# Check that the InfluxDB-Grafana node exists in the environment
$influxdb_node_name = $influxdb_grafana['node_name']
$influxdb_nodes = filter_nodes(hiera('nodes'), 'user_node_name', $influxdb_node_name)
if size($influxdb_nodes) < 1 {
fail("Could not find node '${influxdb_node_name}' in the environment")
}
}

View File

@ -28,17 +28,6 @@ attributes:
action: "none"
message: "Please enable Events or Metrics analytics or both"
elasticsearch_node_name:
value: 'elasticsearch'
label: "Elasticsearch node name"
description: 'Label of the node running the Elasticsearch/Kibana plugin that is deployed in the environment.'
weight: 30
type: "text"
restrictions:
- condition: "settings:lma_collector.elasticsearch_mode.value != 'local'"
action: "disable"
elasticsearch_address:
value: ''
label: 'Elasticsearch address'
@ -66,16 +55,6 @@ attributes:
label: "Remote server"
restrictions: *all_disabled_msg
influxdb_node_name:
value: 'influxdb'
label: "InfluxDB node name"
description: 'Label of the node running the InfluxDB/Grafana plugin that is deployed in the environment.'
weight: 65
type: "text"
restrictions:
- condition: "settings:lma_collector.influxdb_mode.value != 'local'"
action: "disable"
influxdb_address:
value: ''
label: 'InfluxDB address'