fix(inventory): mark plugin-supplied strings as trusted for ansible-core 2.19+#325
Merged
Merged
Conversation
…ore 2.19+
ansible-core 2.19 introduced a data-tagging model. The legacy JSON encoder
that backs `ansible-inventory --list` wraps any untagged string under
`_meta.hostvars` as `{"__ansible_unsafe": "..."}`, which broke this
collection's inventory output (#323). Tagging plugin-emitted strings with
`ansible.template.trust_as_template` restores the pre-2.19 plain-string
output. The shim falls back to a no-op on ansible-core < 2.19.
Also refresh the supported-version metadata against the official ansible-core
support matrix (2.17 EOL Nov 2025; 2.18 EOL May 2026; Ansible 11/12 EOL
Dec 2025; Ansible 13 = ansible-core 2.20 is the current package release;
2.20 is the first release officially supporting Python 3.14):
- pyproject.toml: requires-python `>=3.11,<3.15`; ansible-core `>=2.18`
- meta/runtime.yml: requires_ansible `>=2.18.0` (was `>=2.16.0`)
- tox-ansible.ini: skip py3.10 and ansible-core 2.17, allow py3.14
- README.md and docs installation guide refreshed accordingly
uv.lock regenerated for the new floor.
https://claude.ai/code/session_0135UA9kz9Smiwz3aYVe8vRz
mypy rejects untyped test functions; annotate them as `-> None`. https://claude.ai/code/session_0135UA9kz9Smiwz3aYVe8vRz
Deploying infrahub-ansible with
|
| Latest commit: |
7fcdf82
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://ed7f429c.infrahub-ansible.pages.dev |
| Branch Preview URL: | https://claude-expand-python-version.infrahub-ansible.pages.dev |
BaptisteGi
approved these changes
Apr 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Related Issue
#323
New Behavior
The
opsmill.infrahub.inventorydynamic inventory plugin now produces clean JSON inansible-inventory --liston ansible-core 2.19+. Plugin-supplied string values are tagged withansible.template.trust_as_templateso the legacy inventory JSON encoder serialises them as plain strings rather than{"__ansible_unsafe": "..."}dictionaries.Supported-version metadata is also refreshed and aligned across
pyproject.toml,meta/runtime.yml,tox-ansible.ini, README, and the installation guide:requires-python = ">=3.11,<3.15"(allows Python 3.14, which ansible-core 2.20 is the first to officially support)ansible-core>=2.18floor;requires_ansible: ">=2.18.0"inmeta/runtime.yml(was>=2.16.0and inconsistent with pyproject)tox-ansible.iniskip list updated: drops py3.10 and ansible-core 2.17 (both below the new floor), unblocks py3.14uv.lockregenerated against the new floorContrast to Current Behavior
Before this PR, running
ansible-inventory --listagainst ansible-core 2.19 / 2.20 returned every string host variable wrapped as{"__ansible_unsafe": "value"}, e.g.:After this PR the output is the same shape as on ansible-core 2.18:
On ansible-core < 2.19 the behaviour is unchanged (the trust shim is a no-op).
The version-floor changes drop already-EOL combinations (Python 3.10, ansible-core 2.17) instead of carrying configuration that no longer matches reality. The previous
pyproject.tomlupper bound<3.14blocked Python 3.14 entirely even though ansible-core 2.20 supports it; the new ceiling<3.15admits 3.14.Discussion: Benefits and Drawbacks
ansible-inventory --listJSON shape, which is consumed verbatim by downstream tooling (AWX, ansible-navigator, custom scripts that parse_meta.hostvars).set_hosts_and_groupsand gated byImportError, so it is a no-op on older ansible-core and adds no runtime cost there.{{ ... }}literals into Infrahub attributes will see them rendered, but that surface area was already implicit when those values flowed into Ansible variables.ansible-core>=2.18,python>=3.11) are breaking for any consumer still on EOL ansible-core 2.17 or Python 3.10; both tracks are already past their official EOL dates per the ansible-core support matrix.Changes to the Documentation
README.md: requirements section now statesPython >=3.11, <3.15andAnsible 2.18+.docs/docs/guides/installation.mdx: requirements section now statesPython 3.11+andAnsible 2.18+.Proposed Release Note Entry
Fix
opsmill.infrahub.inventorysoansible-inventory --listreturns plain JSON strings instead of{"__ansible_unsafe": "..."}wrappers under ansible-core 2.19+ (#323). Bump supported floors to Python 3.11 and ansible-core 2.18; allow Python 3.14.Double Check
developbranch.