Welcome, Guest Login

Rundeck Enterprise Support Center

Enable CGI script on Jetty

Last Updated: Oct 26, 2017 09:59AM PDT

This tutorial explains how to deploy CGI scripts to the Rundeck instance. For example, this can be used to add a custom health check for a load balancer or define custom remote input options based on API calls.

 

These settings are valid for the rpm/deb or launcher install (for jetty container).

 

Edit the web.xml

 

In the launcher, the file web.xml is located on $RDECK_BASE/server/exp/webapp/WEB-INF. For deb/rpm installers, the web.xml is located in /var/lib/rundeck/server/exp/webapp/WEB-INF.

 
  • Add the following attributes before the last “security-constraint” label (the one that contains the auth-constraint attribute). This will avoid the redirect to the login page if you are not logged in rundeck.
 


<security-constraint>

        <web-resource-collection>

            <web-resource-name>cgi</web-resource-name>

            <url-pattern>/cgi-bin/*</url-pattern>

        </web-resource-collection>

    </security-constraint>

 
  • After the last servlet attribute, add the following settings. A folder called WEB-INF/cgi-bin must be created (the name of the folder can be defined by the user)
 

   <servlet>

       <servlet-name>CGI</servlet-name>

       <servlet-class>org.eclipse.jetty.servlets.CGI</servlet-class>

       <init-param>

           <param-name>Path</param-name>

           <param-value>/bin:/usr/bin:/usr/local/bin</param-value>

       </init-param>

       <init-param>

           <param-name>cgibinResourceBaseIsRelative</param-name>

           <param-value>true</param-value>

       </init-param>      

       <init-param>

           <param-name>commandPrefix</param-name>

           <param-value>/usr/bin/python</param-value>

       </init-param>         

       <init-param>

           <param-name>cgibinResourceBase</param-name>

           <param-value>WEB-INF/cgi-bin</param-value>

       </init-param>

       <async-supported>true</async-supported>

       <load-on-startup>1</load-on-startup>

   </servlet>

 
  • Add the following settings after the last “servlet-mapping” attribute. The “cgi-bin” name must match with the settings defined on the servlet.
 

  <servlet-mapping>

       <servlet-name>CGI</servlet-name>

       <url-pattern>/cgi-bin/*</url-pattern>

   </servlet-mapping>

 

Run the Script

 

With this settings, any script added to $RDECK_BASE/server/exp/webapp/WEB-INF/cgi-bin, can be called as an endpoint, for example:

 
  1. For the URL: http://localhost:4440/cgi-bin/somescript  
  2. Will call the script  $RDECK_BASE/server/exp/webapp/WEB-INF/cgi-bin/somescript
1fb43f9155a47800b95738aff7e657fc@rundeck.desk-mail.com
http://assets1.desk.com/
false
desk
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
false
Invalid characters found
/customer/en/portal/articles/autocomplete