# Passing values in a file

**URL:** <https://forum.ansible.com/t/passing-values-in-a-file/21905>\
**Category:** Ansible Project\
**Created:** [July 1, 2016, 10:21am UTC](https://forum.ansible.com/t/passing-values-in-a-file/21905 "2016-07-01T10:21:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rakshatha\_shetty1](https://avatars.discourse-cdn.com/v4/letter/r/7ab992/32.png) [@Rakshatha\_shetty1](https://forum.ansible.com/u/Rakshatha_shetty1)\
**Post date:** [July 1, 2016, 10:21am UTC](https://forum.ansible.com/t/passing-values-in-a-file/21905/1 "2016-07-01T10:21:00Z")

</div>

Hi,

I’m using Ansible 2.0.0.2 to create multiple directories by passing path to directories in a file and reading the values from file. How can multiple values be passed in a single file? Please revert with the format in which values (i.e. path to directories) should be passed in the file.

Thanks & Regards,  
Rakshatha

---

<div class="post-metadata">

**Author:** ![jtanner](https://avatars.discourse-cdn.com/v4/letter/j/6bbea6/32.png) [@jtanner](https://forum.ansible.com/u/jtanner)\
**Post date:** [July 1, 2016, 4:42pm UTC](https://forum.ansible.com/t/passing-values-in-a-file/21905/2 "2016-07-01T16:42:40Z")

</div>

Can you show an example of what you are trying to accomplish?

---

<div class="post-metadata">

**Author:** ![Rakshatha\_shetty1](https://avatars.discourse-cdn.com/v4/letter/r/7ab992/32.png) [@Rakshatha\_shetty1](https://forum.ansible.com/u/Rakshatha_shetty1)\
**Post date:** [July 4, 2016, 5:33am UTC](https://forum.ansible.com/t/passing-values-in-a-file/21905/3 "2016-07-04T05:33:14Z")

</div>

- name: Create directory structure  
hosts: newserver  
tasks:
- name: Directory structure  
win\_file: path=“{{ item }}” state=directory

with\_file:

- first\_example\_file

Above is the ansible script I’m using to create directory, path to the new directory is given in the file ‘first\_example\_file’. How should we pass multiple values in the file (i.e. when we have to create multiple directories, what is the format of tje file?)

---

<div class="post-metadata">

**Author:** ![sdarwin](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sdarwin/32/2450_2.png) [@sdarwin](https://forum.ansible.com/u/sdarwin)\
**Post date:** [July 4, 2016, 2:14pm UTC](https://forum.ansible.com/t/passing-values-in-a-file/21905/4 "2016-07-04T14:14:23Z")

</div>

This stackoverflow article explains how to iterate over multiple lines in a file with ansible: [http://stackoverflow.com/questions/33541870/how-do-i-loop-over-each-line-inside-a-file-with-ansible](http://stackoverflow.com/questions/33541870/how-do-i-loop-over-each-line-inside-a-file-with-ansible)

---

<div class="post-metadata">

**Author:** ![Rakshatha\_shetty1](https://avatars.discourse-cdn.com/v4/letter/r/7ab992/32.png) [@Rakshatha\_shetty1](https://forum.ansible.com/u/Rakshatha_shetty1)\
**Post date:** [July 5, 2016, 1:49pm UTC](https://forum.ansible.com/t/passing-values-in-a-file/21905/5 "2016-07-05T13:49:48Z")

</div>

Thank you, with\_lines module was very much helpful

---

<div class="post-metadata">

**Author:** ![Rakshatha\_shetty1](https://avatars.discourse-cdn.com/v4/letter/r/7ab992/32.png) [@Rakshatha\_shetty1](https://forum.ansible.com/u/Rakshatha_shetty1)\
**Post date:** [July 7, 2016, 6:22am UTC](https://forum.ansible.com/t/passing-values-in-a-file/21905/6 "2016-07-07T06:22:49Z")

</div>

With\_lines module is working fine when I pass values for single parameter. How to pass values for multiple parameters in a single file?

For example: win\_file: path=“{{ item }}” state=“{{ item }}”

In the above example values for path and state should be passed. Is it possible to accomplish this using with\_lines? Please help…
