List Rundeck Projects

Posted by in IT, Software, Tutorial

The other day I found out that Rundeck has an API which allows it to be controlled remotely by scripts. I’ve decided to write a script to list all the projects defined in a rundeck instance.

Prerequisites

Before you start, you need:

  • The instance’s URL (server and port)
  • An api key for the user
  • Make sure the user has enough credentials to list the projects

The code

I’ve picked up Python as language for the task just because I’m more familiar with it in this context. Therefore, another dependency is Python 3 and something like virtualenv to allow installation of 3rd party packages.

The code is quite trivial:

This function will return an XML containing all the projects (or an error if the user is not allowed to list projects via API).

If you need to get the names only, you can process the XML:

Now, all you need to do is:

Simple.

HTH,


A little experiment: If you find this post and ad below useful, please check the ad out :-)