Skip to content

Fix ansible-core version preservation during ansible-dev-tools installation#356

Merged
cidrblock merged 4 commits intoansible:mainfrom
cidrblock:fix_user_core
Aug 14, 2025
Merged

Fix ansible-core version preservation during ansible-dev-tools installation#356
cidrblock merged 4 commits intoansible:mainfrom
cidrblock:fix_user_core

Conversation

@cidrblock
Copy link
Copy Markdown
Collaborator

@cidrblock cidrblock commented Aug 14, 2025

Fixes: #354

Problem

When users specify a specific ansible-core version via --ansible-core-version, the subsequent installation of ansible-dev-tools would override the user-specified version due to dependency resolution conflicts. For example, ansible-core==2.16.0 would be upgraded to ansible-core==2.19.0 during ansible-dev-tools installation.

Solution

This PR implements a dependency-aware installation strategy that preserves user-specified ansible-core versions while providing compatibility warnings:

Core Changes

  1. Installation Order: Reorder dependency installation to install ansible-dev-tools first, then force-reinstall the user-specified ansible-core version
  2. Dynamic Dependency Detection: Add get_dependency_constraint() utility that uses pip install --dry-run to determine ansible-dev-tools' ansible-core requirements at runtime
  3. Compatibility Warnings: Implement proactive warning system when user-requested versions fall outside ansible-dev-tools compatibility bounds
  4. Configuration Refactor: Split venv_pip_install_cmd into separate venv_pip_cmd and venv_pip_install_cmd properties following DRY principles

Implementation Details

  • Leverages pip's native dependency resolution instead of hardcoded version constraints
  • Uses subprocess with timeout and robust error handling for external pip commands
  • Implements packaging library integration with graceful fallback when unavailable
  • Adds comprehensive test suite with 50+ test cases covering edge cases and error scenarios

Testing

  • New integration test validates core version preservation
  • Unit tests cover dependency constraint detection, warning logic, and error handling
  • All existing tests pass, maintaining backward compatibility

Technical Notes

The solution respects pip's dependency resolution while ensuring user intent is preserved. The warning system helps users understand potential compatibility issues without blocking installation.

Files changed: 5 files, 1215 insertions, 8 deletions

- Reorder installation to install ansible-dev-tools first, then ansible-core
- Add force reinstallation for user-specified ansible-core versions
- Implement runtime dependency constraint checking with pip --dry-run
- Add version compatibility warnings for conflicting requirements
- Refactor config properties: split venv_pip_install_cmd into venv_pip_cmd and venv_pip_install_cmd
- Add comprehensive test coverage for dependency constraint detection and warning system
- Move packaging imports to module level with proper fallback handling
- Remove redundant integration test (seed enabled by default)

Resolves issue where ansible-dev-tools installation would override user-specified
ansible-core versions by leveraging pip's native dependency resolution.
cidrblock and others added 3 commits August 14, 2025 10:06
- Cast FakeConfig to Config type in test fixtures
- Change timeout parameter from float to int in timeout test
- Add proper typing imports for cast function

Resolves remaining mypy type checker warnings.
@cidrblock cidrblock merged commit 0733af8 into ansible:main Aug 14, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Ansible core version constraint is ignored

2 participants