Automating patch deployments in ServiceNow

Overview of automated patching

Use the ServiceNow Flow Designer to create an automated ServiceNow flow that integrates with the Tanium Patch module to deploy patches to endpoints. An automated flow orchestrates all the deployment actions based on the trigger that you specify, such as a recurring date. You can include any patching actions that you want to automate, such as creating change requests and patch requests. Automation eliminates manual tasks beyond the initial flow configuration, and thereby improves productivity in your organization, reduces the chance of human errors, and improves compliance by reducing the time to patch.

The following figure shows an example flow for automatically deploying patches to Windows endpoints on Patch Tuesday, which is the second Tuesday of every month when Microsoft releases its software patches. This example is useful for understanding the triggers and actions that are common to many automated patch flows.

Figure 1. Flow for Windows Patch Tuesday
Flow for Windows Patch Tuesday

The sections in this topic describe the components of the preceding example flow. After you create or edit the flow, be sure to Save, test, and activate the flow. The flow then runs automatically every Patch Tuesday.

Tanium Patch Management for IT Operations provides several of the components in the example flow as predefined actions that you can reuse for your own custom flows, as described in Predefined actions for patch management. The processes and policies of your organization determine the specific triggers and actions that you configure for patch flows.

Note: The following sections assume familiarity with the ServiceNow Flow Designer. For more information, see the Flow Designer documenation.
Note: Test each action before adding it to a flow, as described in Test an action.

Predefined actions for patch management

Tanium provides the following actions that you can use to create patch management flows.

Table 1. Predefined actions for patch management

Action

Description

Create Tanium Patch Request

Creates an empty record in the Tanium Patch Request table

To populate the record with endpoints and patches, use other actions, such as Add endpoints to Patch Request from Change and Add Patches by Filter to Patch Request. For an example of how to use this action in a flow, see Create a Tanium Patch Request.

Add endpoints to Patch Request from Change

Adds endpoints that you specify in a change request to a patch request

In a flow for deploying patches, creating a change request is a prerequisite for creating the patch request. On a change request record, the Affected CIs tab shows the targeted endpoints. For an example of how to use this action in a flow, see Add endpoints from a change request to a patch request.

Add Endpoints by Filter to Patch Request

Adds all endpoints that match the specified filters to a Tanium patch request

Configure the filters to include only endpoints with the same operating system (OS) as the OS that the patch request specifies. The following example shows a filter that includes only Windows endpoints that are virtual machines (VMs).

Figure 2. Add Endpoints by Filter to Patch Request
Add Endpoints by Filter to Patch Request

Add endpoints missing selected patches

Adds endpoints to a patch request if its patches meet the following conditions:

  • The patches are applicable to the endpoints. For example, if the request specifies Windows patches, this action adds Windows endpoints but not Linux endpoints.

  • The patches are not already installed on the endpoints.

For example, you can use the action to add Windows endpoints that do not have a specific Windows patch installed. The Tanium Patch Status table records the patch installation status for endpoints. For an example of how to use this action in a flow, see Add endpoints missing selected patches.

Add Patches by CVE to Patch Request

Adds patches that are associated with specific common vulnerabilities and exposures (CVE) to a patch request

This action is useful for addressing specific security flaws on endpoints. For an example of how to use this action in a flow, see Add patches by CVE to a patch request.

Add Patches by Filter to Patch Request

Adds all patches that match the specified filters to a Tanium patch request

The Tanium Patch Definition table has a record for each available patch. For an example of how to use this action in a flow, see Add patches by filter to a patch request.

Add Patch Lists by Filter to Patch Request

Adds all patch lists that match the specified filters to a Tanium patch request

The Tanium Patch List table has a record for each available patch list. For an example of how to use this action in a flow, see Add patch lists by filter to a patch request.

Check if Patch Request is ready

Checks whether all the required fields in a patch request are populated, in which case the request is ready to proceed with deployment

Use this action to verify that a deployment can succeed or to generate useful error messages if the request is not ready. Error messages can help you troubleshoot the deployment. For an example of how to use this action in a flow, see Check if the patch request is ready.

Get Confidence Scores for a Tanium Patch Request

Outputs a formatted string that contains the confidence score status for patches associated with a Tanium Patch Request

Use this action for informational purposes, such as adding the confidence score information to a Change Request for review. You can also open the action in Action Designer and complete a Test run. Then, copy the output string to a Patch Request or Change Request description.

Trigger Patch Request Deployment

Runs a patch request, which creates a deployment in the Tanium Patch module

For an example of how to use this action in a flow, see Trigger patch request deployment.

Important: Always run the action Check if Patch Request is ready before running Trigger Patch Request Deployment.

View, edit, or create flows

Perform the following steps to view, edit, or create a flow. Each new or existing flow opens in a separate tab in the ServiceNow Flow Designer. Switching between tabs can help you create a new flow by basing it on the components of an existing flow.

  1. Sign in to your ServiceNow instance.

  2. In the Main menu, click All, enter flow designer in the filter Filter field, and click Flow Designer.

  3. Click Flows to view all the existing flows. To view all the components of a specific flow, click its Name to open the flow in a new tab. If you edit any component, click Done in the corresponding section. After you finish making all your edits, click Save in the flow toolbar.

  4. Create a flow by selecting New > Flow. For the remaining steps, see Building flows.

Figure 3. Flow Designer
Flow Designer

Configure the trigger

Configure a trigger that starts the flow actions based on a recurring event. In this example, the event is Patch Tuesday, which can be on any day of the month from the eighth to the fourteenth because it is always the second Tuesday. Therefore, set the Trigger to Monthly and set the Day of Month to the fifteenth to ensure the patch flow always starts after the second Tuesday. In this example, the Time for the flow to start is 12:10 AM.

Figure 4. Schedule based trigger
Schedule-based trigger

Set flow variables

Set the variables that provide input for other actions in the flow. In this example, you add the following variables for the action Create a change request:

  • Requestor: Select the user role that is responsible for creating change requests. In this example, the role is System Administrator because patching can have a significant impact on your network and therefore warrants a highly privileged role.

  • Assignment Group: Select the team that is responsible for reviewing and approving change requests that initiate patch requests. In the example flow, the team is Patch request approval group.

Figure 5. Set flow variables
Set flow variables

Create a change request

A change request is required to initiate patch deployment. Therefore, this action creates a record (State equals New) in the Change Request table and populates the record fields with the values that you specify. This example uses the following values:

  • Short description helps other users understand the purpose of the change request.

  • Requested by and Assignment group are set to the variables that you specified in Set flow variables.

  • Planned start/end date are set to the trigger that you configured in Configure the trigger.

  • Category is set to System Software because the requested change is for an OS patch.

Figure 6. Create change request record
Create change request record

Create a patch request and add patches and endpoints

Creating a patch request from a change request involves multiple actions for adding the patches and endpoints to the patch request. The sequence of actions might be useful in other flows, such as manual patch requests. Therefore, instead of reconfiguring each action for each flow that uses the same action sequence, you can create a reusable subflow that contains the entire sequence. This example uses the Create Patch Request & Add Patches/Endpoints subflow with the following settings:

Table 2. Patching subflow settings

Setting

Description

wait_for_completion

Select this setting to specify that the parent flow Monthly Patch Tuesday Windows Patching does not continue until all the actions in the subflow finish.

Patch Request [Name | Description]

Enter a name to identify the patch request and a description to help other users understand its purpose. In this example, both settings have the value Monthly Patch Tuesday Windows Patching: <flow start time> , where the trigger defines the flow start time (in UTC format), as described in Configure the trigger.

Operating System Type

Specify the OS of the endpoints you plan to patch. This example flow is for Windows endpoints.

Change Request

Select the change request that you configured in Create a change request.

Add Endpoints from Change

Select this setting to run the action Add endpoints from a change request to a patch request.

CVE IDs

Enter CVE identifiers to run the action Add patches by CVE to a patch request.

Include Superseded in CVE Patches

Select this setting to include patches for all CVEs even if the patches have been replaced by more recent patches.

Additional Patches Filter

Add additional filters for selecting patches to include in the patch request to run the action Add patches by filter to a patch request.

Tip: You can add confidence score conditions, such as Confidence Score Status is High.

Patch Lists Filter

Add additional filters for selecting patch lists to include in the patch request to run the action Add patch lists by filter to a patch request.

Figure 7. Create Patch Request & Add Patches/Endpoints subflow
Subflow to create patch request

The preceding subflow runs the following actions in the following sequence:

  1. Create a Tanium Patch Request.
  2. Add endpoints from a change request to a patch request.
  3. Add patches by CVE to a patch request.
  4. Add patches by filter to a patch request.
  5. Add patch lists by filter to a patch request.
  6. Assign flow outputs.

Create a Tanium Patch Request

This action creates an empty record in the Tanium Patch Request table. The subsequent actions in the Create Patch Request & Add Patches/Endpoints subflow all have a Tanium Patch Request setting that specifies this patch request and they populate the record with endpoints and patches.

Figure 8. Create Tanium patch request
Create Tanium patch request

The settings in this request are similar to the Patching subflow settings and includes the following additional options:

Table 3. Tanium Patch Request additional settings

Setting

Description

Restart After Install

Select whether to restart the endpoint after a successful patch deployment.

Restart Client Notification [Tanium End User Notification]

If you enabled restarts, you can optionally add an end-user notification to warn the user about the restart. Select the deployment template that includes the notification message to display to the user. This setting is available only if you enabled and imported Tanium Patch deployment templates. For more information, see Import patch deployment templates.

Note: Do not update the ServiceNow Tanium End User Notification records that were created during the import process. Any edits to those records are overwritten during the next import. To add more notification message options, create more deployment templates in Tanium and then run the import again.

Add endpoints from a change request to a patch request

If you selected the Add Endpoints from Change option in the Create Patch Request & Add Patches/Endpoints subflow, then the action Add Endpoints to Patch Request from Change copies the endpoints from a change request to the patch request. The Change Request identifies the request created in Create a change request.

Figure 9. Add endpoints from change request to patch request
Add endpoints from change request to patch request

Add patches by CVE to a patch request

If you specified CVE IDs in the Create Patch Request & Add Patches/Endpoints subflow, then the action Add Patches by CVE to Patch Request adds patches that are associated with specific CVEs to the patch request. The Include Superseded setting indicates whether you selected the Include Superseded in CVE Patches option in the subflow.

Figure 10. Add endpoints from change request to patch request
Add endpoints from change request to patch request

Add patches by filter to a patch request

If you configured an Additional Patches Filter in the Create Patch Request & Add Patches/Endpoints subflow, then the action Add Patches by Filter to Patch Request adds a list of patches to the patch request based on the filter.

Figure 11. Add endpoints from change request to patch request
Add endpoints from change request to patch request

Add patch lists by filter to a patch request

If you configured a Patch Lists Filter in the Create Patch Request & Add Patches/Endpoints subflow, then the action Add Patch Lists by Filter to Patch Request adds a list of patch lists to the patch request based on the filter.

Figure 12. Add Patch Lists by Filter to Patch Request
Add Patch Lists by Filter to Patch Request

Assign flow outputs

Assign Flow Outputs assigns the outputs of the Create Patch Request & Add Patches/Endpoints subflow to the Tanium patch request, thereby populating the empty record in the Tanium Patch Request table.

Figure 13. Assign flow outputs
Assign flow outputs

Add endpoints missing selected patches

This action adds endpoints to a patch request if the patches in that request are applicable to the endpoints and are not already installed. In the example flow, this action is intended to add endpoints that the action Add Endpoints from Change request did not add to the patch request.

Figure 14. Add endpoints missing selected patches
Add endpoints missing selected patches

Create records of affected CIs

This action creates a record in the CIs Affected table for each endpoint that the action Add endpoints missing selected patches added to the patch request. The table enables you to track which endpoints are targeted for a patch deployment.

Figure 15. Create records of affected CIs
Create records of affected CIs

Update the change request state to assess

This action updates the change request State to Assess, which initiates the process that your organization uses for assessing and approving change requests. In this example, the Patch request approval group that you selected in Set flow variables assesses the change request and sets its state to scheduled (approved) or cancelled (rejected).

Update change request record for assessment

Wait for change request to be scheduled or cancelled

The action pauses the flow until the users who assess change requests (the Patch request approval group in this example) set the change request State to:

Figure 16. Wait condition for scheduled change request
Wait condition for scheduled change request

Update the patch request state to cancelled

If the users who assess the change request decide to cancel the request, this action updates the State of the associated patch request to Cancelled and then ends the flow. The error handler flow then starts if you configured it. For more information, see Add actions for errors.

Figure 17. Update patch request record for change request cancellation
Update patch request record for change request cancellation

Check if the patch request is ready

This action checks whether all the required fields in the patch request are populated, in which case the request is ready for deployment. If the action determines that the patch request is not ready, ServiceNow shows the corresponding error message and the error handler flow starts if you configured it. For more information, see Add actions for errors.

Important: When you create a patching flow that is customized for your organization, always include this action before the action Trigger patch request deployment.
Figure 18. Check readiness of patch request
Check readiness of patch request

Trigger patch request deployment

This action runs the patch request, which creates a deployment in the Tanium Patch module. To review the deployment details, see Reviewing deployments.

The next action in the flow depends on whether the deployment encountered issues:

Figure 19. Trigger patch request deployment
Trigger patch request deployment

Update the change request if deployment issues occurred

If the patch request failed to run or the deployment ID from the Patch module is missing, this action adds a note about the issue to the change request and then ends the flow. The error handler flow then starts if you configured it. For more information, see Add actions for errors.

Figure 20. Update change request for deployment issue
Update change request for deployment issue

Update the change request with the deployment ID

This action adds the patch deployment ID to the change request to conclude the flow.

Figure 21. Update change request record with deployment ID
Update change request record with deployment ID

Add actions for errors

Optionally enable the Error Handler and add subflows, actions, and flow logic if you want to run a sequence of actions to identify and correct issues that occur during the patch flow. For example, you might want to log an error message and notify certain users by email. For more information, see Flow error handler.

Figure 22. Error Handler actions
Error Handler actions

Save, test, and activate the flow

Perform the following tasks after you configure all the triggers and actions for your patch flow:

  1. Click Save to save the flow configuration.

  2. Click Test to simulate a trigger and run the flow. Edit the flow if the test execution details show unexpected results. For more information, see Test a flow and Flow execution details. To troubleshoot patch request errors, see Troubleshooting patch requests in ServiceNow.

  3. Click Activate when the flow is ready to use.