OBLYTECH Logo
OBLYTECH Logo

Pre and Post Provisioning Operations for Cloud Catalog Items

Pre-provisioning and post-provisioning operations run tasks before a catalog item is provisioned and after provisioning finishes. You add them from the item’s own tabs in the Cloud Admin Portal: choose a step type (script, CAPI call, resource operation or subflow), set the run order, and map each value the step needs.

What pre- and post-provisioning operations do

A pre-provisioning operation fires when a provisioning request is submitted, so it suits a notification to the requester or a script that prepares something before the build. A post-provisioning operation fires once the new resources exist, which is where day-one configuration usually happens: running a script on a new virtual machine, recording tags, or emailing the requester an address they need. Both are configured on the catalog item’s own tabs in the Cloud Admin Portal, so the settings belong to that item.

Prerequisites for a template-based catalog item

For the platform setup behind these prerequisites, see setting up cloud provisioning for AWS, Azure and VMware.

Requirement Why it matters
Cloud service designer role (sn_cmp.cloud_service_designer) Needed to open catalog items and add operations
A template-based catalog item Both operation types can only be added to catalog items based on templates
An active subflow in the instance The Flow field lists the active subflows in the instance
Credentials and profiles created ahead of time A VMware post-provision step refers to a credential by its ID

Adding a pre-provisioning operation

  1. In the Cloud Admin Portal, go to Design, then Cloud Catalog Items, and open the item.
  2. Select the Pre Provisioning Operation tab and choose New.
  3. Pick a Step Type. The form then reveals the fields for that type.
  4. Enter an Order value and tick Enabled.
  5. Submit. Open Manage Attributes, select PreProvision, map each attribute or generate a variable for it, and choose Apply Changes.
Step type Fields to complete Typical use
CAPI Provider, method and version Calling a cloud provider API method directly
InstanceScript Script name Running a named script at submission time
Resource Resource interface and interface operation Invoking an operation a resource block already defines
Flow A subflow picked from the lookup Running a multi-step process built in Flow Designer

Adding a post-provisioning operation

The form matches the pre-provisioning one, with two differences. The tab is named Post Provisioning Operation, and the CAPI group also asks for an interface. Post-provision parameters are created as operation attributes, which you reach through Manage Attributes by selecting the operation.

VMware attribute Mapping expression to set
NodeCredential A credential resolver call that takes the sys_id of a credential you created beforehand
NodeAddress A script call that returns a reachable IP address for the stack item’s sys_id
ScriptExpression A reference to the cloud script by name, through CloudScript.scripts

Create the credential first, because the mapping has nothing to resolve until it exists. Setting Generate Variable to false keeps a value off the request form while still passing it to the operation. For the request form side, see cloud catalog item order forms and visibility defaults.

Setting the run order and enabling steps

Lower Order numbers run first. An InstanceScript step set to 3 runs after a CAPI step set to 2. Leave the field blank and the system assigns values in increments of 20. Leaving gaps is a practical habit, since a step numbered 30 can later sit between steps at 20 and 40. Tick Enabled to have the system invoke a step; a step left unticked is not invoked.

Mapping attributes with expressions

The Mapping column decides where each value comes from, and the notation of the expression shows when the platform reads it.

Form Notation When it is evaluated What it can read
Definitional Curly braces, for example a parameter lookup When the request form is submitted Form and request values, stack item attributes by alias, a random number. No data created during orchestration
Runtime Parentheses, for example a table lookup When the orchestration step runs Table fields, stack items, script results, outputs of an earlier operation

Some expressions mix both forms, and any expression can be nested inside another. To get a private address for a virtual server, a runtime expression passes the server’s sys_id to a script include, which finds the matching network interface. The expression then reads the private_ip field from that table. Swapping the field for public_ip returns the public address.

Blueprint steps and resource operation steps can also carry JavaScript conditions, so a step can be skipped when a parameter holds a value you do not want to act on. Policies work at another layer. A policy action can override a value the user submitted, and a short script can build a stack name from a naming convention. For the governance side, see automating cloud governance in ServiceNow.

Building a subflow step that reports back

Four things have to line up.

  1. The subflow needs an input named flowcorrelationid, whose expression calls the correlation ID generator in the CMPFlowStepHandler script. The flow does not work without it.
  2. Each step must tell Cloud Provisioning and Governance whether it succeeded. Create a response action in Flow Designer with four inputs (error, log, output and correlation ID), add a script step that works on them, then save and publish.
  3. Inside the subflow, add the response action after each step, and reuse the flowcorrelationid input at each logical end step.
  4. For a post-provision flow, make CMPTfeReturnAction the final step, confirm control returns to the main order, and send an error from the action when a step is designed to fail.

A subflow can only be tested or published once it contains at least one action. As a known limitation, flows cannot be invoked while you add a resource operation step.

Built-in actions that ship with the catalog

The out-of-the-box actions are Integration Hub subflows built on Flow Designer, so you can read their logic before adjusting their inputs.

Action Where it runs What it does What must be in place
ACC deployment Post-provision on the Basic Linux VM item Installs the agent client collector on the new machine An ACC Listener on a MID Server, with its endpoint and API key entered (both empty by default), and SSH open from the MID Server to the VM
CCG scan Post-provision on simple Windows and Linux deployments Scans with the default out-of-the-box policy set in CCG Remediate any violation and close its task
Tagging Post-provision on all catalog items Writes StackName, Application, CostCenter and BusinessService to CMDB key-value records Empty fields are not saved. Cloud tags are not changed
Retrieve Windows password Windows catalog items Emails the Administrator password to the requester An SSH credential alias from the CSC content pack, a keypath default in the Provision variable set, and the requester’s email. Custom catalogs get it only with open-source Terraform Linux items

For how tags are governed across cloud resources, see tag governance for cloud resources.

Worked example: a post-provision script on a virtual machine

This example needs an OS resource profile mapped to an image template, with basic authentication credentials on the image, and a compute resource profile mapped to a hardware type. The person doing it needs the cloud admin role.

  1. Create a cloud script template, then a cloud script that refers to it.
  2. Open the virtual server resource block and set the switch to Draft.
  3. On the Operations tab, choose Virtual Server Interface and confirm that Block Until Ready and Execute Script are present.
  4. On the Steps tab, clear the Script check box for each script step and map it to the cloud script’s name, not the template’s name.
  5. Publish the resource block, place it in a blueprint, and publish that blueprint to a catalog item.
  6. Launch a stack with the OS and compute profiles.

The Stack Status page then runs CreateNode, BlockUntilReady and ExecuteShellScript in turn. If the script does not run, check step 4 first, since the mapping must name the cloud script itself, not the template it was built from.

How this differs from life-cycle operations

Pre- and post-provisioning operations belong to the build. Life-cycle operations, which the platform also calls day-2 operations, run later on a stack that already exists, such as Start, Stop, Deprovision and ExecuteScript. Each request creates a change request that is approved automatically or by a named approver. For the wider set of pages in this area, see the cloud provisioning and governance section.

Frequently asked questions

Can I add a pre-provisioning step to any catalog item? No. Pre-provisioning and post-provisioning operations can only be added to catalog items based on templates, so check the item’s basis first.

What happens if I leave the order blank? The system assigns values in increments of 20, so the sequence still runs from the lowest number upward. Enter your own numbers when the order matters.

Why does my post-provision script not run? Check three things in order. The mapping must name the cloud script rather than the template. The resource block must be published. The blueprint containing it must be published to the catalog item.

Does a subflow step need a response action? Yes, if you want the order to show each step’s outcome. The response action is how the platform learns whether a step succeeded.

Do cloud users see the values I map? Not unless you want them to. Setting Generate Variable to false keeps a value off the request form.