# Scripting

> Configure and use the OneFuse Scripting module with Red Hat Ansible

---

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

---

To learn more about this OneFuse module, refer to [Scripting](/docs/onefuse/configure/modules/scripting/).

## 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: `scripting`

## present

Run Provisioning Script(s) configured on the OneFuse Scripting Policy for a resource.

### Sample Play

```yaml
- name: OneFuse Scripting - present
  hosts: localhost
  gather_facts: false
  vars:
    policy_name: <REPLACEME_with_OneFusePolicyName>
  tasks:
  - name: Execute Provisioning Script
    onefuse:
      module: scripting
      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 Script Outputs to workflow"
    set_stats:
        data:
          onefuse_script: '{{ onefuse_script }}'
```

### Parameter references

The following defines the function of each Scripting 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. |

## absent

Run Deprovisioning Script(s), if configured on the OneFuse Scripting Policy, for a resource.

### Sample Play

```yaml
- name: OneFuse Scripting - absent
  hosts: '{{ ansible_host }}'
  gather_facts: false
  tasks:
  - name: Run Deprovision Script
    onefuse:
      module: scripting
      state: absent
      object_name: '{{ onefuse_script.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). |
