# Cannot extract the proper ENV value for SUDO\_USER while invoking ansible script using python

**URL:** <https://forum.ansible.com/t/cannot-extract-the-proper-env-value-for-sudo-user-while-invoking-ansible-script-using-python/31796>\
**Category:** Ansible Project\
**Created:** [December 10, 2019, 11:31am UTC](https://forum.ansible.com/t/cannot-extract-the-proper-env-value-for-sudo-user-while-invoking-ansible-script-using-python/31796 "2019-12-10T11:31:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rakesh\_Parida](https://avatars.discourse-cdn.com/v4/letter/r/3ab097/32.png) [@Rakesh\_Parida](https://forum.ansible.com/u/Rakesh_Parida)\
**Post date:** [December 10, 2019, 11:31am UTC](https://forum.ansible.com/t/cannot-extract-the-proper-env-value-for-sudo-user-while-invoking-ansible-script-using-python/31796/1 "2019-12-10T11:31:19Z")

</div>

Hi

I have a Ansible playbook as below:  
test.env.yml

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [December 10, 2019, 12:45pm UTC](https://forum.ansible.com/t/cannot-extract-the-proper-env-value-for-sudo-user-while-invoking-ansible-script-using-python/31796/2 "2019-12-10T12:45:47Z")

</div>

STOP

Running playbooks is done using 'ansible-playbook' - not with hand  
crafted python scripts.  
See [https://docs.ansible.com/ansible/latest/cli/ansible-playbook.html](https://docs.ansible.com/ansible/latest/cli/ansible-playbook.html)

Also, it looks like you have an issue understanding privilege  
escalation. Please look at the docs about that as well:  
[https://docs.ansible.com/ansible/latest/user\_guide/become.html](https://docs.ansible.com/ansible/latest/user_guide/become.html)

Lastly - you haven't told what you are actually trying to achieve with ansible?  
What are you trying to automate?
