summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Bourdon <obourdon@mirantis.com>2016-07-12 10:46:02 +0200
committerOlivier Bourdon <obourdon@mirantis.com>2016-07-26 14:32:45 +0000
commitc179e925cb69abe270be1557f50f670248213e70 (patch)
tree8bd65a1b175ca232d526dafa57668e60632e155e
parent704cd712521973769e639c7e85fb022c8d462a35 (diff)
Add SNMP related packages
Notes
Notes (review): Code-Review+2: Swann Croiset <scroiset@mirantis.com> Code-Review+2: Olivier Bourdon <obourdon@mirantis.com> Workflow+1: Olivier Bourdon <obourdon@mirantis.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Wed, 27 Jul 2016 07:33:18 +0000 Reviewed-on: https://review.openstack.org/340782 Project: openstack/fuel-plugin-zabbix-snmptrapd Branch: refs/heads/master
-rw-r--r--deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/manifests/init.pp10
-rw-r--r--deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/manifests/params.pp10
-rw-r--r--functions.sh46
-rwxr-xr-xpre_build_hook22
4 files changed, 75 insertions, 13 deletions
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 62a096e..343dc8c 100644
--- a/deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/manifests/init.pp
+++ b/deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/manifests/init.pp
@@ -18,7 +18,8 @@ class plugin_zabbix_snmptrapd {
18 include plugin_zabbix_snmptrapd::params 18 include plugin_zabbix_snmptrapd::params
19 19
20 $service_name = $plugin_zabbix_snmptrapd::params::service_name 20 $service_name = $plugin_zabbix_snmptrapd::params::service_name
21 $package_name = $plugin_zabbix_snmptrapd::params::package_name 21 $daemon_pkg_name = $plugin_zabbix_snmptrapd::params::daemon_pkg_name
22 $utils_pkg_name = $plugin_zabbix_snmptrapd::params::utils_pkg_name
22 23
23 $plugin_settings = hiera('zabbix_snmptrapd') 24 $plugin_settings = hiera('zabbix_snmptrapd')
24 25
@@ -41,6 +42,11 @@ class plugin_zabbix_snmptrapd {
41 port => $server_port, 42 port => $server_port,
42 } 43 }
43 44
45 package { $utils_pkg_name:
46 ensure => 'present',
47 name => $utils_pkg_name,
48 }
49
44 # The following resource overwrites default initscript for snmptrapd. 50 # The following resource overwrites default initscript for snmptrapd.
45 # Version provided by the plugin supports namespaces. 51 # Version provided by the plugin supports namespaces.
46 # If there is a need to run snmptrad in a specific namespace, 52 # If there is a need to run snmptrad in a specific namespace,
@@ -51,7 +57,7 @@ class plugin_zabbix_snmptrapd {
51 group => 'root', 57 group => 'root',
52 mode => '0755', 58 mode => '0755',
53 source => "puppet:///modules/plugin_zabbix_snmptrapd/initscripts/${service_name}", 59 source => "puppet:///modules/plugin_zabbix_snmptrapd/initscripts/${service_name}",
54 require => Package[$package_name], 60 require => [Package[$daemon_pkg_name], Package[$utils_pkg_name]],
55 notify => Service[$service_name], 61 notify => Service[$service_name],
56 } 62 }
57 63
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 bf8f653..44f0b66 100644
--- a/deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/manifests/params.pp
+++ b/deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/manifests/params.pp
@@ -17,12 +17,14 @@ class plugin_zabbix_snmptrapd::params {
17 17
18 case $::osfamily { 18 case $::osfamily {
19 'Debian': { 19 'Debian': {
20 $service_name = 'snmpd' 20 $service_name = 'snmpd'
21 $package_name = 'snmpd' 21 $daemon_pkg_name = 'snmpd'
22 $utils_pkg_name = 'snmp'
22 } 23 }
23 'RedHat': { 24 'RedHat': {
24 $service_name = 'snmptrapd' 25 $service_name = 'snmptrapd'
25 $package_name = 'net-snmp' 26 $daemon_pkg_name = 'net-snmp'
27 $utils_pkg_name = 'snmp'
26 } 28 }
27 default: { 29 default: {
28 fail("unsuported osfamily ${::osfamily}, currently Debian and RedHat are the only supported platforms") 30 fail("unsuported osfamily ${::osfamily}, currently Debian and RedHat are the only supported platforms")
diff --git a/functions.sh b/functions.sh
new file mode 100644
index 0000000..cf9e407
--- /dev/null
+++ b/functions.sh
@@ -0,0 +1,46 @@
1#!/bin/bash
2# Copyright 2015 Mirantis, Inc.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16set -eux
17
18ROOT="$(dirname "$(readlink -f "$0")")"
19MODULES_DIR="${ROOT}"/deployment_scripts/puppet/modules
20RPM_REPO="${ROOT}"/repositories/centos/
21DEB_REPO="${ROOT}"/repositories/ubuntu/
22
23# Download RPM or DEB packages and store them in the local repository directory
24function download_package {
25 while [ $# -gt 0 ]; do
26 if [[ "$1" == *.deb ]]; then
27 REPO=$DEB_REPO
28 elif [[ "$1" == *.rpm ]]; then
29 REPO=$RPM_REPO
30 else
31 echo "Invalid URL for download_package(): $1"
32 fi
33
34 FILE=$(basename "$1")
35 wget -qO - "$1" > "$REPO"/"$FILE"
36 shift
37 done
38}
39
40# Download official Puppet module and store it in the local directory
41function download_puppet_module {
42 rm -rf "${MODULES_DIR:?}"/"$1"
43 mkdir -p "${MODULES_DIR}"/"$1"
44 wget -qO- "$2" | tar -C "${MODULES_DIR}/$1" --strip-components=1 -xz
45}
46
diff --git a/pre_build_hook b/pre_build_hook
index 7f3560a..7bf1be9 100755
--- a/pre_build_hook
+++ b/pre_build_hook
@@ -2,13 +2,17 @@
2set -eux 2set -eux
3 3
4ROOT="$(dirname `readlink -f $0`)" 4ROOT="$(dirname `readlink -f $0`)"
5
6. "${ROOT}"/functions.sh
7
8# Puppet manifests
9# Dependency for SNMP
10SNMP_TARBALL_URL="https://forgeapi.puppetlabs.com/v3/files/razorsedge-snmp-3.3.1.tar.gz"
11
5RPM_REPO="${ROOT}"/repositories/centos 12RPM_REPO="${ROOT}"/repositories/centos
6DEB_REPO="${ROOT}"/repositories/ubuntu 13DEB_REPO="${ROOT}"/repositories/ubuntu
7MODULES="${ROOT}"/deployment_scripts/puppet/modules 14MODULES="${ROOT}"/deployment_scripts/puppet/modules
8SNMP_TARBALL_URL="https://forgeapi.puppetlabs.com/v3/files/razorsedge-snmp-3.3.1.tar.gz" 15mkdir -p $RPM_REPO $DEB_REPO
9mkdir -p $RPM_REPO
10mkdir -p $DEB_REPO
11mkdir -p $MODULES
12 16
13# Downloads needed RPM or DEB packages 17# Downloads needed RPM or DEB packages
14function download { 18function download {
@@ -25,7 +29,11 @@ function download {
25 done 29 done
26} 30}
27 31
28#download snmp module 32download deb http://archive.ubuntu.com/ubuntu/pool/universe/n/net-snmp/libsnmp-perl_5.7.2~dfsg-8.1ubuntu3.1_amd64.deb \
29mkdir -p "${MODULES}/snmp" 33 http://archive.ubuntu.com/ubuntu/pool/main/n/net-snmp/snmpd_5.7.2~dfsg-8.1ubuntu3.1_amd64.deb \
30wget -qO- "${SNMP_TARBALL_URL}" | tar -C "${MODULES}/snmp" --strip-components=1 -xz 34 http://archive.ubuntu.com/ubuntu/pool/main/n/net-snmp/snmp_5.7.2~dfsg-8.1ubuntu3.1_amd64.deb \
35 http://archive.ubuntu.com/ubuntu/pool/universe/s/snmptt/snmptt_1.4-1_all.deb
36
31 37
38# Install puppet manifests
39download_puppet_module "snmp" "$SNMP_TARBALL_URL"