# Unclear templating error started from 2.19.0

**URL:** <https://forum.ansible.com/t/unclear-templating-error-started-from-2-19-0/44874>\
**Category:** Get Help\
**Tags:** kubernetes, jinja2, ansible-lint, galaxy-ng\
**Created:** [November 21, 2025, 12:34am UTC](https://forum.ansible.com/t/unclear-templating-error-started-from-2-19-0/44874 "2025-11-21T00:34:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![yurnov](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/yurnov/32/3964_2.png) [@yurnov](https://forum.ansible.com/u/yurnov)\
**Post date:** [November 21, 2025, 12:34am UTC](https://forum.ansible.com/t/unclear-templating-error-started-from-2-19-0/44874/1 "2025-11-21T00:34:38Z")

</div>

Going to migrate from ansible-core 2.18 to 2.20 for 3pp lifecycle management, and it was actually delayed due to changes in 2.19, and I am still stuck with that.

So, simple playbook (written for test):

```auto
---
- name: Test play
  hosts: active
  tasks:

    - name: Get secret with k8s_info
      kubernetes.core.k8s_info:
        kind: Secret
        name: secretname
        namespace: "{{ namespace }}"
        kubeconfig: "~/.kube/config"
      register: mysecret
      ignore_errors: true

```

Simple inventory:

```auto
all:
  children:
    active_group:
      hosts:
        active:
          ansible_connection: local
          namespace: test-namespace

```

Versions:

```auto
root@6e49f0e3df11:/# ansible --version
ansible [core 2.20.0]
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.13/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.13.7 (main, Aug 15 2025, 22:13:08) [GCC 14.2.0] (/usr/local/bin/python3.13)
  jinja version = 3.1.6
  pyyaml version = 6.0.3 (with libyaml v0.2.5)
root@6e49f0e3df11:/# ansible-lint --version
ansible-lint 25.11.0 using ansible-core:2.20.0 ansible-compat:25.11.0 ruamel-yaml:0.18.16 ruamel-yaml-clib:0.2.15
root@6e49f0e3df11:/# ansible-galaxy collection list

# /root/.ansible/collections/ansible_collections
Collection Version
--------------- -------
kubernetes.core 6.2.0
root@6e49f0e3df11:/#

```

It’s look completely fine, hovewer I got lint error:

```auto
jinja[invalid]: Error rendering template: Type 'type' is unsupported for variable storage.
opt/test.yml:13:20 Task/Handler: Get secret with k8s_info

Read documentation for instructions on how to ignore specific rule violations.

# Rule Violation Summary

  1 jinja profile:basic tags:formatting

Failed: 1 failure(s), 0 warning(s) in 2 files processed of 3 encountered. The last profile that met the validation criteria was 'min'.

```

It worked completely fine for 2.18 and earlier, and I’m struggling with understanding what is wrong here. Any suggestions?

---

<div class="post-metadata">

**Author:** ![yurnov](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/yurnov/32/3964_2.png) [@yurnov](https://forum.ansible.com/u/yurnov)\
**Post date:** [November 21, 2025, 1:14am UTC](https://forum.ansible.com/t/unclear-templating-error-started-from-2-19-0/44874/2 "2025-11-21T01:14:07Z")

</div>

~~Ok, as the WA changed to~~

```auto
---
- name: Test play
  hosts: active
  tasks:

    - name: Get secret with k8s_info
      kubernetes.core.k8s_info:
        kind: Secret
        name: secretname
        namespace: "{{ namespace | to_string }}"
        kubeconfig: "~/.kube/config"
      register: mysecret
      ignore_errors: true

```

~~So, actual change is `namespace: "{{ namespace }}"` → `namespace: "{{ namespace | to_string }}"`~~

Update 21-11-2021 16:35 UTC: it’s wrong solution, actual fix is bellow

---

<div class="post-metadata">

**Author:** ![markstos](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/markstos/32/9706_2.png) [@markstos](https://forum.ansible.com/u/markstos)\
**Post date:** [November 21, 2025, 4:04am UTC](https://forum.ansible.com/t/unclear-templating-error-started-from-2-19-0/44874/3 "2025-11-21T04:04:14Z")

</div>

There were several documented breaking changes in 2.19. One appears to have been triggered in your code.

You can read about breaking changes in each release in the Changelog:

[https://github.com/ansible/ansible/blob/v2.19.0//CHANGELOG-v2.19.rst#breaking-changes-porting-guide](https://github.com/ansible/ansible/blob/v2.19.0//CHANGELOG-v2.19.rst#breaking-changes-porting-guide)

To your point: I agree the error message could be clearer!

---

<div class="post-metadata">

**Author:** ![mariolenz](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mariolenz/32/108_2.png) [@mariolenz](https://forum.ansible.com/u/mariolenz)\
**Post date:** [November 21, 2025, 4:16pm UTC](https://forum.ansible.com/t/unclear-templating-error-started-from-2-19-0/44874/4 "2025-11-21T16:16:40Z")

</div>

It’s somewhat weird that you should need a `| to_string` there.

Out of curiosity, do you get the same error when you use `namespace: "test-namespace"` in your inventory, another error or does it work then?

@markstos Your link to the Changelog somehow doesn’t work for me, I get 404. [ansible/changelogs/CHANGELOG-v2.19.rst at stable-2.19 · ansible/ansible · GitHub](https://github.com/ansible/ansible/blob/stable-2.19/changelogs/CHANGELOG-v2.19.rst#breaking-changes-porting-guide) does, though.

Maybe the [Ansible-core 2.19 Porting Guide](https://docs.ansible.com/projects/ansible-core/devel/porting_guides/porting_guide_core_2.19.html) might also be helpful.

---

<div class="post-metadata">

**Author:** ![yurnov](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/yurnov/32/3964_2.png) [@yurnov](https://forum.ansible.com/u/yurnov)\
**Post date:** [November 21, 2025, 4:35pm UTC](https://forum.ansible.com/t/unclear-templating-error-started-from-2-19-0/44874/5 "2025-11-21T16:35:08Z")

</div>

Actually, this `to_string` was a wrong assumption; it fixed the linter, but not actual playbook 🙂 First of all, it should be `ansible.builtin.string`, not `to_string`, but the actual issue with the `namespace` that is a reserved variable name.

So, the actual fix is just rename variable `namespace` to `kube_namespace`.
