# How to access a variable between different play/hosts in the same playbook?

**URL:** <https://forum.ansible.com/t/how-to-access-a-variable-between-different-play-hosts-in-the-same-playbook/37309>\
**Category:** Ansible Project\
**Created:** [November 6, 2022, 9:06pm UTC](https://forum.ansible.com/t/how-to-access-a-variable-between-different-play-hosts-in-the-same-playbook/37309 "2022-11-06T21:06:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ramkumar\_A](https://avatars.discourse-cdn.com/v4/letter/r/ea666f/32.png) [@Ramkumar\_A](https://forum.ansible.com/u/Ramkumar_A)\
**Post date:** [November 6, 2022, 9:06pm UTC](https://forum.ansible.com/t/how-to-access-a-variable-between-different-play-hosts-in-the-same-playbook/37309/1 "2022-11-06T21:06:17Z")

</div>

Hi Experts,

I am a newcomer to Ansible.  
I need help in accessing a variable between different hosts/play on the playbook. In below code, group of servers is passed here dynamically and creating tempfile directory for each hosts on the Ansible server.  
In the second play, i am unable to access the tempfile directory name (stagingdir) for the hosts, probably i am not using the correct approach using hostvars.  
Can you please help & guide me to access the stagingdir value of hosts in the first play from the second play below ?
