# Launch instances from a file

**URL:** <https://forum.ansible.com/t/launch-instances-from-a-file/29989>\
**Category:** Ansible Project\
**Created:** [March 26, 2019, 3:59am UTC](https://forum.ansible.com/t/launch-instances-from-a-file/29989 "2019-03-26T03:59:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shyam.rpms](https://avatars.discourse-cdn.com/v4/letter/s/a88e57/32.png) [@shyam.rpms](https://forum.ansible.com/u/shyam.rpms)\
**Post date:** [March 26, 2019, 3:59am UTC](https://forum.ansible.com/t/launch-instances-from-a-file/29989/1 "2019-03-26T03:59:36Z")

</div>

Hi,

I want to launch instances from a file. The file contains the variables like “InstanceName”, HttpPortnumber and Portnumber and I want to pass this file as a Input parameter to the playbook to launch the instances on server.

can any one help.

Example file:

InstanceName HttpPortnumber Portnumber

Sample1 1122 2211  
Sample2 1233 4321  
sample3 4432 3321

Thank you,  
Shyam

---

<div class="post-metadata">

**Author:** ![Sudheer\_S1](https://avatars.discourse-cdn.com/v4/letter/s/e99b99/32.png) [@Sudheer\_S1](https://forum.ansible.com/u/Sudheer_S1)\
**Post date:** [March 26, 2019, 4:52am UTC](https://forum.ansible.com/t/launch-instances-from-a-file/29989/2 "2019-03-26T04:52:35Z")

</div>

You can read the file contents using the lookup plugin. Once you have the file contents, you can then try to apply regex filter to obtain the pattern you need.

Is it possible to use a more structured format like JSON instead of text file like the one you have? That would make the task a lot easier.

---

<div class="post-metadata">

**Author:** ![shyam.rpms](https://avatars.discourse-cdn.com/v4/letter/s/a88e57/32.png) [@shyam.rpms](https://forum.ansible.com/u/shyam.rpms)\
**Post date:** [March 26, 2019, 5:46pm UTC](https://forum.ansible.com/t/launch-instances-from-a-file/29989/3 "2019-03-26T17:46:12Z")

</div>

> ```auto
> Hi Sudheer,
> 
> Thanks for your update. I want to read the file line by line. is it possible to do through Ansible ?
> 
> I have tried with Lookup plugin and Im able to save the instance name, HTTP port number and Portnumber in a separate vaiable from CSV file.
> 
> Here my requirement is to iterate the CSV file contents line by line and need to launch the instances from the CSV file.
> 
> Any suggestions please.
> 
> ```

Thank you,  
Shyam

---

<div class="post-metadata">

**Author:** ![Sudheer\_S1](https://avatars.discourse-cdn.com/v4/letter/s/e99b99/32.png) [@Sudheer\_S1](https://forum.ansible.com/u/Sudheer_S1)\
**Post date:** [March 27, 2019, 5:58am UTC](https://forum.ansible.com/t/launch-instances-from-a-file/29989/4 "2019-03-27T05:58:26Z")

</div>

So, you are already reading the file and fetching the details you want?
