# We have a file module now!

**URL:** <https://forum.ansible.com/t/we-have-a-file-module-now/11354>\
**Category:** Ansible Project\
**Created:** [March 16, 2012, 2:10am UTC](https://forum.ansible.com/t/we-have-a-file-module-now/11354 "2012-03-16T02:10:14Z")\
**Posts on this page:** 2\
**Page:** 1

<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:** [March 16, 2012, 2:10am UTC](https://forum.ansible.com/t/we-have-a-file-module-now/11354/1 "2012-03-16T02:10:14Z")

</div>

That was quick, eh?

usage:

ansible \<pattern\> -m file -a "name=/tmp/blarg mode=622 owner=mdehaan  
group=mdehaan state=file"

The default for state is file

Other valid states are 'directory' (if not exists, will do mkdir -p  
equivalent), and 'absent' (which unlinks symlinks or files  
and does recursive directory removals).

The module will return info about files so if you don't pass in  
owner/group/mode it's useful for doing basic queries about  
things.

EX:

ansible \<pattern\> -m file -a "name=/tmp/blarg"

That will tell you all about /tmp/blarg

Things not done yet, which I'll file RFEs for to be fixed in short order:

&nbsp;&nbsp;&nbsp;&nbsp;support for SELinux context  
&nbsp;&nbsp;&nbsp;&nbsp;return the file size  
&nbsp;&nbsp;&nbsp;&nbsp;return the md5sum

I'm updating the module documentation to explain how it works soon, as  
well as wiring it in "magically" so all these options are available to  
"copy" and "template" for free.

Please help test.

THANKS!

---

<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:** [March 16, 2012, 2:59am UTC](https://forum.ansible.com/t/we-have-a-file-module-now/11354/2 "2012-03-16T02:59:00Z")

</div>

I've now wired up the copy & template modules so they work with the  
powers granted by the file module.

You can read documentation on all this here:

[http://ansible.github.com/examples.html](http://ansible.github.com/examples.html)

[http://ansible.github.com/modules.html](http://ansible.github.com/modules.html)

Again, testing and upgrades very very welcome.
