# Facts not available when using debug module in ad-hoc mode

**URL:** <https://forum.ansible.com/t/facts-not-available-when-using-debug-module-in-ad-hoc-mode/27932>\
**Category:** Ansible Project\
**Created:** [July 2, 2018, 4:05pm UTC](https://forum.ansible.com/t/facts-not-available-when-using-debug-module-in-ad-hoc-mode/27932 "2018-07-02T16:05:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kai\_Weber](https://avatars.discourse-cdn.com/v4/letter/k/f6c823/32.png) [@Kai\_Weber](https://forum.ansible.com/u/Kai_Weber)\
**Post date:** [July 2, 2018, 4:05pm UTC](https://forum.ansible.com/t/facts-not-available-when-using-debug-module-in-ad-hoc-mode/27932/1 "2018-07-02T16:05:52Z")

</div>

Hi,

I try to find an easy way to test jinja2 statments. I tried the debug  
module in ad-hoc mode and found that machine facts are not availabe.

Is this so by design?

How else can I test jinja2 statments?

$ ansible -m debug -a "msg={{ansible\_processor}}" -i localhost, localhost  
localhost | FAILED! =\> {  
&nbsp;&nbsp;&nbsp;&nbsp;"msg": "The task includes an option with an undefined variable. The error was: 'ansible\_processor' is undefined"  
}

$ ansible -m debug -a "var=ansible\_processor" -i localhost, localhost  
localhost | SUCCESS =\> {  
&nbsp;&nbsp;&nbsp;&nbsp;"ansible\_processor": "VARIABLE IS NOT DEFINED!"  
}

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [July 2, 2018, 5:30pm UTC](https://forum.ansible.com/t/facts-not-available-when-using-debug-module-in-ad-hoc-mode/27932/2 "2018-07-02T17:30:33Z")

</div>

If you are not using a cache, you need to gather facts yourself, but  
adhoc is a 'single task' and that would make it 2 tasks.

Use a play or setup the fact cache..

---

<div class="post-metadata">

**Author:** ![Kai\_Weber](https://avatars.discourse-cdn.com/v4/letter/k/f6c823/32.png) [@Kai\_Weber](https://forum.ansible.com/u/Kai_Weber)\
**Post date:** [July 3, 2018, 5:42pm UTC](https://forum.ansible.com/t/facts-not-available-when-using-debug-module-in-ad-hoc-mode/27932/3 "2018-07-03T17:42:58Z")

</div>

\* Brian Coca \<bcoca@redhat.com\> (2018-07-02 13:30:33 -0400):

> If you are not using a cache, you need to gather facts yourself, but  
> adhoc is a 'single task' and that would make it 2 tasks.
> 
> Use a play or setup the fact cache..

I went for the fact cache option.  
Thanks for the answer.

Kai

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [July 3, 2018, 6:12pm UTC](https://forum.ansible.com/t/facts-not-available-when-using-debug-module-in-ad-hoc-mode/27932/4 "2018-07-03T18:12:42Z")

</div>

I forgot to mention, another option is using ansilbe-console:

```auto
#>ansible-console
Welcome to the ansible console.
Type help or ? to list commands.

bcoca@all (0)[f:5]$ cd localhost
bcoca@localhost (1)[f:5]$ setup
.....

bcoca@localhost (1)[f:5]$ debug var=ansible_processor
localhost | SUCCESS => {
   "ansible_processor": [
       "0",
       "GenuineIntel",
       "Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz",
       "1",
       "GenuineIntel",
...

```
