Aria Automation with ChatGPT part 2

3–5 minutes

read –

in

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

So in previous post i tested the creation of a yaml file from ChatGPT. My first experience was that it was missing some info in the file, and that made me think i could benefit from trying a smarter AI, like the 4.0.

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:

  1. Replace Placeholders:
    • Replace Windows-2019 with the actual image name in your cloud template.
    • Replace NSX-Network with your actual NSX network name.
  2. Disk Device Letter:
    • The deviceName property specifies the drive letter. Ensure the disk initialization and formatting script handles the drive letter assignment correctly.
  3. 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:

  1. PowerShell Script Logic:
    • The script identifies uninitialized disks (PartitionStyle is RAW).
    • Initializes them and assigns specific drive letters.
  2. Formatting Details:
    • The Format-Volume cmdlet creates an NTFS filesystem on each new partition.
  3. 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:

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 }
}
}

Well, i must say there`s quite a difference in the latest ChatGPT, in terms of logic and smartness in how to best set this up, and now we can see that the template is more complete, and with more settings it requires. But i still missed some settings, so i added 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

  1. Domain Join
    • domain: Domain to join (e.g., example.com).
    • domainUserName: Username with sufficient privileges to join the domain.
    • domainPassword: Password for the user.
  2. Admin Credentials
    • adminUsername: The username of the administrator account.
    • adminPassword: The password for the administrator account.
  3. Computer Name
    • Automatically generates a unique computer name using the VM’s resource ID.
  4. 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.

So here we got our answer. The output is as good as the question.

I think i am in a better position to test the yaml file now, with all the extra settings and info. Hopefully it will work, but i am sure there`s some need for a little adjusting. It`s a start.


Comments

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.