使用 Terraform 和 Jenkins 的 Azure VM 创建自动化?

Azure VM creation automation using Terraform and Jenkins?

我有 Terraform script/template 在 Azure 中提供 VM,它接受输入并提供 VM 以及所需的资源。

我已经创建了 Azure 存储帐户并将脚本上传到 blob 容器中。

我们正在使用 Jenkins 作为我们的 CI/CD 工具。

现在,我想使用 Jenkins 构建管道或自动化,这将采用必要的输入和 运行 Terraform 脚本来配置 VM。

如何构建 Jenkins 管道,以便我可以多次 运行 管道/自动化并配置各个 VM?

任何示例 Jenkins 管道都会非常有用。

Immutable Infrastructure CI/CD using Jenkins and Terraform on Azure Virtual Architecture

上的 Azure 文档中提供了专门的体系结构参考和示例

这里还有template

New-AzResourceGroup -Name <resource-group-name> -Location <resource-group-location> #use this command when you need to create a new resource group for your deployment
New-AzResourceGroupDeployment -ResourceGroupName <resource-group-name> -TemplateUri https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/application-workloads/jenkins/jenkins-cicd-vmss/azuredeploy.json

如果你的唯一目的是通过 jenkins 运行 terraform 那么有很多可用的管道脚本,我已经在 link 下面粘贴了一个,这将有助于构建一个 jenkins 管道并且有还有指导文档。

https://github.com/manheim/terraform-pipeline