Add cross-referencing file injection test for custom credentials#16489
Open
TheRealHaoLiu wants to merge 5 commits into
Open
Add cross-referencing file injection test for custom credentials#16489TheRealHaoLiu wants to merge 5 commits into
TheRealHaoLiu wants to merge 5 commits into
Conversation
tower.filename is a namespace when using named file templates (template.X), so the env injector must reference the specific file attribute (tower.filename.custom_file) instead of tower.filename directly. Assisted-By: Claude Opus 4.6 <noreply@anthropic.com>
Two fixes to make the live test pass:
1. Credential association: credentials passed in jt_params are silently
ignored by the JT creation API (not a writable serializer field).
Use jt.credentials.add() to associate the credential with the JT
before creating the job.
2. Remove | quote filter: the Jinja2 sandbox used for credential
injection does not have the quote filter registered. Rendering
{{ tower.filename.custom_file | quote }} would fail with a template
error. The base file injection works without it.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds two Ansible playbooks and live tests that verify custom CredentialType file injection and cross-file referencing; updates the test job factory to accept and attach credentials to created JobTemplates. ChangesCustom Credential Type Live Tests
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 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 |
Add a test that mirrors the customer's OCI credential type from
AAP-78106 where oci_dummy_config contains
key_file={{ tower.filename.ssh_keyfile }}.
This test will fail without the fix in
ansible/awx_plugins.interfaces#42 which restores incremental
tower.filename assignment inside the file injection loop.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
6e8bc24 to
067b68a
Compare
Remove Jinja2 braces from fail_msg so Ansible doesn't try to resolve tower.filename.ssh_keyfile as a playbook variable. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Member
|
assertion seems pretty clear |
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.
Summary
Builds on @chrismeyersfsu's test from #16488 (credential association fix + simple file injection test) and adds a test case for cross-referencing between file templates.
What this tests
A credential type where one file template references another injected file's path:
This is the pattern used by OCI and similar credential types — a config file that needs to contain the path to a key file. This is the pattern reported broken in AAP-78106.
Why this fails without the awx_plugins.interfaces fix
When
inject_credentialwas moved toawx_plugins.interfaces(38f76f0f), the file injection loop was refactored to settower.filenameafter the loop instead of incrementally inside it. This means{{ tower.filename.key_file }}isNonewhenconfig_fileis rendered, producingkey_file=(blank) in the config file content.Fix: ansible/awx_plugins.interfaces#42
Depends on
credentialsparameter forrun_job_from_playbookfixturetower.filenameassignment fixTest plan
test_custom_credential_type_file_injection— simple file injection (from Add integration test for custom credential file injection #16488)test_custom_credential_type_file_cross_reference— config file references key file path (new)Summary by CodeRabbit