# What is the best approach to creating a inlude\_vars file for my requirement

**URL:** <https://forum.ansible.com/t/what-is-the-best-approach-to-creating-a-inlude-vars-file-for-my-requirement/32055>\
**Category:** Ansible Project\
**Created:** [January 24, 2020, 11:10pm UTC](https://forum.ansible.com/t/what-is-the-best-approach-to-creating-a-inlude-vars-file-for-my-requirement/32055 "2020-01-24T23:10:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shifa\_Shaikh](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@Shifa\_Shaikh](https://forum.ansible.com/u/Shifa_Shaikh)\
**Post date:** [January 24, 2020, 11:10pm UTC](https://forum.ansible.com/t/what-is-the-best-approach-to-creating-a-inlude-vars-file-for-my-requirement/32055/1 "2020-01-24T23:10:01Z")

</div>

I use the stat module to read multiple files statistics from each remote server.

Thus, I’m able to get the file mode and checksum value of say 3 files on host1 and 2 files on host2.

I wish to know what is a good way to create/construct an include\_vars file so that I can easily read back each file’s mode and checksum for any given server?

I thought of constructing a myvars.yaml as below:

`

---

<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:** [January 25, 2020, 10:54pm UTC](https://forum.ansible.com/t/what-is-the-best-approach-to-creating-a-inlude-vars-file-for-my-requirement/32055/2 "2020-01-25T22:54:53Z")

</div>

Hi

The information you've provided seems to contain several cases of  
wheel reinvention.  
Rather than helping you do that, please explain what you are REALLY  
looking to achieve.  
The file names in your example suggest: "configuring a web server".  
In which case, a few template tasks and a handler might be all you need.

Dick

---

<div class="post-metadata">

**Author:** ![Shifa\_Shaikh](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@Shifa\_Shaikh](https://forum.ansible.com/u/Shifa_Shaikh)\
**Post date:** [January 26, 2020, 2:11pm UTC](https://forum.ansible.com/t/what-is-the-best-approach-to-creating-a-inlude-vars-file-for-my-requirement/32055/3 "2020-01-26T14:11:08Z")

</div>

Dick Hi,

My requirement is not about configuring a webserver.

It is to maintain a check on a set of files. If the file changes by checksum or permissions I wish to trigger an alert.

Thus, my ansible will stat the file and then compare the checksum and mode that was previously stored in the include\_vars file.

If they match we are good else we will trigger an alert.

Thus, I want to understand if my approach/format of storing mode and checksum information for all files on all servers good? if not please propose how should i design the include\_vars files so I could read the checksum and mode of a file on a particular IP.

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [January 28, 2020, 9:13pm UTC](https://forum.ansible.com/t/what-is-the-best-approach-to-creating-a-inlude-vars-file-for-my-requirement/32055/4 "2020-01-28T21:13:06Z")

</div>

> Dick Hi,
> 
> My requirement is not about configuring a webserver.
> 
> It is to maintain a check on a set of files. If the file changes by checksum or permissions I wish to trigger an alert.
> 
> Thus, my ansible will stat the file and then compare the checksum and mode that was previously stored in the  
> include\_vars file.
> 
> If they match we are good else we will trigger an alert.
> 
> Thus, I want to understand if my approach/format of storing mode and checksum information for all files on all servers  
> good? if not please propose how should i design the include\_vars files so I could read the checksum and mode of a file  
> on a particular IP.

Why don't use an existing checksum tool (e.g Google for linux ids checksum tools) ?

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<div class="post-metadata">

**Author:** ![jean-yves](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jean-yves](https://forum.ansible.com/u/jean-yves)\
**Post date:** [January 28, 2020, 9:53pm UTC](https://forum.ansible.com/t/what-is-the-best-approach-to-creating-a-inlude-vars-file-for-my-requirement/32055/5 "2020-01-28T21:53:06Z")

</div>

Hi,

As said by Racke, why not using a tool designed for it like these (there are available for other distro) : [https://doc.ubuntu-fr.org/rootkit](https://doc.ubuntu-fr.org/rootkit)

Another way to make some controls is to use package tools with some options....

dpkg --verify or rpm -Va can be interesting to use....

Regards,

JYL
