Skip to main content

Call APIs from Rundeck


Call APIs from Rundeck

Modern applications use the HTTPopen in new window protocol to communicate with each other and send or obtain information from any web service using HTTP methodsopen in new window like GET, POST, or PUT. For example, to obtain a valid user ID from a web service to use it later in another process/application.

To make those HTTP calls we can use an inline-script] with a cURLopen in new window command inside, curl is used in scripts or commands to transfer data and it’s available for any operating system. But this implies maintaining a lot of code inside a Rundeck workflow.

Rundeck’s Job Steps offer a more user-friendly way to make these calls. For HTTP calls, use the HTTP Workflow Step Pluginopen in new window in Rundeck. This plugin will send HTTP calls to any web service or HTTP endpoint. The returned data can then be used in subsequent steps. (Check out our Passing Variables guide).

If you are using our Enterprise version the plugin is already bundled with your installation. Skip straight to the exercises.

Community Version Prerequisite

The HTTP Workflows Step plugin isn’t bundled with the Rundeck Community version (it is included with Process Automationopen in new window). For Rundeck Community, follow these steps to install it.

  1. Go to the System Menu (Gear Icon in upper right) > Plugins > Upload Plugin.
  2. Copy the plugin file location from the repository (Latest link as of last update is below)
    https://github.com/rundeck-plugins/http-step/releases/download/1.0.12/http-step-1.0.12.jar
    
    Upload Plugin
    Upload Plugin
  3. Paste it on the Plugin URL textbox, and click on the Install button. Plugin Installed!

An alternative method to install the plugin is to download the .jar file directly from the repositoryopen in new window and put it on the libext directory (at /var/lib/rundeck/libext` on RPM / DEB based installations or $RDECK_BASE/libext` directory on WAR based installations). Just copy the the .jar to the folder, no restart is needed.

Exercise

Note

For this exercise we will use the site httpbin.orgopen in new window test website, httpbin.orgopen in new window is a simple HTTP request and response service written in python by Ken Reitz. This is not a site owned or run by PagerDuty. Note: Don't send any sensitive data. This site is simply used as a test. If you would like to run your own their site has more information about using their Docker Imagesopen in new window.

Other Parameters

Other parameters available:

  • Request Timeout (How long to wait for a request to complete before failing).
  • Validate SSL Certificatesopen in new window (true or false, validate that SSL certificates are trusted, match the hostname, etc.)
  • Authentication section. If the HTTP service uses Basic / OAuth2open in new window authentication. On Basic Auth it’s possible to define the user and password from the Rundeck Key Storage. On OAuth 2.0 add the OAuth Token URL and OAuth Validate URL.
  • Validate Response can check the HTTP response codeopen in new window that is returned and fail the step if it is not the expected value. (typically looking for 200)
  • Proxy Settings section, if the HTTP service is behind a proxy server, you can define the Proxy IP address and port.

Additional Information