# ServiceNow CMDB

> Configure and use the OneFuse ServiceNow CMDB module with Red Hat Ansible

---

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

---

To learn more about this OneFuse module, refer to [ServiceNow CMDB](/docs/onefuse/configure/modules/servicenow-cmdb/).

## Prerequisites

1. [Configure OneFuse Manager](/docs/onefuse/consume/red-hat-ansible/getting-started/#configure-onefuse-manager)
1. Review an overview on [OneFuse Modules](/docs/onefuse/consume/red-hat-ansible/modules/) with OneFuse Ansible Module

## Ansible OneFuse Module name

- Ansible OneFuse Module name for this OneFuse Module is: `cmdb`

## present

Run Provisioning IRE Template(s) configured on the OneFuse ServiceNow CMDB Policy for a resource.

### Sample Play

```yaml
- name: OneFuse ServiceNow CMDB - present
  hosts: localhost
  gather_facts: false
  vars:
    policy_name: <REPLACEME_with_OneFusePolicyName>
  tasks:
  - name: Create ServiceNow CMDB CI Record
    onefuse:
     module: cmdb
     state: present
     policy_name: '{{ policy_name }}'
     template_properties: {}
     tracking_id: '{{ tracking_id  | default(omit) }}'
    delegate_to: localhost
    register: output
  - name: Output Results
    debug:
      msg: '{{ output }}'
  - name: "Pass ServiceNow CMDB Outputs to workflow"
    set_stats:
        data:
         onefuse_cmdb: '{{ onefuse_cmdb }}'
         tracking_id: '{{ tracking_id }}'
```

### Parameter references

The following defines the function of each ServiceNow CMDB specific Task Parameters for `onefuse`.

| Parameter Name | Required? | Notes |
| --- | --- | --- |
| `module` | Required | OneFuse Module Name (string). *(Refer to [Module names for OneFuse modules](/docs/onefuse/consume/red-hat-ansible/modules/#module-names-for-onefuse-modules).)* |
| `state` | Required | `present` for provision, or the appropriate "update" state for the OneFuse Module. |
| `policy_name` | Required | OneFuse Module Policy Name (string). |
| `template_properties` | *Optional* | Additional properties that are referenced within the Policy. Python [dict](https://www.w3schools.com/python/python_dictionaries.asp) format. |
| `tracking_id` | *Optional* | Tracking ID (string) to link multiple OneFuse Policy Executions and resulting OneFuse Managed Objects together. If none is passed, one gets generated by OneFuse for that specific Policy Execution. Recommended value: `{{ tracking_id \| default(omit) }}` |

## Update

Run Update IRE Template(s), if configured on the OneFuse ServiceNow CMDB Policy, for a resource.

### Sample play {#sample-play-update}

A sample play is coming soon.

### Parameter references {#parameter-references-update}

The following defines the function of the Task Parameters for `onefuse`.

| Parameter Name | Required? | Notes |
| --- | --- | --- |
| `template_properties` | *Optional* | Additional properties that are referenced within the Policy.<br>Python [dict](https://www.w3schools.com/python/python_dictionaries.asp) format. |
| `cmdb_id` | Required | ID of the OneFuse ServiceNow CMDB Deployment Managed Object |

## absent

Run Deprovisioning IRE Template(s), if configured on the OneFuse ServiceNow CMDB Policy, for a resource.

### Sample Play

```yaml
- name: OneFuse ServiceNow CMDB - absent
  hosts: '{{ ansible_hosts }}'
  gather_facts: false
  tasks:
  - name: Update CMDB Record and run Deprovisioning IRE Template
    onefuse:
      module: cmdb
      state: absent
      object_name: '{{ onefuse_cmdb.id | default(omit) }}'
    delegate_to: localhost
    register: output
  - name: Output Results
    debug:
      msg: '{{ output }}'
```

### Parameter references

The following defines the function of the Task Parameters for `onefuse`.

| Parameter Name | Required? | Notes |
| --- | --- | --- |
| `module` | Required | OneFuse Module Name (string). *(Refer to [Module names for OneFuse modules](/docs/onefuse/consume/red-hat-ansible/modules/#module-names-for-onefuse-modules).)* |
| `state` | Required | `absent` for deprovision. |
| `object_name` | Required | OneFuse Managed Object ID (string). |
