Fix deployment when using network templates
InfluxDB and Grafana can be deployed on any network thanks to network templates. This change removes all the hard-coded dependencies on the management network. All port numbers for InfluxDB and Grafana are also moved to Hiera to make it easier to customize if needed. Closes-Bug: #1577358 Related-Bug: #1514365 Change-Id: I9b8f692151dec28963f1acbc93bc7d92925cbeae
This commit is contained in:
parent
387bad0a55
commit
8528e5ae47
@ -33,7 +33,7 @@ firewall { '002 accept related established rules':
|
||||
action => 'accept',
|
||||
}
|
||||
|
||||
firewall {'020 ssh':
|
||||
firewall { '020 ssh':
|
||||
port => 22,
|
||||
proto => 'tcp',
|
||||
action => 'accept',
|
||||
@ -52,13 +52,13 @@ firewall { '114 corosync-output':
|
||||
}
|
||||
|
||||
firewall { '200 influxdb':
|
||||
port => [8083, 8086, 8088, 8091],
|
||||
port => [8083, hiera('lma::influxdb::influxdb_port'), 8088, 8091],
|
||||
proto => 'tcp',
|
||||
action => 'accept',
|
||||
}
|
||||
|
||||
firewall { '201 grafana':
|
||||
port => 8000,
|
||||
port => hiera('lma::influxdb::grafana_port'),
|
||||
proto => 'tcp',
|
||||
action => 'accept',
|
||||
}
|
||||
|
@ -14,8 +14,6 @@
|
||||
|
||||
notice('fuel-plugin-influxdb-grafana: grafana.pp')
|
||||
|
||||
$mgmt_vip = hiera('lma::influxdb::vip')
|
||||
|
||||
$influxdb_grafana = hiera('influxdb_grafana')
|
||||
$db_mode = $influxdb_grafana['mysql_mode']
|
||||
$db_name = $influxdb_grafana['mysql_dbname']
|
||||
@ -39,7 +37,6 @@ case $db_mode {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class {'lma_monitoring_analytics::grafana':
|
||||
db_host => $db_host,
|
||||
db_name => $db_name,
|
||||
@ -47,5 +44,6 @@ class {'lma_monitoring_analytics::grafana':
|
||||
db_password => $db_password,
|
||||
admin_username => $admin_username,
|
||||
admin_password => $admin_password,
|
||||
domain => $mgmt_vip,
|
||||
domain => hiera('lma::influxdb::vip'),
|
||||
http_port => hiera('lma::influxdb::grafana_port')
|
||||
}
|
||||
|
@ -16,10 +16,12 @@ notice('fuel-plugin-influxdb-grafana: grafana_configuration.pp')
|
||||
|
||||
$deployment_id = hiera('deployment_id')
|
||||
$master_ip = hiera('master_ip')
|
||||
$mgmt_vip = hiera('lma::influxdb::vip')
|
||||
$vip = hiera('lma::influxdb::vip')
|
||||
$grafana_port = hiera('lma::influxdb::grafana_port')
|
||||
$influxdb_port = hiera('lma::influxdb::influxdb_port')
|
||||
$grafana_link_data = "{\"title\":\"Grafana\",\
|
||||
\"description\":\"Dashboard for visualizing metrics\",\
|
||||
\"url\":\"http://${mgmt_vip}:8000/\"}"
|
||||
\"url\":\"http://${vip}:${grafana_port}/\"}"
|
||||
$grafana_link_created_file = '/var/cache/grafana_link_created'
|
||||
$influxdb_grafana = hiera('influxdb_grafana')
|
||||
|
||||
@ -45,13 +47,13 @@ $import_elasticsearch = $elasticsearch_mode ? {
|
||||
|
||||
grafana_datasource { 'lma':
|
||||
ensure => present,
|
||||
url => "http://${mgmt_vip}:8086",
|
||||
url => "http://${vip}:${influxdb_port}",
|
||||
user => $influxdb_username,
|
||||
password => $influxdb_password,
|
||||
database => $influxdb_database,
|
||||
access_mode => 'proxy',
|
||||
is_default => true,
|
||||
grafana_url => "http://${mgmt_vip}:8000",
|
||||
grafana_url => "http://${vip}:${grafana_port}",
|
||||
grafana_user => $admin_username,
|
||||
grafana_password => $admin_password,
|
||||
}
|
||||
@ -59,7 +61,7 @@ grafana_datasource { 'lma':
|
||||
class {'lma_monitoring_analytics::grafana_dashboards':
|
||||
admin_username => $admin_username,
|
||||
admin_password => $admin_password,
|
||||
host => $mgmt_vip,
|
||||
host => $vip,
|
||||
import_elasticsearch => $import_elasticsearch,
|
||||
import_influxdb => $import_influxdb,
|
||||
require => Grafana_datasource['lma'],
|
||||
|
@ -14,10 +14,11 @@
|
||||
|
||||
notice('fuel-plugin-influxdb-grafana: haproxy.pp')
|
||||
|
||||
$cluster_nodes = hiera('lma::influxdb::backends')
|
||||
$nodes_ips = hiera('lma::influxdb::raft_nodes')
|
||||
$nodes_names = prefix(range(1, size($nodes_ips)), 'server_')
|
||||
$stats_port = '1000'
|
||||
$influxdb_port = '8086'
|
||||
$grafana_port = '8000'
|
||||
$influxdb_port = hiera('lma::influxdb::influxdb_port')
|
||||
$grafana_port = hiera('lma::influxdb::grafana_port')
|
||||
|
||||
Openstack::Ha::Haproxy_service {
|
||||
balancermember_options => 'check',
|
||||
@ -25,8 +26,8 @@ Openstack::Ha::Haproxy_service {
|
||||
internal_virtual_ip => hiera('lma::influxdb::vip'),
|
||||
public => false,
|
||||
public_virtual_ip => undef,
|
||||
ipaddresses => values($cluster_nodes),
|
||||
server_names => keys($cluster_nodes),
|
||||
ipaddresses => $nodes_ips,
|
||||
server_names => $nodes_names,
|
||||
}
|
||||
|
||||
openstack::ha::haproxy_service { 'influxdb':
|
||||
|
@ -14,49 +14,46 @@
|
||||
|
||||
notice('fuel-plugin-influxdb-grafana: hiera.pp')
|
||||
|
||||
$hiera_dir = '/etc/hiera/plugins'
|
||||
$plugin_name = 'influxdb_grafana'
|
||||
$plugin_yaml = "${plugin_name}.yaml"
|
||||
$vip_name = 'influxdb'
|
||||
# Initialize network-related variables
|
||||
$network_scheme = hiera('network_scheme')
|
||||
$network_metadata = hiera('network_metadata')
|
||||
prepare_network_config($network_scheme)
|
||||
|
||||
$network_metadata = hiera_hash('network_metadata')
|
||||
$influxdb_grafana = hiera('influxdb_grafana')
|
||||
$hiera_file = '/etc/hiera/plugins/influxdb_grafana.yaml'
|
||||
$listen_address = get_network_role_property('influxdb_vip', 'ipaddr')
|
||||
$vip_name = 'influxdb'
|
||||
if ! $network_metadata['vips'][$vip_name] {
|
||||
fail('InfluxDB VIP is not defined')
|
||||
}
|
||||
|
||||
$influxdb_leader = get_nodes_hash_by_roles($network_metadata, ["primary-${plugin_name}"])
|
||||
$influxdb_others = get_nodes_hash_by_roles($network_metadata, [$plugin_name])
|
||||
$influxdb_nodes = merge($influxdb_leader, $influxdb_others)
|
||||
$influxdb_address_map = get_node_to_ipaddr_map_by_network_role($influxdb_nodes, 'influxdb_vip')
|
||||
|
||||
$influxdb_vip = $network_metadata['vips'][$vip_name]['ipaddr']
|
||||
|
||||
$corosync_roles = [$plugin_name, "primary-${plugin_name}"]
|
||||
$influxdb_leader = get_nodes_hash_by_roles($network_metadata, ['primary-influxdb_grafana'])
|
||||
$leader_ip_addresses = values(get_node_to_ipaddr_map_by_network_role($influxdb_leader, 'influxdb_vip'))
|
||||
$leader_ip_address = $leader_ip_addresses[0]
|
||||
|
||||
$influxdb_others = get_nodes_hash_by_roles($network_metadata, ['influxdb_grafana'])
|
||||
$others_ip_addresses = sort(values(get_node_to_ipaddr_map_by_network_role($influxdb_others, 'influxdb_vip')))
|
||||
|
||||
$calculated_content = inline_template('
|
||||
---
|
||||
lma::influxdb::data_dir: "<%= @influxdb_grafana["data_dir"] %>"
|
||||
lma::influxdb::listen_address: "<%= @listen_address %>"
|
||||
lma::influxdb::influxdb_port: 8086
|
||||
lma::influxdb::grafana_port: 8000
|
||||
lma::influxdb::raft_leader: <%= @leader_ip_address == @listen_address ? "true" : "false" %>
|
||||
lma::influxdb::raft_nodes: # The first node is the leader
|
||||
- <%= @influxdb_leader.keys.first %>
|
||||
<% @influxdb_others.keys.sort.each do |k| -%>
|
||||
- <%= k %>
|
||||
- "<%= @leader_ip_address %>"
|
||||
<% @others_ip_addresses.each do |x| -%>
|
||||
- "<%= x %>"
|
||||
<% end -%>
|
||||
|
||||
lma::influxdb::backends:
|
||||
<% @influxdb_address_map.keys.sort.each do |k| -%>
|
||||
<%= k %>: <%= @influxdb_address_map[k] %>
|
||||
<% end -%>
|
||||
|
||||
lma::influxdb::vip: <%= @influxdb_vip %>
|
||||
|
||||
lma::corosync_roles:
|
||||
<% @corosync_roles.sort.each do |crole| -%>
|
||||
- <%= crole %>
|
||||
<% end -%>
|
||||
|
||||
- primary-influxdb_grafana
|
||||
- influxdb_grafana
|
||||
')
|
||||
|
||||
file { "${hiera_dir}/${plugin_yaml}":
|
||||
file { $hiera_file:
|
||||
ensure => file,
|
||||
content => "${calculated_content}\n",
|
||||
content => $calculated_content,
|
||||
}
|
||||
|
@ -14,15 +14,11 @@
|
||||
|
||||
notice('fuel-plugin-influxdb-grafana: influxdb.pp')
|
||||
|
||||
$influxdb_grafana = hiera('influxdb_grafana')
|
||||
$directory = $influxdb_grafana['data_dir']
|
||||
$data_directory = hiera('lma::influxdb::data_dir')
|
||||
|
||||
# We set raft_nodes only for non primary node. The primary node will be
|
||||
# We set raft_nodes only for the non-primary node. The primary node will be
|
||||
# started as the first node and it will be the leader of the Raft cluster.
|
||||
$current_roles = hiera('roles')
|
||||
$is_primary = member($current_roles, 'primary-influxdb_grafana')
|
||||
|
||||
if $is_primary {
|
||||
if hiera('lma::influxdb::raft_leader') {
|
||||
$raft_nodes = undef
|
||||
} else {
|
||||
$raft_nodes = hiera('lma::influxdb::raft_nodes')
|
||||
@ -34,7 +30,7 @@ user { 'influxdb':
|
||||
shell => '/usr/sbin/nologin',
|
||||
}
|
||||
|
||||
file { $directory:
|
||||
file { $data_directory:
|
||||
ensure => 'directory',
|
||||
owner => 'influxdb',
|
||||
group => 'influxdb',
|
||||
@ -42,10 +38,11 @@ file { $directory:
|
||||
}
|
||||
|
||||
# We cannot mix IP addresses and hostnames otherwise the Raft cluster won't
|
||||
# start. We decide to stick with hostnames because they are more meaningful.
|
||||
# start. We have to stick with IP addresses because hostnames map to the
|
||||
# managament network space.
|
||||
class { 'lma_monitoring_analytics::influxdb':
|
||||
base_directory => $influxdb_grafana['data_dir'],
|
||||
hostname => hiera('node_name'),
|
||||
base_directory => $data_directory,
|
||||
hostname => hiera('lma::influxdb::listen_address'),
|
||||
raft_nodes => $raft_nodes,
|
||||
require => File[$directory],
|
||||
require => File[$data_directory],
|
||||
}
|
||||
|
@ -14,8 +14,11 @@
|
||||
|
||||
notice('fuel-plugin-influxdb-grafana: influxdb_configuration.pp')
|
||||
|
||||
prepare_network_config(hiera('network_scheme', {}))
|
||||
$mgmt_address = get_network_role_property('management', 'ipaddr')
|
||||
# We are using the local IP address instead of the VIP to avoid race condition
|
||||
# between the creation of the admin user and the normal user.
|
||||
$local_address = hiera('lma::influxdb::listen_address')
|
||||
$local_port = hiera('lma::influxdb::influxdb_port')
|
||||
$influxdb_url = "http://${local_address}:${local_port}"
|
||||
|
||||
$influxdb_grafana = hiera('influxdb_grafana')
|
||||
|
||||
@ -29,23 +32,21 @@ $replication_factor = $influxdb_grafana['replication_factor']
|
||||
lma_monitoring_analytics::influxdb_user { $admin_user:
|
||||
password => $admin_password,
|
||||
admin_role => true,
|
||||
# We are using the management IP instead of the VIP to avoid race condition
|
||||
# between the creation of the admin user and the normal user.
|
||||
influxdb_url => "http://${mgmt_address}:8086",
|
||||
influxdb_url => $influxdb_url,
|
||||
}
|
||||
|
||||
lma_monitoring_analytics::influxdb_user { $username:
|
||||
admin_user => $admin_user,
|
||||
admin_password => $admin_password,
|
||||
password => $password,
|
||||
influxdb_url => "http://${mgmt_address}:8086",
|
||||
influxdb_url => $influxdb_url,
|
||||
require => Lma_monitoring_analytics::Influxdb_user[$admin_user],
|
||||
}
|
||||
|
||||
lma_monitoring_analytics::influxdb_database { 'lma':
|
||||
admin_user => $admin_user,
|
||||
admin_password => $admin_password,
|
||||
influxdb_url => "http://${mgmt_address}:8086",
|
||||
influxdb_url => $influxdb_url,
|
||||
db_user => $username,
|
||||
db_password => $password,
|
||||
retention_period => $retention_period,
|
||||
|
@ -22,13 +22,15 @@ class lma_monitoring_analytics::grafana (
|
||||
$admin_username = undef,
|
||||
$admin_password = undef,
|
||||
$domain = $lma_monitoring_analytics::params::grafana_domain,
|
||||
$http_port = $lma_monitoring_analytics::params::listen_port,
|
||||
$http_address = $lma_monitoring_analytics::params::grafana_address,
|
||||
$http_port = $lma_monitoring_analytics::params::grafana_port,
|
||||
) inherits lma_monitoring_analytics::params {
|
||||
|
||||
validate_string($db_host)
|
||||
validate_string($db_name)
|
||||
validate_string($db_username)
|
||||
validate_string($db_password)
|
||||
validate_string($http_address)
|
||||
|
||||
# If no port is specified Grafana will not start. So we check if the
|
||||
# variable contains a port value and if not, we add ':3306'.
|
||||
@ -44,8 +46,9 @@ class lma_monitoring_analytics::grafana (
|
||||
manage_package_repo => false,
|
||||
cfg => {
|
||||
server => {
|
||||
http_port => $http_port,
|
||||
domain => $domain,
|
||||
http_address => $http_address,
|
||||
http_port => $http_port,
|
||||
domain => $domain,
|
||||
},
|
||||
database => {
|
||||
type => 'mysql',
|
||||
|
@ -18,7 +18,7 @@ class lma_monitoring_analytics::grafana_dashboards (
|
||||
$admin_username,
|
||||
$admin_password,
|
||||
$host = $lma_monitoring_analytics::params::grafana_domain,
|
||||
$port = $lma_monitoring_analytics::params::listen_port,
|
||||
$port = $lma_monitoring_analytics::params::grafana_port,
|
||||
$import_influxdb = false,
|
||||
$import_elasticsearch = false,
|
||||
) inherits lma_monitoring_analytics::params {
|
||||
|
@ -15,10 +15,11 @@
|
||||
# == Class lma_monitoring_analytics::params
|
||||
|
||||
class lma_monitoring_analytics::params {
|
||||
$listen_port = 8000
|
||||
$influxdb_url = 'http://localhost:8086'
|
||||
$influxdb_dir = '/var/lib/influxdb'
|
||||
$influxdb_retention_period = 'INF'
|
||||
$influxdb_replication_factor = 1
|
||||
$grafana_domain = 'localhost'
|
||||
$grafana_address = ''
|
||||
$grafana_port = 8000
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user