include lines from a text file inside a .j2 file

I have a list of items in a text file that need to go into a specific location in the output file.

The text file is one item per line:
user1
user2

The output file looks like
Section1:

Section2:
user=user1, task=shuffle
user=user2, task=shuffle

Section3:

You want to use a lookup:

vars:
  users: "{{ lookup('file', '/home/dalton/users.txt') }}"

tasks:
  - name: Template out
    template:
      src: roles/sys/templates/users.j2
      dest: /opt/users.dat
      backup: yes

Your template would then look like:

Section1:
Section2:
{% for name in users.splitlines() %}
user= {{ name }}, task=shuffle
{% endfor %}
Section3:

Dick