Skip to content
← Back to activity

Immutable solution version

Inconsistent rendering of vaulted inline vs. file vaulted variables

Version 1Sign in to save

Complete solution

If vaulted inline variables render differently than vaulted file variables, normalize the decrypted data through JSON and back: `data | to_json(vault_to_text=True) | from_json | to_nice_yaml`. That strips the inconsistent vault formatting.

Inconsistent rendering of vaulted inline vs. file vaulted variables

If vaulted inline variables render differently than vaulted file variables, normalize the decrypted data through JSON and back: data | to_json(vault_to_text=True) | from_json | to_nice_yaml. That strips the inconsistent vault formatting. The maintainers say they are still looking for a permanent fix.

Context from the issue

gh:ansible/ansible#85722: Issue ansible/ansible#85722 (closed, 15 comments): ### Summary When a variable is defined inline using the !vault tag, rendering behavior differs depending on context since 2.19. Direct references resolve to the decrypted value, but the same variable remains encrypted when rendered via to_nice_yaml. If the entire file is vaulted with ansible-vault encrypt, this problem does not occur. This makes variable substitution unpredictable and requires workarounds. ### Issue Type Bug Report ### Component Name vault ### Ansible Version ```console ansible [core 2.19.0] config file = [HOME]/... configured module search pat

Evidence

Issue gh:ansible/ansible#85722: the reporter asked: Issue ansible/ansible#85722 (closed, 15 comments): ### Summary When a variable is defined inline using the !vault tag, rendering behavior differs depending on context since 2.19. Direct references resolve to the decrypted value, but the same variable remains encrypted when rendered via to_nice_yaml. If the entire file is vaulted with ansible-vault encrypt, this problem does not occur. This makes variable substitution unpredictable and requires workarounds. ### Issue Type Bug Report ### Component Name vault ### Ansible Version ``console ansible [core 2.19.0] config file = [HOME]/... configured module search pat The verified answer was: If vaulted inline variables render differently than vaulted file variables, normalize the decrypted data through JSON and back: data | tojson(vaulttotext=True) | fromjson | toniceyaml`. That strips the inconsistent vault formatting. The maintainers say they are still looking for a permanent fix. Evidence thread: https://github.com/ansible/ansible/issues/85722

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_Ui8w1WcWfmPqENjsluNTcA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Inconsistent rendering of vaulted inline vs. file vaulted variables <span>— Vectle</span></a>