# Scripting

> Configure OneFuse Scripting policies to run scripts on SSH-enabled hosts

---

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

---

The OneFuse Scripting Module allows users to consume scripts as API-based services that are executed in context of a specific machine lifecycle (create/destroy) or independently on any SSH-based host.

The OneFuse Scripting Module allows OneFuse admins to create simple API-based services using Scripting policies that can connect to SSH-enabled hosts/devices, track the outputs as inventory items, and enable create/destroy for lifecycle support.

End users of automation tools such as VMware Aria Automation, Terraform, ServiceNow, and others can execute these Policies and consume the variable outputs. This allows you to drive your automation use cases simply and securely, without requiring direct access to the target host.

## Create Scripting Policies

<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/) for the selected technology.
</div>


1. In OneFuse, select **Scripting** from **Home**, or select **Modules** > **Scripting** from the left navigation menu.
2. Select **Create** and fill out the [Scripting Policy form](#scripting-policy-form-fields).
3. When finished, select **Create**.

### Deployments

1. View generated Scripting Deployments from Scripting Policy executions in the **Deployments** datatable. For a more detailed report, select the view icon to open the **Job Summary**, which includes API, Input, Result, and Logs.
2. Select the details caret to view the Provision Script's JSON output.

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


Use the [OneFuse API](https://app.swaggerhub.com/apis-docs/cloudbolt/OneFuse/) to retrieve this JSON output to view in an API browser or use it in a custom node.js application.
</div>


## Lifecycle management

Provision and deprovision using Scripting with the [OneFuse API](https://app.swaggerhub.com/apis-docs/cloudbolt/OneFuse/) or an [Upstream Provider](/docs/onefuse/consume/what-is-upstream-provider/). Follow the steps below to set up provisioning and deprovisioning in OneFuse.

### Provisioning

1. Create a new Scripting Policy or select the Edit icon on an existing policy.
2. Select the **Provisioning** tab.
3. Enter the [Provisioning form field](#provisioning-and-deprovisioning-form-fields) requirements.
4. Select the **Deprovisioning** tab to enter Deprovisioning commands and script templates, or select **Create/Update** to save.

### Deprovisioning (optional)

1. Create a new Scripting Policy or select the Edit icon on an existing policy.
2. Select the **Deprovisioning** tab.
3. Enter the [Deprovisioning form field](#provisioning-and-deprovisioning-form-fields) requirements.
4. Select **Create/Update** to save.

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


OneFuse supports asynchronous Scripting Deployment. To view Job Status, make a polling request via the API.
</div>


## Scripting Policy form fields

| Field | Description |
| --- | --- |
| **Scripting Policy Name** | Enter a name for the Scripting Policy. |
| **Description** | Optional description for this Scripting Policy. |
| **Target Host** | Define the target host on which to run scripts. |
| **Module Credential** | Select an existing Module Credential. Type to filter. |

## Provisioning and deprovisioning form fields

| Field | Description |
| --- | --- |
| **Launch Command** | Launch command to run the script on the target host. Reference the rendered script with `{{ ScriptName }}`. |
| **Script Template** | Enter the script using a mix of static and templated text to run on the target host. |
| **Success Exit Code(s)** | Enter success exit codes as comma-separated numbers. Success is determined by matching the exit code(s) against the script's exit code. |

---

Section pages:

- [Disable OpenSSH on Windows servers](/docs/onefuse/configure/modules/scripting/disable-openssh/): Use OneFuse Scripting to uninstall OpenSSH from Windows servers via a bastion host
- [Install packages with Chocolatey](/docs/onefuse/configure/modules/scripting/install-chocolatey/): Use OneFuse Scripting to install packages with Chocolatey on Windows servers
- [Execute PowerShell scripts using a bastion host](/docs/onefuse/configure/modules/scripting/bastion-host/): Use a bastion host to execute PowerShell scripts via the OneFuse Scripting Module
- [Produce output from Scripting policies](/docs/onefuse/configure/modules/scripting/producing-output/): Capture JSON output from OneFuse Scripting policies
