code: def rename(name, new_name, root=None):
      '''
      Change the username for a named user
  
      name
          User to modify
  
      new_name
          New value of the login name
  
      root
          Directory to chroot into
  
      CLI Example:
  
      .. code-block:: bash
  
          salt '*' user.rename name new_name
      '''
      if info(new_name, root=root):
          raise CommandExecutionError('User \'{0}\' already exists'.format(new_name))
  
      return _chattrib(name, 'name', new_name, '-l', root=rootf rename(name, new_name, root=None):
      '''
      Change the username for a named user
  
      name
          User to modify
  
      new_name
          New value of the login name
  
      root
          Directory to chroot into
  
      CLI Example:
  
      .. code-block:: bash
  
          salt '*' user.rename name new_name
      '''
      if info(new_name, root=root):
          raise CommandExecutionError('User \'{0}\' already exists'.format(new_name))
  
      return _chattrib(name, 'name', new_name, '-l', root=root)
docs: Change the username for a named user
  
      name
          User to modify
  
      new_name
          New value of the login name
  
      root
          Directory to chroot into
  
      CLI Example:
  
      .. code-block:: bash
  
          salt '*' user.rename name new_name