# How to template tasks file?

**URL:** <https://forum.ansible.com/t/how-to-template-tasks-file/19830>\
**Category:** Ansible Project\
**Tags:** ansible-project\
**Created:** [November 23, 2015, 5:04pm UTC](https://forum.ansible.com/t/how-to-template-tasks-file/19830 "2015-11-23T17:04:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [November 23, 2015, 5:04pm UTC](https://forum.ansible.com/t/how-to-template-tasks-file/19830/1 "2015-11-23T17:04:07Z")

</div>

You cannot template a whole task file.

What you need is to put a with\_indexed\_items on each of those lineinfile tasks, as opposed to using a jinja for loop around them.

[http://docs.ansible.com/ansible/playbooks\_loops.html#looping-over-a-list-with-an-index](http://docs.ansible.com/ansible/playbooks_loops.html#looping-over-a-list-with-an-index)
