From 1e6fe34139d920df69fa13d2563d40c6ecb630e8 Mon Sep 17 00:00:00 2001 From: Piotr Misiak Date: Wed, 12 Aug 2015 11:40:02 +0200 Subject: [PATCH] bind to VIP reserved for Zabbix instead of management VIP do not overwrite initscripts with the network namespace support version change compatible MOS version Change-Id: I991d21b07d416720cf2225871e297fd039fa0950 --- .../puppet/manifests/primary_controller.pp | 16 -------- .../files/initscripts/snmpd | 2 + .../files/initscripts/snmptrapd | 1 + .../plugin_zabbix_snmptrapd/manifests/init.pp | 39 ++++++++++++------- .../manifests/params.pp | 3 -- .../manifests/primary_controller.pp | 24 ------------ metadata.yaml | 8 ++-- pre_build_hook | 6 +-- tasks.yaml | 7 ---- 9 files changed, 36 insertions(+), 70 deletions(-) delete mode 100644 deployment_scripts/puppet/manifests/primary_controller.pp delete mode 100644 deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/manifests/primary_controller.pp diff --git a/deployment_scripts/puppet/manifests/primary_controller.pp b/deployment_scripts/puppet/manifests/primary_controller.pp deleted file mode 100644 index ea84d2d..0000000 --- a/deployment_scripts/puppet/manifests/primary_controller.pp +++ /dev/null @@ -1,16 +0,0 @@ -# -# Copyright 2015 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -include plugin_zabbix_snmptrapd::primary_controller diff --git a/deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/files/initscripts/snmpd b/deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/files/initscripts/snmpd index 3477079..1141077 100755 --- a/deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/files/initscripts/snmpd +++ b/deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/files/initscripts/snmpd @@ -42,12 +42,14 @@ IP_BINARY="/sbin/ip" SNMPD_BINARY="/usr/sbin/snmpd" SNMPD_PID="/run/snmpd.pid" +#run snmpd process in the following namespace: SNMPDNS="haproxy" SNMPDRUN="yes" SNMPDOPTS="-Lsd -Lf /dev/null -p $SNMPD_PID" TRAPD_BINARY="/usr/sbin/snmptrapd" TRAPD_PID="/run/snmptrapd.pid" +#run snmptrapd process in the following namespace: TRAPDNS="haproxy" TRAPDRUN="no" TRAPDOPTS="-Lsd -p $TRAPD_PID" diff --git a/deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/files/initscripts/snmptrapd b/deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/files/initscripts/snmptrapd index b5ea24b..333186a 100755 --- a/deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/files/initscripts/snmptrapd +++ b/deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/files/initscripts/snmptrapd @@ -40,6 +40,7 @@ # source function library . /etc/init.d/functions +#run service in the following network namespace: NS="haproxy" OPTIONS="-Lsd -p /var/run/snmptrapd.pid" if [ -e /etc/sysconfig/snmptrapd ]; then diff --git a/deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/manifests/init.pp b/deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/manifests/init.pp index a4e15a7..510a1d1 100644 --- a/deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/manifests/init.pp +++ b/deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/manifests/init.pp @@ -17,14 +17,17 @@ class plugin_zabbix_snmptrapd { include plugin_zabbix_snmptrapd::params - $service_name = $plugin_zabbix_snmptrapd::params::service_name - $package_name = $plugin_zabbix_snmptrapd::params::package_name + $service_name = $plugin_zabbix_snmptrapd::params::service_name + $package_name = $plugin_zabbix_snmptrapd::params::package_name - $server_ip = hiera('management_vip') - $plugin_settings = hiera('zabbix_snmptrapd') + $plugin_settings = hiera('zabbix_snmptrapd') + + $network_metadata = hiera('network_metadata') + $server_ip = $network_metadata['vips']['zabbix_vip_management']['ipaddr'] + $server_port = '162' class { 'snmp': - snmptrapdaddr => ["udp:${server_ip}:162"], + snmptrapdaddr => ["udp:${server_ip}:${server_port}"], ro_community => $plugin_settings['community'], service_ensure => 'stopped', trap_service_ensure => 'running', @@ -32,16 +35,26 @@ class plugin_zabbix_snmptrapd { trap_handlers => ['default /usr/sbin/snmptthandler'], } - file { "/etc/init.d/${service_name}": - ensure => present, - owner => 'root', - group => 'root', - mode => '0755', - source => "puppet:///modules/plugin_zabbix_snmptrapd/initscripts/${service_name}", - require => Package[$package_name], - notify => Service[$service_name], + firewall { '998 snmptrapd': + proto => 'udp', + action => 'accept', + port => $server_port, } + # The following resource overwrites default initscript for snmptrapd. + # Version provided by the plugin supports namespaces. + # If there is a need to run snmptrad in a specific namespace, + # uncomment the following resource and put the correct namespace in the file. + #file { "/etc/init.d/${service_name}": + # ensure => present, + # owner => 'root', + # group => 'root', + # mode => '0755', + # source => "puppet:///modules/plugin_zabbix_snmptrapd/initscripts/${service_name}", + # require => Package[$package_name], + # notify => Service[$service_name], + #} + class { 'plugin_zabbix_snmptrapd::snmptt': require => Class['snmp'], } diff --git a/deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/manifests/params.pp b/deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/manifests/params.pp index 9d0eaa9..13c7bed 100644 --- a/deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/manifests/params.pp +++ b/deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/manifests/params.pp @@ -29,7 +29,4 @@ class plugin_zabbix_snmptrapd::params { } } - $zabbix_cs_name = 'p_zabbix-server' - $vip_cs_name = 'vip__management' - } diff --git a/deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/manifests/primary_controller.pp b/deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/manifests/primary_controller.pp deleted file mode 100644 index e744f3d..0000000 --- a/deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/manifests/primary_controller.pp +++ /dev/null @@ -1,24 +0,0 @@ -# -# Copyright 2015 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -class plugin_zabbix_snmptrapd::primary_controller { - - include plugin_zabbix_snmptrapd::params - - cs_group { 'g_zabbix': - primitives => [$plugin_zabbix_snmptrapd::params::vip_cs_name, $plugin_zabbix_snmptrapd::params::zabbix_cs_name], - } - -} diff --git a/metadata.yaml b/metadata.yaml index 92c79d5..e6e079b 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -6,9 +6,9 @@ version: 1.0.0 # Description description: Gives ability to receive SNMP traps and pass them to Zabbix. # Required fuel version -fuel_version: ['6.1'] +fuel_version: ['7.0'] # Groups -groups: [] +groups: ['monitoring'] # Licenses licenses: ['Apache License, Version 2.0'] # Homepage @@ -19,12 +19,12 @@ authors: ['Dmitry Klenov ', 'Piotr Misiak