Skip to content

Conversation

@cidrblock
Copy link
Contributor

@cidrblock cidrblock commented Aug 7, 2025

Summary

This PR adds the missing --all flag support to the molecule reset command, bringing it in line with other molecule commands and extending the shared directory functionality previously introduced for shared-state and shared-inventory.

Problem Statement

The molecule reset command was the only core command lacking --all flag support, creating inconsistency in the CLI interface. Additionally, the command did not clean up shared ephemeral directories (introduced for shared-state and shared-inventory), leaving artifacts behind during full resets.

Changes Made

Per-file Changes:

src/molecule/command/reset.py (+37 lines, -5 lines)

  • Implemented --all flag handling with shared directory cleanup logic
  • Added conditional cleanup of shared ephemeral directories when --all is used
  • Integrated with existing execute_cmdline_scenarios workflow

src/molecule/command/base.py (+1 line, -1 line)

  • Fixed multi-scenario processing bug (changed return to continue in _run_scenarios)
  • Ensures all scenarios are processed when using --all flag

tests/unit/command/test_reset.py (+513 lines, new file)

  • Comprehensive test suite with 9 test cases covering:
    • Basic scenario reset functionality
    • Multi-scenario processing with --all flag
    • Exclude functionality integration
    • Shared directory cleanup behavior
    • Edge cases and backward compatibility

Relation to Shared-State/Shared-Inventory

This change complements the shared-state and shared-inventory features introduced months ago by ensuring the reset command properly cleans up shared ephemeral directories. When --all is specified, the command now performs a "nuclear" cleanup, removing both per-scenario artifacts and shared directories, providing a complete reset functionality.

Testing

All existing tests pass, and the new test suite provides comprehensive coverage of the reset command functionality including edge cases and integration with the shared directory system.

Backward Compatibility

This change is fully backward compatible. Existing molecule reset [scenario] usage remains unchanged, with the --all flag being purely additive functionality.

- Add all_scenarios_reset option to click_cfg.py with custom help text
- Implement --all flag support in reset.py with shared directory cleanup
- Fix multi-scenario processing bug in base.py (return -> continue)
- Add comprehensive test suite for reset command with 9 test cases
- Tests cover basic scenarios, --all flag, excludes, and shared cleanup
- Resolves missing --all flag support in reset command
- Extends shared-state/shared-inventory functionality to reset operations

This comment was marked as outdated.

Copy link
Collaborator

@Qalthos Qalthos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant in the help text for reset itself, but this works too

@Qalthos Qalthos merged commit 436837d into ansible:main Aug 11, 2025
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants