# Read the values from file and store in variable.

**URL:** <https://forum.ansible.com/t/read-the-values-from-file-and-store-in-variable/33025>\
**Category:** Ansible Project\
**Created:** [May 26, 2020, 6:14am UTC](https://forum.ansible.com/t/read-the-values-from-file-and-store-in-variable/33025 "2020-05-26T06:14:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Akshay\_Bora](https://avatars.discourse-cdn.com/v4/letter/a/8edcca/32.png) [@Akshay\_Bora](https://forum.ansible.com/u/Akshay_Bora)\
**Post date:** [May 26, 2020, 6:14am UTC](https://forum.ansible.com/t/read-the-values-from-file-and-store-in-variable/33025/1 "2020-05-26T06:14:31Z")

</div>

Hi All,

I have a file named as /etc/oraInst.loc. The file contents are as below.

inventory\_loc=/u01/app/oraInventory  
inst\_group=oinstall

**I need to store the value of inventory\_loc , that is ,/u01/app/oraInventory in any variable.**

These files are at remote host and not on ansible controller host. I used the INI module to read the file stored locally and I could do it but I am not able to read files stored on the remote host and it throws the error saying file is not present. Can you please help me to accomplish this task.

---

<div class="post-metadata">

**Author:** ![Sivakumar\_Saravanamu](https://avatars.discourse-cdn.com/v4/letter/s/ce73a5/32.png) [@Sivakumar\_Saravanamu](https://forum.ansible.com/u/Sivakumar_Saravanamu)\
**Post date:** [May 26, 2020, 6:18am UTC](https://forum.ansible.com/t/read-the-values-from-file-and-store-in-variable/33025/2 "2020-05-26T06:18:38Z")

</div>

Hi

Why can’t you grep the required output using shell and store in \>\> remote server.

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [May 26, 2020, 6:53am UTC](https://forum.ansible.com/t/read-the-values-from-file-and-store-in-variable/33025/3 "2020-05-26T06:53:15Z")

</div>

Or slurp it and parse it with ini:

[https://docs.ansible.com/ansible/latest/plugins/lookup/ini.html](https://docs.ansible.com/ansible/latest/plugins/lookup/ini.html)
