Roll back the given dataset to a previous snapshot.

    name : string
        name of snapshot
    recursive : boolean
        destroy any snapshots and bookmarks more recent than the one
        specified.
    recursive_all : boolean
        destroy any more recent snapshots and bookmarks, as well as any
        clones of those snapshots.
    force : boolean
        used with the -R option to force an unmount of any clone file
        systems that are to be destroyed.

    .. warning::

        When a dataset is rolled back, all data that has changed since
        the snapshot is discarded, and the dataset reverts to the state
        at the time of the snapshot. By default, the command refuses to
        roll back to a snapshot other than the most recent one.

        In order to do so, all intermediate snapshots and bookmarks
        must be destroyed by specifying the -r option.

    .. versionadded:: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt '*' zfs.rollback myzpool/mydataset@yesterday

def rollback(name, **kwargs):
    '''
    Roll back the given dataset to a previous snapshot.

    name : string
        name of snapshot
    recursive : boolean
        destroy any snapshots and bookmarks more recent than the one
        specified.
    recursive_all : boolean
        destroy any more recent snapshots and bookmarks, as well as any
        clones of those snapshots.
    force : boolean
        used with the -R option to force an unmount of any clone file
        systems that are to be destroyed.

    .. warning::

        When a dataset is rolled back, all data that has changed since
        the snapshot is discarded, and the dataset reverts to the state
        at the time of the snapshot. By default, the command refuses to
        roll back to a snapshot other than the most recent one.

        In order to do so, all intermediate snapshots and bookmarks
        must be destroyed by specifying the -r option.

    .. versionadded:: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt '*' zfs.rollback myzpool/mydataset@yesterday

    '''
    ## Configure command
    # NOTE: initialize the defaults
    flags = []

    # NOTE: set extra config from kwargs
    if kwargs.get('recursive_all', False):
        flags.append('-R')
    if kwargs.get('recursive', False):
        flags.append('-r')
    if kwargs.get('force', False):
        if kwargs.get('recursive_all', False) or kwargs.get('recursive', False):
            flags.append('-f')
        else:
            log.warning('zfs.rollback - force=True can only be used with recursive_all=True or recursive=True')

    ## Rollback to snapshot
    res = __salt__['cmd.run_all'](
        __utils__['zfs.zfs_command'](
            command='rollback',
            flags=flags,
            target=name,
        ),
        python_shell=False,
    )

    return __utils__['zfs.parse_command_result'](res, 'rolledback')