# how to get the playbook directory in the python source

**URL:** <https://forum.ansible.com/t/how-to-get-the-playbook-directory-in-the-python-source/28278>\
**Category:** Ansible Project\
**Created:** [August 7, 2018, 8:56am UTC](https://forum.ansible.com/t/how-to-get-the-playbook-directory-in-the-python-source/28278 "2018-08-07T08:56:02Z")\
**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:** [August 7, 2018, 8:56am UTC](https://forum.ansible.com/t/how-to-get-the-playbook-directory-in-the-python-source/28278/1 "2018-08-07T08:56:02Z")

</div>

Hello,

Ansible has a variable “{{ playbook\_dir }}” that gives the playbook directory path.

Currently, I am doing in this way to get the playbook directory in the hive(python source code) task, but is there any other way to directly get the “{{ playbook\_dir }}” path without passing as an option explicitly?

```auto
---
- name: hive playbook
  hosts: yum_hosts
  tasks:
  - name: execute a DDL statement from a HQL file.
    hive:
      playbook_path: "{{ playbook_dir }}"
    register: result_execute

  - name: dump
    debug:
      msg: '{{ result_execute }}'

```

Thank you
