# Write to a config file on each server with a certain line from a CSV file stored locally using Ansible

**URL:** <https://forum.ansible.com/t/write-to-a-config-file-on-each-server-with-a-certain-line-from-a-csv-file-stored-locally-using-ansible/23278>\
**Category:** Ansible Project\
**Created:** [December 18, 2016, 5:30pm UTC](https://forum.ansible.com/t/write-to-a-config-file-on-each-server-with-a-certain-line-from-a-csv-file-stored-locally-using-ansible/23278 "2016-12-18T17:30:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Akashi\_Seih](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@Akashi\_Seih](https://forum.ansible.com/u/Akashi_Seih)\
**Post date:** [December 18, 2016, 5:30pm UTC](https://forum.ansible.com/t/write-to-a-config-file-on-each-server-with-a-certain-line-from-a-csv-file-stored-locally-using-ansible/23278/1 "2016-12-18T17:30:45Z")

</div>

I have 15 servers that I need to set up and configure. I’ve been playing with Ansible a bit and I’ve come very far. I have one last thing to do that I don’t know how to solve, and that is:

Each server has a file called “server.txt”. In this file, the server must contain a certain value to be able to communicate with the master.

I have a file (locally) that has 15 different keys, and I need to ship these keys (on by one) to each server. I can do this manually, but I want to do this with Ansible since the servers will become more and more.

Is there a smart and easy way to do this with Ansible? E.g loop through each line, take the line, and write it to each server?

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [December 19, 2016, 9:27pm UTC](https://forum.ansible.com/t/write-to-a-config-file-on-each-server-with-a-certain-line-from-a-csv-file-stored-locally-using-ansible/23278/2 "2016-12-19T21:27:14Z")

</div>

Since you have provided little information, the only thing I can say is check out lookup  
[https://docs.ansible.com/ansible/playbooks\_lookups.html#the-csv-file-lookup](https://docs.ansible.com/ansible/playbooks_lookups.html#the-csv-file-lookup)
