In Ansible, I can run a python script if it contains code in the same script. However, if i try to use
name: Restarting service on different nodes
hosts: nodes
connection: ssh
tasks:
- name: Restarting tomcat service
script: main.py 1
args:
executable: python3
And main.py has import restart_tomcat (restart_tomcat.py is present in the same folder as main.py) it is not able to import this module , though present in the same directory.
How to make it understand that the other supporting files for main.py is present in same directory. Note : it is failing, when its trying to execute it on remote servers
Edit : It would get too complicated to create custom_module on Ansible for every example we want to run