ansible-lint complaining about usage of reigstered variable in a Jinja template

377 Views Asked by At

I have the following ansible role:

- name: Copy trusted certificates
  ansible.builtin.copy:
    src: "{{ item }}"
    dest: '{{ ssl_certs_path }}/'
  register: installed_certs
  with_items: '{{ ssl_trusted_certs }}'
  become: true

- name: Calculate certificate hash
  ansible.builtin.command: openssl x509 -noout -hash -in {{ item }}
  register: cert_hash
  loop: "{{ installed_certs | json_query('results[*].dest') }}"

The variable ssl_trusted_certs is defined in the playbook:

- hosts: all
  name: Run role
  roles:
    - myRole
  vars:
    ssl_trusted_certs:
      - '/foo/myCa.crt'

This has worked well for some time, but today ansible-lint started complaining, that the variable installed_certs (which is registered in the first task) used in the Jinja template is unknown:

WARNING  Listing 1 violation(s) that are fatal
jinja[invalid]: Error in jmespath.search in json_query filter plugin:
'installed_certs' is undefined

The problem occurs on Debian Testing with the ansible-lint package from the repository. That's ansible-lint-6.13.1 and ansible-7.2.0.

0

There are 0 best solutions below