# Need help with executing a python script automation

**URL:** <https://forum.ansible.com/t/need-help-with-executing-a-python-script-automation/38134>\
**Category:** Ansible Project\
**Created:** [June 21, 2023, 1:23am UTC](https://forum.ansible.com/t/need-help-with-executing-a-python-script-automation/38134 "2023-06-21T01:23:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Prady\_A](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/prady_a/32/4792_2.png) [@Prady\_A](https://forum.ansible.com/u/Prady_A)\
**Post date:** [June 21, 2023, 1:23am UTC](https://forum.ansible.com/t/need-help-with-executing-a-python-script-automation/38134/1 "2023-06-21T01:23:02Z")

</div>

Hi all

I want to execute a python script which is available in control node. And the python script uses the ansible\_hostname variable and update in an excel template available in the control node.

My role is very simple:

- name: execute python script  
script: ./roles/writetoexcel.py {{ ansible\_hostname }}  
args:  
executable: python3

Since this role executes the python file in the remote node it is failing. Python3 command not found… my intention is to run this python script in the control node for all the hosts and just use the ansible\_hostname variable from ansible to update the excel which is also available in local.

Regards  
Prady

---

<div class="post-metadata">

**Author:** ![Prady\_A](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/prady_a/32/4792_2.png) [@Prady\_A](https://forum.ansible.com/u/Prady_A)\
**Post date:** [June 21, 2023, 1:59am UTC](https://forum.ansible.com/t/need-help-with-executing-a-python-script-automation/38134/2 "2023-06-21T01:59:32Z")

</div>

I found one solution to with delegate\_to option to run on the task on particular server.

Regards
