Browse Source

Merge "Add SNMP related packages"

Jenkins 2 years ago
parent
commit
59866c3fa0

+ 8
- 2
deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/manifests/init.pp View File

@@ -18,7 +18,8 @@ class plugin_zabbix_snmptrapd {
18 18
   include plugin_zabbix_snmptrapd::params
19 19
 
20 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 24
   $plugin_settings  = hiera('zabbix_snmptrapd')
24 25
 
@@ -41,6 +42,11 @@ class plugin_zabbix_snmptrapd {
41 42
     port   => $server_port,
42 43
   }
43 44
 
45
+  package { $utils_pkg_name:
46
+    ensure => 'present',
47
+    name   => $utils_pkg_name,
48
+  }
49
+
44 50
   # The following resource overwrites default initscript for snmptrapd.
45 51
   # Version provided by the plugin supports namespaces.
46 52
   # If there is a need to run snmptrad in a specific namespace,
@@ -51,7 +57,7 @@ class plugin_zabbix_snmptrapd {
51 57
     group   => 'root',
52 58
     mode    => '0755',
53 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 61
     notify  => Service[$service_name],
56 62
   }
57 63
 

+ 6
- 4
deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/manifests/params.pp View File

@@ -17,12 +17,14 @@ class plugin_zabbix_snmptrapd::params {
17 17
 
18 18
   case $::osfamily {
19 19
     'Debian': {
20
-      $service_name = 'snmpd'
21
-      $package_name = 'snmpd'
20
+      $service_name     = 'snmpd'
21
+      $daemon_pkg_name  = 'snmpd'
22
+      $utils_pkg_name    = 'snmp'
22 23
     }
23 24
     'RedHat': {
24
-      $service_name = 'snmptrapd'
25
-      $package_name = 'net-snmp'
25
+      $service_name     = 'snmptrapd'
26
+      $daemon_pkg_name  = 'net-snmp'
27
+      $utils_pkg_name    = 'snmp'
26 28
     }
27 29
     default: {
28 30
       fail("unsuported osfamily ${::osfamily}, currently Debian and RedHat are the only supported platforms")

+ 46
- 0
functions.sh View File

@@ -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
+
16
+set -eux
17
+
18
+ROOT="$(dirname "$(readlink -f "$0")")"
19
+MODULES_DIR="${ROOT}"/deployment_scripts/puppet/modules
20
+RPM_REPO="${ROOT}"/repositories/centos/
21
+DEB_REPO="${ROOT}"/repositories/ubuntu/
22
+
23
+# Download RPM or DEB packages and store them in the local repository directory
24
+function 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
41
+function 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
+

+ 15
- 7
pre_build_hook View File

@@ -2,13 +2,17 @@
2 2
 set -eux
3 3
 
4 4
 ROOT="$(dirname `readlink -f $0`)"
5
+
6
+. "${ROOT}"/functions.sh
7
+
8
+# Puppet manifests
9
+# Dependency for SNMP
10
+SNMP_TARBALL_URL="https://forgeapi.puppetlabs.com/v3/files/razorsedge-snmp-3.3.1.tar.gz"
11
+
5 12
 RPM_REPO="${ROOT}"/repositories/centos
6 13
 DEB_REPO="${ROOT}"/repositories/ubuntu
7 14
 MODULES="${ROOT}"/deployment_scripts/puppet/modules
8
-SNMP_TARBALL_URL="https://forgeapi.puppetlabs.com/v3/files/razorsedge-snmp-3.3.1.tar.gz"
9
-mkdir -p $RPM_REPO
10
-mkdir -p $DEB_REPO
11
-mkdir -p $MODULES
15
+mkdir -p $RPM_REPO $DEB_REPO
12 16
 
13 17
 # Downloads needed RPM or DEB packages
14 18
 function download {
@@ -25,7 +29,11 @@ function download {
25 29
     done
26 30
 }
27 31
 
28
-#download snmp module
29
-mkdir -p "${MODULES}/snmp"
30
-wget -qO- "${SNMP_TARBALL_URL}" | tar -C "${MODULES}/snmp" --strip-components=1 -xz
32
+download deb http://archive.ubuntu.com/ubuntu/pool/universe/n/net-snmp/libsnmp-perl_5.7.2~dfsg-8.1ubuntu3.1_amd64.deb \
33
+             http://archive.ubuntu.com/ubuntu/pool/main/n/net-snmp/snmpd_5.7.2~dfsg-8.1ubuntu3.1_amd64.deb \
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
39
+download_puppet_module "snmp" "$SNMP_TARBALL_URL"

Loading…
Cancel
Save