`Vault format unhexlify error: Odd-length string` after pasting an `encrypt_string` value
IntermediateTroubleshootingVault, Performance and Execution Behaviour
Answer
Likely causes → The !vault | block was damaged when pasted: lines re-wrapped, a line dropped, inconsistent indentation, or the trailing digits cut off. Non-hexadecimal digit found points to the same problem.
Fix → Generate the value again and paste it as one block:
ansible-vault encrypt_string --vault-id prod@prompt --stdin-name db_password
db_password: !vault |
$ANSIBLE_VAULT;1.2;AES256;prod
6233... # every line indented the same, no edits
Check with ansible localhost -m debug -a var=db_password -e @file.yml --vault-id prod@prompt.
Prevent → For many secrets, prefer whole-file encryption (vault.yml), which cannot be mangled by YAML indentation.
More on Vault, Performance and Execution Behaviour
`ERROR! Attempting to decrypt but no vault secrets found`Beginner`ERROR! Decryption failed (no vault secrets were found that could decrypt) on inventories/prod/group_vars/all/vault.yml`BeginnerBoth `--vault-id [email protected]` and `--vault-id prod@prompt` are passed, and prod files still fail to decryptIntermediate`Problem running vault password script /home/ci/.vault_pass ([Errno 8] Exec format error). If this is not a script, remove the executable bit from the file.`AdvancedEvery change to `vault.yml` produces an unreadable diff and constant merge conflictsIntermediateVaulted variables are undefined, although the file decrypts fine with `ansible-vault view`Beginner