# documenting module return values

**URL:** <https://forum.ansible.com/t/documenting-module-return-values/17513>\
**Category:** Ansible Developer\
**Created:** [February 13, 2015, 7:51pm UTC](https://forum.ansible.com/t/documenting-module-return-values/17513 "2015-02-13T19:51:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [February 13, 2015, 7:51pm UTC](https://forum.ansible.com/t/documenting-module-return-values/17513/1 "2015-02-13T19:51:44Z")

</div>

Hi,

This is a draft of a new facility that will allow modules to document  
their return values (what you'll find if you register a var).

Keep in mind that the common returns (failed/changed/skipped/msg/etc)  
will be documented globally, so each module only has to return their  
specific returns.

As an example I've updated the acl and copy modules and in the 2nd  
commit added the ability to present this data to ansible-doc.

[https://github.com/bcoca/ansible-modules-core/commit/9575cbc99f8ed43d37a54b47430a2b72e3e8c7ba](https://github.com/bcoca/ansible-modules-core/commit/9575cbc99f8ed43d37a54b47430a2b72e3e8c7ba)

[https://github.com/bcoca/ansible/commit/a788301864101c7a9af3f9de47d5e07165c43037](https://github.com/bcoca/ansible/commit/a788301864101c7a9af3f9de47d5e07165c43037)

comments? improvements?

---

<div class="post-metadata">

**Author:** ![Jesse\_Keating](https://avatars.discourse-cdn.com/v4/letter/j/3bc359/32.png) [@Jesse\_Keating](https://forum.ansible.com/u/Jesse_Keating)\
**Post date:** [February 13, 2015, 8:05pm UTC](https://forum.ansible.com/t/documenting-module-return-values/17513/2 "2015-02-13T20:05:33Z")

</div>

It'd be helpful if you showed an example output with this new good stuff 🙂

I've been wanting something like this for a long time. I think many modules will benefit, and the outliers are the things that return data that is not known ahead of time (cloud modules and the like). I think that's acceptable and fixes a lot of frustration I see in new users.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [February 13, 2015, 8:22pm UTC](https://forum.ansible.com/t/documenting-module-return-values/17513/3 "2015-02-13T20:22:05Z")

</div>

nothing on the html side as it would be too much work before getting  
the fields defined, but here is the output from ansible-doc in patch  
(copy module):

RETURN VALUES:  
dest:  
&nbsp;&nbsp;&nbsp;&nbsp;description: destination file/path  
&nbsp;&nbsp;&nbsp;&nbsp;returned: always  
&nbsp;&nbsp;&nbsp;&nbsp;type: string  
&nbsp;&nbsp;&nbsp;&nbsp;sample: "/path/to/file.txt"  
src:  
&nbsp;&nbsp;&nbsp;&nbsp;description: source file used for the copy on the target machine  
&nbsp;&nbsp;&nbsp;&nbsp;returned: changed  
&nbsp;&nbsp;&nbsp;&nbsp;type: string  
&nbsp;&nbsp;&nbsp;&nbsp;sample: "/home/httpd/.ansible/tmp/ansible-tmp-1423796390.97-147729857856000/source"  
md5sum:  
&nbsp;&nbsp;&nbsp;&nbsp;description: md5 checksum of the file after running copy  
&nbsp;&nbsp;&nbsp;&nbsp;returned: when supported  
&nbsp;&nbsp;&nbsp;&nbsp;type: string  
&nbsp;&nbsp;&nbsp;&nbsp;sample: "2a5aeecc61dc98c4d780b14b330e3282",  
checksum:  
&nbsp;&nbsp;&nbsp;&nbsp;description: checksum of the file after running copy  
&nbsp;&nbsp;&nbsp;&nbsp;returned: always  
&nbsp;&nbsp;&nbsp;&nbsp;type: string  
&nbsp;&nbsp;&nbsp;&nbsp;sample: "6e642bb8dd5c2e027bf21dd923337cbb4214f827"  
backup\_file:  
&nbsp;&nbsp;&nbsp;&nbsp;description: name of backup file created  
&nbsp;&nbsp;&nbsp;&nbsp;returned: changed and if backup=yes  
&nbsp;&nbsp;&nbsp;&nbsp;type: string

---

<div class="post-metadata">

**Author:** ![Garrett\_Plasky](https://avatars.discourse-cdn.com/v4/letter/g/5f9b8f/32.png) [@Garrett\_Plasky](https://forum.ansible.com/u/Garrett_Plasky)\
**Post date:** [February 17, 2015, 7:36pm UTC](https://forum.ansible.com/t/documenting-module-return-values/17513/4 "2015-02-17T19:36:37Z")

</div>

Having recently written a couple of modules, I went looking for something like this and was mildly sad to find nothing. Doing away with the need to write a debug task in playbooks to figure out module return values is a great win. This makes me happy, thanks Brian!

---

<div class="post-metadata">

**Author:** ![Rittik\_Mondal](https://avatars.discourse-cdn.com/v4/letter/r/3be4f8/32.png) [@Rittik\_Mondal](https://forum.ansible.com/u/Rittik_Mondal)\
**Post date:** [June 10, 2015, 10:24am UTC](https://forum.ansible.com/t/documenting-module-return-values/17513/5 "2015-06-10T10:24:58Z")

</div>

hi,  
I am new to ansible. I was trying a way to find a way to document the data returned by ACL module. is it possible?

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [June 10, 2015, 2:18pm UTC](https://forum.ansible.com/t/documenting-module-return-values/17513/6 "2015-06-10T14:18:26Z")

</div>

Yes, you just need to add a RETURN documentation entry in module, you  
can look at stat module as example.
