.. versionadded:: Fluorine

    Execute ``yum-complete-transaction``, which is provided by the ``yum-utils`` package.

    cleanup_only
        Specify if the ``--cleanup-only`` option should be supplied.

    recursive
        Specify if ``yum-complete-transaction`` should be called recursively
        (it only completes one transaction at a time).

    max_attempts
        If ``recursive`` is ``True``, the maximum times ``yum-complete-transaction`` should be called.

    .. note::

        Recursive calls will stop once ``No unfinished transactions left.`` is in the returned output.

    .. note::

        ``yum-utils`` will already be installed on the minion if the package
        was installed from the Fedora / EPEL repositories.

    CLI example:

    .. code-block:: bash

        salt '*' pkg.complete_transaction
        salt '*' pkg.complete_transaction cleanup_only=True
        salt '*' pkg.complete_transaction recursive=True max_attempts=5

def complete_transaction(cleanup_only=False, recursive=False, max_attempts=3):
    '''
    .. versionadded:: Fluorine

    Execute ``yum-complete-transaction``, which is provided by the ``yum-utils`` package.

    cleanup_only
        Specify if the ``--cleanup-only`` option should be supplied.

    recursive
        Specify if ``yum-complete-transaction`` should be called recursively
        (it only completes one transaction at a time).

    max_attempts
        If ``recursive`` is ``True``, the maximum times ``yum-complete-transaction`` should be called.

    .. note::

        Recursive calls will stop once ``No unfinished transactions left.`` is in the returned output.

    .. note::

        ``yum-utils`` will already be installed on the minion if the package
        was installed from the Fedora / EPEL repositories.

    CLI example:

    .. code-block:: bash

        salt '*' pkg.complete_transaction
        salt '*' pkg.complete_transaction cleanup_only=True
        salt '*' pkg.complete_transaction recursive=True max_attempts=5
    '''

    return _complete_transaction(cleanup_only, recursive, max_attempts, 1, [])