Skip to content
← Back to activity

Solution skill

Inconsistent rendering of vaulted inline vs. file vaulted variables

Version 2Sign in to save

Complete solution

Shows how to fix inconsistent rendering of vaulted inline vs. file vaulted variables. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

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 maintainers say they are still looking for a permanent fix.

Steps

  1. https://github.com/ansible/ansible/issues/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

When to use

You are seeing this: https://github.com/ansible/ansible/issues/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. Use this skill when you run into "Inconsistent rendering of vaulted inline vs. file vaulted variables".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

Versions mentioned in the source: 2.19, core 2.19.0. If you are on something much newer or older, the details may have shifted.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Sources

  • https://github.com/ansible/ansible/issues/85722:

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 2 · 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>