Hi,
I'm pretty sure you could query facts cache to that end :
$ less test_facts_sharing.yml
---
- name: Local host play
connection: local
hosts: localhost
gather_facts: false
tasks:
- name: Store value
ansible.builtin.set_fact:
foo: "bar"
- name: Remote host play
hosts: anotherhost
gather_facts: false
tasks:
- name: Print stored value from another host
ansible.builtin.debug:
var: hostvars['localhost']['foo']
$ ansible-playbook -i ~/conf/ansible/inventories/ test_facts_sharing.yml
PLAY [Local host play] *******************************************************************************************************************************************************************************************************************************************************************
TASK [Store value] ***********************************************************************************************************************************************************************************************************************************************************************
ok: [localhost]
PLAY [Remote host play] ******************************************************************************************************************************************************************************************************************************************************************
TASK [Print stored value from another host] **********************************************************************************************************************************************************************************************************************************************
ok: [anotherhost] => {
"hostvars['localhost']['foo']": "bar"
}
PLAY RECAP *******************************************************************************************************************************************************************************************************************************************************************************
anotherhost : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
localhost : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0