It does set the fact in tower. When I review the host in the inventory and click on the facts, they show up as set. If this is supposed to not work because of the invalid host, it could be a bug. But for me (using tower 3.5.4) it's working.
Regards, Glen On Friday, January 31, 2020 at 10:30:04 PM UTC-8, Vladimir Botka wrote: > > On Fri, 31 Jan 2020 20:14:51 -0800 (PST) > Glen Collins <[email protected] <javascript:>> 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 > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/b643721a-2dca-4a41-8bff-6acc0b817c52%40googlegroups.com.
