def generate_pyproject(tmp_path):
    """Return function which generates pyproject.toml with a given ignore_fail value."""

    def generator(ignore_fail):
        project_tmpl = """
            [tool.poe.tasks]
            task_1 = { shell = "echo 'task 1 error'; exit 1;" }
            task_2 = { shell = "echo 'task 2 error'; exit 1;" }
            task_3 = { shell = "echo 'task 3 success'; exit 0;" }

            [tool.poe.tasks.all_tasks]
            sequence = ["task_1", "task_2", "task_3"]
        """
        if isinstance(ignore_fail, bool) and ignore_fail:
            project_tmpl += "\nignore_fail = true"
        elif not isinstance(ignore_fail, bool):
            project_tmpl += f'\nignore_fail = "{ignore_fail}"'
        with open(tmp_path / "pyproject.toml", "w") as fp:
            fp.write(project_tmpl)

        return tmp_path

    return generator