Reverted: Add MOLECULE_SHARED_INVENTORY_DIR environment variable and playbook variable #4500
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add MOLECULE_SHARED_INVENTORY_DIR environment variable and playbook variable
Summary
Introduces
MOLECULE_SHARED_INVENTORY_DIRas both an environment variable and playbook variable to enable access to shared inventory directories when using the--shared-inventoryoption. This enhancement allows scenarios to programmatically create and consume shared inventory files across multiple test runs.Use Case
When testing complex multi-scenario setups, users often need to share inventory data between scenarios. The existing
--shared-inventoryoption provides shared storage but lacks programmatic access from playbooks. This implementation enables:Implementation Details
Core Changes
Environment Variable (
src/molecule/config.py)MOLECULE_SHARED_INVENTORY_DIRto environment variables--shared-inventoryenabled and not in parallel modePlaybook Variable (
src/molecule/provisioner/ansible.py)molecule_shared_inventory_dirto molecule variables available in all playbooks{{ lookup('env', 'MOLECULE_SHARED_INVENTORY_DIR') }}dict[str, str]todict[str, Any]Testing
Unit Tests
tests/unit/test_config.py: Environment variable behavior across all modestests/unit/provisioner/test_ansible.py: Playbook variable inclusion verificationIntegration Tests
tests/fixtures/integration/.../shared_inventory/: Complete test scenario with realistic inventory templatingtests/integration/test_command.py: Dedicated test for shared inventory functionalityDocumentation
Configuration Reference (
docs/configuration.md)Usage Guide (
docs/guides/sharing.md)Behavior
shared_inventoryparallelfalsefalse""(empty)truefalse/path/to/shared/inventorytruetrue""(shared disabled)Example Usage
Compatibility