You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sw...@apache.org on 2013/04/13 02:50:00 UTC
svn commit: r1467532 - in /incubator/ambari/trunk: ./
ambari-agent/src/main/puppet/modules/hdp-nagios/manifests/
ambari-agent/src/main/puppet/modules/hdp-nagios/manifests/server/
ambari-agent/src/main/puppet/modules/hdp-nagios/templates/ ambari-agent/s...
Author: swagle
Date: Sat Apr 13 00:49:59 2013
New Revision: 1467532
URL: http://svn.apache.org/r1467532
Log:
AMBARI-1923. Allow for users to customize Nagios user accounts. (Sumit Mohanty via swagle)
Added:
incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-nagios/templates/nagios.erb
Modified:
incubator/ambari/trunk/CHANGES.txt
incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-nagios/manifests/params.pp
incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-nagios/manifests/server.pp
incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-nagios/manifests/server/config.pp
incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-nagios/templates/nagios.cfg.erb
incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp/manifests/init.pp
Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1467532&r1=1467531&r2=1467532&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Sat Apr 13 00:49:59 2013
@@ -12,6 +12,9 @@ Trunk (unreleased changes):
NEW FEATURES
+ AMBARI-1923. Allow for users to customize Nagios user accounts.
+ (Sumit Mohanty via swagle)
+
AMBARI-1922. Support not root ssh via a user that can sudo in as root.
(Sumit Mohanty via swagle)
Modified: incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-nagios/manifests/params.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-nagios/manifests/params.pp?rev=1467532&r1=1467531&r2=1467532&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-nagios/manifests/params.pp (original)
+++ incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-nagios/manifests/params.pp Sat Apr 13 00:49:59 2013
@@ -20,15 +20,19 @@
#
class hdp-nagios::params() inherits hdp::params
{
-
- $nagios_user = "nagios"
- $nagios_group = hdp_default("smoke_user_group","nagios")
+ $nagios_default_user = "nagios"
+ $nagios_default_group = "nagios"
+ $nagios_user = hdp_default("nagios_user", $nagios_default_user)
+ $nagios_group = hdp_default("nagios_group",$nagios_default_group)
$conf_dir = hdp_default("nagios_conf_dir","/etc/nagios")
$plugins_dir = "/usr/lib64/nagios/plugins"
$eventhandlers_dir = "/usr/lib64/nagios/eventhandlers" # Does not exist yet
$nagios_pid_dir = "/var/run/nagios"
+ $nagios_log_dir = '/var/log/nagios'
+ $nagios_log_archives_dir = "${nagios_log_dir}/archives"
+
$nagios_obj_dir = hdp_default("nagios_obj_dir","/etc/nagios/objects")
$nagios_var_dir = hdp_default("nagios_var_dir","/var/nagios")
Modified: incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-nagios/manifests/server.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-nagios/manifests/server.pp?rev=1467532&r1=1467531&r2=1467532&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-nagios/manifests/server.pp (original)
+++ incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-nagios/manifests/server.pp Sat Apr 13 00:49:59 2013
@@ -99,10 +99,20 @@ class hdp-nagios::server(
} elsif ($service_state in ['running','stopped','installed_and_configured']) {
class { 'hdp-nagios::server::packages' : service_state => $service_state}
-
+
+ group { $nagios_group:
+ ensure => present
+ }
+
+ hdp::user { $nagios_user:
+ gid => $nagios_group
+ }
+
hdp::directory { $nagios_config_dir:
service_state => $service_state,
- force => true
+ force => true,
+ owner => $nagios_user,
+ group => $nagios_group
}
hdp::directory { $plugins_dir:
@@ -128,22 +138,40 @@ class hdp-nagios::server(
hdp::directory_recursive_create { $nagios_var_dir:
service_state => $service_state,
force => true,
- owner => $hdp-nagios::params::nagios_user,
- group => $hdp-nagios::params::nagios_group
+ owner => $nagios_user,
+ group => $nagios_group
}
-
+
hdp::directory_recursive_create { $check_result_path:
service_state => $service_state,
force => true,
- owner => $hdp-nagios::params::nagios_user,
- group => $hdp-nagios::params::nagios_group
+ owner => $nagios_user,
+ group => $nagios_group
}
hdp::directory_recursive_create { $nagios_rw_dir:
service_state => $service_state,
force => true,
- owner => $hdp-nagios::params::nagios_user,
- group => $hdp-nagios::params::nagios_group
+ owner => $nagios_user,
+ group => $nagios_group
+ }
+
+ hdp::directory { $nagios_log_dir:
+ service_state => $service_state,
+ force => true,
+ owner => $nagios_user,
+ group => $nagios_group,
+ mode => '0755',
+ override_owner => true
+ }
+
+ hdp::directory { $nagios_log_archives_dir:
+ service_state => $service_state,
+ force => true,
+ owner => $nagios_user,
+ group => $nagios_group,
+ mode => '0755',
+ override_owner => true
}
if ($service_state == 'installed_and_configured') {
@@ -174,9 +202,12 @@ class hdp-nagios::server(
class { 'hdp-nagios::server::services': ensure => $service_state}
- Class['hdp-nagios::server::packages'] -> Class['hdp-nagios::server::enable_snmp']-> Hdp::Directory[$nagios_config_dir] -> Hdp::Directory[$plugins_dir] -> Hdp::Directory_recursive_create[$nagios_pid_dir] ->
+ Class['hdp-nagios::server::packages'] -> Class['hdp-nagios::server::enable_snmp']->
+ Group[$nagios_group] -> Hdp::User[$nagios_user] ->
+ Hdp::Directory[$nagios_config_dir] -> Hdp::Directory[$plugins_dir] -> Hdp::Directory_recursive_create[$nagios_pid_dir] ->
Hdp::Directory[$nagios_obj_dir] -> Hdp::Directory_Recursive_Create[$nagios_var_dir] ->
Hdp::Directory_Recursive_Create[$check_result_path] -> Hdp::Directory_Recursive_Create[$nagios_rw_dir] ->
+ Hdp::Directory[$nagios_log_dir] -> Hdp::Directory[$nagios_log_archives_dir] ->
Class['hdp-nagios::server::config'] -> Class['hdp-nagios::server::web_permisssions'] -> File["$nagios_config_dir/command.cfg"] -> Class['hdp-nagios::server::services'] -> Class['hdp-monitor-webserver']
} else {
@@ -217,8 +248,8 @@ class hdp-nagios::server::web_permisssio
}
file { "/etc/nagios/htpasswd.users" :
- owner => $hdp-nagios::params::nagios_user,
- group => $hdp-nagios::params::nagios_group,
+ owner => $hdp-nagios::params::nagios_default_user,
+ group => $hdp-nagios::params::nagios_default_group,
mode => '0750'
}
Modified: incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-nagios/manifests/server/config.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-nagios/manifests/server/config.pp?rev=1467532&r1=1467531&r2=1467532&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-nagios/manifests/server/config.pp (original)
+++ incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-nagios/manifests/server/config.pp Sat Apr 13 00:49:59 2013
@@ -32,6 +32,9 @@ class hdp-nagios::server::config()
hdp-nagios::server::configfile { 'hadoop-services.cfg': }
hdp-nagios::server::configfile { 'hadoop-commands.cfg': }
hdp-nagios::server::configfile { 'contacts.cfg': }
+ if ($hdp::params::hdp_os_type in ['centos5', 'centos6', 'redhat5', 'redhat6', 'oraclelinux5', 'oraclelinux6']) {
+ hdp-nagios::server::configfile { 'nagios': conf_dir => '/etc/init.d/', mode => '0755', owner => 'root', group => 'root'}
+ }
hdp-nagios::server::check { 'check_cpu.pl': }
hdp-nagios::server::check { 'check_datanode_storage.php': }
Modified: incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-nagios/templates/nagios.cfg.erb
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-nagios/templates/nagios.cfg.erb?rev=1467532&r1=1467531&r2=1467532&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-nagios/templates/nagios.cfg.erb (original)
+++ incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-nagios/templates/nagios.cfg.erb Sat Apr 13 00:49:59 2013
@@ -147,7 +147,7 @@ status_update_interval=10
# This determines the effective user that Nagios should run as.
# You can either supply a username or a UID.
-nagios_user=nagios
+nagios_user=<%=scope.function_hdp_template_var("nagios_user")%>
Added: incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-nagios/templates/nagios.erb
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-nagios/templates/nagios.erb?rev=1467532&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-nagios/templates/nagios.erb (added)
+++ incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp-nagios/templates/nagios.erb Sat Apr 13 00:49:59 2013
@@ -0,0 +1,146 @@
+#!/bin/sh
+# $Id$
+# Nagios Startup script for the Nagios monitoring daemon
+#
+# chkconfig: - 85 15
+# description: Nagios is a service monitoring system
+# processname: nagios
+# config: /etc/nagios/nagios.cfg
+# pidfile: /var/nagios/nagios.pid
+#
+### BEGIN INIT INFO
+# Provides: nagios
+# Required-Start: $local_fs $syslog $network
+# Required-Stop: $local_fs $syslog $network
+# Short-Description: start and stop Nagios monitoring server
+# Description: Nagios is is a service monitoring system
+### END INIT INFO
+
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+#
+#
+#
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+prefix="/usr"
+exec_prefix="/usr"
+exec="/usr/bin/nagios"
+prog="nagios"
+config="/etc/nagios/nagios.cfg"
+pidfile="/var/nagios/nagios.pid"
+user="<%=scope.function_hdp_template_var("nagios_user")%>"
+
+[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+lockfile=/var/lock/subsys/$prog
+
+start() {
+ [ -x $exec ] || exit 5
+ [ -f $config ] || exit 6
+ echo -n $"Starting $prog: "
+ daemon --user=$user $exec -d $config
+ retval=$?
+ echo
+ [ $retval -eq 0 ] && touch $lockfile
+ return $retval
+}
+
+stop() {
+ echo -n $"Stopping $prog: "
+ killproc -d 10 $exec
+ retval=$?
+ echo
+ [ $retval -eq 0 ] && rm -f $lockfile
+ return $retval
+}
+
+
+restart() {
+ stop
+ start
+}
+
+reload() {
+ echo -n $"Reloading $prog: "
+ killproc $exec -HUP
+ RETVAL=$?
+ echo
+}
+
+force_reload() {
+ restart
+}
+
+check_config() {
+ $nice runuser -s /bin/bash - $user -c "$corelimit >/dev/null 2>&1 ; $exec -v $config > /dev/null 2>&1"
+ RETVAL=$?
+ if [ $RETVAL -ne 0 ] ; then
+ echo -n $"Configuration validation failed"
+ failure
+ echo
+ exit 1
+
+ fi
+}
+
+
+case "$1" in
+ start)
+ status $prog && exit 0
+ check_config
+ $1
+ ;;
+ stop)
+ status $prog|| exit 0
+ $1
+ ;;
+ restart)
+ check_config
+ $1
+ ;;
+ reload)
+ status $prog || exit 7
+ check_config
+ $1
+ ;;
+ force-reload)
+ check_config
+ force_reload
+ ;;
+ status)
+ status $prog
+ ;;
+ condrestart|try-restart)
+ status $prog|| exit 0
+ check_config
+ restart
+ ;;
+ configtest)
+ echo -n $"Checking config for $prog: "
+ check_config && success
+ echo
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
+ exit 2
+esac
+exit $?
Modified: incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp/manifests/init.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp/manifests/init.pp?rev=1467532&r1=1467531&r2=1467532&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp/manifests/init.pp (original)
+++ incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp/manifests/init.pp Sat Apr 13 00:49:59 2013
@@ -164,7 +164,7 @@ class hdp::create_smoke_user()
require => Hdp::User[$smoke_user]
}
- Group<||> -> Hdp::User[$smoke_user]
+ Group<|title == $smoke_group or title == $proxyuser_group|> -> Hdp::User[$smoke_user]
}