# Share value between hosts in playbook

**URL:** <https://forum.ansible.com/t/share-value-between-hosts-in-playbook/19215>\
**Category:** Ansible Project\
**Created:** [September 9, 2015, 5:46pm UTC](https://forum.ansible.com/t/share-value-between-hosts-in-playbook/19215 "2015-09-09T17:46:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gaetano\_Mazzeo](https://avatars.discourse-cdn.com/v4/letter/g/7bcc69/32.png) [@Gaetano\_Mazzeo](https://forum.ansible.com/u/Gaetano_Mazzeo)\
**Post date:** [September 9, 2015, 5:46pm UTC](https://forum.ansible.com/t/share-value-between-hosts-in-playbook/19215/1 "2015-09-09T17:46:48Z")

</div>

Hi,  
I need to do the following thing.  
On the first host, calculate the checksum of a certain file (es. /etc/hosts) and save it into a variable, let’s say “file\_checksum”.  
On the second host, I would like to calculate newly the checksum and compare it with the one from the first host (i.e. the value saved in “file\_checksum”). And so on with the other hosts of my inventory.  
I tried several ways without success. Also run\_once on set\_fact doesn’t seem to work (see below the snippet not fully working).  
Any Idea how to save a value between hosts in a playbook?  
Thanks in advance.  
Cheers.  
Gaetano

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [September 11, 2015, 6:52am UTC](https://forum.ansible.com/t/share-value-between-hosts-in-playbook/19215/2 "2015-09-11T06:52:13Z")

</div>

You can share values between hosts using the hostvars[host\_name] variable, however I believe in your situation you’ll want to run this in separate plays, as these task will still run on all of your systems (just one system at a time, due to the serial use).
