# ServiceNow CMDB policy

> Create, update, and delete ServiceNow CMDB policies in OneFuse

---

Site [llms.txt](/llms.txt)

---

## Setup overview

To use the ServiceNow CMDB module:

1. Create a ServiceNow CMDB [Module Credential](/docs/onefuse/configure/module-credentials/).
2. Create a [ServiceNow Endpoint](/docs/onefuse/configure/module-endpoints/#servicenow). If applicable, configure [ServiceNow proxy support](/docs/onefuse/configure/module-endpoints/#proxy-support).
3. [Create a ServiceNow CMDB Policy](#create-a-servicenow-cmdb-policy) and define [ServiceNow IRE Templates](#example-ire-templates).
4. [Provision with ServiceNow CMDB](#provision-with-servicenow-cmdb).

The user setting up the ServiceNow Policy must have the credentials to log in to the ServiceNow instance.

## Create a ServiceNow CMDB policy

<div class="alert alert-info" role="alert"><div class="h4 alert-heading" role="heading">Prerequisite</div>


Create a [Module Credential](/docs/onefuse/configure/module-credentials/) and [Endpoint](/docs/onefuse/configure/module-endpoints/) for the selected technology.
</div>


1. In OneFuse, select **ServiceNow CMDB** from **Home**. Or, select **Modules** > **ServiceNow CMDB** from the left navigation menu.
2. Select **Create**, and fill out the [ServiceNow CMDB Policy form](#servicenow-cmdb-policy-form) under the **General** tab.
3. Select **Next**, and enter a provisioning template for the ServiceNow Identification and Reconciliation Engine (IRE).

## Update a ServiceNow CMDB policy

Update the ServiceNow CMDB Policy to change the name, description, Endpoint, and IRE templates.

1. Access the ServiceNow CMDB policies dashboard.
2. Find the Policy to update and select the edit button.
3. Edit the information on the ServiceNow CMDB Policy form or IRE templates.
4. Select **Update**.

## Delete a ServiceNow CMDB policy

A ServiceNow CMDB Policy cannot be deleted if it is associated to an existing ServiceNow Deployment. Remove or unregister any deployments attached to this policy before deleting.

1. Access the ServiceNow CMDB Policies dashboard.
2. Find the policy and select the delete button.
3. Select **Delete** to confirm.

## ServiceNow CMDB policy form

| Field | Description |
| --- | --- |
| **Policy Name - Required** | Enter a name for the ServiceNow CMDB Policy. |
| **Description - Optional** | Optional description for the ServiceNow CMDB Policy. |
| **ServiceNow Endpoint - Required** | Select the ServiceNow Endpoint for this policy. Begin typing to filter. |
| **Provision Template - Required** | Enter an IRE template or pre-populate a default template to Provision. |
| **Update Template - Required** | Enter an IRE template or pre-populate a default template to Update. |
| **Deprovision Template - Required** | Enter an IRE template or pre-populate a default template to Deprovision. |

## Provisioning IRE template

This template passes values to the API or upstream providers to **create** specified Configuration Items in ServiceNow.

1. **Create** a new ServiceNow CMDB policy or select the edit icon on an existing policy.
2. Select the second tab, **Provision**.
3. Enter a provision template for the ServiceNow Identification and Reconciliation Engine (IRE). See example IRE templates below.

## Update IRE template

This template passes values to the API or upstream providers to **update** specified Configuration Items in ServiceNow.

1. Go to the ServiceNow Policy to edit and select the edit icon.
2. Select the **Update** tab.
3. Define an Update template for the ServiceNow Identification and Reconciliation Engine (IRE). See example IRE templates below.
4. Select **Update** at the bottom to save the changes, or **Next** to continue creation in the Deprovision tab.

## Deprovisioning IRE template

This template passes values to the API or upstream providers to **deprovision** specified Configuration Items in ServiceNow.

1. Go to the ServiceNow Policy to edit and select the edit icon.
2. Select the **Deprovision** tab.
3. Define a Deprovision template for the ServiceNow Identification and Reconciliation Engine (IRE). See example IRE templates below.
4. Select **Create/Update** to save the changes.

## Example IRE templates

The following templates are a good place to start to pre-populate the OneFuse SNOW IRE templates (for provision, update, and deprovision).

In the examples below, notice `discovery_source`. This is a list of "system identifiers" in ServiceNow, which can populate the CMDB. We recommend adding an entry to the Discovery Source list with "onefuse", "OneFuse", or something distinguishable. In the example below, the value of "Manual Entry" is inserted as this is a known discovery source in ServiceNow Development instances.

<div class="alert alert-warning" role="alert">


The value is required and needs to be an actual ServiceNow Discovery Source. The value can be templated if passed during execution. In the examples below, it is hardcoded to "Manual Entry".
</div>


### Cloud agnostic machines

The following templates have minimal dependencies for Cloud Agnostic Machines. The templates support arrays of objects to deploy multiple items.

<div class="alert alert-info" role="alert">


A CI will be created/updated in **Virtual Machine Instances** and in corresponding Servers: **Linux** or **Windows**.

`serial_number` or `name` is required in the templates below.
</div>


#### Linux VM: provision {#linux-provision-cloud-agnostic}

```jinja2
{
  "items": [
    {
      "className": "cmdb_ci_linux_server",
      "values": {
        "discovery_source": "Manual Entry",
        "os": "GNU/Linux",
        "name": "{{ OneFuse_VmNic0.hostname }}",
        "dns_domain": "{{ OneFuse_VmNic0.dnsSuffix }}",
        "host_name": "{{ OneFuse_VmNic0.hostname }}",
        "fqdn": "{{ OneFuse_VmNic0.fqdn }}",
        "ip_address": "{{ OneFuse_VmNic0.ipAddress }}",
        "serial_number": "machine-{{ OneFuse_VmHardware.platformUuid }}",
        "cpu_count": "{{ OneFuse_VmHardware.cpuCount }}",
        "disk_space": "{{ OneFuse_VmHardware.totalStorageGB }}",
        "ram": "{{ OneFuse_VmHardware.memoryMB }}",
        "virtual": "true",
        "hardware_status": "installed",
        "state": "{{ OneFuse_VmHardware.powerState }}"
      }
    }
  ]
}
```

#### Linux VM: update {#linux-update-cloud-agnostic}

```jinja2
{
  "items": [
    {
      "className": "cmdb_ci_linux_server",
      "values": {
        "discovery_source": "Manual Entry",
        "os": "GNU/Linux",
        "name": "{{ OneFuse_VmNic0.hostname }}",
        "dns_domain": "{{ OneFuse_VmNic0.dnsSuffix }}",
        "host_name": "{{ OneFuse_VmNic0.hostname }}",
        "fqdn": "{{ OneFuse_VmNic0.fqdn }}",
        "ip_address": "{{ OneFuse_VmNic0.ipAddress }}",
        "serial_number": "vmware-{{ OneFuse_VmHardware.platformUuid }}",
        "cpu_count": "{{ OneFuse_VmHardware.cpuCount }}",
        "disk_space": "{{ OneFuse_VmHardware.totalStorageGB }}",
        "ram": "{{ OneFuse_VmHardware.memoryMB }}",
        "virtual": "true",
        "hardware_status": "installed",
        "state": "{{ OneFuse_VmHardware.powerState }}"
      }
    }
  ]
}
```

#### Linux VM: deprovision {#linux-deprovision-cloud-agnostic}

```jinja2
{
  "items": [
    {
      "className": "cmdb_ci_linux_server",
      "values": {
        "name": "{{ OneFuse_VmNic0.hostname }}",
        "hardware_status": "retired",
        "serial_number": "machine-{{ OneFuse_VmHardware.platformUuid }}",
        "state": "Terminated"
      }
    }
  ]
}
```

#### Windows VM: provision {#windows-provision-cloud-agnostic}

```jinja2
{
  "items": [
    {
      "className": "cmdb_ci_win_server",
      "values": {
        "discovery_source": "Manual Entry",
        "os": "Windows",
        "name": "{{ OneFuse_VmNic0.hostname }}",
        "dns_domain": "{{ OneFuse_VmNic0.dnsSuffix }}",
        "host_name": "{{ OneFuse_VmNic0.hostname }}",
        "fqdn": "{{ OneFuse_VmNic0.fqdn }}",
        "ip_address": "{{ OneFuse_VmNic0.ipAddress }}",
        "serial_number": "machine-{{ OneFuse_VmHardware.platformUuid }}",
        "cpu_count": "{{ OneFuse_VmHardware.cpuCount }}",
        "disk_space": "{{ OneFuse_VmHardware.totalStorageGB }}",
        "ram": "{{ OneFuse_VmHardware.memoryMB }}",
        "virtual": "true",
        "hardware_status": "installed",
        "state": "{{ OneFuse_VmHardware.powerState }}"
      }
    }
  ]
}
```

#### Windows VM: update {#windows-update-cloud-agnostic}

```jinja2
{
  "items": [
    {
      "className": "cmdb_ci_win_server",
      "values": {
        "discovery_source": "Manual Entry",
        "os": "Windows",
        "name": "{{ OneFuse_VmNic0.hostname }}",
        "dns_domain": "{{ OneFuse_VmNic0.dnsSuffix }}",
        "host_name": "{{ OneFuse_VmNic0.hostname }}",
        "fqdn": "{{ OneFuse_VmNic0.fqdn }}",
        "ip_address": "{{ OneFuse_VmNic0.ipAddress }}",
        "serial_number": "vmware-{{ OneFuse_VmHardware.platformUuid }}",
        "cpu_count": "{{ OneFuse_VmHardware.cpuCount }}",
        "disk_space": "{{ OneFuse_VmHardware.totalStorageGB }}",
        "ram": "{{ OneFuse_VmHardware.memoryMB }}",
        "virtual": "true",
        "hardware_status": "installed",
        "state": "{{ OneFuse_VmHardware.powerState }}"
      }
    }
  ]
}
```

#### Windows VM: deprovision {#windows-deprovision-cloud-agnostic}

```jinja2
{
  "items": [
    {
      "className": "cmdb_ci_win_server",
      "values": {
        "name": "{{ OneFuse_VmNic0.hostname }}",
        "hardware_status": "retired",
        "serial_number": "machine-{{ OneFuse_VmHardware.platformUuid }}",
        "state": "Terminated"
      }
    }
  ]
}
```

### vRealize Automation 7/8 VMs

The following templates have minimal dependencies for vRealize Automation 7/8 VMs, including Aria Automation Cloud. The templates support arrays of objects to deploy multiple items.

**Prerequisites:**

- vRealize Orchestrator Package 1.4.0 Build: 11362313 or newer for [vRealize Automation 7.6](/docs/onefuse/consume/vmware-aria-automation/vrealize-automation-76/installation-and-setup/) or [Aria Automation 8x/Cloud](/docs/onefuse/consume/vmware-aria-automation/aria-automation-8x/installation-and-setup/)
- [ServiceNow VMware Discovery](https://docs.servicenow.com/bundle/rome-it-operations-management/page/product/discovery/concept/c_DiscoverVMwareInfrastructure.html)
  - The templates below have minimal dependencies required. To resolve a `Partial` state for the CI in Class: `cmdb_ci_vm_instance`, perform a ServiceNow Discovery for VMware vCenter.

<div class="alert alert-info" role="alert">


A CI will be created/updated in **Virtual Machine Instances** and in corresponding Servers: **Linux** or **Windows**

- Class: `cmdb_ci_vm_instance`: `object_id` is required for this class
- Classes: `cmdb_ci_linux_server` and `cmdb_ci_win_server`: `serial_number` or `name` is required for these classes

</div>


#### Linux VM: provision {#linux-provision-vra}

```jinja2
{
  "items": [
    {
      "className": "cmdb_ci_vmware_instance",
      "lookup": [],
      "values": {
        "discovery_source": "Manual Entry",
        "name": "{{ OneFuse_VmNic0.hostname }}",
        "state": "{{ OneFuse_VmHardware.powerState }}",
        "cpus": "{{ OneFuse_VmHardware.cpuCount }}",
        "memory": "{{ OneFuse_VmHardware.memoryMB }}",
        "disks_size": "{{ OneFuse_VmHardware.totalStorageGB }}",
        "dns_domain": "{{ OneFuse_VmNic0.dnsSuffix }}",
        "fqdn": "{{ OneFuse_VmNic0.fqdn }}",
        "ip_address": "{{ OneFuse_VmNic0.ipAddress }}",
        "vm_instance_uuid": "{{ instanceUUID }}",
        "u_vcenter_folder": "{{ folderName }}",
        "object_id": "{{ vcVmMoRefId | required("vcVmMoRefId is required") }}"
      }
    },
    {
      "className": "cmdb_ci_linux_server",
      "lookup": [],
      "values": {
        "discovery_source": "Manual Entry",
        "os": "GNU/Linux",
        "name": "{{ OneFuse_VmNic0.hostname }}",
        "dns_domain": "{{ OneFuse_VmNic0.dnsSuffix }}",
        "host_name": "{{ OneFuse_VmNic0.hostname }}",
        "fqdn": "{{ OneFuse_VmNic0.fqdn }}",
        "ip_address": "{{ OneFuse_VmNic0.ipAddress }}",
        "cpu_count": "{{ OneFuse_VmHardware.cpuCount }}",
        "disk_space": "{{ OneFuse_VmHardware.totalStorageGB }}",
        "ram": "{{ OneFuse_VmHardware.memoryMB }}",
        "serial_number": "vmware-{{ instanceUUID }}",
        "virtual": "true",
        "hardware_status": "installed",
        "state": "{{ OneFuse_VmHardware.powerState }}"
      }
    }
  ],
  "relations": [
    {
      "type": "Runs on::Runs",
      "parent": 1,
      "child": 0
    }
  ]
}
```

#### Linux VM: update {#linux-update-vra}

```jinja2
{
  "items": [
    {
      "className": "cmdb_ci_vmware_instance",
      "lookup": [],
      "values": {
        "discovery_source": "Manual Entry",
        "name": "{{ OneFuse_VmNic0.hostname }}",
        "state": "{{ OneFuse_VmHardware.powerState }}",
        "cpus": "{{ OneFuse_VmHardware.cpuCount }}",
        "memory": "{{ OneFuse_VmHardware.memoryMB }}",
        "disks_size": "{{ OneFuse_VmHardware.totalStorageGB }}",
        "dns_domain": "{{ OneFuse_VmNic0.dnsSuffix }}",
        "fqdn": "{{ OneFuse_VmNic0.fqdn }}",
        "ip_address": "{{ OneFuse_VmNic0.ipAddress }}",
        "vm_instance_uuid": "{{ instanceUUID }}",
        "u_vcenter_folder": "{{ folderName }}",
        "object_id": "{{ vcVmMoRefId | required("vcVmMoRefId is required") }}"
      }
    },
    {
      "className": "cmdb_ci_linux_server",
      "lookup": [],
      "values": {
        "discovery_source": "Manual Entry",
        "os": "GNU/Linux",
        "name": "{{ OneFuse_VmNic0.hostname }}",
        "dns_domain": "{{ OneFuse_VmNic0.dnsSuffix }}",
        "host_name": "{{ OneFuse_VmNic0.hostname }}",
        "fqdn": "{{ OneFuse_VmNic0.fqdn }}",
        "ip_address": "{{ OneFuse_VmNic0.ipAddress }}",
        "cpu_count": "{{ OneFuse_VmHardware.cpuCount }}",
        "disk_space": "{{ OneFuse_VmHardware.totalStorageGB }}",
        "ram": "{{ OneFuse_VmHardware.memoryMB }}",
        "serial_number": "vmware-{{ instanceUUID }}",
        "virtual": "true",
        "hardware_status": "installed",
        "state": "{{ OneFuse_VmHardware.powerState }}"
      }
    }
  ],
  "relations": [
    {
      "type": "Runs on::Runs",
      "parent": 1,
      "child": 0
    }
  ]
}
```

#### Linux VM: deprovision {#linux-deprovision-vra}

```jinja2
{
  "items": [
    {
      "className": "cmdb_ci_vmware_instance",
      "lookup": [],
      "values": {
        "discovery_source": "Manual Entry",
        "object_id": "{{ vcVmMoRefId | required("vcVmMoRefId is required") }}",
        "name": "{{ OneFuse_VmNic0.hostname }}",
        "vm_instance_uuid": "{{ instanceUUID }}",
        "state": "Terminated"
      }
    },
    {
      "className": "cmdb_ci_linux_server",
      "lookup": [],
      "values": {
        "discovery_source": "Manual Entry",
        "name": "{{ OneFuse_VmNic0.hostname }}",
        "serial_number": "vmware-{{ instanceUUID }}",
        "hardware_status": "retired",
        "state": "Terminated"
      }
    }
  ],
  "relations": [
    {
      "type": "Runs on::Runs",
      "parent": 1,
      "child": 0
    }
  ]
}
```

#### Windows VM: provision {#windows-provision-vra}

```jinja2
{
  "items": [
    {
      "className": "cmdb_ci_vmware_instance",
      "lookup": [],
      "values": {
        "discovery_source": "Manual Entry",
        "name": "{{ OneFuse_VmNic0.hostname }}",
        "state": "{{ OneFuse_VmHardware.powerState }}",
        "cpus": "{{ OneFuse_VmHardware.cpuCount }}",
        "memory": "{{ OneFuse_VmHardware.memoryMB }}",
        "disks_size": "{{ OneFuse_VmHardware.totalStorageGB }}",
        "dns_domain": "{{ OneFuse_VmNic0.dnsSuffix }}",
        "fqdn": "{{ OneFuse_VmNic0.fqdn }}",
        "ip_address": "{{ OneFuse_VmNic0.ipAddress }}",
        "vm_instance_uuid": "{{ instanceUUID }}",
        "u_vcenter_folder": "{{ folderName }}",
        "object_id": "{{ vcVmMoRefId | required("vcVmMoRefId is required") }}"
      }
    },
    {
      "className": "cmdb_ci_win_server",
      "lookup": [],
      "values": {
        "discovery_source": "Manual Entry",
        "os": "Windows",
        "name": "{{ OneFuse_VmNic0.hostname }}",
        "dns_domain": "{{ OneFuse_VmNic0.dnsSuffix }}",
        "host_name": "{{ OneFuse_VmNic0.hostname }}",
        "fqdn": "{{ OneFuse_VmNic0.fqdn }}",
        "ip_address": "{{ OneFuse_VmNic0.ipAddress }}",
        "cpu_count": "{{ OneFuse_VmHardware.cpuCount }}",
        "disk_space": "{{ OneFuse_VmHardware.totalStorageGB }}",
        "ram": "{{ OneFuse_VmHardware.memoryMB }}",
        "serial_number": "vmware-{{ instanceUUID }}",
        "virtual": "true",
        "hardware_status": "installed",
        "state": "{{ OneFuse_VmHardware.powerState }}"
      }
    }
  ],
  "relations": [
    {
      "type": "Runs on::Runs",
      "parent": 1,
      "child": 0
    }
  ]
}
```

#### Windows VM: update {#windows-update-vra}

```jinja2
{
  "items": [
    {
      "className": "cmdb_ci_vmware_instance",
      "lookup": [],
      "values": {
        "discovery_source": "Manual Entry",
        "name": "{{ OneFuse_VmNic0.hostname }}",
        "state": "{{ OneFuse_VmHardware.powerState }}",
        "cpus": "{{ OneFuse_VmHardware.cpuCount }}",
        "memory": "{{ OneFuse_VmHardware.memoryMB }}",
        "disks_size": "{{ OneFuse_VmHardware.totalStorageGB }}",
        "dns_domain": "{{ OneFuse_VmNic0.dnsSuffix }}",
        "fqdn": "{{ OneFuse_VmNic0.fqdn }}",
        "ip_address": "{{ OneFuse_VmNic0.ipAddress }}",
        "vm_instance_uuid": "{{ instanceUUID }}",
        "u_vcenter_folder": "{{ folderName }}",
        "object_id": "{{ vcVmMoRefId | required("vcVmMoRefId is required") }}"
      }
    },
    {
      "className": "cmdb_ci_linux_server",
      "lookup": [],
      "values": {
        "discovery_source": "Manual Entry",
        "os": "Windows",
        "name": "{{ OneFuse_VmNic0.hostname }}",
        "dns_domain": "{{ OneFuse_VmNic0.dnsSuffix }}",
        "host_name": "{{ OneFuse_VmNic0.hostname }}",
        "fqdn": "{{ OneFuse_VmNic0.fqdn }}",
        "ip_address": "{{ OneFuse_VmNic0.ipAddress }}",
        "cpu_count": "{{ OneFuse_VmHardware.cpuCount }}",
        "disk_space": "{{ OneFuse_VmHardware.totalStorageGB }}",
        "ram": "{{ OneFuse_VmHardware.memoryMB }}",
        "serial_number": "vmware-{{ instanceUUID }}",
        "virtual": "true",
        "hardware_status": "installed",
        "state": "{{ OneFuse_VmHardware.powerState }}"
      }
    }
  ],
  "relations": [
    {
      "type": "Runs on::Runs",
      "parent": 1,
      "child": 0
    }
  ]
}
```

#### Windows VM: deprovision {#windows-deprovision-vra}

```jinja2
{
  "items": [
    {
      "className": "cmdb_ci_vmware_instance",
      "lookup": [],
      "values": {
        "discovery_source": "Manual Entry",
        "object_id": "{{ vcVmMoRefId | required("vcVmMoRefId is required") }}",
        "name": "{{ OneFuse_VmNic0.hostname }}",
        "vm_instance_uuid": "{{ instanceUUID }}",
        "state": "Terminated"
      }
    },
    {
      "className": "cmdb_ci_win_server",
      "lookup": [],
      "values": {
        "discovery_source": "Manual Entry",
        "name": "{{ OneFuse_VmNic0.hostname }}",
        "serial_number": "vmware-{{ instanceUUID }}",
        "hardware_status": "retired",
        "state": "Terminated"
      }
    }
  ],
  "relations": [
    {
      "type": "Runs on::Runs",
      "parent": 1,
      "child": 0
    }
  ]
}
```

## Update an existing CI using sysId

To update an existing ServiceNow CI during deployment using the sysId, use the OneFuse property `OneFuse_ServiceNowCmdbSysId` in the upstream provider syntax as follows:

| Parameter Name Format | Property Value Format |
| --- | --- |
| OneFuse_ServiceNowCmdbSysId | "\<The existing sysId\>" |

## Provision with ServiceNow CMDB

Use the defined IRE Templates in the ServiceNow CMDB OneFuse Policy to provision, update, and deprovision Configuration Items in your ServiceNow CMDB instance.

1. [Create a ServiceNow CMDB Policy](#create-a-servicenow-cmdb-policy).
2. Define ServiceNow IRE templates. See the [Example IRE templates](#example-ire-templates) for guidance.
3. Execute your ServiceNow Policy using the [OneFuse API](https://app.swaggerhub.com/apis-docs/cloudbolt/OneFuse/) or an [Upstream Provider](/docs/onefuse/consume/what-is-upstream-provider/).

Now that you have executed a ServiceNow Policy using the API or an Upstream Provider, [track your deployments in OneFuse](/docs/onefuse/configure/modules/servicenow-cmdb/tracking-deployments/).
