Orchestration SSH Activities

From ServiceNow Wiki
Jump to: navigation, search
Discovery
Orchestration
Related Topics
Get the Book
Knowledge.gif Discovery
Knowledge.gif Data Collected by Discovery
Knowledge.gif Orchestration for VMWare


1 Overview

SSH activities allow workflows to perform operations on Linux and Unix computers. Your ServiceNow instance must have access to a MID Server configured to use SSH to run these activities.

2 File Copy

The File Copy activity copies a file on a Linux or Unix computer. The source file and destination files can be absolute paths, or relative paths from the Directory parameter. If both paths are absolute, the Directory parameter doesn’t matter. If the destination file exists, it is overwritten.

2.1 Input Variables

Field Description
Hostname Hostname or IP address of destination server for SSH activity.
Directory Name of the working directory.
Source File The name of the file to copy.
Destination File The name of the destination file.

3 File Read

The File Read activity reads a file on a Linux or Unix computer. The source file can be an absolute or relative path from the Directory. If an absolute path is used, then no value is required in the Directory field.

3.1 Input Variables

Field Description
Hostname Hostname or IP address of destination server for SSH activity.
Directory Name of the working directory.
Source File The name of the file to read.
Scratchpad Variable The variable name to which the file contents are written. For example, if the variable is called file_content, it can later be accessed as workflow.scratchpad.file_content in a subsequent script in the execution path.

4 File Replace String

The File Replace String activity finds and replaces a string in a file on a Linux or Unix computer.

4.1 Input Variables

Field Description
Hostname Hostname or IP address of destination server for SSH activity.
Directory Name of the working directory.
File Name of the file in which the string is to be replaced.
Find Pattern A regular expression of the text to replace
Replace String The replacement string for the text found by the expression in the Find Pattern field.
Options Select whether to replace only the first occurrence of the string or all occurrences.

5 File Write

The File Write activity writes a file on a Linux or Unix computer. The source file can be an absolute or relative path from the Directory. If an absolute path is used, then no value is required in the Directory field.

5.1 Input Variables

Field Description
Hostname Hostname or IP address of destination server for SSH activity.
Directory Name of the working directory.
File Name of the file to be written.
Behavior Select one of the following behaviors:
  • Overwrite: Creates the file if it doesn't exist and overwrites the file if it does exist.
  • Append: Creates the file if it doesn't exist and appends the new content to an existing file.
  • Create only: Creates the file if it doesn't exist and fails if the file does exist.
Contents What to write or append (depending on the behavior) to the file

6 Files Compare

The Files Compare activity compares two files on a Linux or Unix computer. The source file can be an absolute or relative path from the Directory. If an absolute path is used, then no value is required in the Directory field.

6.1 Input Variables

Field Description
Hostname Hostname or IP address of the destination server for SSH activity.
Directory Name of the working directory.
Old File Name of the first file to compare.
New File Name of the second file to compare.
Scratchpad Variable Create a variable to hold any differences found during the comparison. If the parameter is called compare, for example, it can be referenced later as workflow.scratchpad.compare.

7 Reset Linux User Password

The Reset Linux User Password activity resets the password for a given user on a Linux computer. This activity requires that the user executing the command be able to run the chpasswd command and, if expiring the password immediately, to run chage with sudo privileges.

7.1 Input Variables

Field Description
Hostname IP address of the target Linux machine.
User Name of the user whose password is being reset.
Password New password set for this user. The password is a workflow variable that is encrypted either as a password2 field or by calling the encryption method of a Packages.com.glide.util.Encrypter object.
Force user to change password on login Select the checkbox to make this password temporary and to force the named user to change the password when he logs in.

8 Run Command

The Run Command activity runs a command (including shell scripts) on a Linux or Unix computer.

8.1 Input Variables

Field Description
Long running Select this check box to disable the SSH connection timeout if you think the command will take longer to run than the default 60 seconds. Orchestration periodically checks the running process to determine its status until it is finished.
Hostname Hostname or IP address of destination server for SSH activity.
Directory Name of the working directory.
Command The command to run from this activity.
Sudo Select this check box to use sudo to run the command on the host machine.
Sensor script The script to run using the results of the probe. The output from the probe is contained in a variable called output. Any error from the probe is contained in a variable called error.

9 Run SCP

The Run SCP activity uses the Secure Copy (SCP) protocol to copy a file from one computer to another, including the directory in which the file resides.

9.1 Input Variables

Field Description
From Host Hostname or IP address of the computer to copy the file from.
From File The file to copy. Enter an absolute path to the file.
To Host Hostname or IP address of the machine to copy the file to.
To File Path to the target file. If this is a relative path, then it is relative to the home directory for the logged in user. The specified directory must already exist on the target computer.
Copy directory If the selected From File is a directory, select this check box to copy the directory and all files in the directory.

10 SCP Relay

The SCP Relay activity copies a file from one host to another. This activity does not store the copied file on the MID server. This activity is more efficient than the Run SCP activity. Use this activity instead of Run SCP whenever possible.

10.1 Input Variables

Field Description
From host (or IP) Hostname or IP address of the machine to copy the file from.
From file (with path) The file to copy. Enter an absolute path to the file.
To host (or IP) Hostname or IP address of the machine to copy the file to.
To file (with path) Path to the target file. If this is a relative path, then it is relative to the home directory for the logged in user.
Debug Enables debug logging when selected.
Debug SSH Enables J2SSH debug logging when selected.
Was this article helpful?
Yes, I found what I needed
No, I need more assistance