Add support for MOS 9.0

Remove usage of deprecated filter_nodes, node_roles and hiera('nodes') functions
Tested on MOS 7.0, 8.0 and 9.0-4014

Change-Id: Idc863b0ab9420f1b6bb4f14c573255b44d640f33
This commit is contained in:
Olivier Bourdon 2016-04-07 13:13:54 +02:00
parent 9e3199d663
commit aebba74777
4 changed files with 53 additions and 25 deletions

View File

@ -13,19 +13,36 @@
# License for the specific language governing permissions and limitations
# under the License.
#
$nodes_hash = hiera('nodes')
$fuel_version = 0 + hiera('fuel_version')
$network_metadata = hiera_hash('network_metadata')
$primary_controller_nodes = get_nodes_hash_by_roles($network_metadata, ['primary-controller'])
$controllers = get_nodes_hash_by_roles($network_metadata, ['primary-controller', 'controller'])
$controller_internal_addresses = get_node_to_ipaddr_map_by_network_role($controllers, 'management')
$controller_nodes = ipsort(values($controller_internal_addresses))
$hostinfo = $network_metadata['nodes'][$::hostname]
$netinfo = $hostinfo['network_roles']
$internal_address = $netinfo['management']
$public_address = $netinfo['ex']
$swift_address = $netinfo['storage']
$primary_controller_nodes = filter_nodes($nodes_hash,'role','primary-controller')
$controllers = concat($primary_controller_nodes, filter_nodes($nodes_hash,'role','controller'))
$controller_internal_addresses = nodes_to_hash($controllers,'name','internal_address')
$controller_nodes = ipsort(values($controller_internal_addresses))
$node_data = filter_nodes($nodes_hash,'fqdn',$::fqdn)
$internal_address = join(values(nodes_to_hash($node_data,'name','internal_address')))
$public_address = join(values(nodes_to_hash($node_data,'name','public_address')))
$swift_address = join(values(nodes_to_hash($node_data,'name','storage_address')))
if $fuel_version < 8.0 {
$cur_node_roles = node_roles(hiera_array('nodes'), hiera('uid'))
$is_base_os = member($cur_node_roles, 'base-os')
$is_virt = member($cur_node_roles, 'virt')
$is_controller = member($cur_node_roles, 'controller') or
member($cur_node_roles, 'primary-controller')
$roles_nb = size($cur_node_roles)
} else {
$is_base_os = roles_include(['base-os'])
$is_virt = roles_include(['virt'])
$is_controller = roles_include(['controller', 'primary-controller'])
$roles_nb = size($network_metadata['nodes'][$::hostname]['node_roles'])
}
class { 'plugin_zabbix::monitoring':
server_ips => $controller_nodes,
roles => node_roles(hiera('nodes'), hiera('uid')),
server_ips => $controller_nodes,
roles_nb => $roles_nb,
has_role_baseos => $is_base_os,
has_role_virt => $is_virt,
has_role_controller => $is_controller,
}

View File

@ -24,11 +24,11 @@ class plugin_zabbix::ha::haproxy {
$public_vip = hiera('public_vip')
$ssl = hiera('public_ssl')
$zabbix_vip = $plugin_zabbix::params::server_ip
$nodes_hash = hiera('nodes')
$primary_controller_nodes = filter_nodes($nodes_hash,'role','primary-controller')
$controllers = concat($primary_controller_nodes, filter_nodes($nodes_hash,'role','controller'))
$server_names = filter_hash($controllers, 'name')
$ipaddresses = filter_hash($controllers, 'internal_address')
$network_metadata = hiera_hash('network_metadata')
$primary_controller_nodes = get_nodes_hash_by_roles($network_metadata, ['primary-controller'])
$controllers = get_nodes_hash_by_roles($network_metadata, ['primary-controller', 'controller'])
$server_names = keys($controllers)
$ipaddresses = values(get_node_to_ipaddr_map_by_network_role($controllers, 'management'))
Plugin_zabbix::Ha::Haproxy_service {
server_names => $server_names,
ipaddresses => $ipaddresses,

View File

@ -15,18 +15,19 @@
#
class plugin_zabbix::monitoring(
$server_ips = undef,
$roles = [],
$roles_nb = 1,
$has_role_baseos = false,
$has_role_virt = false,
$has_role_controller = false,
) {
# This should evaluate to false on base-os or virt only nodes
# and therefore Zabbix should not be installed neither configured in this case
$zabbix_agent_not_supported = (member($roles, 'base-os') or member($roles, 'virt')) and (size($roles) == 1)
$zabbix_agent_not_supported = ($has_role_baseos or $has_role_virt) and ($roles_nb == 1)
if $zabbix_agent_not_supported {
notice('Skipping Zabbix configuration for base-os or virt only host')
} else {
validate_array($roles)
include plugin_zabbix::params
$api_hash = $plugin_zabbix::params::api_hash
@ -96,14 +97,14 @@ class plugin_zabbix::monitoring(
api => $api_hash,
}
if ! member($roles, 'controller') and ! member($roles, 'primary-controller') {
if ! $has_role_controller {
# default way to check NTP binding
plugin_zabbix_template_link { "${plugin_zabbix::params::host_name} Template NTP binding":
host => $plugin_zabbix::params::host_name,
template => 'Template NTP binding',
api => $api_hash,
}
}else{
} else {
plugin_zabbix_template_link { "${plugin_zabbix::params::host_name} Template OS Controller":
host => $plugin_zabbix::params::host_name,
template => 'Template OS Controller',

View File

@ -2,11 +2,11 @@
name: zabbix_monitoring
title: Zabbix for Fuel
# Plugin version
version: 2.5.0
version: 2.6.0
# Description
description: Enables Zabbix Monitoring. For information how to access Zabbix UI refer to Zabbix plugin User Guide. Zabbix URL schema is http://<VIP>/zabbix
# Required fuel version
fuel_version: ['7.0', '8.0']
fuel_version: ['7.0', '8.0', '9.0']
# Groups
groups: ['monitoring']
# Licenses
@ -28,6 +28,16 @@ releases:
mode: ['ha']
deployment_scripts_path: deployment_scripts/
repository_path: repositories/ubuntu
- os: ubuntu
version: liberty-9.0
mode: ['ha']
deployment_scripts_path: deployment_scripts/
repository_path: repositories/ubuntu
- os: ubuntu
version: mitaka-9.0
mode: ['ha']
deployment_scripts_path: deployment_scripts/
repository_path: repositories/ubuntu
# Version of plugin package
package_version: '3.0.0'