You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ma...@apache.org on 2012/09/29 03:30:33 UTC
svn commit: r1391722 [4/9] - in /incubator/ambari/branches/AMBARI-666: ./
ambari-agent/src/main/puppet/manifestloader/
ambari-agent/src/main/puppet/modules/
ambari-agent/src/main/puppet/modules/configgenerator/manifests/
ambari-agent/src/main/puppet/mo...
Added: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hcat/templates/hcat-env.sh.erb
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hcat/templates/hcat-env.sh.erb?rev=1391722&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hcat/templates/hcat-env.sh.erb (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hcat/templates/hcat-env.sh.erb Sat Sep 29 01:30:22 2012
@@ -0,0 +1,25 @@
+# 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.
+
+JAVA_HOME=<%=scope.function_hdp_java_home()%>
+HCAT_PID_DIR=<%=scope.function_hdp_template_var("hcat_pid_dir")%>/
+HCAT_LOG_DIR=<%=scope.function_hdp_template_var("hcat_log_dir")%>/
+HCAT_CONF_DIR=<%=scope.function_hdp_template_var("hcat_conf_dir")%>
+HADOOP_HOME=${HADOOP_HOME:-<%=scope.function_hdp_template_var("::hdp::params::hadoop_home")%>}
+#DBROOT is the path where the connector jars are downloaded
+DBROOT=<%=scope.function_hdp_template_var("hcat_dbroot")%>
+USER=<%=scope.function_hdp_user("hcat_user")%>
+METASTORE_PORT=<%=scope.function_hdp_template_var("hcat_metastore_port")%>
Added: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hive/files/hiveSmoke.sh
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hive/files/hiveSmoke.sh?rev=1391722&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hive/files/hiveSmoke.sh (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hive/files/hiveSmoke.sh Sat Sep 29 01:30:22 2012
@@ -0,0 +1,23 @@
+#
+#
+# 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.
+#
+#
+export tablename=$1
+echo "CREATE EXTERNAL TABLE IF NOT EXISTS ${tablename} ( foo INT, bar STRING );" | hive
+echo "DESCRIBE ${tablename};" | hive
Added: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hive/manifests/client.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hive/manifests/client.pp?rev=1391722&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hive/manifests/client.pp (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hive/manifests/client.pp Sat Sep 29 01:30:22 2012
@@ -0,0 +1,40 @@
+#
+#
+# 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.
+#
+#
+class hdp-hive::client(
+ $service_state = $hdp::params::cluster_client_state,
+ $hive_server_host = undef
+) inherits hdp::params
+{
+ if ($service_state == 'no_op') {
+ } elsif ($service_state in ['installed_and_configured','uninstalled']) {
+ if ($hdp::params::service_exists['hdp-hive::server'] != true) {
+ #installs package, creates user, sets configuration
+ class { 'hdp-hive':
+ service_state => $service_state
+ }
+ if ($hive_server_host != undef) {
+ Hdp-Hive::Configfile<||>{hive_server_host => $hive_server_host}
+ }
+ }
+ } else {
+ hdp_fail("TODO not implemented yet: service_state = ${service_state}")
+ }
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hive/manifests/hive/service_check.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hive/manifests/hive/service_check.pp?rev=1391722&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hive/manifests/hive/service_check.pp (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hive/manifests/hive/service_check.pp Sat Sep 29 01:30:22 2012
@@ -0,0 +1,55 @@
+#
+#
+# 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.
+#
+#
+class hdp-hive::hive::service_check()
+{
+ $unique = hdp_unique_id_and_date()
+ $smoke_test_user = $hdp::params::smokeuser
+ $output_file = "/apps/hive/warehouse/hivesmoke${unique}"
+
+ $test_cmd = "fs -test -e ${output_file}"
+
+ anchor { 'hdp-hive::hive::service_check::begin':}
+
+ file { '/tmp/hiveSmoke.sh':
+ ensure => present,
+ source => "puppet:///modules/hdp-hive/hiveSmoke.sh",
+ mode => '0755',
+ }
+
+ exec { '/tmp/hiveSmoke.sh':
+ command => "su - ${smoke_test_user} -c 'sh /tmp/hiveSmoke.sh hivesmoke${unique}'",
+ tries => 3,
+ try_sleep => 5,
+ require => File['/tmp/hiveSmoke.sh'],
+ path => '/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin',
+ notify => Hdp-hadoop::Exec-hadoop['hive::service_check::test'],
+ logoutput => "true"
+ }
+
+ hdp-hadoop::exec-hadoop { 'hive::service_check::test':
+ command => $test_cmd,
+ refreshonly => true,
+ require => Exec['/tmp/hiveSmoke.sh'],
+ before => Anchor['hdp-hive::hive::service_check::end']
+ }
+
+ anchor{ 'hdp-hive::hive::service_check::end':}
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hive/manifests/init.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hive/manifests/init.pp?rev=1391722&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hive/manifests/init.pp (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hive/manifests/init.pp Sat Sep 29 01:30:22 2012
@@ -0,0 +1,88 @@
+#
+#
+# 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.
+#
+#
+class hdp-hive(
+ $service_state,
+ $server = false
+)
+{
+ include hdp-hive::params
+ include manifestloader
+
+ $hive_user = $hdp-hive::params::hive_user
+ $hive_config_dir = $hdp-hive::params::hive_conf_dir
+
+ configgenerator::configfile{'hive-site.xml.erb':
+ module => 'hdp-hive',
+ properties => $manifestloader::hdp_hive_hive_site_props
+ }
+
+ anchor { 'hdp-hive::begin': }
+ anchor { 'hdp-hive::end': }
+
+ if ($service_state == 'uninstalled') {
+ hdp::package { 'hive' :
+ ensure => 'uninstalled'
+ }
+
+ hdp::directory { $hive_config_dir:
+ service_state => $service_state,
+ force => true
+ }
+
+ Anchor['hdp-hive::begin'] -> Hdp::Package['hive'] -> Hdp::Directory[$hive_config_dir] -> Anchor['hdp-hive::end']
+
+ } else {
+ hdp::package { 'hive' : }
+ if ($server == true ) {
+ class { 'hdp-hive::mysql-connector': }
+ }
+
+ hdp::user{ $hive_user:}
+
+ hdp::directory { $hive_config_dir:
+ service_state => $service_state,
+ force => true
+ }
+
+ hdp-hive::configfile { ['hive-env.sh','hive-site.xml']: }
+
+ Anchor['hdp-hive::begin'] -> Hdp::Package['hive'] -> Hdp::User[$hive_user] ->
+ Hdp::Directory[$hive_config_dir] -> Hdp-hive::Configfile<||> -> Anchor['hdp-hive::end']
+
+ if ($server == true ) {
+ Hdp::Package['hive'] -> Hdp::User[$hive_user] -> Class['hdp-hive::mysql-connector'] -> Anchor['hdp-hive::end']
+ }
+ }
+}
+
+### config files
+define hdp-hive::configfile(
+ $mode = undef,
+ $hive_server_host = undef
+)
+{
+ hdp::configfile { "${hdp-hive::params::hive_conf_dir}/${name}":
+ component => 'hive',
+ owner => $hdp-hive::params::hive_user,
+ mode => $mode,
+ hive_server_host => $hive_server_host
+ }
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hive/manifests/mysql-connector.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hive/manifests/mysql-connector.pp?rev=1391722&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hive/manifests/mysql-connector.pp (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hive/manifests/mysql-connector.pp Sat Sep 29 01:30:22 2012
@@ -0,0 +1,45 @@
+#
+#
+# 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.
+#
+#
+class hdp-hive::mysql-connector()
+{
+ include hdp-hive::params
+
+ $hive_lib = $hdp-hive::params::hive_lib
+ $target = "${hive_lib}/mysql-connector-java.jar"
+
+ anchor { 'hdp-hive::mysql-connector::begin':}
+
+ hdp::package { 'mysql-connector' :
+ require => Anchor['hdp-hive::mysql-connector::begin']
+ }
+
+ hdp::exec { 'hive mkdir -p ${artifact_dir} ; cp /usr/share/java/mysql-connector-java.jar ${target}':
+ command => "mkdir -p ${artifact_dir} ; cp /usr/share/java/mysql-connector-java.jar ${target}",
+ unless => "test -f ${target}",
+ creates => $target,
+ path => ["/bin","/usr/bin/"],
+ require => Hdp::Package['mysql-connector'],
+ notify => Anchor['hdp-hive::mysql-connector::end'],
+ }
+
+ anchor { 'hdp-hive::mysql-connector::end':}
+
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hive/manifests/params.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hive/manifests/params.pp?rev=1391722&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hive/manifests/params.pp (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hive/manifests/params.pp Sat Sep 29 01:30:22 2012
@@ -0,0 +1,62 @@
+#
+#
+# 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.
+#
+#
+class hdp-hive::params() inherits hdp::params
+{
+
+ #TODO: will move to globals
+ $hive_metastore_user_name = hdp_default("hadoop/hive-site/hive_metastore_user_name","dbusername")
+ $hive_metastore_user_passwd = hdp_default("hadoop/hive-site/hive_metastore_user_passwd","dbpassword")
+
+ ### users
+ $hive_user = $hdp::params::hive_user
+
+ ### common
+ $hive_metastore_port = hdp_default("hive_metastore_port",9083)
+ $hive_lib = hdp_default("hive_lib","/usr/lib/hive/lib/") #TODO: should I remove and just use hive_dbroot
+
+ ### hive-env
+ $hive_conf_dir = $hdp::params::hive_conf_dir
+
+ $hive_dbroot = hdp_default("hadoop/hive-env/hive_dbroot",$hive_lib)
+
+ $hive_log_dir = hdp_default("hadoop/hive-env/hive_log_dir","/var/log/hive")
+
+ $hive_pid_dir = hdp_default("hadoop/hive-env/hive_pid_dir","/var/run/hive")
+
+ ### hive-site
+ $hive_database_name = hdp_default("hadoop/hive-site/hive_database_name","hive")
+
+ if ($hdp::params::security_enabled == true) {
+ $hive_metastore_sasl_enabled = "true"
+ } else {
+ $hive_metastore_sasl_enabled = "false"
+ }
+
+ $keytab_path = hdp_default("keytab_path","/etc/security/keytabs")
+
+ #TODO: using instead hive_server_host in hdp::params
+ #$hive_metastore_server_host = hdp_default("hadoop/hive-site/hive_metastore_server_host")
+
+ ###mysql connector
+ $download_url = $hdp::params::gpl_artifacts_download_url
+ $mysql_connector_url = "${download_url}/mysql-connector-java-5.1.18.zip"
+ $hive_aux_jars_path = hdp_default("hive_aux_jars_path","/usr/lib/hcatalog/share/hcatalog/hcatalog-0.4.0.14.jar")
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hive/manifests/server.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hive/manifests/server.pp?rev=1391722&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hive/manifests/server.pp (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hive/manifests/server.pp Sat Sep 29 01:30:22 2012
@@ -0,0 +1,60 @@
+#
+#
+# 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.
+#
+#
+class hdp-hive::server(
+ $service_state = $hdp::params::cluster_service_state,
+ $opts = {}
+) inherits hdp-hive::params
+{
+
+ if ($service_state == 'no_op') {
+ } elsif ($service_state in ['running','stopped','installed_and_configured','uninstalled']) {
+
+ $hdp::params::service_exists['hdp-hive::server'] = true
+
+ if ( ($service_state == 'installed_and_configured') and
+ ($security_enabled == true) and ($kerberos_install_type == "AMBARI_SET_KERBEROS") ) {
+ $masterHost = $kerberos_adminclient_host[0]
+ hdp::download_keytab { 'hive_server_service_keytab' :
+ masterhost => $masterHost,
+ keytabdst => "${$keytab_path}/hive.service.keytab",
+ keytabfile => 'hive.service.keytab',
+ owner => $hdp-hive::params::hive_user
+ }
+ }
+
+ #installs package, creates user, sets configuration
+ class{ 'hdp-hive' :
+ service_state => $service_state,
+ server => true
+ }
+
+ Hdp-Hive::Configfile<||>{hive_server_host => $hdp::params::host_address}
+
+ class { 'hdp-hive::service' :
+ ensure => $service_state
+ }
+
+ #top level does not need anchors
+ Class['hdp-hive'] -> Class['hdp-hive::service']
+ } else {
+ hdp_fail("TODO not implemented yet: service_state = ${service_state}")
+ }
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hive/manifests/service.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hive/manifests/service.pp?rev=1391722&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hive/manifests/service.pp (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hive/manifests/service.pp Sat Sep 29 01:30:22 2012
@@ -0,0 +1,74 @@
+#
+#
+# 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.
+#
+#
+class hdp-hive::service(
+ $ensure
+)
+{
+ include $hdp-hive::params
+
+ $user = $hdp-hive::params::hive_user
+ $hadoop_home = $hdp::params::hadoop_home
+ $hive_log_dir = $hdp-hive::params::hive_log_dir
+ $cmd = "env HADOOP_HOME=${hadoop_home} nohup hive --service metastore > ${hive_log_dir}/hive.out 2> ${hive_log_dir}/hive.log &"
+ $pid_file = "${hdp-hive::params::hive_pid_dir}/hive.pid"
+
+ if ($ensure == 'running') {
+ $daemon_cmd = "su - ${user} -c '${cmd} '"
+ $no_op_test = "ls ${pid_file} >/dev/null 2>&1 && ps `cat ${pid_file}` >/dev/null 2>&1"
+ } elsif ($ensure == 'stopped') {
+ #TODO: this needs to be fixed
+ $daemon_cmd = "ps aux | awk '{print \$1,\$2}' | grep \"^${user} \" | awk '{print \$2}' | xargs kill >/dev/null 2>&1"
+ $no_op_test = "ps aux | awk '{print \$1,\$2}' | grep \"^${user} \""
+ } else {
+ $daemon_cmd = undef
+ }
+
+ hdp-hive::service::directory { $hdp-hive::params::hive_pid_dir : }
+ hdp-hive::service::directory { $hdp-hive::params::hive_log_dir : }
+
+ anchor{'hdp-hive::service::begin':} -> Hdp-hive::Service::Directory<||> -> anchor{'hdp-hive::service::end':}
+
+ if ($daemon_cmd != undef) {
+ if ($ensure == 'running') {
+ hdp::exec { $daemon_cmd:
+ command => $daemon_cmd,
+ unless => $no_op_test
+ }
+ } elsif ($ensure == 'stopped') {
+ hdp::exec { $daemon_cmd:
+ command => $daemon_cmd,
+ onlyif => $no_op_test
+ }
+ }
+ Hdp-hive::Service::Directory<||> -> Hdp::Exec[$daemon_cmd] -> Anchor['hdp-hive::service::end']
+ }
+}
+
+define hdp-hive::service::directory()
+{
+ hdp::directory_recursive_create { $name:
+ owner => $hdp-hive::params::hive_user,
+ mode => '0755',
+ service_state => $ensure,
+ force => true
+ }
+}
+
Added: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hive/templates/hive-env.sh.erb
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hive/templates/hive-env.sh.erb?rev=1391722&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hive/templates/hive-env.sh.erb (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-hive/templates/hive-env.sh.erb Sat Sep 29 01:30:22 2012
@@ -0,0 +1,54 @@
+# 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.
+
+# Set Hive and Hadoop environment variables here. These variables can be used
+# to control the execution of Hive. It should be used by admins to configure
+# the Hive installation (so that users do not have to set environment variables
+# or set command line parameters to get correct behavior).
+#
+# The hive service being invoked (CLI/HWI etc.) is available via the environment
+# variable SERVICE
+
+# Hive Client memory usage can be an issue if a large number of clients
+# are running at the same time. The flags below have been useful in
+# reducing memory usage:
+#
+ if [ "$SERVICE" = "cli" ]; then
+ if [ -z "$DEBUG" ]; then
+ export HADOOP_OPTS="$HADOOP_OPTS -XX:NewRatio=12 -Xms10m -XX:MaxHeapFreeRatio=40 -XX:MinHeapFreeRatio=15 -XX:+UseParNewGC -XX:-UseGCOverheadLimit"
+ else
+ export HADOOP_OPTS="$HADOOP_OPTS -XX:NewRatio=12 -Xms10m -XX:MaxHeapFreeRatio=40 -XX:MinHeapFreeRatio=15 -XX:-UseGCOverheadLimit"
+ fi
+ fi
+
+# The heap size of the jvm stared by hive shell script can be controlled via:
+
+export HADOOP_HEAPSIZE=${HADOOP_HEAPSIZE:-1024}
+
+# Larger heap size may be required when running queries over large number of files or partitions.
+# By default hive shell scripts use a heap size of 256 (MB). Larger heap size would also be
+# appropriate for hive server (hwi etc).
+
+
+# Set HADOOP_HOME to point to a specific hadoop install directory
+HADOOP_HOME=${HADOOP_HOME:-<%=scope.function_hdp_template_var("::hdp::params::hadoop_home")%>}
+
+# Hive Configuration Directory can be controlled by:
+export HIVE_CONF_DIR=<%=scope.function_hdp_template_var("hive_conf_dir")%>
+
+# Folder containing extra ibraries required for hive compilation/execution can be controlled by:
+# export HIVE_AUX_JARS_PATH=
+export HIVE_AUX_JARS_PATH=<%=scope.function_hdp_template_var("hive_aux_jars_path")%>
Added: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/lib/facter/kadm_keytab.rb
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/lib/facter/kadm_keytab.rb?rev=1391722&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/lib/facter/kadm_keytab.rb (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/lib/facter/kadm_keytab.rb Sat Sep 29 01:30:22 2012
@@ -0,0 +1,21 @@
+# 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.
+
+require 'facter'
+Facter.add("kadm_keytab") do
+ setcode do
+ %x{[ -f /etc/kadm5.keytab ] && base64 </etc/kadm5.keytab 2>/dev/null} + "\n"
+ end
+end
Added: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/lib/puppet/parser/functions/kerberos_keytabs_input.rb
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/lib/puppet/parser/functions/kerberos_keytabs_input.rb?rev=1391722&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/lib/puppet/parser/functions/kerberos_keytabs_input.rb (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/lib/puppet/parser/functions/kerberos_keytabs_input.rb Sat Sep 29 01:30:22 2012
@@ -0,0 +1,34 @@
+#
+#
+# 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.
+#
+#
+
+module Puppet::Parser::Functions
+ newfunction(:kerberos_keytabs_input, :type => :rvalue) do |args|
+ fqdn,node_components,keytab_map = args
+ ndx_ret = Hash.new
+ node_components.each do |cmp|
+ if info = keytab_map[cmp]
+ keytab = info["keytab"]
+ ndx_ret[keytab] ||= {"keytab" => keytab, "principals" => info["primaries"].map{|p|"#{p}/#{fqdn}"}}
+ end
+ end
+ ndx_ret.values
+ end
+end
Added: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/manifests/adminclient.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/manifests/adminclient.pp?rev=1391722&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/manifests/adminclient.pp (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/manifests/adminclient.pp Sat Sep 29 01:30:22 2012
@@ -0,0 +1,140 @@
+#
+#
+# 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.
+#
+#
+
+class hdp-kerberos::adminclient(
+ $service_state = $hdp::params::cluster_service_state
+) inherits hdp-kerberos::params
+{
+ import 'hdp'
+
+ $kadmin_pw = "bla123"
+ $kadmin_admin = "kadmin/admin"
+ $realm = $kerberos_domain
+ $krb_realm = $kerberos_domain
+ $hdp::params::service_exists['hdp-kerberos::adminclient'] = true
+ $krbContext = {}
+ $krbContext['kadmin_pw'] = $kadmin_pw
+ $krbContext['kadmin_admin'] = $kadmin_admin
+ $krbContext['realm' ] = $kerberos_domain
+ $krbContext['local_or_remote'] = 'remote'
+ $krbContext['principals_to_create'] = $principals_to_create
+ $krbContext['keytabs_to_create'] = $keytabs_to_create
+ $krbContext['principals_in_keytabs'] = $principals_in_keytabs
+
+ $kdc_server = $kdc_host
+
+ package { $package_name_client:
+ ensure => installed,
+ }
+ if ($hdp::params::service_exists['hdp-kerberos::server'] != true) {
+ file { "/etc/krb5.conf":
+ content => template('hdp-kerberos/krb5.conf'),
+ owner => "root",
+ group => "root",
+ mode => "0644",
+ require => Package[$package_name_client],
+ }
+ }
+
+ if ($create_principals_keytabs == "yes") {
+ notice("Creating principals and keytabs..")
+ hdp-kerberos::principals_and_keytabs::services { 'alphabeta':
+ krb_context => $krbContext
+ }
+ }
+}
+
+
+define hdp-kerberos::principals_and_keytabs::services(
+ $krb_context
+)
+{
+ include hdp-kerberos::params
+ $principals_to_create = $krb_context[principals_to_create]
+ $keytabs_to_create = $krb_context[keytabs_to_create]
+
+ hdp-kerberos::principal {$principals_to_create:
+ krb_context => $krb_context,
+ }
+
+ hdp-kerberos::keytab { $keytabs_to_create :
+ krb_context => $krb_context,
+ require => Hdp-kerberos::Principal[$principals_to_create]
+ }
+}
+
+define hdp-kerberos::keytab(
+ $krb_context,
+ $keytable_file_owner = undef,
+ $keytable_file_mode = undef
+)
+{
+ include hdp-kerberos::params
+ $keytab = $name
+ $realm = $krb_context['realm']
+ $local_or_remote = $krb_context['local_or_remote']
+ $kadmin_pw = $krb_context['kadmin_pw']
+ $kadmin_admin = $krb_context['kadmin_admin']
+ $kadmin_cmd = "kadmin -w ${kadmin_pw} -p ${kadmin_admin}"
+ if ($local_or_remote == 'local') {
+ $kadmin_cmd = 'kadmin.local'
+ }
+ $principals_in_keytabs = $krb_context['principals_in_keytabs']
+
+ $principals = $principals_in_keytabs[$keytab]
+ $principals_list = inline_template("<%= principals.join(' ')%>")
+ $keytab_filename = $keytab
+
+ exec { "xst ${keytab}":
+ command => "rm -rf ${keytab_filename}; ${kadmin_cmd} -q 'xst -k ${keytab_filename} ${principals_list}'; chown puppet:apache ${keytab_filename}",
+ unless => "klist -kt ${keytab_filename} 2>/dev/null | grep -q ' ${principals[0]}'", #TODO may make more robust test
+ path => $hdp-kerberos::params::exec_path,
+ }
+
+ if (($keytable_file_owner != undef) or ($keytable_file_mode != undef)) {
+ file { $keytab_filename:
+ owner => $keytable_file_owner,
+ mode => $keytable_file_mode,
+ require => Exec["xst ${keytab}"]
+ }
+ }
+}
+
+define hdp-kerberos::principal(
+ $krb_context
+)
+{
+ include hdp-kerberos::params
+ $realm = $krb_context['realm']
+ $local_or_remote = $krb_context['local_or_remote']
+ $kadmin_pw = $krb_context['kadmin_pw']
+ $kadmin_admin = $krb_context['kadmin_admin']
+ $kadmin_cmd = "kadmin -w ${kadmin_pw} -p ${kadmin_admin}"
+ if ($local_or_remote == 'local') {
+ $kadmin_cmd = 'kadmin.local'
+ }
+ $principal = $name
+ exec { "addprinc ${principal}":
+ command => "${kadmin_cmd} -q 'addprinc -randkey ${principal}'",
+ unless => "${kadmin_cmd} -q listprincs | grep -q '^${principal}$'",
+ path => $hdp-kerberos::params::exec_path
+ }
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/manifests/bigtop/init.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/manifests/bigtop/init.pp?rev=1391722&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/manifests/bigtop/init.pp (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/manifests/bigtop/init.pp Sat Sep 29 01:30:22 2012
@@ -0,0 +1,217 @@
+# 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.
+
+class kerberos {
+ class site {
+ # The following is our interface to the world. This is what we allow
+ # users to tweak from the outside (see tests/init.pp for a complete
+ # example) before instantiating target classes.
+ # Once we migrate to Puppet 2.6 we can potentially start using
+ # parametrized classes instead.
+ $domain = $kerberos_domain ? { '' => inline_template('<%= domain %>'),
+ default => $kerberos_domain }
+ $realm = $kerberos_realm ? { '' => inline_template('<%= domain.upcase %>'),
+ default => $kerberos_realm }
+ $kdc_server = $kerberos_kdc_server ? { '' => 'localhost',
+ default => $kerberos_kdc_server }
+ $kdc_port = $kerberos_kdc_port ? { '' => '88',
+ default => $kerberos_kdc_port }
+ $admin_port = 749 /* BUG: linux daemon packaging doesn't let us tweak this */
+
+ $keytab_export_dir = "/var/lib/bigtop_keytabs"
+
+ case $operatingsystem {
+ 'ubuntu': {
+ $package_name_kdc = 'krb5-kdc'
+ $service_name_kdc = 'krb5-kdc'
+ $package_name_admin = 'krb5-admin-server'
+ $service_name_admin = 'krb5-admin-server'
+ $package_name_client = 'krb5-user'
+ $exec_path = '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
+ $kdc_etc_path = '/etc/krb5kdc/'
+ }
+ # default assumes CentOS, Redhat 5 series (just look at how random it all looks :-()
+ default: {
+ $package_name_kdc = 'krb5-server'
+ $service_name_kdc = 'krb5kdc'
+ $package_name_admin = 'krb5-libs'
+ $service_name_admin = 'kadmin'
+ $package_name_client = 'krb5-workstation'
+ $exec_path = '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/kerberos/sbin:/usr/kerberos/bin'
+ $kdc_etc_path = '/var/kerberos/krb5kdc/'
+ }
+ }
+
+ file { "/etc/krb5.conf":
+ content => template('kerberos/krb5.conf'),
+ owner => "root",
+ group => "root",
+ mode => "0644",
+ }
+
+ @file { $keytab_export_dir:
+ ensure => directory,
+ owner => "root",
+ group => "root",
+ }
+
+ # Required for SPNEGO
+ @principal { "HTTP":
+
+ }
+ }
+
+ class kdc inherits kerberos::site {
+ package { $package_name_kdc:
+ ensure => installed,
+ }
+
+ file { $kdc_etc_path:
+ ensure => directory,
+ owner => root,
+ group => root,
+ mode => "0700",
+ require => Package["$package_name_kdc"],
+ }
+ file { "${kdc_etc_path}/kdc.conf":
+ content => template('kerberos/kdc.conf'),
+ require => Package["$package_name_kdc"],
+ owner => "root",
+ group => "root",
+ mode => "0644",
+ }
+ file { "${kdc_etc_path}/kadm5.acl":
+ content => template('kerberos/kadm5.acl'),
+ require => Package["$package_name_kdc"],
+ owner => "root",
+ group => "root",
+ mode => "0644",
+ }
+
+ exec { "kdb5_util":
+ path => $exec_path,
+ command => "rm -f /etc/kadm5.keytab ; kdb5_util -P cthulhu -r ${realm} create -s && kadmin.local -q 'cpw -pw secure kadmin/admin'",
+
+ creates => "${kdc_etc_path}/stash",
+
+ subscribe => File["${kdc_etc_path}/kdc.conf"],
+ # refreshonly => true,
+
+ require => [Package["$package_name_kdc"], File["${kdc_etc_path}/kdc.conf"], File["/etc/krb5.conf"]],
+ }
+
+ service { $service_name_kdc:
+ ensure => running,
+ require => [Package["$package_name_kdc"], File["${kdc_etc_path}/kdc.conf"], Exec["kdb5_util"]],
+ subscribe => File["${kdc_etc_path}/kdc.conf"],
+ hasrestart => true,
+ }
+
+
+ class admin_server inherits kerberos::kdc {
+ $se_hack = "setsebool -P kadmind_disable_trans 1 ; setsebool -P krb5kdc_disable_trans 1"
+
+ package { "$package_name_admin":
+ ensure => installed,
+ require => Package["$package_name_kdc"],
+ }
+
+ service { "$service_name_admin":
+ ensure => running,
+ require => [Package["$package_name_admin"], Service["$service_name_kdc"]],
+ hasrestart => true,
+ restart => "${se_hack} ; service ${service_name_admin} restart",
+ start => "${se_hack} ; service ${service_name_admin} start",
+ }
+ }
+ }
+
+ class client inherits kerberos::site {
+ package { $package_name_client:
+ ensure => installed,
+ }
+ }
+
+ class server {
+ include kerberos::client
+
+ class { "kerberos::kdc": }
+ ->
+ Class["kerberos::client"]
+
+ class { "kerberos::kdc::admin_server": }
+ ->
+ Class["kerberos::client"]
+ }
+
+ define principal {
+ require "kerberos::client"
+
+ realize(File[$kerberos::site::keytab_export_dir])
+
+ $principal = "$title/$::fqdn"
+ $keytab = "$kerberos::site::keytab_export_dir/$title.keytab"
+
+ exec { "addprinc.$title":
+ path => $kerberos::site::exec_path,
+ command => "kadmin -w secure -p kadmin/admin -q 'addprinc -randkey $principal'",
+ unless => "kadmin -w secure -p kadmin/admin -q listprincs | grep -q $principal",
+ require => Package[$kerberos::site::package_name_client],
+ }
+ ->
+ exec { "xst.$title":
+ path => $kerberos::site::exec_path,
+ command => "kadmin -w secure -p kadmin/admin -q 'xst -k $keytab $principal'",
+ unless => "klist -kt $keytab 2>/dev/null | grep -q $principal",
+ require => File[$kerberos::site::keytab_export_dir],
+ }
+ }
+
+ define host_keytab($princs = undef, $spnego = disabled) {
+ $keytab = "/etc/$title.keytab"
+
+ $requested_princs = $princs ? {
+ undef => [ $title ],
+ default => $princs,
+ }
+
+ $internal_princs = $spnego ? {
+ /(true|enabled)/ => [ 'HTTP' ],
+ default => [ ],
+ }
+ realize(Kerberos::Principal[$internal_princs])
+
+ $includes = inline_template("<%=
+ [requested_princs, internal_princs].flatten.map { |x|
+ \"rkt $kerberos::site::keytab_export_dir/#{x}.keytab\"
+ }.join(\"\n\")
+ %>")
+
+ kerberos::principal { $requested_princs:
+ }
+
+ exec { "ktinject.$title":
+ path => $kerberos::site::exec_path,
+ command => "/usr/bin/ktutil <<EOF
+ $includes
+ wkt $keytab
+EOF
+ chown $title $keytab",
+ creates => $keytab,
+ require => [ Kerberos::Principal[$requested_princs],
+ Kerberos::Principal[$internal_princs] ],
+ }
+ }
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/manifests/client.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/manifests/client.pp?rev=1391722&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/manifests/client.pp (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/manifests/client.pp Sat Sep 29 01:30:22 2012
@@ -0,0 +1,50 @@
+#
+#
+# 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.
+#
+#
+
+class hdp-kerberos::client(
+ $service_state = $hdp::params::cluster_service_state
+) inherits hdp-kerberos::params
+{
+ import 'hdp'
+
+ $hdp::params::service_exists['hdp-kerberos::client'] = true
+
+ $kdc_server = $kdc_host
+ $krb_realm = $kerberos_domain
+ $realm = $kerberos_domain
+
+ if ($hdp::params::service_exists['hdp-kerberos::adminclient'] != true) {
+ package { $package_name_client:
+ ensure => installed,
+ }
+ }
+
+ if (($hdp::params::service_exists['hdp-kerberos::server'] != true) and
+ ($hdp::params::service_exists['hdp-kerberos::adminclient'] != true) ) {
+ file { "/etc/krb5.conf":
+ content => template('hdp-kerberos/krb5.conf'),
+ owner => "root",
+ group => "root",
+ mode => "0644",
+ require => Package[$package_name_client],
+ }
+ }
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/manifests/init.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/manifests/init.pp?rev=1391722&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/manifests/init.pp (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/manifests/init.pp Sat Sep 29 01:30:22 2012
@@ -0,0 +1,25 @@
+#
+#
+# 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.
+#
+#
+
+class hdp-kerberos()
+{
+}
+
Added: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/manifests/params.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/manifests/params.pp?rev=1391722&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/manifests/params.pp (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/manifests/params.pp Sat Sep 29 01:30:22 2012
@@ -0,0 +1,70 @@
+#
+#
+# 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.
+#
+#
+
+class hdp-kerberos::params(
+) inherits hdp::params
+{
+ $domain = 'hadoop.com'
+ $realm = inline_template('<%= @domain.upcase %>')
+ $kdc_server = $::fqdn
+ $kdc_port = 88
+ $keytab_export_base_dir = '/etc/security/'
+ $keytab_export_dir = "${keytab_export_base_dir}/keytabs"
+
+ $keytab_map = {
+ 'hdp-hadoop::namenode' =>
+ {keytab => 'nn.service.keytab',
+ primaries => ['nn', 'host', 'HTTP']},
+ 'hdp-hadoop::snamenode' =>
+ {keytab => 'nn.service.keytab',
+ primaries => ['nn', 'host', 'HTTP']},
+ 'hdp-hadoop::datanode' =>
+ {keytab => 'dn.service.keytab',
+ primaries => ['dn']},
+ 'hdp-hadoop::jobtracker' =>
+ {keytab => 'jt.service.keytab',
+ primaries => ['jt']},
+ 'hdp-hadoop::tasktracker' =>
+ {keytab => 'tt.service.keytab',
+ primaries => ['tt']}
+ }
+
+ case $::operatingsystem {
+ 'ubuntu': {
+ $package_name_kdc = 'krb5-kdc'
+ $service_name_kdc = 'krb5-kdc'
+ $package_name_admin = 'krb5-admin-server'
+ $service_name_admin = 'krb5-admin-server'
+ $package_name_client = 'krb5-user'
+ $exec_path = '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
+ $kdc_etc_path = '/etc/krb5kdc/'
+ }
+ default: {
+ $package_name_kdc = 'krb5-server'
+ $service_name_kdc = 'krb5kdc'
+ $package_name_admin = 'krb5-libs'
+ $service_name_admin = 'kadmin'
+ $package_name_client = 'krb5-workstation'
+ $exec_path = '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/kerberos/sbin:/usr/kerberos/bin'
+ $kdc_etc_path = '/var/kerberos/krb5kdc/'
+ }
+ }
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/manifests/server.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/manifests/server.pp?rev=1391722&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/manifests/server.pp (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/manifests/server.pp Sat Sep 29 01:30:22 2012
@@ -0,0 +1,116 @@
+#
+#
+# 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.
+#
+#
+
+class hdp-kerberos::server(
+ $service_state = $hdp::params::cluster_service_state,
+ $opts = {}
+) inherits hdp-kerberos::params
+{
+ import 'hdp'
+
+ $hdp::params::service_exists['hdp-kerberos::server'] = true
+
+ $krb_realm = $kerberos_domain
+ $kadmin_pw = "bla123"
+ $kadmin_admin = "kadmin/admin"
+
+ if ($service_state == 'no_op') {
+ } elsif ($service_state in ['running','stopped','installed_and_configured']) {
+ # Install kdc server and client
+ package { $package_name_kdc:
+ ensure => installed
+ }
+
+ # set the realm
+ $realm = $krb_realm
+ # SUHAS: This should be set on all the nodes in addition to kdc server
+ file { "/etc/krb5.conf":
+ content => template('hdp-kerberos/krb5.conf'),
+ owner => "root",
+ group => "root",
+ mode => "0644",
+ require => Package[$package_name_kdc],
+ }
+
+ file { $kdc_etc_path:
+ ensure => directory,
+ owner => root,
+ group => root,
+ mode => "0700",
+ require => Package[$package_name_kdc],
+ }
+
+ file { "${kdc_etc_path}/kdc.conf":
+ content => template('hdp-kerberos/kdc.conf'),
+ require => Package["$package_name_kdc"],
+ owner => "root",
+ group => "root",
+ mode => "0644",
+ }
+
+ # SUHAS: kadm5.acl file template is missing in gsInsaller
+ # SUHAS: gsInstaller stops stopIptables at this point (sequence is not relevant here).
+ file { "${kdc_etc_path}/kadm5.acl":
+ content => template('hdp-kerberos/kadm5.acl'),
+ require => Package["$package_name_kdc"],
+ owner => "root",
+ group => "root",
+ mode => "0644",
+ }
+
+ exec { "kdb5_util":
+ path => $exec_path,
+ command => "rm -f ${kdc_etc_path}/kadm5.keytab; kdb5_util -P x86yzh12 -r ${realm} create -s && kadmin.local -q 'cpw -pw ${kadmin_pw} ${kadmin_admin}'",
+ creates => "${kdc_etc_path}/stash",
+ subscribe => File["${kdc_etc_path}/kdc.conf"],
+ require => [Package[$package_name_kdc], File["${kdc_etc_path}/kdc.conf"], File["/etc/krb5.conf"]]
+ }
+
+ # SUHAS: gsInstaller has checkconfig_on
+ exec { "chkconfig_krb5kdc_on":
+ path => $exec_path,
+ command => "chkconfig krb5kdc on",
+ require => [Package["$package_name_kdc"], File["${kdc_etc_path}/kdc.conf"], Exec["kdb5_util"]],
+ }
+
+ # Start KDC Server
+ if ($service_state in ['running','stopped']) {
+ service { $service_name_kdc:
+ ensure => $service_state,
+ require => [Exec["chkconfig_krb5kdc_on"]],
+ subscribe => File["${kdc_etc_path}/kdc.conf"],
+ hasrestart => true,
+ }
+
+ # SUHAS: This is to be done on HMC not KDC Server??
+ $se_hack = "setsebool -P kadmind_disable_trans 1 ; setsebool -P krb5kdc_disable_trans 1"
+ service { $service_name_admin:
+ ensure => $service_state,
+ require => Service[$service_name_kdc],
+ hasrestart => true,
+ restart => "${se_hack} ; service ${service_name_admin} restart",
+ start => "${se_hack} ; service ${service_name_admin} start",
+ }
+ }
+ } else {
+ hdp_fail("TODO not implemented yet: service_state = ${service_state}")
+ }
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/templates/kadm5.acl
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/templates/kadm5.acl?rev=1391722&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/templates/kadm5.acl (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/templates/kadm5.acl Sat Sep 29 01:30:22 2012
@@ -0,0 +1,21 @@
+# 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.
+
+# This file Is the access control list for krb5 administration.
+# When this file is edited run /etc/init.d/krb5-admin-server restart to activate
+# One common way to set up Kerberos administration is to allow any principal
+# ending in /admin is given full administrative rights.
+# To enable this, uncomment the following line:
+*/admin *
Added: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/templates/kdc.conf
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/templates/kdc.conf?rev=1391722&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/templates/kdc.conf (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/templates/kdc.conf Sat Sep 29 01:30:22 2012
@@ -0,0 +1,36 @@
+# 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.
+
+default_realm = <%= realm %>
+
+[kdcdefaults]
+ v4_mode = nopreauth
+ kdc_ports = 0
+ kdc_tcp_ports = 88
+
+[realms]
+ <%= realm %> = {
+ acl_file = <%= kdc_etc_path %>/kadm5.acl
+ dict_file = /usr/share/dict/words
+ admin_keytab = <%= kdc_etc_path %>/kadm5.keytab
+ supported_enctypes = des3-hmac-sha1:normal arcfour-hmac:normal des-hmac-sha1:normal des-cbc-md5:normal des-cbc-crc:normal des-cbc-crc:v4 des-cbc-crc:afs3
+ kdc_ports = <%= kdc_port %>
+ database_name = <%= kdc_etc_path %>/principal
+ key_stash_file = <%= kdc_etc_path %>/stash
+ max_life = 10h 0m 0s
+ max_renewable_life = 7d 0h 0m 0s
+ master_key_type = des3-hmac-sha1
+ default_principal_flags = +preauth
+ }
Added: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/templates/krb5.conf
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/templates/krb5.conf?rev=1391722&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/templates/krb5.conf (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/templates/krb5.conf Sat Sep 29 01:30:22 2012
@@ -0,0 +1,47 @@
+# 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.
+
+[libdefaults]
+ default_realm = <%= realm %>
+ dns_lookup_realm = false
+ dns_lookup_kdc = false
+ ticket_lifetime = 24h
+ forwardable = yes
+ udp_preference_limit = 1
+
+[realms]
+ <%= realm %> = {
+ kdc = <%= kdc_server %>:<%= kdc_port %>
+ admin_server = <%= kdc_server %>:749
+ default_domain = <%= domain %>
+ }
+
+[appdefaults]
+ pam = {
+ debug = false
+ ticket_lifetime = 36000
+ renew_lifetime = 36000
+ forwardable = true
+ krb4_convert = false
+ }
+
+[domain_realm]
+ .<%= domain %> = <%= realm %>
+ <%= domain %> = <%= realm %>
+
+[logging]
+ default = FILE:/var/log/krb5libs.log
+ kdc = FILE:/var/log/krb5kdc.log
+ admin_server = FILE:/var/log/kadmind.log
Added: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/tests/init.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/tests/init.pp?rev=1391722&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/tests/init.pp (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-kerberos/tests/init.pp Sat Sep 29 01:30:22 2012
@@ -0,0 +1,31 @@
+# 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.
+
+$kerberos_domain = "krb.test.com"
+$kerberos_realm = "KRB.TEST.COM"
+$kerberos_kdc_server = "localhost"
+$kerberos_kdc_port = 88
+# the following turns a node into a fully functional KDC
+include kerberos::kdc
+# the following opens up KDC principle datbase for remote
+# administration (it really should be optional, but it is
+# required for now in order to make kerberos::client::host_keytab
+# work)
+include kerberos::kdc::admin_server
+
+# the following turns a node into a Kerberos client hosts with..
+include kerberos::client
+# ...an optional host_keytab for as many services as you want:
+kerberos::client::host_keytab { ["host", "hdfs", "mapred"]: }
Added: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-monitor-webserver/manifests/init.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-monitor-webserver/manifests/init.pp?rev=1391722&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-monitor-webserver/manifests/init.pp (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-monitor-webserver/manifests/init.pp Sat Sep 29 01:30:22 2012
@@ -0,0 +1,43 @@
+#
+#
+# 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.
+#
+#
+class hdp-monitor-webserver(
+ $service_state = $hdp::params::cluster_service_state,
+ $opts = {}
+) inherits hdp::params
+{
+ #TODO: does not install apache package
+ if ($service_state == 'no_op') {
+ } elsif ($service_state in ['running','stopped','installed_and_configured']) {
+ if ($service_state == 'running') {
+ #TODO: refine by using notify/subscribe
+ hdp::exec { 'monitor webserver start':
+ command => '/etc/init.d/httpd start',
+ unless => '/etc/init.d/httpd status'
+ }
+ } elsif ($service_state == 'stopped') {
+ package { 'httpd':
+ ensure => 'stopped'
+ }
+ }
+ } else {
+ hdp_fail("TODO not implemented yet: service_state = ${service_state}")
+ }
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-mysql/files/startMysql.sh
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-mysql/files/startMysql.sh?rev=1391722&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-mysql/files/startMysql.sh (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-mysql/files/startMysql.sh Sat Sep 29 01:30:22 2012
@@ -0,0 +1,30 @@
+#!/bin/sh
+#
+#
+# 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.
+#
+#
+
+mysqldbuser=$1
+mysqldbpasswd=$2
+mysqldbhost=$3
+
+echo "Adding user $mysqldbuser@$mysqldbhost"
+echo "CREATE USER '$mysqldbuser'@'$mysqldbhost' IDENTIFIED BY '$mysqldbpasswd';" | mysql -u root
+echo "GRANT ALL PRIVILEGES ON *.* TO '$mysqldbuser'@'$mysqldbhost';" | mysql -u root
+echo "flush privileges;" | mysql -u root
Added: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-mysql/manifests/init.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-mysql/manifests/init.pp?rev=1391722&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-mysql/manifests/init.pp (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-mysql/manifests/init.pp Sat Sep 29 01:30:22 2012
@@ -0,0 +1,22 @@
+#
+#
+# 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.
+#
+#
+class hdp-mysql(){}
+
Added: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-mysql/manifests/params.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-mysql/manifests/params.pp?rev=1391722&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-mysql/manifests/params.pp (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-mysql/manifests/params.pp Sat Sep 29 01:30:22 2012
@@ -0,0 +1,26 @@
+#
+#
+# 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.
+#
+#
+class hdp-mysql::params() inherits hdp-hive::params
+{
+ $db_name = "$hdp-hive::params::hive_database_name"
+ $db_user = $hdp-hive::params::hive_metastore_user_name
+ $db_pw = $hdp-hive::params::hive_metastore_user_passwd
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-mysql/manifests/server.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-mysql/manifests/server.pp?rev=1391722&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-mysql/manifests/server.pp (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-mysql/manifests/server.pp Sat Sep 29 01:30:22 2012
@@ -0,0 +1,71 @@
+#
+#
+# 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.
+#
+#
+class hdp-mysql::server(
+ $service_state = $hdp::params::cluster_service_state,
+ $opts = {}
+) inherits hdp-mysql::params
+{
+ if ($service_state in ['no_op','uninstalled']) {
+ } elsif ($service_state in ['running','stopped','installed_and_configured']) {
+
+ $db_user = $hdp-mysql::params::db_user
+ $db_pw = $hdp-mysql::params::db_pw
+ $db_name = $hdp-mysql::params::db_name
+ $host = $hdp::params::hive_mysql_host
+
+ anchor { 'hdp-mysql::server::begin':}
+
+ hdp::package { 'mysql' :
+ size => 32,
+ require => Anchor['hdp-mysql::server::begin']
+ }
+
+ hdp::exec { 'mysqld start':
+ command => '/etc/init.d/mysqld start',
+ unless => '/etc/init.d/mysqld status',
+ require => Hdp::Package['mysql'],
+ notify => File['/tmp/startMysql.sh']
+ }
+
+ file { '/tmp/startMysql.sh':
+ ensure => present,
+ source => "puppet:///modules/hdp-mysql/startMysql.sh",
+ mode => '0755',
+ require => Hdp::Exec['mysqld start'],
+ notify => Exec['/tmp/startMysql.sh']
+ }
+
+ exec { '/tmp/startMysql.sh':
+ command => "sh /tmp/startMysql.sh ${db_user} ${db_pw} ${host}",
+ tries => 3,
+ try_sleep => 5,
+ require => File['/tmp/startMysql.sh'],
+ path => '/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin',
+ notify => Anchor['hdp-mysql::server::end'],
+ logoutput => "true"
+ }
+
+ anchor { 'hdp-mysql::server::end':}
+
+ } else {
+ hdp_fail("TODO not implemented yet: service_state = ${service_state}")
+ }
+}
Added: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-nagios/files/check_aggregate.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-nagios/files/check_aggregate.php?rev=1391722&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-nagios/files/check_aggregate.php (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-nagios/files/check_aggregate.php Sat Sep 29 01:30:22 2012
@@ -0,0 +1,243 @@
+<?php
+/*
+ * 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.
+ */
+
+ $options = getopt ("f:s:n:w:c:t:");
+ if (!array_key_exists('t', $options) || !array_key_exists('f', $options) || !array_key_exists('w', $options)
+ || !array_key_exists('c', $options) || !array_key_exists('s', $options)) {
+ usage();
+ exit(3);
+ }
+ $status_file=$options['f'];
+ $status_code=$options['s'];
+ $type=$options['t'];
+ $warn=$options['w']; $warn = preg_replace('/%$/', '', $warn);
+ $crit=$options['c']; $crit = preg_replace('/%$/', '', $crit);
+ if ($type == "service" && !array_key_exists('n', $options)) {
+ echo "Service description not provided -n option\n";
+ exit(3);
+ }
+ if ($type == "service") {
+ $service_name=$options['n'];
+ /* echo "DESC: " . $service_name . "\n"; */
+ }
+
+ $result = array();
+ $status_file_content = file_get_contents($status_file);
+
+ $counts;
+ if ($type == "service") {
+ $counts=query_alert_count($status_file_content, $service_name, $status_code);
+ } else {
+ $counts=query_host_count($status_file_content, $status_code);
+ }
+
+ if ($counts['total'] == 0) {
+ $percent = 0;
+ } else {
+ $percent = ($counts['actual']/$counts['total'])*100;
+ }
+ if ($percent >= $crit) {
+ echo "CRITICAL: total:<" . $counts['total'] . ">, affected:<" . $counts['actual'] . ">\n";
+ exit (2);
+ }
+ if ($percent >= $warn) {
+ echo "WARNING: total:<" . $counts['total'] . ">, affected:<" . $counts['actual'] . ">\n";
+ exit (1);
+ }
+ echo "OK: total:<" . $counts['total'] . ">, affected:<" . $counts['actual'] . ">\n";
+ exit(0);
+
+
+ # Functions
+ /* print usage */
+ function usage () {
+ echo "Usage: $0 -f <status_file_path> -t type(host/service) -s <status_codes> -n <service description> -w <warn%> -c <crit%>\n";
+ }
+
+ /* Query host count */
+ function query_host_count ($status_file_content, $status_code) {
+ $num_matches = preg_match_all("/hoststatus \{([\S\s]*?)\}/", $status_file_content, $matches, PREG_PATTERN_ORDER);
+ $hostcounts_object = array ();
+ $total_hosts = 0;
+ $hosts = 0;
+ foreach ($matches[0] as $object) {
+ $total_hosts++;
+ if (getParameter($object, "current_state") == $status_code) {
+ $hosts++;
+ }
+ }
+ $hostcounts_object['total'] = $total_hosts;
+ $hostcounts_object['actual'] = $hosts;
+ return $hostcounts_object;
+ }
+
+ /* Query Alert counts */
+ function query_alert_count ($status_file_content, $service_name, $status_code) {
+ $num_matches = preg_match_all("/servicestatus \{([\S\s]*?)\}/", $status_file_content, $matches, PREG_PATTERN_ORDER);
+ $alertcounts_objects = array ();
+ $total_alerts=0;
+ $alerts=0;
+ foreach ($matches[0] as $object) {
+ if (getParameter($object, "service_description") == $service_name) {
+ $total_alerts++;
+ if (getParameter($object, "current_state") >= $status_code) {
+ $alerts++;
+ }
+ }
+ }
+ $alertcounts_objects['total'] = $total_alerts;
+ $alertcounts_objects['actual'] = $alerts;
+ return $alertcounts_objects;
+ }
+
+ function get_service_type($service_description)
+ {
+ $pieces = explode("::", $service_description);
+ switch ($pieces[0]) {
+ case "NAMENODE":
+ $pieces[0] = "HDFS";
+ break;
+ case "JOBTRACKER":
+ $pieces[0] = "MAPREDUCE";
+ break;
+ case "HBASEMASTER":
+ $pieces[0] = "HBASE";
+ break;
+ case "SYSTEM":
+ case "HDFS":
+ case "MAPREDUCE":
+ case "HBASE":
+ break;
+ default:
+ $pieces[0] = "UNKNOWN";
+ }
+ return $pieces[0];
+ }
+
+ function getParameter($object, $key)
+ {
+ $pattern="/\s" . $key . "[\s= ]*([\S, ]*)\n/";
+ $num_mat = preg_match($pattern, $object, $matches);
+ $value = "";
+ if ($num_mat) {
+ $value = $matches[1];
+ }
+ return $value;
+ }
+
+function indent($json) {
+
+ $result = '';
+ $pos = 0;
+ $strLen = strlen($json);
+ $indentStr = ' ';
+ $newLine = "\n";
+ $prevChar = '';
+ $outOfQuotes = true;
+
+ for ($i=0; $i<=$strLen; $i++) {
+
+ // Grab the next character in the string.
+ $char = substr($json, $i, 1);
+
+ // Are we inside a quoted string?
+ if ($char == '"' && $prevChar != '\\') {
+ $outOfQuotes = !$outOfQuotes;
+
+ // If this character is the end of an element,
+ // output a new line and indent the next line.
+ } else if(($char == '}' || $char == ']') && $outOfQuotes) {
+ $result .= $newLine;
+ $pos --;
+ for ($j=0; $j<$pos; $j++) {
+ $result .= $indentStr;
+ }
+ }
+
+ // Add the character to the result string.
+ $result .= $char;
+
+ // If the last character was the beginning of an element,
+ // output a new line and indent the next line.
+ if (($char == ',' || $char == '{' || $char == '[') && $outOfQuotes) {
+ $result .= $newLine;
+ if ($char == '{' || $char == '[') {
+ $pos ++;
+ }
+
+ for ($j = 0; $j < $pos; $j++) {
+ $result .= $indentStr;
+ }
+ }
+
+ $prevChar = $char;
+ }
+
+ return $result;
+}
+
+/* JSON documment format */
+/*
+{
+ "programstatus":{
+ "last_command_check":"1327385743"
+ },
+ "hostcounts":{
+ "up_nodes":"",
+ "down_nodes":""
+ },
+ "hoststatus":[
+ {
+ "host_name"="ip-10-242-191-48.ec2.internal",
+ "current_state":"0",
+ "last_hard_state":"0",
+ "plugin_output":"PING OK - Packet loss = 0%, RTA = 0.04 ms",
+ "last_check":"1327385564",
+ "current_attempt":"1",
+ "last_hard_state_change":"1327362079",
+ "last_time_up":"1327385574",
+ "last_time_down":"0",
+ "last_time_unreachable":"0",
+ "is_flapping":"0",
+ "last_check":"1327385574",
+ "servicestatus":[
+ ]
+ }
+ ],
+ "servicestatus":[
+ {
+ "service_type":"HDFS", {HBASE, MAPREDUCE, HIVE, ZOOKEEPER}
+ "service_description":"HDFS Current Load",
+ "host_name"="ip-10-242-191-48.ec2.internal",
+ "current_attempt":"1",
+ "current_state":"0",
+ "plugin_output":"PING OK - Packet loss = 0%, RTA = 0.04 ms",
+ "last_hard_state_change":"1327362079",
+ "last_time_ok":"1327385479",
+ "last_time_warning":"0",
+ "last_time_unknown":"0",
+ "last_time_critical":"0",
+ "last_check":"1327385574",
+ "is_flapping":"0"
+ }
+ ]
+}
+*/
+
+?>
Added: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-nagios/files/check_cpu.pl
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-nagios/files/check_cpu.pl?rev=1391722&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-nagios/files/check_cpu.pl (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-nagios/files/check_cpu.pl Sat Sep 29 01:30:22 2012
@@ -0,0 +1,114 @@
+#!/usr/bin/perl -w
+#
+#
+# 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.
+#
+#
+use strict;
+use Net::SNMP;
+use Getopt::Long;
+
+# Variable
+my $base_proc = "1.3.6.1.2.1.25.3.3.1";
+my $proc_load = "1.3.6.1.2.1.25.3.3.1.2";
+my $o_host = undef;
+my $o_community = undef;
+my $o_warn= undef;
+my $o_crit= undef;
+my $o_timeout = 15;
+my $o_port = 161;
+
+sub Usage {
+ print "Usage: $0 -H <host> -C <snmp_community> -w <warn level> -c <crit level>\n";
+}
+
+Getopt::Long::Configure ("bundling");
+GetOptions(
+ 'H:s' => \$o_host,
+ 'C:s' => \$o_community,
+ 'c:s' => \$o_crit,
+ 'w:s' => \$o_warn
+ );
+if (!defined $o_host || !defined $o_community || !defined $o_crit || !defined $o_warn) {
+ Usage();
+ exit 3;
+}
+$o_warn =~ s/\%//g;
+$o_crit =~ s/\%//g;
+alarm ($o_timeout);
+$SIG{'ALRM'} = sub {
+ print "Unable to contact host: $o_host\n";
+ exit 3;
+};
+
+# Connect to host
+my ($session,$error);
+($session, $error) = Net::SNMP->session(
+ -hostname => $o_host,
+ -community => $o_community,
+ -port => $o_port,
+ -timeout => $o_timeout
+ );
+if (!defined($session)) {
+ printf("Error opening session: %s.\n", $error);
+ exit 3;
+}
+
+my $exit_val=undef;
+my $resultat = (Net::SNMP->VERSION < 4) ?
+ $session->get_table($base_proc)
+ : $session->get_table(Baseoid => $base_proc);
+
+if (!defined($resultat)) {
+ printf("ERROR: Description table : %s.\n", $session->error);
+ $session->close;
+ exit 3;
+}
+
+$session->close;
+
+my ($cpu_used,$ncpu)=(0,0);
+foreach my $key ( keys %$resultat) {
+ if ($key =~ /$proc_load/) {
+ $cpu_used += $$resultat{$key};
+ $ncpu++;
+ }
+}
+
+if ($ncpu==0) {
+ print "Can't find CPU usage information : UNKNOWN\n";
+ exit 3;
+}
+
+$cpu_used /= $ncpu;
+
+print "$ncpu CPU, ", $ncpu==1 ? "load" : "average load";
+printf(" %.1f%%",$cpu_used);
+$exit_val=0;
+
+if ($cpu_used > $o_crit) {
+ print " > $o_crit% : CRITICAL\n";
+ $exit_val=2;
+} else {
+ if ($cpu_used > $o_warn) {
+ print " > $o_warn% : WARNING\n";
+ $exit_val=1;
+ }
+}
+print " < $o_warn% : OK\n" if ($exit_val eq 0);
+exit $exit_val;
Added: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-nagios/files/check_datanode_storage.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-nagios/files/check_datanode_storage.php?rev=1391722&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-nagios/files/check_datanode_storage.php (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-nagios/files/check_datanode_storage.php Sat Sep 29 01:30:22 2012
@@ -0,0 +1,63 @@
+<?php
+/*
+ * 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.
+ */
+
+/* This plugin makes call to master node, get the jmx-json document
+ * check the storage capacity remaining on local datanode storage
+ */
+
+ $options = getopt ("h:p:w:c:");
+ if (!array_key_exists('h', $options) || !array_key_exists('p', $options) || !array_key_exists('w', $options)
+ || !array_key_exists('c', $options)) {
+ usage();
+ exit(3);
+ }
+
+ $host=$options['h'];
+ $port=$options['p'];
+ $warn=$options['w']; $warn = preg_replace('/%$/', '', $warn);
+ $crit=$options['c']; $crit = preg_replace('/%$/', '', $crit);
+
+ /* Get the json document */
+ $json_string = file_get_contents("http://".$host.":".$port."/jmx?qry=Hadoop:service=DataNode,name=FSDatasetState-DS-*");
+ $json_array = json_decode($json_string, true);
+ $object = $json_array['beans'][0];
+ $cap_remain = $object['Remaining']; /* Total capacity - any extenal files created in data directories by non-hadoop app */
+ $cap_total = $object['Capacity']; /* Capacity used by all data partitions minus space reserved for M/R */
+ $percent_full = ($cap_total - $cap_remain)/$cap_total * 100;
+
+ $out_msg = "Capacity:[" . $cap_total .
+ "], Remaining Capacity:[" . $cap_remain .
+ "], percent_full:[" . $percent_full . "]";
+
+ if ($percent_full > $crit) {
+ echo "CRITICAL: " . $out_msg . "\n";
+ exit (2);
+ }
+ if ($percent_full > $warn) {
+ echo "WARNING: " . $out_msg . "\n";
+ exit (1);
+ }
+ echo "OK: " . $out_msg . "\n";
+ exit(0);
+
+ /* print usage */
+ function usage () {
+ echo "Usage: $0 -h <host> -p port -w <warn%> -c <crit%>\n";
+ }
+?>