code: def rename(name, new_name):
      '''
      Change the username for a named user
  
      CLI Example:
  
      .. code-block:: bash
  
          salt '*' user.rename name new_name
      '''
      current_info = info(name)
      if not current_info:
          raise CommandExecutionError('User \'{0}\' does not exist'.format(name))
      new_info = info(new_name)
      if new_info:
          raise CommandExecutionError(
              'User \'{0}\' already exists'.format(new_name)
          )
      _dscl(
          ['/Users/{0}'.format(name), 'RecordName', name, new_name],
          ctype='change'
      )
      # dscl buffers changes, sleep 1 second before checking if new value
      # matches desired value
      time.sleep(1)
      return info(new_name).get('RecordName') == new_namf rename(name, new_name):
      '''
      Change the username for a named user
  
      CLI Example:
  
      .. code-block:: bash
  
          salt '*' user.rename name new_name
      '''
      current_info = info(name)
      if not current_info:
          raise CommandExecutionError('User \'{0}\' does not exist'.format(name))
      new_info = info(new_name)
      if new_info:
          raise CommandExecutionError(
              'User \'{0}\' already exists'.format(new_name)
          )
      _dscl(
          ['/Users/{0}'.format(name), 'RecordName', name, new_name],
          ctype='change'
      )
      # dscl buffers changes, sleep 1 second before checking if new value
      # matches desired value
      time.sleep(1)
      return info(new_name).get('RecordName') == new_name
docs: Change the username for a named user
  
      CLI Example:
  
      .. code-block:: bash
  
          salt '*' user.rename name new_name