Good day all,
I am trying to figure out how to execute a python script using Rundeck.
Currently I have setup a node step that executes the following command
python3 /home/ansible/reboot_cctv.py
The permissions for the python script are
-rwxrwxrwx 1 ansible ansible 455 Feb 24 16:14 reboot_cctv.py
I have it set to execute locally, but am getting the following error when i run the job
python3: can't open file '/home/ansible/reboot_cctv.py': [Errno 13] Permission denied
Result: 2
Failed: NonZeroResultCode: Result code was 2
This is the full job definition
- defaultTab: nodes
description: ''
executionEnabled: true
id: fb24247a-0e30-4533-ad00-01ed4cbc00ff
loglevel: INFO
name: CCTV Restart Python
nodeFilterEditable: false
plugins:
ExecutionLifecycle: null
scheduleEnabled: true
sequence:
commands:
- exec: python3 /home/ansible/reboot_cctv.py
keepgoing: false
strategy: node-first
uuid: fb24247a-0e30-4533-ad00-01ed4cbc00ff
I am not sure what other modifications I need to make in order for this to work.
Any input or advice is grately appreciated
The rundeck
user needs access to the python script file.
You have two options.
The first option, running an inline python script (defined within the rundeck job)
/usr/bin/python3
) and the .py
extension on the "File Extension" textbox.The second option is to call a script stored in the Rundeck server filesystem (closer to your approach). This option and your approach need that the rundeck
user (created at the moment of installing Rundeck via RPM/DEB) can reach the path of your python script.
/usr/bin/python3
) and the .py
extension on the "File Extension" textbox.