# stat module?

**URL:** <https://forum.ansible.com/t/stat-module/12191>\
**Category:** Ansible Project\
**Created:** [January 9, 2013, 11:43pm UTC](https://forum.ansible.com/t/stat-module/12191 "2013-01-09T23:43:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dylan\_Martin](https://avatars.discourse-cdn.com/v4/letter/d/8797f3/32.png) [@Dylan\_Martin](https://forum.ansible.com/u/Dylan_Martin)\
**Post date:** [January 9, 2013, 11:43pm UTC](https://forum.ansible.com/t/stat-module/12191/1 "2013-01-09T23:43:09Z")

</div>

This is both a module idea and a reality check. If this idea is stupid and redundant, than I’ve obviously missed something.

Basically, the stat module would run stat on a target and produce json. It would work like so:

- name: check for /etc/httpd  
stat: name=/etc/httpd  
register: httpd\_stat
- name: tar /etc/httpd  
command: tar -czf /tmp/httpd.tgz /etc/httpd  
when\_string: ${httpd\_stat.type} == ‘directory’

I think I could use “command: removes=/etc/httpd tar -xvzf /tmp/httpd.tgz /etc/httpd” to do the same thing but it isn’t readable

The value of this module would be to make it easy for play writers to check files for size, mtime etc… without having to write a custom fact finding module.

Aaaand just to be a total weirdo:

- name: simulate stat module using command  
command: stat -c ‘{ “dev\_id”: “%d”,“inode”:“%i” }’ /etc/httpd  
register: httpd\_stat

That only does two of the 13 or so standard stat fields, but I’m lazy enough not to do the whole thing.

Again, I’m pretty sure this is not needed and I’ve just missed the elegant way to handle this.

Thanks  
-Dylan

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [January 10, 2013, 12:10am UTC](https://forum.ansible.com/t/stat-module/12191/2 "2013-01-10T00:10:15Z")

</div>

this might make sense as an expansion of the file module

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [January 11, 2013, 6:01pm UTC](https://forum.ansible.com/t/stat-module/12191/3 "2013-01-11T18:01:12Z")

</div>

Seems like this just produces output.

Therefore it seems like you just want to make a custom module  
(non-core) and run it in debug mode.
