How do I use Ansible facts in a custom module?

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”))

`