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 2 commits
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 @@ -65,8 +65,7 @@ func OrchestratedVirtualMachineScaleSetWindowsConfigurationSchema() *pluginsdk.S

"computer_name_prefix": computerPrefixWindowsSchema(),

// I am only commenting this out as this is going to be supported in the next release of the API in October 2021
// "additional_unattend_content": additionalUnattendContentSchema(),
"additional_unattend_content": additionalUnattendContentSchema(),

// TODO 4.0: change this from enable_* to *_enabled
"enable_automatic_updates": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,12 @@ func resourceOrchestratedVirtualMachineScaleSetCreate(d *pluginsdk.ResourceData,
provisionVMAgent := winConfig["provision_vm_agent"].(bool)
patchAssessmentMode := winConfig["patch_assessment_mode"].(string)
vmssOsProfile = expandOrchestratedVirtualMachineScaleSetOsProfileWithWindowsConfiguration(winConfig, customData)
additionalUnattendContentRaw := winConfig["additional_unattend_content"].([]interface{})
additionalUnattendContent := expandAdditionalUnattendContent(additionalUnattendContentRaw)

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 {
Expand Down Expand Up @@ -1301,6 +1307,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("os_profile.0.windows_configuration.0.additional_unattend_content.0.setting").HasValue("AutoLogon"),
),
},
})
Expand Down Expand Up @@ -1000,6 +1001,11 @@ resource "azurerm_orchestrated_virtual_machine_scale_set" "test" {
winrm_listener {
protocol = "Http"
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ A `windows_configuration` block supports the following:

* `winrm_listener` - (Optional) One or more `winrm_listener` blocks as defined below. Changing this forces a new resource to be created.

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

---

A `linux_configuration` block supports the following:
Expand Down Expand Up @@ -211,6 +213,14 @@ A `secret` 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.

---

A (Windows) `certificate` block supports the following:

* `store` - (Required) The certificate store on the Virtual Machine where the certificate should be added.
Expand Down
Loading