On Mon, 4 Nov 2019 00:46:03 -0800 (PST)
Vicente Domínguez <
vi1...@gmail.com> wrote:
> So I can say that the wording of the doc is not totally accurate...
No. The wording is OK.
https://docs.ansible.com/ansible/latest/user_guide/playbooks_delegation.html#delegated-facts
Short story
===========
Read "delegate_facts: true" as "In the task, which is delegated to hostX,
use the facts of hostX as well".
Details
=======
Statement: "By default, (1) any fact gathered by a delegated task (2) are
assigned to the inventory_hostname (the current host) (3) instead of the
host which actually produced the facts (the delegated to host). (4) The
directive delegate_facts may be set to True to assign the task’s gathered
facts to the delegated host instead of the current one."
Example
- hosts: test_01
tasks:
- setup:
delegate_to: test_02
delegate_facts: true
- debug:
var: ansible_hostname
1) "any fact gathered by a delegated task" - Is the setup facts of test_02
in my example
"ansible_hostname": "test_02"
2) "are assigned to the inventory_hostname (the current host)" - Which is
test_01 in my example
3) "instead of the host which actually produced the facts (the delegated to
host)" - which is test_02 in my example
This has been confirmed. The play without the line "delegate_facts:
true" gives
ok: [test_01] => {
"ansible_hostname": "test_02"
}
4) "The directive delegate_facts may be set to True to assign the task’s
gathered facts to the delegated host" - which is test_02 in my example
This has been confirmed. The variable "ansible_hostname" of test_01 was
not replaced with "test_02". The play gives
ok: [test_01] => {
"ansible_hostname": "test_01"
}
* Opposite to "delegate_facts: true" is "delegate_facts: false"
> Regarding "your example" I meant that It was suggested by you to check :)
> Thank you very much Vlado, hope it helps for my certification exam this
> week!
(Please. Put me at least into CC when you address me in the text.)
You're welcome. Good luck!
-vlado