Can I set a variable on one host and use them on other hosts?

I’m writing a playbook to restore the latest backup of my DB on all my Database servers. This is done in two main steps:

  1. figure out which backup is the latest (once)
  2. download that file to all DB servers
  3. …and run the restore

While step 2 and 3 are straight forward, my problem is to acquire the correct filename once and share it among all DB hosts.

I was trying something like this for testing, but I cant access last_mongo on the DB hosts.

`

Update:

I figured it out:

`

Yes, use hostvars.localhost.lmongo.stdout

Thanks for the good adivce!