Exemplo n.º 1
0
def setup_ambari_krb5_jaas(options):
    jaas_conf_file = search_file(SECURITY_KERBEROS_JASS_FILENAME,
                                 get_conf_dir())
    if os.path.exists(jaas_conf_file):
        print 'Setting up Ambari kerberos JAAS configuration to access ' + \
              'secured Hadoop daemons...'
        principal = get_validated_string_input(
            'Enter ambari server\'s kerberos '
            'principal name ([email protected]): ',
            '*****@*****.**',
            '.*',
            '',
            False,
            False,
            answer=options.jaas_principal)
        keytab = get_validated_string_input(
            'Enter keytab path for ambari '
            'server\'s kerberos principal: ',
            '/etc/security/keytabs/ambari.keytab',
            '.*',
            False,
            False,
            validatorFunction=is_valid_filepath,
            answer=options.jaas_keytab)

        for line in fileinput.FileInput(jaas_conf_file, inplace=1):
            line = re.sub('keyTab=.*$', 'keyTab="' + keytab + '"', line)
            line = re.sub('principal=.*$', 'principal="' + principal + '"',
                          line)
            print line,

        write_property(CHECK_AMBARI_KRB_JAAS_CONFIGURATION_PROPERTY, "true")
    else:
        raise NonFatalException('No jaas config file found at location: ' +
                                jaas_conf_file)
Exemplo n.º 2
0
  def do_checks(self):
    try:
      user = read_ambari_user()
      create_user = False
      update_user_setting = False
      if user is not None:
        create_user = get_YN_input(self.NR_USER_CHANGE_PROMPT.format(user), False)
        update_user_setting = create_user  # Only if we will create another user
      else:  # user is not configured yet
        update_user_setting = True  # Write configuration anyway
        create_user = get_YN_input(self.NR_USER_CUSTOMIZE_PROMPT, False)
        if not create_user:
          user = self.NR_DEFAULT_USER

      if create_user:
        (retcode, user) = self._create_custom_user()
        if retcode != 0:
          return retcode

      if update_user_setting:
        write_property(NR_USER_PROPERTY, user)

      adjust_directory_permissions(user)
    except OSError as e:
      print_error_msg("Failed: %s" % str(e))
      return 4
    except Exception as e:
      print_error_msg("Unexpected error %s" % str(e))
      return 1
    return 0
Exemplo n.º 3
0
  def do_checks(self):
    try:
      user = read_ambari_user()
      create_user = False
      update_user_setting = False
      if user is not None:
        create_user = get_YN_input_optional(self.NR_USER_CHANGE_PROMPT.format(user), False,SETUP_USE_DEFAULT)
        update_user_setting = create_user  # Only if we will create another user
      else:  # user is not configured yet
        update_user_setting = True  # Write configuration anyway
        create_user = get_YN_input_optional(self.NR_USER_CUSTOMIZE_PROMPT, False,SETUP_USE_DEFAULT)
        if not create_user:
          user = self.NR_DEFAULT_USER

      if create_user:
        (retcode, user) = self._create_custom_user()
        if retcode != 0:
          return retcode

      if update_user_setting:
        write_property(NR_USER_PROPERTY, user)

      adjust_directory_permissions(user)
    except OSError as e:
      print_error_msg("Failed: %s" % str(e))
      return 4
    except Exception as e:
      print_error_msg("Unexpected error %s" % str(e))
      return 1
    return 0
Exemplo n.º 4
0
def service_setup(register_service, svc_user, svc_password):
  from ambari_windows_service import svcsetup

  svc_user_setup = svc_user if svc_user.upper() != "NT AUTHORITY\\SYSTEM" else None

  result = svcsetup(register_service, svc_user_setup, svc_password)
  if result == 0:
    write_property(NR_USER_PROPERTY, svc_user)
Exemplo n.º 5
0
def configure_os_settings():
  properties = get_ambari_properties()
  if properties == -1:
    print_error_msg("Error getting ambari properties")
    return -1
  try:
    conf_os_type = properties[OS_TYPE_PROPERTY]
    if conf_os_type != '':
      print_info_msg("os_type already set in the properties file")
      return 0
  except (KeyError):
    print_error_msg("os_type is not set in the properties file. Setting it now.")

  # to check server/agent compatibility
  master_os_family = OS_FAMILY + OS_VERSION
  # to check supported os_types
  master_os_type = OS_TYPE + OS_VERSION

  write_property(OS_FAMILY_PROPERTY, master_os_family)
  write_property(OS_TYPE_PROPERTY, master_os_type)
  return 0
Exemplo n.º 6
0
def service_setup(register_service, svc_user, svc_password):
  #Nothing else to do in Linux
  write_property(NR_USER_PROPERTY, svc_user)
Exemplo n.º 7
0
def service_setup(register_service, svc_user, svc_password):
    from ambari_windows_service import svcsetup

    result = svcsetup(register_service, svc_user, svc_password)
    if result == 0:
        write_property(NR_USER_PROPERTY, svc_user)