I have been trying to write a role which has a variable that initiated to null and values are appended based on the Jinja filters applied on the items, But it frequently errors out in
{
"msg": "template error while templating string: expected token 'name', got 'string'. String: {{\n append\n | default([])\n | \"{{ statement }}\"\n}}"
}
testplaybook.yml:
- name: Processing role
include_role:
name: processing
vars:
statement: "combine({item._ansible_item_label.1:item.status|default('no status')})"
processing\tasks\main.yml:
- name: Matching items to values
set_fact:
append: >-
{{ 'append | default([]) |' + statement }}
loop: "{{ results }}"
register: append
Expected result is that "append" should be able to populate based on the filters applied to the items in the "statement" variable just like it will be to do in a single page playbook.