# How do I use Ansible facts in a custom module?

**URL:** <https://forum.ansible.com/t/how-do-i-use-ansible-facts-in-a-custom-module/23262>\
**Category:** Ansible Project\
**Created:** [December 14, 2016, 5:39pm UTC](https://forum.ansible.com/t/how-do-i-use-ansible-facts-in-a-custom-module/23262 "2016-12-14T17:39:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ZillaYT](https://avatars.discourse-cdn.com/v4/letter/z/4da419/32.png) [@ZillaYT](https://forum.ansible.com/u/ZillaYT)\
**Post date:** [December 14, 2016, 5:39pm UTC](https://forum.ansible.com/t/how-do-i-use-ansible-facts-in-a-custom-module/23262/1 "2016-12-14T17:39:29Z")

</div>

I’m trying to write my first Ansible module. How do I refer to the built-in facts that Ansible gathers during the setup phase? I just want to be able to do this inside my module, for example.I want to be able to do the “when” part in my module.

`

- name: Issue some command  
command: ls -al /tmp  
when: (ansible\_product\_version | search(“.\*.amazon”))

`
