Hello Varma,
Welcome to the Microsoft Q&A and thank you for posting your questions here.
Problem
I understand that you would like to know if there is possibility to create maintenance configurations solely using the azurerm without relying on the azureapi provider. Also, you seek further information on configuring patch installations for both Windows and Linux VMs, including other relevant arguments, if possible.
Scenario
You are tasked with automating maintenance configurations for virtual machines (VMs). Your goal is to create patching configurations for both Windows and Linux VMs using only the azurerm provider. You need to ensure that the configurations include scheduling details and specific settings for patch installations, tailored for each operating system and all maintenance configuration is performed by azurerm.
Solution
This prescribed solution was based on the scenario given and your questions, while focusing on the problem statement. From your first question:
can we create manintenance configuration only with azurerm provider not with azureapi
Yes, you can create maintenance configurations using only the azurerm
provider in Terraform without relying on the azureapi
provider. This is an example of how you can define a maintenance configuration:
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "example" {
name = "example-resources"
location = "West Europe"
}
resource "azurerm_maintenance_configuration" "example" {
name = "example-mc"
resource_group_name = azurerm_resource_group.example.name
scope = "InGuestPatch" # Specify the maintenance scope
# Other configuration settings go here
}
Your second question:
could you please provide more info on assigning install patches, windows, linux and other arguments.
To configure maintenance tasks, including installing patches for Windows and Linux machines, you can utilize the azurerm_automation_patch_configuration
resource in Terraform. This resource allows you to define patch configurations for virtual machines in Azure.
Below is an example of Terraform configuration demonstrating how you can create a maintenance configuration to install patches for Windows and Linux VMs using the azurerm_automation_patch_configuration
resource:
provider "azurerm" {
features {}
}
resource "azurerm_automation_account" "example" {
name = "automationaccount"
location = "West Europe"
resource_group_name = azurerm_resource_group.example.name
sku_name = "Basic"
}
resource "azurerm_automation_patch_configuration" "windows_patch_config" {
name = "WindowsPatchConfig"
resource_group_name = azurerm_resource_group.example.name
automation_account_name = azurerm_automation_account.example.name
operating_system = "Windows"
schedule {
frequency = "Month"
interval = 1
start_time = "2024-04-27T00:00:00+00:00"
}
windows_configuration {
included_update_classifications = ["Critical", "Security"]
excluded_kb_numbers = ["KB123456"]
included_kb_numbers = ["KB987654"]
}
}
resource "azurerm_automation_patch_configuration" "linux_patch_config" {
name = "LinuxPatchConfig"
resource_group_name = azurerm_resource_group.example.name
automation_account_name = azurerm_automation_account.example.name
operating_system = "Linux"
schedule {
frequency = "Month"
interval = 1
start_time = "2024-04-27T00:00:00+00:00"
}
linux_configuration {
included_packages = ["openssl", "openssh"]
excluded_packages = ["nginx"]
}
}
Finally
The above configuration creates an Automation Account in Azure and defines patch configurations for both Windows and Linux VMs, specifying the patching schedules and other relevant settings. You can adjust the configuration and the scope as needed to fit your specific requirements.
References
For more information and reading:
Terraform Registry: azurerm_maintenance_configuration
GitHub Issue: Could not create azure maintenance configuration with scope InGuestPatch
Azure Maintenance Configuration - Examples and best practices
20% Source: Conversation with Microsoft Bing, 4/27/2024.
Additional resources: Check the right side of this page.
Accept Answer
I hope this is helpful! Do not hesitate to let me know if you have any other questions.
** Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful ** so that others in the community facing similar issues can easily find the solution.
Best Regards,
Sina Salam