Featured image of post Aria Automation with ChatGPT part 2

Aria Automation with ChatGPT part 2

Creating a Cloud Template yaml file using chatgpt v.4.0:

In the previous post, I tested creating a YAML file with ChatGPT. The result was missing information, so I tried a newer version to see whether it would produce a more complete template.

I started like last time:

**Me: **

Write me a aria automation cloud template, for a windows 2019, with a c disk with 100gb, and 3 additional disk. a DB disk with 300gb with letter E, a log disk with 120gb with letter F and a temp disk with 50gb with letter G. The vm uses NSX network, and needs 4 cpu and 16gb ram.

ChatGPT4:

Creating an Aria Automation Cloud template involves defining the virtual machine specifications, including CPU, memory, storage, and network. Here is an example YAML file you could use:

Notes:

  • Replace Placeholders:

Replace Windows-2019 with the actual image name in your cloud template.

  • Replace NSX-Network with your actual NSX network name.

  • Disk Device Letter:

The deviceName property specifies the drive letter. Ensure the disk initialization and formatting script handles the drive letter assignment correctly.

  • Flavors:

If custom flavors are not available, use a pre-defined flavor that matches the desired CPU and memory configuration.

Cloud-Init or PowerShell Customization

To ensure the correct disk letters and formatting, include a customization script. You could use a PowerShell script like this:

Integrate the script into the YAML file:

The additional disks will be formatted and ready to use in Windows.

Here’s a summary of how the customizationSpec works in this YAML template:

  • Pre-Script: Runs the provided PowerShell commands to initialize, partition, and format the additional disks.

  • Drive Letter Assignment: Ensures each disk is assigned a specific drive letter as requested.

Adjusted Template

Here’s the adjusted template with a complete PowerShell script:

Notes:

  • PowerShell Script Logic:

The script identifies uninitialized disks (PartitionStyle is RAW).

  • Initializes them and assigns specific drive letters.

  • Formatting Details:

The Format-Volume cmdlet creates an NTFS filesystem on each new partition.

  • Disk Number Assumption:

The script assumes that the additional disks will have numbers starting from 1.

  • If the disk numbers change due to configuration, you might need to adjust the switch statement.

CODE:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
name: "windows-2019-template"
description: "Windows Server 2019 with NSX network, 4 CPUs, 16GB RAM, 100GB C:, and 3 additional disks"
version: "1.0"

resources:
  windowsVm:
    type: Cloud.Machine
    properties:
      image: "Windows-2019"
      flavor: "custom"
      cpuCount: 4
      totalMemoryMB: 16384
      constraints:
        - tag: "os:windows"
      networks:
        - networkType: "existing"
          networkName: "NSX-Network"
      disks:
        - name: "C Disk"
          capacityGB: 100
          bootDisk: true
        - name: "DB Disk"
          capacityGB: 300
          deviceName: "E:"
        - name: "Log Disk"
          capacityGB: 120
          deviceName: "F:"
        - name: "Temp Disk"
          capacityGB: 50
          deviceName: "G:"
      customizationSpec:
        customizationType: "windows"
        preScript:
          inline: |
            # Initialize and format additional disks
            Get-Disk | Where-Object PartitionStyle -eq 'RAW' | Initialize-Disk -PartitionStyle MBR -PassThru | 
            ForEach-Object {
                $disk = $_
                switch ($disk.Number) {
                    1 { New-Partition -DiskNumber $disk.Number -DriveLetter 'E' -UseMaximumSize | Format-Volume -FileSystem NTFS -NewFileSystemLabel 'DBDisk' -Confirm:$false }
                    2 { New-Partition -DiskNumber $disk.Number -DriveLetter 'F' -UseMaximumSize | Format-Volume -FileSystem NTFS -NewFileSystemLabel 'LogDisk' -Confirm:$false }
                    3 { New-Partition -DiskNumber $disk.Number -DriveLetter 'G' -UseMaximumSize | Format-Volume -FileSystem NTFS -NewFileSystemLabel 'TempDisk' -Confirm:$false }
                }
            }

ChatGPT 4.0 produced a more complete template and included more of the required settings. I still found settings missing, so I asked another question:

Me:

Are there any other settings in the template we need ?

ChatGPT4:

In addition to the CPU, memory, disk, and network configuration already provided in the template, there are a few other important settings you might want to include:

1. Security Settings

Ensure Windows Firewall or other security configurations are in place.

2. Domain Joining

If the VM needs to join a domain, you can use the domainJoin property.

3. Admin Credentials

Specify admin credentials for access post-deployment.

4. Time Zone Configuration

Set the time zone if needed.

5. NSX Advanced Settings

In cases where NSX needs specific configurations, you might need additional settings.

Enhanced Template Example

Below is a more comprehensive template including the additional settings:

Explanation of Additional Settings

  • Domain Join

domain: Domain to join (e.g., example.com).

  • domainUserName: Username with sufficient privileges to join the domain.

  • domainPassword: Password for the user.

  • Admin Credentials

adminUsername: The username of the administrator account.

  • adminPassword: The password for the administrator account.

  • Computer Name

Automatically generates a unique computer name using the VM’s resource ID.

  • Time Zone

Specifies the Windows timezone setting (timezone property).

Security Reminder

Make sure sensitive information like passwords are handled securely and use secrets management where possible.

This produced a better answer, but only after I asked a more complete question.

With the extra settings, I now have a better YAML file to test. I still expect to adjust it after importing it into my environment.