# Dynamically including task files?

**URL:** <https://forum.ansible.com/t/dynamically-including-task-files/14439>\
**Category:** Ansible Project\
**Created:** [January 27, 2014, 10:28pm UTC](https://forum.ansible.com/t/dynamically-including-task-files/14439 "2014-01-27T22:28:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Miguel\_Fonseca](https://avatars.discourse-cdn.com/v4/letter/m/22d042/32.png) [@Miguel\_Fonseca](https://forum.ansible.com/u/Miguel_Fonseca)\
**Post date:** [January 27, 2014, 10:28pm UTC](https://forum.ansible.com/t/dynamically-including-task-files/14439/1 "2014-01-27T22:28:06Z")

</div>

I’m trying to dynamically include multiple separated tasks files based on a list - I went straight to using include while iterating on with\_items until I saw the deprecation warning.

Before everyone just jumps on me, I do realise that this has been discussed a LOT of times on this list but after reading a bunch of threads I tend to think that my use case is a bit different and is not really achievable by using with\_items inside of a task.

Use case:

list.yml  
task\_files:

- x
- y
- z

playbook.yml

- hosts: localhost  
vars\_files:  
list.yml  
include: {{ item }}  
with\_items: task\_files

Please note that this is just part of a hack I’m running on my local box and do not intend to use it in production-like environments. Any advice on how to achieve this?

Thanks in advance.

Miguel

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [January 28, 2014, 3:03am UTC](https://forum.ansible.com/t/dynamically-including-task-files/14439/2 "2014-01-28T03:03:33Z")

</div>

At that point i would just dynamically write the playbook, easy to do with an jinja template if you want ansible to do it (I used to do it, but somehow sanity crept in).
