Ansible loops and template... again

Solution 1:

Try this

task

  - name: Rsyslog logs config
    template:
      src: ./templates/99-generic-template.conf.j2
      dest: /tmp/{{ item.rsyslog_conf_file }}
    with_items:
    - "{{ loglist }}"

template

{% for val in item.logfiles %}
input(type="imfile"
    File="{{ val.name }}"
    Tag="{{ item.app_id }}__"
{% if val.regex|length %}
    startmsg.regex="{{ val.regex }}"
{% endif %}
    Ruleset="{{ item.ruleset }}"
    addMetadata="on")
{% endfor %}