class

Krikri::VarOrigin

Inherits Reference < Object

Where a variable's stored (raw) value was defined - the locator real ansible-core 2.19 prints in a [WARNING]: Encountered N template error(s). block when a task NAME's template chain fails inside that value (live-verified 2.19.11: the Origin points at the DEFINING site of the failing value, e.g. vars/main.yml:3:12 for a role var, not at the task). Three shapes exist, because Ansible's Origin covers values that did not all come from a YAML file:

  • a YAML-defined value: Origin: <file>:<line>:<col> with the usual 2-context-line excerpt and a caret under the value token's first character (quote included);
  • an inventory-line value: Origin: <file>:<line> - NO column - with the same excerpt but a full-line caret RUN under the whole line;
  • a CLI extra var: Origin: <CLI option '-e'> with the raw value excerpted verbatim and no line numbers or caret at all.

Class methods

vars_file_origins(path : String, keys : Enumerable(String)) : Hash(String, VarOrigin)

Top-level key: value origins of a vars-style YAML file (a role's vars/main.yml or defaults/main.yml, a vars_files entry): the VALUE scalar's own start mark - Ansible's Origin for the value points at the value token's first character, quote included (live-verified 2.19.11: nats_name: "{{ ... }}" reports column 12, the opening quote). keys are the file's top-level variable names as the caller parsed them; a key the source-map scan cannot locate simply gets no origin (the warning block for it is then omitted, never mislabeled).

Source

Instance methods

group_key

Grouping key for the consecutive same-origin run a context exit collapses into one warning block (live-verified: two errors from one defining file share a block, an intervening error from another file splits it).

Source