Skip to content

support ansible-core 2.21; lock ansible.posix to 2.1.X#242

Merged
richm merged 1 commit into
linux-system-roles:mainfrom
richm:ansible.posix-2.1.x
May 20, 2026
Merged

support ansible-core 2.21; lock ansible.posix to 2.1.X#242
richm merged 1 commit into
linux-system-roles:mainfrom
richm:ansible.posix-2.1.x

Conversation

@richm

@richm richm commented May 19, 2026

Copy link
Copy Markdown
Contributor

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

    • Added support for Ansible Core 2.21 with dedicated QEMU and container test environments
    • Ansible.posix collection version is now configurable via environment variable with default version constraint
  • Improvements

    • Simplified Ansible Core 2.20 environment configuration by removing unnecessary settings

Review Change Stack

Add support for ansible-core 2.21

lock ansible.posix to version 2.1.X

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
@coderabbitai

coderabbitai Bot commented May 19, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This 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.

Changes

Ansible version support and configurability

Layer / File(s) Summary
Ansible.posix version configurability
src/tox_lsr/config_files/tox-default.ini, src/tox_lsr/test_scripts/runcontainer.sh, src/tox_lsr/test_scripts/runqemu.py, tests/fixtures/test_tox_merge_ini/result.ini
LSR_ANSIBLE_POSIX_VERSION environment variable is added to tox configuration with default ansible.posix>=2.1.0,<2.2.0, and test scripts are updated to read this variable when invoking ansible-galaxy collection install instead of hardcoding ansible.posix. Test fixture mirrors the configuration changes.
Ansible core 2.21 support and 2.20 cleanup
src/tox_lsr/config_files/tox-default.ini, tests/fixtures/test_tox_merge_ini/result.ini
Two new test environments (qemu-ansible-core-2-21 and container-ansible-core-2-21) are added to pin ansible-core==2.21.*. Pre-release pip behavior (pip_pre = true) is removed from existing qemu-ansible-core-2-20 and container-ansible-core-2-20 environments. Test fixture updates verify both configuration merging and the new environment definitions.

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the two main changes: adding support for ansible-core 2.21 and locking ansible.posix to 2.1.X, which aligns with the modifications across all changed files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between ce34bbe and 6016078.

📒 Files selected for processing (4)
  • src/tox_lsr/config_files/tox-default.ini
  • src/tox_lsr/test_scripts/runcontainer.sh
  • src/tox_lsr/test_scripts/runqemu.py
  • tests/fixtures/test_tox_merge_ini/result.ini

Comment on lines +540 to +549
[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}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 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"
fi

Repository: linux-system-roles/tox-lsr

Length of output: 235


🏁 Script executed:

grep -n "qemu_common" src/tox_lsr/config_files/tox-default.ini | head -20

Repository: linux-system-roles/tox-lsr

Length of output: 752


🏁 Script executed:

sed -n '404,430p' src/tox_lsr/config_files/tox-default.ini

Repository: 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}"

@coderabbitai coderabbitai Bot May 19, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

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.

Suggested change
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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@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"),

@coderabbitai coderabbitai Bot May 19, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

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.

Suggested change
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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@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.

@richm richm merged commit 1a28455 into linux-system-roles:main May 20, 2026
8 checks passed
@richm richm deleted the ansible.posix-2.1.x branch May 20, 2026 00:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant