support ansible-core 2.21; lock ansible.posix to 2.1.X#242
Conversation
Add support for ansible-core 2.21 lock ansible.posix to version 2.1.X Signed-off-by: Rich Megginson <rmeggins@redhat.com>
📝 WalkthroughWalkthroughThis PR introduces configurable ansible.posix collection versioning through an environment variable and adds support for Ansible core 2.21 test environments. The tox configuration and test scripts are updated to read the externalized version constraint, and corresponding test fixture updates verify the configuration merging behavior. ChangesAnsible version support and configurability
🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/tox_lsr/config_files/tox-default.ini`:
- Around line 540-549: The testenv [testenv:qemu-ansible-core-2-21] currently
inherits an unversioned basepython from qemu_common but ansible-core 2.21
requires Python >=3.12; update this section to set basepython = python3.12 (or
alternatively update qemu_common to enforce python3.12+) so the environment uses
an explicit supported interpreter, and in deps replace any 2.21.* RC pin with a
stable 2.21.0 release specifier once available for reproducible builds.
In `@src/tox_lsr/test_scripts/runcontainer.sh`:
- Line 129: The script uses LSR_ANSIBLE_POSIX_VERSION as a fallback for the
galaxy_collection install but currently defaults to "ansible.posix" which
installs the latest release; change the fallback to the constrained version
string used in tox-default.ini (ansible.posix>=2.1.0,<2.2.0) so the
galaxy_collection command (galaxy_collection "$LSR_TOX_ENV_TMP_DIR" install -vv
"${LSR_ANSIBLE_POSIX_VERSION:-...}") will install the intended 2.1.x series when
LSR_ANSIBLE_POSIX_VERSION is unset.
In `@src/tox_lsr/test_scripts/runqemu.py`:
- Line 1402: The default fallback for LSR_ANSIBLE_POSIX_VERSION is currently
"ansible.posix" which pulls the latest release and conflicts with the constraint
in tox-default.ini; update the fallback value used in runqemu.py (the
os.environ.get call that references "LSR_ANSIBLE_POSIX_VERSION") to the
version-constrained string "ansible.posix>=2.1.0,<2.2.0" so the script installs
the intended 2.1.x series when the env var is not set.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a7bb7d72-5cb4-4374-94f2-889ae2d11f7f
📒 Files selected for processing (4)
src/tox_lsr/config_files/tox-default.inisrc/tox_lsr/test_scripts/runcontainer.shsrc/tox_lsr/test_scripts/runqemu.pytests/fixtures/test_tox_merge_ini/result.ini
| [testenv:qemu-ansible-core-2-21] | ||
| changedir = {[qemu_common]changedir} | ||
| basepython = {[qemu_common]basepython} | ||
| setenv = | ||
| {[qemu_common]setenv} | ||
| deps = | ||
| {[qemu_common]deps} | ||
| ansible-core==2.21.* | ||
| commands = | ||
| {[qemu_common]commands} |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check if ansible-core 2.21.* is available on PyPI
echo "Checking ansible-core versions on PyPI..."
curl -s https://pypi.org/pypi/ansible-core/json | jq -r '.releases | keys[]' | grep '^2\.21\.' | head -5 || echo "No 2.21.* versions found"
# Check Python version requirements for latest 2.21 if available
echo ""
echo "Checking Python version requirements..."
latest_21=$(curl -s https://pypi.org/pypi/ansible-core/json | jq -r '.releases | keys[]' | grep '^2\.21\.' | sort -V | tail -1)
if [ -n "$latest_21" ]; then
echo "Latest 2.21 version: $latest_21"
curl -s "https://pypi.org/pypi/ansible-core/$latest_21/json" | jq -r '.info.requires_python'
else
echo "No 2.21 version found"
fiRepository: linux-system-roles/tox-lsr
Length of output: 235
🏁 Script executed:
grep -n "qemu_common" src/tox_lsr/config_files/tox-default.ini | head -20Repository: linux-system-roles/tox-lsr
Length of output: 752
🏁 Script executed:
sed -n '404,430p' src/tox_lsr/config_files/tox-default.iniRepository: linux-system-roles/tox-lsr
Length of output: 906
Specify explicit Python version for ansible-core 2.21 compatibility.
The qemu_common basepython is python3 (unversioned), but ansible-core 2.21 requires Python >=3.12. Either set basepython = python3.12 in this section or update qemu_common to enforce the requirement. Additionally, ansible-core 2.21.0rc1 is a release candidate—consider using a stable 2.21.0 release once available if reproducibility is important.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/tox_lsr/config_files/tox-default.ini` around lines 540 - 549, The testenv
[testenv:qemu-ansible-core-2-21] currently inherits an unversioned basepython
from qemu_common but ansible-core 2.21 requires Python >=3.12; update this
section to set basepython = python3.12 (or alternatively update qemu_common to
enforce python3.12+) so the environment uses an explicit supported interpreter,
and in deps replace any 2.21.* RC pin with a stable 2.21.0 release specifier
once available for reproducible builds.
| if [ -n "${need_debug_py:-}" ] || [ -n "${need_profile_py:-}" ]; then | ||
| info installing callback plugins in "$callback_plugin_dir" | ||
| galaxy_collection "$LSR_TOX_ENV_TMP_DIR" install -vv ansible.posix | ||
| galaxy_collection "$LSR_TOX_ENV_TMP_DIR" install -vv "${LSR_ANSIBLE_POSIX_VERSION:-ansible.posix}" |
There was a problem hiding this comment.
Inconsistent default version constraint.
The fallback value ansible.posix will install the latest version, inconsistent with the default constraint ansible.posix>=2.1.0,<2.2.0 defined in tox-default.ini (line 34). If LSR_ANSIBLE_POSIX_VERSION is not set, this script will install the latest ansible.posix instead of the intended 2.1.X series, defeating the purpose of the PR.
🔧 Proposed fix
- galaxy_collection "$LSR_TOX_ENV_TMP_DIR" install -vv "${LSR_ANSIBLE_POSIX_VERSION:-ansible.posix}"
+ galaxy_collection "$LSR_TOX_ENV_TMP_DIR" install -vv "${LSR_ANSIBLE_POSIX_VERSION:-ansible.posix>=2.1.0,<2.2.0}"📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| galaxy_collection "$LSR_TOX_ENV_TMP_DIR" install -vv "${LSR_ANSIBLE_POSIX_VERSION:-ansible.posix}" | |
| galaxy_collection "$LSR_TOX_ENV_TMP_DIR" install -vv "${LSR_ANSIBLE_POSIX_VERSION:-ansible.posix>=2.1.0,<2.2.0}" |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/tox_lsr/test_scripts/runcontainer.sh` at line 129, The script uses
LSR_ANSIBLE_POSIX_VERSION as a fallback for the galaxy_collection install but
currently defaults to "ansible.posix" which installs the latest release; change
the fallback to the constrained version string used in tox-default.ini
(ansible.posix>=2.1.0,<2.2.0) so the galaxy_collection command
(galaxy_collection "$LSR_TOX_ENV_TMP_DIR" install -vv
"${LSR_ANSIBLE_POSIX_VERSION:-...}") will install the intended 2.1.x series when
LSR_ANSIBLE_POSIX_VERSION is unset.
There was a problem hiding this comment.
It should be ok in this context - the runcontainer.sh script should only be run by tox, which will always set the LSR_ANSIBLE_POSIX_VERSION environment variable
There was a problem hiding this comment.
@richm, understood — since tox always populates LSR_ANSIBLE_POSIX_VERSION via the setenv block in tox-default.ini (defaulting to ansible.posix>=2.1.0,<2.2.0), the bare ansible.posix fallback in the script is effectively unreachable in normal usage. My concern doesn't apply here. Thanks for the clarification!
✏️ Learnings added
Learnt from: richm
Repo: linux-system-roles/tox-lsr PR: 242
File: src/tox_lsr/test_scripts/runcontainer.sh:129-129
Timestamp: 2026-05-19T19:21:53.993Z
Learning: In the `linux-system-roles/tox-lsr` repo, `src/tox_lsr/test_scripts/runcontainer.sh` is always invoked via `tox`, which always sets the `LSR_ANSIBLE_POSIX_VERSION` environment variable (defaulting to `ansible.posix>=2.1.0,<2.2.0` via tox-default.ini setenv). The bare `ansible.posix` shell fallback for `LSR_ANSIBLE_POSIX_VERSION` is intentional and safe because direct manual invocation of the script is not a supported use case.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
| "-vv", | ||
| get_galaxy_force_flag(), | ||
| "ansible.posix", | ||
| os.environ.get("LSR_ANSIBLE_POSIX_VERSION", "ansible.posix"), |
There was a problem hiding this comment.
Inconsistent default version constraint.
The fallback value ansible.posix will install the latest version, inconsistent with the default constraint ansible.posix>=2.1.0,<2.2.0 defined in tox-default.ini (line 34). If LSR_ANSIBLE_POSIX_VERSION is not set, this script will install the latest ansible.posix instead of the intended 2.1.X series.
🔧 Proposed fix
- os.environ.get("LSR_ANSIBLE_POSIX_VERSION", "ansible.posix"),
+ os.environ.get("LSR_ANSIBLE_POSIX_VERSION", "ansible.posix>=2.1.0,<2.2.0"),📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| os.environ.get("LSR_ANSIBLE_POSIX_VERSION", "ansible.posix"), | |
| os.environ.get("LSR_ANSIBLE_POSIX_VERSION", "ansible.posix>=2.1.0,<2.2.0"), |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/tox_lsr/test_scripts/runqemu.py` at line 1402, The default fallback for
LSR_ANSIBLE_POSIX_VERSION is currently "ansible.posix" which pulls the latest
release and conflicts with the constraint in tox-default.ini; update the
fallback value used in runqemu.py (the os.environ.get call that references
"LSR_ANSIBLE_POSIX_VERSION") to the version-constrained string
"ansible.posix>=2.1.0,<2.2.0" so the script installs the intended 2.1.x series
when the env var is not set.
There was a problem hiding this comment.
It should be ok in this context - the runqemu.py script should only be run by tox, which will always set the LSR_ANSIBLE_POSIX_VERSION environment variable
There was a problem hiding this comment.
@richm, understood — since tox-default.ini always injects LSR_ANSIBLE_POSIX_VERSION into the environment before invoking runqemu.py, the bare "ansible.posix" fallback is effectively unreachable in normal usage. The concern doesn't apply here.
✏️ Learnings added
Learnt from: richm
Repo: linux-system-roles/tox-lsr PR: 242
File: src/tox_lsr/test_scripts/runqemu.py:1402-1402
Timestamp: 2026-05-19T19:22:14.906Z
Learning: In the tox-lsr repository, `src/tox_lsr/test_scripts/runqemu.py` is only ever invoked through tox. The `LSR_ANSIBLE_POSIX_VERSION` environment variable is always set by tox (via `tox-default.ini` setenv), so the bare `"ansible.posix"` fallback in `os.environ.get("LSR_ANSIBLE_POSIX_VERSION", "ansible.posix")` at line 1402 is intentionally unreachable in normal usage.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
Add support for ansible-core 2.21
lock ansible.posix to version 2.1.X
Signed-off-by: Rich Megginson rmeggins@redhat.com
Summary by CodeRabbit
New Features
Improvements