|
@@ -24,6 +24,7 @@ from resource_management.libraries.functions.version import format_hdp_stack_ver
|
|
|
from resource_management.libraries.functions.default import default
|
|
|
from resource_management import *
|
|
|
import status_params
|
|
|
+import json
|
|
|
|
|
|
# server configurations
|
|
|
config = Script.get_config()
|
|
@@ -174,7 +175,7 @@ if hdp_stack_version != "" and compare_versions(hdp_stack_version, '2.2') >= 0:
|
|
|
if hdp_stack_version != "" and compare_versions(hdp_stack_version, '2.2') >= 0:
|
|
|
# Setting Flag value for ranger hbase plugin
|
|
|
enable_ranger_hbase = False
|
|
|
- ranger_plugin_enable = default("/configurations/ranger-hbase-plugin-properties/ranger-hbase-plugin-enabled","no")
|
|
|
+ ranger_plugin_enable = config['configurations']['ranger-hbase-plugin-properties']['ranger-hbase-plugin-enabled']
|
|
|
if ranger_plugin_enable.lower() == 'yes':
|
|
|
enable_ranger_hbase = True
|
|
|
elif ranger_plugin_enable.lower() == 'no':
|
|
@@ -186,38 +187,20 @@ has_ranger_admin = not len(ranger_admin_hosts) == 0
|
|
|
|
|
|
ambari_server_hostname = config['clusterHostInfo']['ambari_server_host'][0]
|
|
|
|
|
|
-
|
|
|
# ranger hbase properties
|
|
|
-policymgr_mgr_url = default("/configurations/admin-properties/policymgr_external_url", "http://localhost:6080")
|
|
|
-sql_connector_jar = default("/configurations/admin-properties/SQL_CONNECTOR_JAR", "/usr/share/java/mysql-connector-java.jar")
|
|
|
-xa_audit_db_flavor = default("/configurations/admin-properties/DB_FLAVOR", "MYSQL")
|
|
|
-xa_audit_db_name = default("/configurations/admin-properties/audit_db_name", "ranger_audit")
|
|
|
-xa_audit_db_user = default("/configurations/admin-properties/audit_db_user", "rangerlogger")
|
|
|
-xa_audit_db_password = default("/configurations/admin-properties/audit_db_password", "rangerlogger")
|
|
|
-xa_db_host = default("/configurations/admin-properties/db_host", "localhost")
|
|
|
+policymgr_mgr_url = config['configurations']['admin-properties']['policymgr_external_url']
|
|
|
+sql_connector_jar = config['configurations']['admin-properties']['SQL_CONNECTOR_JAR']
|
|
|
+xa_audit_db_flavor = config['configurations']['admin-properties']['DB_FLAVOR']
|
|
|
+xa_audit_db_name = config['configurations']['admin-properties']['audit_db_name']
|
|
|
+xa_audit_db_user = config['configurations']['admin-properties']['audit_db_user']
|
|
|
+xa_audit_db_password = config['configurations']['admin-properties']['audit_db_password']
|
|
|
+xa_db_host = config['configurations']['admin-properties']['db_host']
|
|
|
repo_name = str(config['clusterName']) + '_hbase'
|
|
|
-db_enabled = default("/configurations/ranger-hbase-plugin-properties/XAAUDIT.DB.IS_ENABLED", "false")
|
|
|
-hdfs_enabled = default("/configurations/ranger-hbase-plugin-properties/XAAUDIT.HDFS.IS_ENABLED", "false")
|
|
|
-hdfs_dest_dir = default("/configurations/ranger-hbase-plugin-properties/XAAUDIT.HDFS.DESTINATION_DIRECTORY", "hdfs://__REPLACE__NAME_NODE_HOST:8020/ranger/audit/app-type/time:yyyyMMdd")
|
|
|
-hdfs_buffer_dir = default("/configurations/ranger-hbase-plugin-properties/XAAUDIT.HDFS.LOCAL_BUFFER_DIRECTORY", "__REPLACE__LOG_DIR/hadoop/app-type/audit")
|
|
|
-hdfs_archive_dir = default("/configurations/ranger-hbase-plugin-properties/XAAUDIT.HDFS.LOCAL_ARCHIVE_DIRECTORY", "__REPLACE__LOG_DIR/hadoop/app-type/audit/archive")
|
|
|
-hdfs_dest_file = default("/configurations/ranger-hbase-plugin-properties/XAAUDIT.HDFS.DESTINTATION_FILE", "hostname-audit.log")
|
|
|
-hdfs_dest_flush_int_sec = default("/configurations/ranger-hbase-plugin-properties/XAAUDIT.HDFS.DESTINTATION_FLUSH_INTERVAL_SECONDS", "900")
|
|
|
-hdfs_dest_rollover_int_sec = default("/configurations/ranger-hbase-plugin-properties/XAAUDIT.HDFS.DESTINTATION_ROLLOVER_INTERVAL_SECONDS", "86400")
|
|
|
-hdfs_dest_open_retry_int_sec = default("/configurations/ranger-hbase-plugin-properties/XAAUDIT.HDFS.DESTINTATION_OPEN_RETRY_INTERVAL_SECONDS", "60")
|
|
|
-hdfs_buffer_file = default("/configurations/ranger-hbase-plugin-properties/XAAUDIT.HDFS.LOCAL_BUFFER_FILE", "time:yyyyMMdd-HHmm.ss.log")
|
|
|
-hdfs_buffer_flush_int_sec = default("/configurations/ranger-hbase-plugin-properties/XAAUDIT.HDFS.LOCAL_BUFFER_FLUSH_INTERVAL_SECONDS", "60")
|
|
|
-hdfs_buffer_rollover_int_sec = default("/configurations/ranger-hbase-plugin-properties/XAAUDIT.HDFS.LOCAL_BUFFER_ROLLOVER_INTERVAL_SECONDS", "600")
|
|
|
-hdfs_archive_max_file_count = default("/configurations/ranger-hbase-plugin-properties/XAAUDIT.HDFS.LOCAL_ARCHIVE_MAX_FILE_COUNT", "10")
|
|
|
-ssl_keystore_file = default("/configurations/ranger-hbase-plugin-properties/SSL_KEYSTORE_FILE_PATH", "/etc/hadoop/conf/ranger-plugin-keystore.jks")
|
|
|
-ssl_keystore_password = default("/configurations/ranger-hbase-plugin-properties/SSL_KEYSTORE_PASSWORD", "myKeyFilePassword")
|
|
|
-ssl_truststore_file = default("/configurations/ranger-hbase-plugin-properties/SSL_TRUSTSTORE_FILE_PATH", "/etc/hadoop/conf/ranger-plugin-truststore.jks")
|
|
|
-ssl_truststore_password = default("/configurations/ranger-hbase-plugin-properties/SSL_TRUSTSTORE_PASSWORD", "changeit")
|
|
|
-grant_revoke = default("/configurations/ranger-hbase-plugin-properties/UPDATE_XAPOLICIES_ON_GRANT_REVOKE","true")
|
|
|
-common_name_for_certificate = default("/configurations/ranger-hbase-plugin-properties/common.name.for.certificate", "-")
|
|
|
+
|
|
|
+common_name_for_certificate = config['configurations']['ranger-hbase-plugin-properties']['common.name.for.certificate']
|
|
|
|
|
|
zookeeper_znode_parent = config['configurations']['hbase-site']['zookeeper.znode.parent']
|
|
|
-hbase_zookeeoer_quorum = config['configurations']['hbase-site']['hbase.zookeeper.quorum']
|
|
|
+hbase_zookeeper_quorum = config['configurations']['hbase-site']['hbase.zookeeper.quorum']
|
|
|
hbase_zookeeper_property_clientPort = config['configurations']['hbase-site']['hbase.zookeeper.property.clientPort']
|
|
|
hbase_security_authentication = config['configurations']['hbase-site']['hbase.security.authentication']
|
|
|
hadoop_security_authentication = config['configurations']['core-site']['hadoop.security.authentication']
|
|
@@ -225,38 +208,55 @@ hadoop_security_authentication = config['configurations']['core-site']['hadoop.s
|
|
|
repo_config_username = default("/configurations/ranger-hbase-plugin-properties/REPOSITORY_CONFIG_USERNAME", "hbase")
|
|
|
repo_config_password = default("/configurations/ranger-hbase-plugin-properties/REPOSITORY_CONFIG_PASSWORD", "hbase")
|
|
|
|
|
|
-admin_uname = default("/configurations/ranger-env/admin_username", "admin")
|
|
|
-admin_password = default("/configurations/ranger-env/admin_password", "admin")
|
|
|
-admin_uname_password = format("{admin_uname}:{admin_password}")
|
|
|
+admin_uname = config['configurations']['ranger-env']['admin_username']
|
|
|
+admin_password = config['configurations']['ranger-env']['admin_password']
|
|
|
|
|
|
-ambari_ranger_admin = default("/configurations/ranger-env/ranger_admin_username", "amb_ranger_admin")
|
|
|
-ambari_ranger_password = default("/configurations/ranger-env/ranger_admin_password", "ambari123")
|
|
|
-policy_user = default("/configurations/ranger-hbase-plugin-properties/policy_user", "ambari-qa")
|
|
|
+ambari_ranger_admin = config['configurations']['ranger-env']['ranger_admin_username']
|
|
|
+ambari_ranger_password = config['configurations']['ranger-env']['ranger_admin_password']
|
|
|
+policy_user = config['configurations']['ranger-hbase-plugin-properties']['policy_user']
|
|
|
|
|
|
#For curl command in ranger plugin to get db connector
|
|
|
jdk_location = config['hostLevelParams']['jdk_location']
|
|
|
java_share_dir = '/usr/share/java'
|
|
|
-if xa_audit_db_flavor and xa_audit_db_flavor.lower() == 'mysql':
|
|
|
- jdbc_symlink_name = "mysql-jdbc-driver.jar"
|
|
|
- jdbc_jar_name = "mysql-connector-java.jar"
|
|
|
-elif xa_audit_db_flavor and xa_audit_db_flavor.lower() == 'oracle':
|
|
|
- jdbc_jar_name = "ojdbc6.jar"
|
|
|
- jdbc_symlink_name = "oracle-jdbc-driver.jar"
|
|
|
-elif xa_audit_db_flavor and xa_audit_db_flavor.lower() == 'postgres':
|
|
|
- jdbc_jar_name = "postgresql.jar"
|
|
|
- jdbc_symlink_name = "postgres-jdbc-driver.jar"
|
|
|
-elif xa_audit_db_flavor and xa_audit_db_flavor.lower() == 'sqlserver':
|
|
|
- jdbc_jar_name = "sqljdbc4.jar"
|
|
|
- jdbc_symlink_name = "mssql-jdbc-driver.jar"
|
|
|
-
|
|
|
-downloaded_custom_connector = format("{exec_tmp_dir}/{jdbc_jar_name}")
|
|
|
-
|
|
|
-driver_curl_source = format("{jdk_location}/{jdbc_symlink_name}")
|
|
|
-driver_curl_target = format("{java_share_dir}/{jdbc_jar_name}")
|
|
|
-
|
|
|
-#Solr properties added for HDP2.3 - Ranger
|
|
|
-solr_enabled = default("/configurations/ranger-hbase-plugin-properties/XAAUDIT.SOLR.IS_ENABLED", "false")
|
|
|
-solr_max_queue_size = default("/configurations/ranger-hbase-plugin-properties/XAAUDIT.SOLR.MAX_QUEUE_SIZE", "1")
|
|
|
-solr_max_flush_interval = default("/configurations/ranger-hbase-plugin-properties/XAAUDIT.SOLR.MAX_FLUSH_INTERVAL_MS", "1000")
|
|
|
-solr_url = default("/configurations/ranger-hbase-plugin-properties/XAAUDIT.SOLR.SOLR_URL", "http://localhost:6083/solr/ranger_audits")
|
|
|
+if has_ranger_admin:
|
|
|
+ if xa_audit_db_flavor.lower() == 'mysql':
|
|
|
+ jdbc_symlink_name = "mysql-jdbc-driver.jar"
|
|
|
+ jdbc_jar_name = "mysql-connector-java.jar"
|
|
|
+ elif xa_audit_db_flavor.lower() == 'oracle':
|
|
|
+ jdbc_jar_name = "ojdbc6.jar"
|
|
|
+ jdbc_symlink_name = "oracle-jdbc-driver.jar"
|
|
|
+ elif nxa_audit_db_flavor.lower() == 'postgres':
|
|
|
+ jdbc_jar_name = "postgresql.jar"
|
|
|
+ jdbc_symlink_name = "postgres-jdbc-driver.jar"
|
|
|
+ elif xa_audit_db_flavor.lower() == 'sqlserver':
|
|
|
+ jdbc_jar_name = "sqljdbc4.jar"
|
|
|
+ jdbc_symlink_name = "mssql-jdbc-driver.jar"
|
|
|
+
|
|
|
+ downloaded_custom_connector = format("{exec_tmp_dir}/{jdbc_jar_name}")
|
|
|
+
|
|
|
+ driver_curl_source = format("{jdk_location}/{jdbc_symlink_name}")
|
|
|
+ driver_curl_target = format("{java_share_dir}/{jdbc_jar_name}")
|
|
|
+
|
|
|
+hbase_ranger_plugin_config = {
|
|
|
+ 'username': repo_config_username,
|
|
|
+ 'password': repo_config_password,
|
|
|
+ 'hadoop.security.authentication': hadoop_security_authentication,
|
|
|
+ 'hbase.security.authentication': hbase_security_authentication,
|
|
|
+ 'hbase.zookeeper.property.clientPort': hbase_zookeeper_property_clientPort,
|
|
|
+ 'hbase.zookeeper.quorum': hbase_zookeeper_quorum,
|
|
|
+ 'zookeeper.znode.parent': zookeeper_znode_parent,
|
|
|
+ 'commonNameForCertificate': common_name_for_certificate,
|
|
|
+ 'hbase.master.kerberos.principal': master_jaas_princ if security_enabled else ''
|
|
|
+}
|
|
|
+
|
|
|
+hbase_ranger_plugin_repo = {
|
|
|
+ 'isActive': 'true',
|
|
|
+ 'config': json.dumps(hbase_ranger_plugin_config),
|
|
|
+ 'description': 'hbase repo',
|
|
|
+ 'name': repo_name,
|
|
|
+ 'repositoryType': 'hbase',
|
|
|
+ 'assetType': '2'
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
|