# Microsoft Active Directory

> Configure and use the OneFuse Microsoft Active Directory module with Red Hat Ansible

---

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

---

To learn more about this OneFuse module, refer to [Microsoft Active Directory](/docs/onefuse/configure/modules/microsoft-active-directory/).

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

## present

Register a Computer Account in Microsoft Active Directory for a resource.

### Sample Play

```yaml
- name: OneFuse Microsoft Active Directory - present
  hosts: localhost
  gather_facts: false
  vars:
    policy_name: <REPLACEME_with_OneFusePolicyName>
    name: <REPLACEME_with_ComputerAccountName> #{{ onefuse_name.name }}
  tasks:
  - name: Create Computer Account in Active Directory
    onefuse:
     module: ad
     state: present
     policy_name: '{{ policy_name }}'
     name: '{{ name }}'
     template_properties: {}
     tracking_id: '{{ tracking_id  | default(omit) }}'
    register: output
  - name: Output Results
    debug:
      msg: '{{ output }}'
  - name: "Pass Microsoft AD Outputs to workflow"
    set_stats:
        data:
         onefuse_ad: '{{ onefuse_ad }}'
         tracking_id: '{{ tracking_id }}'
```

### Parameter References

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

**Microsoft Active Directory specific Parameters:**

| Parameter Name | Required? | Notes |
| --- | --- | --- |
| `name` | **Required** | Computer Account Name |

## Update: Move OU

Move the Computer Account from the Build OU to final OU for a resource.

### Sample play {#sample-play-move-ou}

A sample play is coming soon.

### Parameter references {#parameter-references-move-ou}

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

| Parameter Name | Required? | Notes |
| --- | --- | --- |
| `ad_id` | Required | ID of the OneFuse Microsoft Active Directory Computer Account Managed Object |

## absent

Delete a Computer Account from Microsoft Active Directory for a resource.

### Sample Play

```yaml
- name: OneFuse Microsoft Active Directory - absent
  hosts: '{{ ansible_hosts }}'
  gather_facts: false
  tasks:
  - name: Delete Computer Account from AD
    onefuse:
      module: ad
      state: absent
      object_name: '{{ onefuse_ad.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). |
