# Ansible Error: The task includes an option with an undefined variable. When Creating new folders

**URL:** <https://forum.ansible.com/t/ansible-error-the-task-includes-an-option-with-an-undefined-variable-when-creating-new-folders/27884>\
**Category:** Ansible Project\
**Created:** [June 27, 2018, 11:26am UTC](https://forum.ansible.com/t/ansible-error-the-task-includes-an-option-with-an-undefined-variable-when-creating-new-folders/27884 "2018-06-27T11:26:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![VS1](https://avatars.discourse-cdn.com/v4/letter/v/bbe5ce/32.png) [@VS1](https://forum.ansible.com/u/VS1)\
**Post date:** [June 27, 2018, 11:26am UTC](https://forum.ansible.com/t/ansible-error-the-task-includes-an-option-with-an-undefined-variable-when-creating-new-folders/27884/1 "2018-06-27T11:26:30Z")

</div>

> - name: Update apt cahce  
> apt: update\_cache=yes cache\_valid\_time=3600
> 
> - name: Install NFS Common on FileServer  
> apt: name={{ item }} state=present  
> with\_items:
> 
> - nfs-common
> 
> - name: Create webservers directory  
> file:  
> path: “{{ item }}”  
> with\_items:
> 
> - /nfs/webserver1
> 
> - /nfs/webserver2  
> state: directory

Hello guys while running this ansible playbook to create multiple folders i get error:

“msg”: “The task includes an option with an undefined variable. The error was: ‘item’ is undefined\n\nThe error appears to have been in ‘/home/user/.ansible/roles/mount/tasks/main.yml’: line 10, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Create webservers directory\n ^ here\n”

What i am doing wrong?

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [June 27, 2018, 11:42am UTC](https://forum.ansible.com/t/ansible-error-the-task-includes-an-option-with-an-undefined-variable-when-creating-new-folders/27884/2 "2018-06-27T11:42:17Z")

</div>

with\_items isn’t a module parameter, so it needs to be indented to same level as file, like this:  
`

- name: Update apt cahce  
apt: update\_cache=yes cache\_valid\_time=3600

- name: Install NFS Common on FileServer  
apt: name={{ item }} state=present  
with\_items:

- nfs-common

- name: Create webservers directory  
file:  
path: “{{ item }}”  
state: directory  
with\_items:

- /nfs/webserver1

- /nfs/webserver2  
`

---

<div class="post-metadata">

**Author:** ![Bachu\_Prathap](https://avatars.discourse-cdn.com/v4/letter/b/6a8cbe/32.png) [@Bachu\_Prathap](https://forum.ansible.com/u/Bachu_Prathap)\
**Post date:** [June 27, 2018, 11:54am UTC](https://forum.ansible.com/t/ansible-error-the-task-includes-an-option-with-an-undefined-variable-when-creating-new-folders/27884/3 "2018-06-27T11:54:17Z")

</div>

Hi

Remove quotes for item under path, it should work.

Regards  
Pratap Bachu
