Refactor rundeck scripts