# Getting A ID Value Unique To An Instance Of An Ansible Playbook

**URL:** <https://forum.ansible.com/t/getting-a-id-value-unique-to-an-instance-of-an-ansible-playbook/35593>\
**Category:** Ansible Project\
**Created:** [August 6, 2021, 7:02am UTC](https://forum.ansible.com/t/getting-a-id-value-unique-to-an-instance-of-an-ansible-playbook/35593 "2021-08-06T07:02:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dhiwakar\_Ravikumar](https://avatars.discourse-cdn.com/v4/letter/d/ecc23a/32.png) [@Dhiwakar\_Ravikumar](https://forum.ansible.com/u/Dhiwakar_Ravikumar)\
**Post date:** [August 6, 2021, 7:02am UTC](https://forum.ansible.com/t/getting-a-id-value-unique-to-an-instance-of-an-ansible-playbook/35593/1 "2021-08-06T07:02:44Z")

</div>

I’m trying to create an external file that every single task (Python modules for which I’ve implemented) in the playbook should read from and write into some information.

I wanted to use the process ID for the playbook itself but I’m not sure how to fetch this information from within the module itself i.e. the python script itself.

$PPID keeps changing as evidenced by the following playbook.

 ![Untitled.png](https://us1.discourse-cdn.com/ansible/original/2X/6/62cbf5e9f7676faf62fd7b8b381b2283e017bc59.png)

the value for the PPID was

“stdout”: “2850132”  
“stdout”: “2850343”

the 1st and 2nd times respectively. Is there any value like a process ID or something similar that is

1. Unique to this instance of the playbook run ?
2. Accessible to the module’s underlying python script ?
3. Without involving use of psutil or any package that doesn’t come as part of Python 3.X

For a better reading experience, check out

> <https://stackoverflow.com/questions/68677124/getting-a-id-value-unique-to-an-instance-of-an-ansible-playbook>

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [August 6, 2021, 9:55am UTC](https://forum.ansible.com/t/getting-a-id-value-unique-to-an-instance-of-an-ansible-playbook/35593/2 "2021-08-06T09:55:37Z")

</div>

> I'm trying to create an external file that every single task (Python modules for which I've implemented) in the playbook should read from and write into some information.
> 
> I wanted to use the process ID for the playbook itself but I'm not sure how to fetch this information from within the module itself i.e. the python script itself.
> 
> $PPID keeps changing as evidenced by the following playbook.
> 
> Untitled.png
> 
> the value for the PPID was
> 
> "stdout": "2850132"  
> "stdout": "2850343"
> 
> the 1st and 2nd times respectively. Is there any value like a process ID or something similar that is
> 
> 1. Unique to this instance of the playbook run ?  
> 2. Accessible to the module's underlying python script ?  
> 3. Without involving use of psutil or any package that doesn't come as part of Python 3.X
> 
> For a better reading experience, check out  
> [https://stackoverflow.com/questions/68677124/getting-a-id-value-unique-to-an-instance-of-an-ansible-playbook](https://stackoverflow.com/questions/68677124/getting-a-id-value-unique-to-an-instance-of-an-ansible-playbook)

That's sound like an awkward and fragile approach to me. Why would you use the process ID as unique value?  
An UUID (see to\_uuid filter) would be definitely unique.

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<div class="post-metadata">

**Author:** ![Dhiwakar\_Ravikumar](https://avatars.discourse-cdn.com/v4/letter/d/ecc23a/32.png) [@Dhiwakar\_Ravikumar](https://forum.ansible.com/u/Dhiwakar_Ravikumar)\
**Post date:** [August 8, 2021, 1:44am UTC](https://forum.ansible.com/t/getting-a-id-value-unique-to-an-instance-of-an-ansible-playbook/35593/3 "2021-08-08T01:44:15Z")

</div>

Thank you Racke.
