Need help with executing a python script automation

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

I found one solution to with delegate_to option to run on the task on particular server.

Regards