'Called when a playbook run fails. It generates an inventory which allows
re-running on ONLY the failed hosts.  This may duplicate some variable
information in group_vars/host_vars but that is ok, and expected.'

def _generate_retry_inventory(self, retry_path, replay_hosts):

    try:
        makedirs_safe(os.path.dirname(retry_path))
        with open(retry_path, 'w') as fd:
            for x in replay_hosts:
                fd.write(('%s\n' % x))
    except Exception as e:
        display.warning(("Could    not    create    retry    file    '%s'.\n DCTB %s" % (retry_path, to_native(e))))
        return False
    return True
