Skip to content
Permalink
Browse files
[AMBARI-23515] : Rearranging configuration file creation for Ranger P…
…lu… (#1038)

* AMBARI-23515 : Rearranging configuration file creation for Ranger Plugins.

* AMBARI-23515 : Rearranging configuration file creation for Ranger Plugins.
  • Loading branch information
vishalsuvagia authored and swagle committed Apr 20, 2018
1 parent 94872ba commit 391de63db4e9e35f857bee77de0a17d4a7c3d898
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 31 deletions.
@@ -45,7 +45,7 @@ def setup_ranger_plugin(component_select_name, service_name, previous_jdbc_jar,
cache_service_list, plugin_audit_properties, plugin_audit_attributes,
plugin_security_properties, plugin_security_attributes,
plugin_policymgr_ssl_properties, plugin_policymgr_ssl_attributes,
component_list, audit_db_is_enabled, credential_file,
component_list, audit_db_is_enabled, credential_file,
xa_audit_db_password, ssl_truststore_password,
ssl_keystore_password, api_version=None, stack_version_override = None, skip_if_rangeradmin_down = True,
is_security_enabled = False, is_stack_supports_ranger_kerberos = False,
@@ -111,7 +111,7 @@ def setup_ranger_plugin(component_select_name, service_name, previous_jdbc_jar,
policy_user)

current_datetime = datetime.now()

File(format('{component_conf_dir}/ranger-security.xml'),
owner = component_user,
group = component_group,
@@ -174,15 +174,15 @@ def setup_ranger_plugin(component_select_name, service_name, previous_jdbc_jar,
configuration_attributes=plugin_policymgr_ssl_attributes,
owner = component_user,
group = component_group,
mode=0744)
mode=0744)
else:
XmlConfig("ranger-policymgr-ssl.xml",
conf_dir=component_conf_dir,
configurations=plugin_policymgr_ssl_properties_copy,
configuration_attributes=plugin_policymgr_ssl_attributes,
owner = component_user,
group = component_group,
mode=0744)
mode=0744)

# creating symblink should be done by rpm package
# setup_ranger_plugin_jar_symblink(stack_version, service_name, component_list)
@@ -193,8 +193,8 @@ def setup_ranger_plugin(component_select_name, service_name, previous_jdbc_jar,

else:
File(format('{component_conf_dir}/ranger-security.xml'),
action="delete"
)
action="delete"
)

def setup_ranger_plugin_jar_symblink(stack_version, service_name, component_list):

@@ -240,8 +240,8 @@ def setup_ranger_plugin_keystore(service_name, audit_db_is_enabled, stack_versio
mode = 0640
)

def setup_core_site_for_required_plugins(component_user, component_group, create_core_site_path, configurations = {}, configuration_attributes = {}):
XmlConfig('core-site.xml',
def setup_configuration_file_for_required_plugins(component_user, component_group, create_core_site_path, configurations = {}, configuration_attributes = {}, file_name='core-site.xml'):
XmlConfig(file_name,
conf_dir = create_core_site_path,
configurations = configurations,
configuration_attributes = configuration_attributes,
@@ -17,7 +17,7 @@
from resource_management.core.logger import Logger
from resource_management.core.resources import File, Execute
from resource_management.libraries.functions.format import format
from resource_management.libraries.functions.setup_ranger_plugin_xml import setup_core_site_for_required_plugins
from resource_management.libraries.functions.setup_ranger_plugin_xml import setup_configuration_file_for_required_plugins

def setup_ranger_kafka():
import params
@@ -84,14 +84,14 @@ def setup_ranger_kafka():
if params.stack_supports_core_site_for_ranger_plugin and params.enable_ranger_kafka and params.kerberos_security_enabled:
if params.has_namenode:
Logger.info("Stack supports core-site.xml creation for Ranger plugin and Namenode is installed, creating create core-site.xml from namenode configurations")
setup_core_site_for_required_plugins(component_user = params.kafka_user, component_group = params.user_group,
setup_configuration_file_for_required_plugins(component_user = params.kafka_user, component_group = params.user_group,
create_core_site_path = params.conf_dir, configurations = params.config['configurations']['core-site'],
configuration_attributes = params.config['configuration_attributes']['core-site'])
configuration_attributes = params.config['configurationAttributes']['core-site'], file_name='core-site.xml')
else:
Logger.info("Stack supports core-site.xml creation for Ranger plugin and Namenode is not installed, creating create core-site.xml from default configurations")
setup_core_site_for_required_plugins(component_user = params.kafka_user, component_group = params.user_group,
setup_configuration_file_for_required_plugins(component_user = params.kafka_user, component_group = params.user_group,
create_core_site_path = params.conf_dir, configurations = { 'hadoop.security.authentication' : 'kerberos' if params.kerberos_security_enabled else 'simple' },
configuration_attributes = {})
configuration_attributes = {}, file_name='core-site.xml')

else:
Logger.info("Stack does not support core-site.xml creation for Ranger plugin, skipping core-site.xml configurations")
@@ -18,7 +18,7 @@
"""
from resource_management.core.logger import Logger
from resource_management.libraries.functions.setup_ranger_plugin_xml import setup_core_site_for_required_plugins
from resource_management.libraries.functions.setup_ranger_plugin_xml import setup_configuration_file_for_required_plugins
from resource_management.core.resources import File
from resource_management.libraries.resources.xml_config import XmlConfig
from resource_management.libraries.functions.format import format
@@ -114,14 +114,14 @@ def setup_ranger_knox(upgrade_type=None):
if params.stack_supports_core_site_for_ranger_plugin and params.enable_ranger_knox and params.security_enabled:
if params.has_namenode:
Logger.info("Stack supports core-site.xml creation for Ranger plugin and Namenode is installed, creating create core-site.xml from namenode configurations")
setup_core_site_for_required_plugins(component_user = params.knox_user, component_group = params.knox_group,
setup_configuration_file_for_required_plugins(component_user = params.knox_user, component_group = params.knox_group,
create_core_site_path = params.knox_conf_dir, configurations = params.config['configurations']['core-site'],
configuration_attributes = params.config['configuration_attributes']['core-site'])
configuration_attributes = params.config['configurationAttributes']['core-site'], file_name = 'core-site.xml')
else:
Logger.info("Stack supports core-site.xml creation for Ranger plugin and Namenode is not installed, creating create core-site.xml from default configurations")
setup_core_site_for_required_plugins(component_user = params.knox_user, component_group = params.knox_group,
setup_configuration_file_for_required_plugins(component_user = params.knox_user, component_group = params.knox_group,
create_core_site_path = params.knox_conf_dir, configurations = { 'hadoop.security.authentication' : 'kerberos' if params.security_enabled else 'simple' },
configuration_attributes = {})
configuration_attributes = {}, file_name = 'core-site.xml')
else:
Logger.info("Stack does not support core-site.xml creation for Ranger plugin, skipping core-site.xml configurations")

@@ -18,7 +18,7 @@
"""
from resource_management.core.logger import Logger
from resource_management.libraries.functions.setup_ranger_plugin_xml import setup_core_site_for_required_plugins
from resource_management.libraries.functions.setup_ranger_plugin_xml import setup_configuration_file_for_required_plugins
from resource_management.libraries.resources.xml_config import XmlConfig
from resource_management.libraries.functions.format import format
from resource_management.core.resources import File, Directory
@@ -114,25 +114,20 @@ def setup_ranger_storm(upgrade_type=None):
if params.stack_supports_core_site_for_ranger_plugin and params.enable_ranger_storm and params.security_enabled:
if params.has_namenode:
Logger.info("Stack supports core-site.xml creation for Ranger plugin and Namenode is installed, creating create core-site.xml from namenode configurations")
setup_core_site_for_required_plugins(component_user = params.storm_user, component_group = params.user_group,
setup_configuration_file_for_required_plugins(component_user = params.storm_user, component_group = params.user_group,
create_core_site_path = site_files_create_path, configurations = params.config['configurations']['core-site'],
configuration_attributes = params.config['configuration_attributes']['core-site'])
configuration_attributes = params.config['configurationAttributes']['core-site'], file_name='core-site.xml')
else:
Logger.info("Stack supports core-site.xml creation for Ranger plugin and Namenode is not installed, creating create core-site.xml from default configurations")
setup_core_site_for_required_plugins(component_user = params.storm_user, component_group = params.user_group,
setup_configuration_file_for_required_plugins(component_user = params.storm_user, component_group = params.user_group,
create_core_site_path = site_files_create_path, configurations = { 'hadoop.security.authentication' : 'kerberos' if params.security_enabled else 'simple' },
configuration_attributes = {})
configuration_attributes = {}, file_name = 'core-site.xml')

if len(params.namenode_hosts) > 1:
Logger.info('Ranger Storm plugin is enabled along with security and NameNode is HA , creating hdfs-site.xml')
XmlConfig("hdfs-site.xml",
conf_dir=site_files_create_path,
configurations=params.config['configurations']['hdfs-site'],
configuration_attributes=params.config['configurationAttributes']['hdfs-site'],
owner=params.storm_user,
group=params.user_group,
mode=0644
)
setup_configuration_file_for_required_plugins(component_user = params.storm_user, component_group = params.user_group,
create_core_site_path = site_files_create_path, configurations = params.config['configurations']['hdfs-site'],
configuration_attributes = params.config['configurationAttributes']['hdfs-site'], file_name = 'hdfs-site.xml')
else:
Logger.info('Ranger Storm plugin is not enabled or security is disabled, removing hdfs-site.xml')
File(format('{site_files_create_path}/hdfs-site.xml'), action="delete")

0 comments on commit 391de63

Please sign in to comment.