#87536·ansible

Document that YAML mapping keys can't be encrypted post-DT (v2.19.0b1+)

Author: webknjazCreated Sep 15, 2026Updated Sep 15, 2026
Labelsneeds_triagedata_taggingcore-internal

I've had something in my old playbooks and @nitzmahone suggested that we should probably document this behavior change. It doesn't look like it was intended or tested before/after https://github.com/ansible/ansible/commit/35750ed3218e7bce68b21f473cecb0a3b9d60321 (https://github.com/ansible/ansible/pull/84621).

The UX of YAML mappings with custom tags can be scary to a casual vars file reader so Nitz and I kinda agreed that it's probably a good idea no to bring this back but at least have it documented.

Here's what used to work and stopped with that DT commit — the error message isn't exactly clear as to why, especially since !vault does work in values just fine:

$ pip install 'ansible-core >= 2.19.0b1'
$ echo '<a secret string here>' | ansible-vault encrypt_string
[WARNING]: You are running the development version of Ansible. You should only run Ansible from "devel" if you are modifying the Ansible engine, or trying out features under development. This is a rapidly changing source of code and can become unstable at any point.
New Vault password: 
Confirm New Vault password: 
Reading plaintext input from stdin. (ctrl-d to end input, twice if your content does not already have a newline)
Encryption successful
!vault |
          $ANSIBLE_VAULT;1.1;AES256
          31323862633331353363333661653061356435383637396434613339623635326366643733626535
          3833356330663064323839356532346463613562663430320a306231633262666166626239626239
          35643432343430633362336266373062646661336531653336613563346361613638303335353335
          3833643134316132320a343463663966333830306335343064326439643831643563626163356138
          63653864343436616434643866306338343561303034336130306262333134396130

$ cat vars.yml
map:
  ? !vault |
    $ANSIBLE_VAULT;1.1;AES256
    31323862633331353363333661653061356435383637396434613339623635326366643733626535
    3833356330663064323839356532346463613562663430320a306231633262666166626239626239
    35643432343430633362336266373062646661336531653336613563346361613638303335353335
    3833643134316132320a343463663966333830306335343064326439643831643563626163356138
    63653864343436616434643866306338343561303034336130306262333134396130
  : криївка

$ ansible --module-name=ansible.builtin.debug --args='{"var": "map"}' [email protected] --ask-vault-password localhost
[WARNING]: You are running the development version of Ansible. You should only run Ansible from "devel" if you are modifying the Ansible engine, or trying out features under development. This is a rapidly changing source of code and can become unstable at any point.
Vault password: 
[WARNING]: No inventory was parsed, only implicit localhost is available
[ERROR]: Task failed: Error while resolving `var` expression: Error rendering expression: Type 'EncryptedString' is unsupported for variable storage.

Task failed.
Origin: <adhoc 'ansible.builtin.debug' task>

{'action': 'ansible.builtin.debug', 'args': {'var': 'map'}, 'timeout': 0, 'async_val': 0, 'poll': 15}

<<< caused by >>>

Error while resolving `var` expression: Error rendering expression.
Origin: <CLI option '-a'>

map

<<< caused by >>>

Type 'EncryptedString' is unsupported for variable storage.
Origin: ~/src/github/ansible/ansible/vars.yml:2:5

1 map:
2   ? !vault |
      ^ column 5

localhost | FAILED! => {
    "changed": false,
    "msg": "Task failed: Error while resolving `var` expression: Error rendering expression: Type 'EncryptedString' is unsupported for variable storage."
}

@ansibot bot_skip