The issue still there, so I have moved the playbook file to the same directory where python script is running ex: /reports/
So both playbook and python script is in the same folder. But still, I get a couple of errors.
Below is my playbook:
********************
- name: Execute the test1 script
command: python /home/{{ username }}/project1/reports/test1.py --- python script running on same folder as yaml playbook
delegate_to:
args:
chdir: /home/{{ username }}/project1/reports/
ignore_errors: False
I get a couple of error if I run the playbook with commenting (#) args: chdir: then i get.
fatal: [switch1]: FAILED! => {"changed": true, "cmd": ["python", "/home/{{ username }}/project1/reports/test1.py"], "delta": "0:00:00.035644", "end": "2020-05-28 19:04:00.583497", "msg": "non-zero return code", "rc": 2, "start": "2020-05-28 19:04:00.547853", "stderr": "python: can't open file
If i uncomment(remove # on those lines) the args: chdir: then i get.
fatal: [switch1]: FAILED! => {"changed": false, "msg": "Unable to change directory before execution: [Errno 2] No such file or directory: '/home/{{ username }}/project1/reports/'"}
Python - unable to identify the path to execute the test1.py that i finally understood. so any permission to the user to execute the same or do i need to move the playbook to back to original directory, so the python script is under subdirectory.
Please suggest. if am missing any logic here.
On Wednesday, May 27, 2020 at 12:31:40 PM UTC+2, aditya govindaraju wrote: