我正在尝试使用新的Azure Automation add-in (https://docs.microsoft.com/en-us/azure/automation/automation-solution-vm-management)将机器设置为自动启动/停止,这是由Terraform设置的。
我可以创建自动化帐户,但我不知道如何创建启动-停止功能,有人可以帮助填写空白吗?
发布于 2018-10-08 01:57:11
AzureRM提供程序可以管理runbooks的各个方面。如果您看过文档here。使用azurerm_automation_runbook和azurerm_automation_schedule,您可以创建和安排runbooks。Microsoft解决方案需要runbooks上的参数,我在提供程序中看不到任何用于添加参数的属性,因此这可能是不可能的。
发布于 2021-09-21 06:45:30
您可以在此资源提供者"azurerm_automation_job_schedule“中传递必需的参数。请注意下面代码中的参数属性,这是我们传递所需参数的方式。您可以参考此链接了解更多详细信息。https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/automation_job_schedule
resource "azurerm_automation_job_schedule" "startvm_sched" {
resource_group_name = "IndraTestRG"
automation_account_name = "testautomation"
schedule_name = azurerm_automation_schedule.scheduledstartvm.name
runbook_name = azurerm_automation_runbook.startstopvmrunbook.name
parameters = {
action = "Start"
}
depends_on = [azurerm_automation_schedule.scheduledstartvm]
}下面是VM启动/停止作业调度资源提供程序"azurerm_automation_schedule“和"azurerm_automation_job_schedule”的完整代码
resource "azurerm_automation_schedule" "scheduledstartvm" {
name = "StartVM"
resource_group_name = "IndraTestRG"
automation_account_name = "testautomation"
frequency = "Day"
interval = 1
timezone = "America/Chicago"
start_time = "2021-09-20T13:00:00Z"
description = "Run every day"
}
resource "azurerm_automation_job_schedule" "startvm_sched" {
resource_group_name = "IndraTestRG"
automation_account_name = "testautomation"
schedule_name = azurerm_automation_schedule.scheduledstartvm.name
runbook_name = azurerm_automation_runbook.startstopvmrunbook.name
parameters = {
action = "Start"
}
depends_on = [azurerm_automation_schedule.scheduledstartvm]
}
resource "azurerm_automation_schedule" "scheduledstopvm" {
name = "StopVM"
resource_group_name = "IndraTestRG"
automation_account_name = "testautomation"
frequency = "Day"
interval = 1
timezone = "America/Chicago"
start_time = "2021-09-20T10:30:00Z"
description = "Run every day"
}
resource "azurerm_automation_job_schedule" "stopvm_sched" {
resource_group_name = "IndraTestRG"
automation_account_name = "testautomation"
schedule_name = azurerm_automation_schedule.scheduledstopvm.name
runbook_name = azurerm_automation_runbook.startstopvmrunbook.name
parameters = {
action = "Stop"
}
depends_on = [azurerm_automation_schedule.scheduledstopvm]
}https://stackoverflow.com/questions/52651326
复制相似问题