Skip to content

fix: remove deprecated Ansible templating - #882

Open
sunlei wants to merge 1 commit into
prometheus-community:mainfrom
sunlei:sunlei/fix-ansible-deprecations
Open

fix: remove deprecated Ansible templating#882
sunlei wants to merge 1 commit into
prometheus-community:mainfrom
sunlei:sunlei/fix-ansible-deprecations

Conversation

@sunlei

@sunlei sunlei commented Aug 21, 2026

Copy link
Copy Markdown

Summary

  • replace deprecated access to Ansible's internal vars dictionary with exact ansible.builtin.varnames queries
  • construct release API URLs with inline Jinja expressions instead of embedded templates
  • apply the URL fix consistently across all exporter and Prometheus roles

Before

With ansible-core 2.21.3, the collection emits these warnings:

[DEPRECATION WARNING]: The internal "vars" dictionary is deprecated.
This feature will be removed from ansible-core version 2.24.
Origin: roles/_common/tasks/preflight.yml:14:9

Use the `vars` and `varnames` lookups instead.
[WARNING]: Jinja constant strings should not contain embedded templates.
This feature will be disabled by default in ansible-core 2.23.
Origin: roles/node_exporter/tasks/preflight.yml:53:28

Use inline expressions instead.

The first warning occurs in three shared preflight checks. The second pattern
occurs in the latest-version lookup of all 25 public roles.

Testing

  • ansible-lint
  • yamllint roles
  • verified the common preflight succeeds without deprecated variables when ANSIBLE_ALLOW_EMBEDDED_TEMPLATES=false
  • verified all three deprecated variable checks still reject variables whose value is false

- Replace internal vars dictionary checks with varnames lookups.
- Build release lookup URLs with inline Jinja expressions.

Signed-off-by: sunlei <guizaicn@gmail.com>
@sunlei
sunlei force-pushed the sunlei/fix-ansible-deprecations branch from b25d043 to cba606b Compare August 21, 2026 08:18
@github-actions github-actions Bot added bugfix and removed bugfix labels Aug 21, 2026
@sunlei
sunlei marked this pull request as ready for review August 21, 2026 08:19
@github-actions github-actions Bot added bugfix and removed bugfix labels Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment