Store node's roles into Hiera

Change-Id: Idbd2a353fb90131e77cb9f21820f61b4d6413e64
This commit is contained in:
Swann Croiset 2016-06-09 13:20:56 +02:00 committed by Simon Pasquier
parent ef564156a4
commit 7a47c34424
7 changed files with 52 additions and 30 deletions

View File

@ -17,9 +17,11 @@ notice('fuel-plugin-lma-collector: aggregator.pp')
prepare_network_config(hiera_hash('network_scheme', {}))
$mgmt_address = get_network_role_property('management', 'ipaddr')
$lma_collector = hiera_hash('lma_collector')
$is_controller = roles_include(['controller', 'primary-controller'])
$is_rabbitmq = roles_include(['standalone-rabbitmq', 'primary-standalone-rabbitmq'])
$is_mysql_server = roles_include(['standalone-database', 'primary-standalone-database'])
$node_profiles = hiera_hash('lma::collector::node_profiles')
$is_controller = $node_profiles['controller']
$is_mysql_server = $node_profiles['mysql']
$is_rabbitmq = $node_profiles['rabbitmq']
$network_metadata = hiera_hash('network_metadata')
$controllers = get_nodes_hash_by_roles($network_metadata, ['primary-controller', 'controller'])

View File

@ -18,25 +18,15 @@ $heka_version = '0.10.0'
# TODO(spasquier): fail if Neutron isn't used
prepare_network_config(hiera_hash('network_scheme', {}))
$fuel_version = 0 + hiera('fuel_version')
$lma_collector = hiera_hash('lma_collector')
$is_controller = roles_include(['controller', 'primary-controller'])
$is_base_os = roles_include('base-os')
$network_metadata = hiera_hash('network_metadata')
$detach_rabbitmq = hiera('detach-rabbitmq', {})
$detach_database = hiera('detach-database', {})
$fuel_version = 0 + hiera('fuel_version')
$lma_collector = hiera_hash('lma_collector')
if $detach_database['metadata'] and $detach_database['metadata']['enabled'] {
$is_mysql_server = roles_include(['standalone-database', 'primary-standalone-database'])
} else {
$is_mysql_server = $is_controller
}
$node_profiles = hiera_hash('lma::collector::node_profiles')
$is_controller = $node_profiles['controller']
$is_base_os = $node_profiles['base_os']
$is_mysql_server = $node_profiles['mysql']
$is_rabbitmq = $node_profiles['rabbitmq']
if $detach_rabbitmq['metadata'] and $detach_rabbitmq['metadata']['enabled'] {
$is_rabbitmq = roles_include(['standalone-rabbitmq', 'primary-standalone-rabbitmq'])
} else {
$is_rabbitmq = $is_controller
}
if $lma_collector['environment_label'] != '' {
$environment_label = $lma_collector['environment_label']

View File

@ -20,7 +20,9 @@ if hiera('lma::collector::influxdb::server', false) {
# module which can be run only by one manifest otherwise the collectd configuration is
# overwritten by the next run. Currently only controller nodes have python
# plugins installed so it's safe to install on all other roles .. for now.
if ! roles_include(['controller', 'primary-controller']) {
$node_profiles = hiera_hash('lma::collector::node_profiles')
$is_controller = $node_profiles['controller']
if ! $is_controller {
class { 'lma_collector::collectd::base':
processes => ['hekad', 'collectd'],
}

View File

@ -15,9 +15,11 @@
notice('fuel-plugin-lma-collector: cinder.pp')
$ceilometer = hiera_hash('ceilometer', {})
$is_controller = roles_include(['controller', 'primary-controller'])
$is_rabbitmq = roles_include(['standalone-rabbitmq', 'primary-standalone-rabbitmq'])
$is_mysql_server = roles_include(['standalone-database', 'primary-standalone-database'])
$node_profiles = hiera_hash('lma::collector::node_profiles')
$is_controller = $node_profiles['controller']
$is_rabbitmq = $node_profiles['rabbitmq']
$is_mysql_server = $node_profiles['mysql']
if $is_controller or $is_rabbitmq or $is_mysql_server {
# On nodes where pacemaker is deployed, make sure Log and Metric collector services

View File

@ -14,10 +14,11 @@
notice('fuel-plugin-lma-collector: configure_afd_filters.pp')
$lma = hiera_hash('lma_collector', {})
$is_controller = roles_include(['controller', 'primary-controller'])
$is_rabbitmq = roles_include(['standalone-rabbitmq', 'primary-standalone-rabbitmq'])
$is_mysql_server = roles_include(['standalone-database', 'primary-standalone-database'])
$lma = hiera_hash('lma_collector', {})
$node_profiles = hiera_hash('lma::collector::node_profiles')
$is_controller = $node_profiles['controller']
$is_mysql_server = $node_profiles['mysql']
$is_rabbitmq = $node_profiles['rabbitmq']
$alarms_definitions = $lma['alarms']
if $alarms_definitions == undef {

View File

@ -19,8 +19,23 @@ $plugin_data = hiera_hash('lma_collector', undef)
if ($plugin_data) {
$network_metadata = hiera_hash('network_metadata')
$is_controller_node = roles_include(['controller', 'primary-controller'])
$is_base_os_node = roles_include('base-os')
if roles_include(['standalone-database', 'primary-standalone-database']) {
$is_mysql_node = true
} else {
$is_mysql_node = $is_controller_node
}
if roles_include(['standalone-rabbitmq', 'primary-standalone-rabbitmq']) {
$is_rabbitmq_node = true
} else {
$is_rabbitmq_node = $is_controller_node
}
# Elasticsearch
$is_elasticsearch_node = roles_include(['elasticsearch_kibana', 'primary-elasticsearch_kibana'])
$elasticsearch_mode = $plugin_data['elasticsearch_mode']
$es_nodes = get_nodes_hash_by_roles($network_metadata, ['elasticsearch_kibana', 'primary-elasticsearch_kibana'])
$es_nodes_count = count($es_nodes)
@ -54,6 +69,7 @@ if ($plugin_data) {
}
# InfluxDB
$is_influxdb_node = roles_include(['influxdb_grafana', 'primary-influxdb_grafana'])
$influxdb_mode = $plugin_data['influxdb_mode']
$influxdb_nodes = get_nodes_hash_by_roles($network_metadata, ['influxdb_grafana', 'primary-influxdb_grafana'])
$influxdb_nodes_count = count($influxdb_nodes)
@ -127,6 +143,14 @@ if ($plugin_data) {
$calculated_content = inline_template('
---
lma::collector::node_profiles:
controller: <%= @is_controller_node %>
influxdb: <%= @is_influxdb_node %>
elasticsearch: <%= @is_elasticsearch_node %>
rabbitmq: <%= @is_rabbitmq_node %>
mysql: <%= @is_mysql_node %>
base_os: <%= @is_base_os_node %>
<% if @es_is_deployed -%>
lma::collector::elasticsearch::server: <%= @es_server %>
lma::collector::elasticsearch::rest_port: 9200

View File

@ -21,8 +21,9 @@ $mgmt_address = get_network_role_property('management', 'ipaddr')
if hiera('lma::collector::influxdb::server', false) {
$network_metadata = hiera_hash('network_metadata')
$is_elasticsearch_node = roles_include(['elasticsearch_kibana', 'primary-elasticsearch_kibana'])
$is_influxdb_node = roles_include(['influxdb_grafana', 'primary-influxdb_grafana'])
$node_profiles = hiera_hash('lma::collector::node_profiles')
$is_elasticsearch_node = $node_profiles['elasticsearch']
$is_influxdb_node = $node_profiles['influxdb']
if $is_elasticsearch_node {
$process_matches = [{name => 'elasticsearch', regex => 'java'}]