Skip to content

ambrisolla/rundeck-servicenow-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rundeck-servicenow-plugin

This plugin can be used in a Rundeck workflow to create and close a Service Now change.

Features

  • Open a Service Now Change;
  • Close a Service Now Change;

How it works

Basically, we can create two types of steps using this plugin: open_change and close_change.

When open_change is used, the plugin will connect to Service Now, create a change and wait for approval. This step will finish when the Change was approved or rejected. If the change was approved, the plugin will finishes with success and the next step will be executed. If the change was rejected, the plugin will finish with error and the next step will not be executed.

When a change is created with this plugin, a file is created in a temporary filesystem with change information. This file is used for the close_change step to recovery a change number associated with the job id. So the action close_change can be used in two situations:

  • on the same job that open_change was used: the plugin will use the current job id to recovery the change information;
  • create a job with a step to close_change: this step uses ${RD_OPTION_JOB_ID} variable content, so you need to configure JOB_ID option passing the job id;

Requirements

This plugins uses Python3 to interact with Service Now, to work this plugins requires the following python libraries:

  • requests;
  • PyYAML;

To instal this libraries executes the following command:

$ pip3 install PyYAML requests

Be sure that the following path exists:

$ ls -l /usr/bin/python3

Build

make clean build

Install

cp build/libs/servicenow-approval-plugin.zip $RDECK_BASE/libext

Plugin configuration

The following configuration is required by the plugin:

  • servicenow_username:
    • description: Username with permissions to create a Change on ServiceNow.
    • type: String
  • servicenow_password:
    • description: Path to Rundeck Key Storage to access ServiceNow password.
    • type: String
  • servicenow_server:
    • description: URL to connect to ServiceNow.
    • type: String
  • servicenow_action:
    • description: Action to perform on ServiceNow. Needs to be open_change or close_change.
    • type: String
  • rundeck_server:
    • description: URL to connecto to Rundeck.
    • type: String
  • rundeck_token:
    • description: Path to Rundeck Key Storage to access Rundeck API token.
    • type: String

Example

ServiceNow Change form

To send data to ServiceNow, the options on the form must be in the following format: sn_<field_name>. If you create an Rundeck option sn_description, the following environment variable will be generated: RD_OPTION_SN_DESCRIPTION.

When the job runs, the script plugin will send all data with the environment variables prefix: RD_OPTION_SN_.

Example

Create a Standard Change using a template

To create a Standard Change, you need to create the following option in Rundeck job: chg_template_id and pass the template sys_id. This option will produce the environment variable RD_OPTION_CHG_TEMPLATE_ID that will be used by the Plugin to create a Change.