Re: [ansible-project] Ansible Tower and Facts

15 views
Skip to first unread message
Message has been deleted

Vladimir Botka

unread,
Feb 1, 2020, 1:30:04 AM2/1/20
to Glen Collins, ansible...@googlegroups.com
On Fri, 31 Jan 2020 20:14:51 -0800 (PST)
Glen Collins <collin...@gmail.com> wrote:

> - name: Set facts
> set_fact:
> dummy_fact: "Hello world"
> cacheable: yes
> delegate_to: fake_host
> 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

- hosts: all
tasks:
- set_fact:
dummy_fact: "Hello world"
cacheable: yes
delegate_to: fake_host
delegate_facts: true
run_once: true
- debug:
var: hostvars.fake_host.ansible_facts
run_once: true


should report

"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

- hosts: all
tasks:
- set_fact:
dummy_fact: "Hello world"
cacheable: yes
delegate_to: test_01
delegate_facts: true
run_once: true
- debug:
var: hostvars.test_01.ansible_facts
run_once: true

- hosts: test_01
tasks:
- debug:
var: hostvars.test_01.ansible_facts
- meta: clear_facts
- debug:
var: hostvars.test_01.ansible_facts

gives

PLAY [all]
ok: [test_01] => {
"hostvars.test_01.ansible_facts": {
"dummy_fact": "Hello world"
}
}

PLAY [test_01]
ok: [test_01] => {
"hostvars.test_01.ansible_facts": {
"dummy_fact": "Hello world"
}
}
ok: [test_01] => {
"hostvars.test_01.ansible_facts": {}
}

To make it reproducible test it without tower. HTH,

-vlado
Message has been deleted

Kai Stian Olstad

unread,
Feb 1, 2020, 3:15:58 AM2/1/20
to ansible...@googlegroups.com
On 01.02.2020 08:42, Glen Collins wrote:
> It does set the fact in tower.

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

--
Kai Stian Olstad
Reply all
Reply to author
Forward
0 new messages