瀏覽代碼

AMBARI-1776. ZooKeeper Servers needs to store correct kerberos principal in zookeeper_jaas.conf. (swagle)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/trunk@1464668 13f79535-47bb-0310-9956-ffa450edef68
Siddharth Wagle 12 年之前
父節點
當前提交
61fab35135

+ 3 - 0
CHANGES.txt

@@ -12,6 +12,9 @@ Trunk (unreleased changes):
 
  NEW FEATURES
 
+ AMBARI-1776. ZooKeeper Servers needs to store correct kerberos principal 
+ in zookeeper_jaas.conf. (swagle)
+
  AMBARI-1424. Upgrade enhancements for Ambari 1.3.0. (smohanty)
 
  AMBARI-1763. Integrate Frontend security work to enable security on

+ 1 - 0
ambari-agent/src/main/puppet/modules/hdp-zookeeper/manifests/init.pp

@@ -89,6 +89,7 @@ class hdp-zookeeper(
       if ($security_enabled == true) {
         if ($type == 'server') {
           hdp-zookeeper::configfile { 'zookeeper_jaas.conf' : }
+          hdp-zookeeper::configfile { 'zookeeper_client_jaas.conf' : }
         } else {
           hdp-zookeeper::configfile { 'zookeeper_client_jaas.conf' : }
         }

+ 9 - 3
ambari-agent/src/main/puppet/modules/hdp-zookeeper/manifests/params.pp

@@ -21,8 +21,8 @@
 class hdp-zookeeper::params() inherits hdp::params 
 {
   $conf_dir = $hdp::params::zk_conf_dir
-
   $zk_user = $hdp::params::zk_user
+  $hostname = $hdp::params::hostname
   
   $zk_log_dir = hdp_default("zk_log_dir","/var/log/zookeeper")
   $zk_data_dir = hdp_default("zk_data_dir","/var/lib/zookeeper/data")
@@ -35,9 +35,15 @@ class hdp-zookeeper::params() inherits hdp::params
   $syncLimit = hdp_default("syncLimit","5")
   $clientPort = hdp_default("clientPort","2181")
 
-  $zk_keytab_path = hdp_default("zk_service_keytab", "${keytab_path}/zk.service.keytab")
-  $zk_principal = hdp_default("zk_kerberos_prinicipal", "zk/_HOST@${kerberos_domain}")
+  $zk_primary_name = hdp_default("zookeeper_primary_name", "zookeeper")
+
+  if ($use_hostname_in_principal) {
+    $zk_principal = "${zk_primary_name}/${hostname}@${kerberos_domain}"
+  } else {
+    $zk_principal = "${zk_primary_name}@${kerberos_domain}"
+  }
 
+  $zk_keytab_path = hdp_default("zookeeper_keytab_path", "${keytab_path}/zk.service.keytab")
   $zk_server_jaas_file = hdp_default("zk_server_jaas_conf_file", "${conf_dir}/zookeeper_jaas.conf")
   $zk_client_jaas_file = hdp_default("zk_client_jaas_conf_file", "${conf_dir}/zookeeper_client_jaas.conf")
 }

+ 5 - 0
ambari-agent/src/main/puppet/modules/hdp/manifests/params.pp

@@ -28,6 +28,10 @@ class hdp::params()
   $cluster_service_state = hdp_default("cluster_service_state","running")
   $cluster_client_state = hdp_default("cluster_client_state","installed_and_configured")
 
+  ## Hostname defaults
+  $hostname = hdp_default("myhostname", $::fqdn)
+  $public_hostname = hdp_default("public_hostname")
+
   ##### for secure install
   $security_enabled = hdp_default("security_enabled",false)
   $kerberos_domain = hdp_default("kerberos_domain","EXAMPLE.COM")
@@ -35,6 +39,7 @@ class hdp::params()
   ## $smoketest_user_secure_uid = 1012
   $kinit_path_local = hdp_default("kinit_path_local","/usr/bin/kinit")
   $keytab_path = hdp_default("keytab_path", "/etc/security/keytabs")
+  $use_hostname_in_principal = hdp_default("instance_name", false)
 
   ###### hostnames
   $namenode_host = hdp_default("namenode_host")

+ 7 - 3
ambari-agent/src/main/python/ambari_agent/manifestGenerator.py

@@ -26,11 +26,12 @@ from shell import shellRunner
 from datetime import datetime
 import AmbariConfig
 import pprint
+import hostname
 
 logger = logging.getLogger()
 
 non_global_configuration_types = ["hdfs-site", "core-site", 
-                          "mapred-queue-acls",
+                             "mapred-queue-acls",
                              "hadoop-policy", "mapred-site", 
                              "capacity-scheduler", "hbase-site",
                              "hbase-policy", "hive-site", "oozie-site", 
@@ -84,8 +85,7 @@ def generateManifest(parsedJson, fileName, modulesdir, ambariconfig):
   
   #writing params from map
   writeParams(manifest, params, modulesdir)
-  
-  
+
   nonGlobalConfigurations = {}
   flatConfigurations = {}
 
@@ -164,12 +164,16 @@ def writeHostAttributes(outputFile, hostAttributes):
 #write flat configurations
 def writeFlatConfigurations(outputFile, flatConfigs):
   flatDict = {}
+  fqdn = hostname.hostname()
+  public_fqdn = hostname.public_hostname()
   logger.info("Generating global configurations =>\n" + pprint.pformat(flatConfigs))
   for flatConfigName in flatConfigs.iterkeys():
     for flatConfig in flatConfigs[flatConfigName].iterkeys():
       flatDict[flatConfig] = flatConfigs[flatConfigName][flatConfig]
   for gconfigKey in flatDict.iterkeys():
     outputFile.write('$' + gconfigKey + ' = "' + flatDict[gconfigKey] + '"' + os.linesep)
+  outputFile.write('$myhostname' + " = '" + fqdn + "'" + os.linesep)
+  outputFile.write('$public_hostname' + " = '" + public_fqdn + "'" + os.linesep)
 
 #write xml configurations
 def writeNonGlobalConfigurations(outputFile, xmlConfigs):