# Ansible Tower and Facts

**URL:** <https://forum.ansible.com/t/ansible-tower-and-facts/32115>\
**Category:** Ansible Project\
**Tags:** ansible-project\
**Created:** [February 1, 2020, 6:29am UTC](https://forum.ansible.com/t/ansible-tower-and-facts/32115 "2020-02-01T06:29:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [February 1, 2020, 6:29am UTC](https://forum.ansible.com/t/ansible-tower-and-facts/32115/1 "2020-02-01T06:29:43Z")

</div>

> - name: Set facts  
> &nbsp;&nbsp;set\_fact:  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dummy\_fact: "Hello world"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cacheable: yes  
> &nbsp;&nbsp;delegate\_to: fake\_host  
> &nbsp;&nbsp;delegate\_facts: true
> 
> This sets the fact in the hostname fake\_host just fine.  
> [...]  
> I have tried to target the playbook using host: fake\_host but the playbook  
> run tells me the host is invalid or something to that effect.

This \*can't\* set the fact in the hostname fake\_host just fine if the host  
in not valid. The play

&nbsp;&nbsp;- hosts: all  
&nbsp;&nbsp;&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- set\_fact:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dummy\_fact: "Hello world"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cacheable: yes  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;delegate\_to: fake\_host  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;delegate\_facts: true  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;run\_once: true  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- debug:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var: hostvars.fake\_host.ansible\_facts  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;run\_once: true

should report

&nbsp;&nbsp;&nbsp;&nbsp;"hostvars.fake\_host.ansible\_facts": "VARIABLE IS NOT DEFINED!"

> Can someone tell me if this is even possible to do? Possible to target  
> directly?

If the host is valid. All works as expected. For example, the playbook  
&nbsp;&nbsp;  
&nbsp;&nbsp;- hosts: all  
&nbsp;&nbsp;&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- set\_fact:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dummy\_fact: "Hello world"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cacheable: yes  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;delegate\_to: test\_01  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;delegate\_facts: true  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;run\_once: true  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- debug:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var: hostvars.test\_01.ansible\_facts  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;run\_once: true

&nbsp;&nbsp;- hosts: test\_01  
&nbsp;&nbsp;&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- debug:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var: hostvars.test\_01.ansible\_facts  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- meta: clear\_facts  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- debug:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var: hostvars.test\_01.ansible\_facts

gives

&nbsp;&nbsp;PLAY [all]  
&nbsp;&nbsp;ok: [test\_01] =\> {  
&nbsp;&nbsp;&nbsp;&nbsp;"hostvars.test\_01.ansible\_facts": {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"dummy\_fact": "Hello world"  
&nbsp;&nbsp;&nbsp;&nbsp;}  
&nbsp;&nbsp;}

&nbsp;&nbsp;PLAY [test\_01]  
&nbsp;&nbsp;ok: [test\_01] =\> {  
&nbsp;&nbsp;&nbsp;&nbsp;"hostvars.test\_01.ansible\_facts": {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"dummy\_fact": "Hello world"  
&nbsp;&nbsp;&nbsp;&nbsp;}  
&nbsp;&nbsp;}  
&nbsp;&nbsp;ok: [test\_01] =\> {  
&nbsp;&nbsp;&nbsp;&nbsp;"hostvars.test\_01.ansible\_facts": {}  
&nbsp;&nbsp;}

To make it reproducible test it without tower. HTH,

&nbsp;&nbsp;-vlado

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [February 1, 2020, 8:14am UTC](https://forum.ansible.com/t/ansible-tower-and-facts/32115/2 "2020-02-01T08:14:54Z")

</div>

This list is for Ansible and not Tower, please contact RedHat for support on Tower.
