Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support additional_unattend_content part of azurerm_orchestrated_virtual_machine_scale_set resource #24292

Merged
merged 4 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ func resourceOrchestratedVirtualMachineScaleSet() *pluginsdk.Resource {
},

"priority_mix": OrchestratedVirtualMachineScaleSetPriorityMixPolicySchema(),

"additional_unattend_content": additionalUnattendContentSchema(),
harshavmb marked this conversation as resolved.
Show resolved Hide resolved
},
}
}
Expand Down Expand Up @@ -403,6 +405,9 @@ func resourceOrchestratedVirtualMachineScaleSetCreate(d *pluginsdk.ResourceData,
extensionOperationsEnabled := d.Get("extension_operations_enabled").(bool)
osProfileRaw := d.Get("os_profile").([]interface{})

additionalUnattendContentRaw := d.Get("additional_unattend_content").([]interface{})
additionalUnattendContent := expandAdditionalUnattendContent(additionalUnattendContentRaw)

if len(osProfileRaw) > 0 {
osProfile := osProfileRaw[0].(map[string]interface{})
winConfigRaw = osProfile["windows_configuration"].([]interface{})
Expand All @@ -420,6 +425,10 @@ func resourceOrchestratedVirtualMachineScaleSetCreate(d *pluginsdk.ResourceData,
patchAssessmentMode := winConfig["patch_assessment_mode"].(string)
vmssOsProfile = expandOrchestratedVirtualMachineScaleSetOsProfileWithWindowsConfiguration(winConfig, customData)

if len(additionalUnattendContentRaw) > 0 {
vmssOsProfile.WindowsConfiguration.AdditionalUnattendContent = additionalUnattendContent
}

// if the Computer Prefix Name was not defined use the computer name
if vmssOsProfile.ComputerNamePrefix == nil || len(*vmssOsProfile.ComputerNamePrefix) == 0 {
// validate that the computer name is a valid Computer Prefix Name
Expand Down Expand Up @@ -1301,6 +1310,12 @@ func resourceOrchestratedVirtualMachineScaleSetRead(d *pluginsdk.ResourceData, m
}
d.Set("encryption_at_host_enabled", encryptionAtHostEnabled)
d.Set("user_data_base64", profile.UserData)

if windows := profile.OsProfile.WindowsConfiguration; windows != nil {
if err := d.Set("additional_unattend_content", flattenAdditionalUnattendContent(windows.AdditionalUnattendContent, d)); err != nil {
return fmt.Errorf("setting `additional_unattend_content`: %+v", err)
}
}
}

if priorityMixPolicy := props.PriorityMixPolicy; priorityMixPolicy != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ func TestAccOrchestratedVirtualMachineScaleSet_basicWindows(t *testing.T) {
Config: r.basicWindows(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("additional_unattend_content.0.setting").HasValue("AutoLogon"),
),
},
})
Expand Down Expand Up @@ -987,6 +988,11 @@ resource "azurerm_orchestrated_virtual_machine_scale_set" "test" {

platform_fault_domain_count = 2

additional_unattend_content {
content = "<UserAccounts><AdministratorPassword><Value>Jasdfds164</Value><PlainText>true</PlainText></AdministratorPassword></UserAccounts>"
setting = "AutoLogon"
}

os_profile {
windows_configuration {
computer_name_prefix = "testvm"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ resource "azurerm_orchestrated_virtual_machine_scale_set" "example" {

* `additional_capabilities` - (Optional) An `additional_capabilities` block as defined below.

* `additional_unattend_content` - (Optional) One or more `additional_unattend_content` blocks as defined below. Changing this forces a new resource to be created.
harshavmb marked this conversation as resolved.
Show resolved Hide resolved

* `encryption_at_host_enabled` - (Optional) Should disks attached to this Virtual Machine Scale Set be encrypted by enabling Encryption at Host?

* `instances` - (Optional) The number of Virtual Machines in the Orcestrated Virtual Machine Scale Set.
Expand Down Expand Up @@ -129,6 +131,14 @@ An `additional_capabilities` block supports the following:

---

An `additional_unattend_content` block supports the following:

* `content` - (Required) The XML formatted content that is added to the unattend.xml file for the specified path and component. Changing this forces a new resource to be created.

* `setting` - (Required) The name of the setting to which the content applies. Possible values are `AutoLogon` and `FirstLogonCommands`. Changing this forces a new resource to be created.

---

An `os_profile` block supports the following:

* `custom_data` - (Optional) The Base64-Encoded Custom Data which should be used for this Orchestrated Virtual Machine Scale Set.
Expand Down
Loading