# VM tagging

> Configure and use the OneFuse VM Tagging module with VMware Aria Automation 8x/Cloud

---

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

---

To learn more, refer to [Templating and Property Toolkit](/docs/onefuse/consume/vmware-aria-automation/aria-automation-8x/modules/templating-property-toolkit/).

## Feature highlights

- Attach one or more Standard Tags to the VM as it is provisioned.
- Automate multiple scenarios of Standard Tag Names and values with OneFuse Template Engine.
- Define one or more vRA custom properties that influence the creation of VM Tags.
- Define a Standard Tag via JSON format of `key:value` pair.
- Supports OneFuse Template Engine for both `key:value` pair.
- Supports ordering sets/groupings of Standard Tags by alphabetizing after the Property Key prefix.

## Prerequisites

1. Run [OneFuse Configuration](/docs/onefuse/consume/vmware-aria-automation/aria-automation-8x/installation-and-setup/#run-the-onefuse-configuration-workflow) per Cloud Assembly Organization.
1. Review an overview on [OneFuse modules](/docs/onefuse/consume/vmware-aria-automation/aria-automation-8x/modules/) with Aria Automation 8.1+/Cloud.
1. Create a new **Cloud Template** (if none exist) or determine which existing Cloud Template(s) will utilize this OneFuse Module.
   - Resource: [Designing your vRealize Automation Cloud Assembly deployments](https://docs.vmware.com/en/vRealize-Automation/8.1/Using-and-Managing-Cloud-Assembly/GUID-BFD33C28-ADCC-43F4-BE43-CC92B62FBE2E.html)

## Steps

1. **Know the name of the OneFuse Endpoint** created via [OneFuse Configuration](/docs/onefuse/consume/vmware-aria-automation/aria-automation-8x/installation-and-setup/#run-the-onefuse-configuration-workflow).
1. **Determine *which* Standard Tag Categories and Tag Names** are needed for this Cloud Template.
1. **Update the Cloud Template** to add in necessary vRA Properties to create Standard Tags.
1. **Deploy the Cloud Template** to provision a vRA Deployment and create and/or associate Tag(s).
1. **Destroy the vRA Deployment** to destroy the vRA Deployment and disassociate itself from Tag(s).

### Update the Cloud Template

1. Log in to vRA > **Cloud Assembly**
1. Select the **Design** tab from the top menu bar
1. Select the **Cloud Templates** tab from the left menu
1. **Edit the Cloud Template** and perform the below:

#### Add in necessary vRA Properties

The following vRA Properties need to be added to the Cloud Template's **Code** section under the **Resource(s)** of interest.

**1. Trigger Property Toolkit and/or VM Tagging:**

| Property Name Format | Property Value |
| --- | --- |
| `OneFuse_PropertyToolkit` | `'<OneFuse Endpoint Name>:true'` |

**Example YAML:**

```yaml
# Execute OneFuse VM Tagging

# -- Property Name
# <CustomID> is replaced with 001Backup

# -- Property Value
# <OneFuse Endpoint Name>  is onefuse
# <Category Name>  is Backup
# <Tag Name> is the provisioned resource hostname

name: Simple Example
resources:
  Cloud_Machine_1:
    type: Cloud.Machine
    properties:
      image: CentOS7
      flavor: small
      count: 1
      OneFuse_PropertyToolkit: 'onefuse:true'
      OneFuse_CreateTags_001Backup: '{"key":"Backup", "value":"{{ OneFuse_VmNic0.hostname }}"}'
```

**2. Add in Tags:**

| Property Name Format | Property Value Format |
| --- | --- |
| `OneFuse_CreateTags_<CustomID>`: Replace `<CustomID>` with a unique, user-defined friendly label. | `'<JSON key:value pairs of Tags>'` |

**Example CustomID with sorting:**

```yaml
001Apache
002WebApp
003BackupClient
```

**Example YAML:**

```yaml
# -- Property Name
# <CustomID> is replaced with 001Backup

# -- Property Value
# <Category Name>  is Backup
# <Tag Name> is the provisioned resource hostname

# Example
OneFuse_CreateTags_001Backup: '{"key":"Backup", "value":"{{ OneFuse_VmNic0.hostname }}"}'
```

##### CustomID

**CustomID** refers to a user-specified text string to identify and can set an order of precedence for execution when calling multiple Policies for the OneFuse Module in the same vRA EBS State.

Replace `<CustomID>` with a unique custom identifier:

- Format is alphanumeric characters only `A-Z, a-z, 0-9`. No spaces, underscores, hyphens, nor special characters.
- Must be unique across all EBS Execution Strings for the OneFuse Module on the specific VM for the Blueprint/Cloud Template.
- Is reusable either between different VM components of the Blueprint/Cloud Template canvas or between different Blueprints/Cloud Templates.

```yaml
# Execute OneFuse VM Tagging

# -- Property Name
# <CustomID> is replaced with 001Backup

# -- Property Value
# <OneFuse Endpoint Name>  is onefuse
# <Category Name>  is Backup
# <Tag Name> is the provisioned resource hostname

name: Simple Example
resources:
  Cloud_Machine_1:
    type: Cloud.Machine
    properties:
      image: CentOS7
      flavor: small
      count: 1
      OneFuse_PropertyToolkit: 'onefuse:true'
      OneFuse_CreateTags_001Backup: '{"key":"Backup", "value":"{{ OneFuse_VmNic0.hostname }}"}'
```

**Specify sorting with CustomID:**

When executing multiple different OneFuse Module Policies in the same EBS State, prefix the `<CustomID>` with a numeric value (for example, `001`, `002`, etc.).

The `<CustomID>` is sorted prior to executing the OneFuse module's policies.

```yaml
# Example CustomID with sorting

001Apache
002WebApp
003BackupClient
```

##### Additional helpful vRA Properties

**Purpose: Relate OneFuse Policy executions from different OneFuse Modules together with a Tracking ID.**

| Property | Value Format |
| --- | --- |
| `OneFuse_Tracking_Id` | A GUID (globally unique identifier) that links OneFuse Policy Executions and the resulting Managed Objects together for a given resource on a deployment. The first OneFuse Module Policy execution will populate this vRA property and it will be passed into other OneFuse Modules automatically. *(When a Tracking ID is not provided, a Tracking ID gets generated for the Policy execution.)* Learn more about OneFuse [Tracking ID](/docs/onefuse/concepts/tracking-id/). |

**Purpose: Reference a specific NIC's values to get hostname, IP Address, etc.**

| Property Format | Example |
| --- | --- |
| `OneFuse_VmNic<#>.<value>`: Replace `<#>` with a number from `0` to `9`, one for each NIC. Replace `<value>` with an appropriate key: `dnsSuffix`, `fqdn`, `gateway`, `hostname`, `ipAddress`, `macAddress`, `netmask`, `network`, `subnet`, `target` | `OneFuse_VmNic0.dnsSuffix`, `OneFuse_VmNic0.fqdn`, `OneFuse_VmNic0.hostname`, `OneFuse_VmNic0.ipAddress`, `OneFuse_VmNic0.target` *(When DNS Suffix is provided, will be the FQDN; otherwise, will be the hostname without domain.)* *(For most use cases, NIC 0 is the primary network interface and the target hostname is a Fully Qualified Domain Name (FQDN).)* |

##### Example Cloud Template YAML code

```yaml
# Execute OneFuse VM Tagging

# -- Property Name
# <CustomID> is replaced with 001Backup

# -- Property Value
# <OneFuse Endpoint Name>  is onefuse
# <Category Name>  is Backup
# <Tag Name> is the provisioned resource hostname

name: Simple Example
resources:
  Cloud_Machine_1:
    type: Cloud.Machine
    properties:
      image: CentOS7
      flavor: small
      count: 1
      OneFuse_PropertyToolkit: 'onefuse:true'
      OneFuse_CreateTags_001Backup: '{"key":"Backup", "value":"{{ OneFuse_VmNic0.hostname }}"}'
```

### Provision

Deploy a Cloud Template with OneFuse VM Tagging configured. The resource will create if necessary and associate to the Standard Tag(s).

#### Outputs

The user-specified vRA Properties will exist on the deployment.

### Deprovision

Destroy an existing deployment with OneFuse VM Tagging configured. The resource will be removed from the Standard Tag(s).

## vRA EBS

| EBS Execution | Subscription State | EBS Priority | EBS Name |
| --- | --- | --- | --- |
| **Provision** | | | |
| ComputeAllocationPre | Early | 1000 | OneFuse_PropertyToolkit_ComputeAllocate |
| NetworkConfigure | Early | 1000 | OneFuse_PropertyToolkit_NetworkConfigure |
| ComputeProvisionPre | Early | 15 | OneFuse_PropertyToolkit_ComputeProvision |
| ComputeProvisionPost | Early | 1000 | OneFuse_PropertyToolkit_ComputePostProvision |

## Troubleshooting

Troubleshoot in vRealize Orchestrator.

1. Log in to **vRealize Orchestrator**.
1. Turn on [Verbose Logging](/docs/onefuse/consume/vmware-aria-automation/aria-automation-8x/modules/#troubleshooting-verbose-logging) and try again to see additional log messages in vRO Workflows:
   - Select **Library** > **Workflows** from the left menu
   - Go to: **OneFuse** > **Property Toolkit** > **vRA8** to find corresponding workflow runs and view logs
   - Optionally, run the workflows in the **Manual** folder to manually test
1. Optionally, [configure timeouts for EBS](/docs/onefuse/consume/vmware-aria-automation/aria-automation-8x/modules/event-broker-subscriptions/#configure-ebs-timeouts) and/or [Configure timeouts for OneFuse modules](/docs/onefuse/consume/vmware-aria-automation/aria-automation-8x/installation-and-setup/#configure-timeouts-for-onefuse-modules).

**Additional resources:**

- Review [Troubleshooting in OneFuse](/docs/onefuse/getting-started/troubleshooting/)
- Review [VMware troubleshooting resources](/docs/onefuse/consume/vmware-aria-automation/aria-automation-8x/getting-started/#troubleshooting)
