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

Le jeudi 3 août 2023 à 15:43:30 UTC+2, Olivier Studer a écrit :

> Hi,
>
> I want to use hostvars to use a result of a task runing for on an host to 
> apply this values/result to another host. The "register" can not be use 
> because it is dedicated to the host, not sharing.
>
> The goals is to active the Slave Mariadb server with the value from the 
> Master server. 
>
> I think that I need to use the host-inventory (ini file) with this value. 
> How can write this value ?
>
> Thanks for your help
> Regards
> Olivier
>

-- 
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/1cb24625-df2a-4e99-8a29-bdb81a51322cn%40googlegroups.com.

Reply via email to