# How to get the "{{ playbook\_dir }}" variable directly in the python source code without passing as option

**URL:** <https://forum.ansible.com/t/how-to-get-the-playbook-dir-variable-directly-in-the-python-source-code-without-passing-as-option/28212>\
**Category:** Ansible Project\
**Created:** [July 31, 2018, 2:08pm UTC](https://forum.ansible.com/t/how-to-get-the-playbook-dir-variable-directly-in-the-python-source-code-without-passing-as-option/28212 "2018-07-31T14:08:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sayed\_Anisul](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@Sayed\_Anisul](https://forum.ansible.com/u/Sayed_Anisul)\
**Post date:** [July 31, 2018, 2:08pm UTC](https://forum.ansible.com/t/how-to-get-the-playbook-dir-variable-directly-in-the-python-source-code-without-passing-as-option/28212/1 "2018-07-31T14:08:33Z")

</div>

##### Hello !#####

Ansible has a variable “{{ playbook\_dir }}” that gives the playbook directory path. What I understand is, while running the Ansible play, the sources related to Ansible playbook are copied to a temporary location for example:  
/root/.ansible/tmp/ansible-tmp-1532003188.07-226176824704061/ and it is run from there. So, currently, for one of my method where I need to read a file, I need to pass “{{ playbook\_dir }}” as a parameter while running the play, source code: [https://gist.github.com/anis016/1c0a54a9fea7283ece474d0727ddb879#file-hive-py-L350](https://gist.github.com/anis016/1c0a54a9fea7283ece474d0727ddb879#file-hive-py-L350) (Also, please check the play.yml below).  
Is there any other way from where I can get the Playbook directory path directly and can use in my python source code without passing as a separate option?
