stat module?

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

this might make sense as an expansion of the file module

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.