Launch instances from a file

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

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.

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

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