首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NSG配置管理

NSG配置管理
EN

Stack Overflow用户
提问于 2021-01-27 10:57:46
回答 1查看 108关注 0票数 0

我正在寻找一种工具或某种方法来管理Azure NSG配置。NSG规则目前是在临时基础上手动更改的。我希望以更脚本化的方式实现此NSG配置更改,这样我也可以跟踪更改历史记录。

我正在寻找基于Git的NSG存储库,其中NSG的所有ARM模板都具有不同的参数文件,并通过Azure powershell运行,或者作为Azure Devops CI/CD管道的一部分运行。

我不确定Ansible是否可以帮助管理NSG或Terraform。

我喜欢为这一点思考Ansible。任何人都知道如何管理NSG这一要求。

谢谢

EN

回答 1

Stack Overflow用户

发布于 2021-01-28 14:45:59

你可以通过ARM模板、Teffaform和Ansible管理Azure NSG配置。

  • ARM模板

1,你可以查看下面的示例来创建ARM模板来管理Azure NSG。

Create a Network Security Group

How to create NSGs using a template

有关更多示例,请查看official document

2,在创建ARM模板并将其推送到git代码库之后。您可以创建azure pipeline来自动执行部署。请在此处查看tutorial

3,然后你需要创建一个azure Resource Manager service connection来将你的Azure订阅连接到Azure devops。有关示例,请参阅this thread

4,在您的azure devops管道中。您可以使用ARM template deployment task部署ARM模板。

代码语言:javascript
复制
steps:
- task: AzureResourceManagerTemplateDeployment@3
  displayName: 'ARM Template deployment: Resource Group scope'
  inputs:
    azureResourceManagerConnection: 'azure Resource Manager service connection'
    subscriptionId: '...'
    resourceGroupName: '...'
    location: 'East US'
    csmFile: azuredeploy.json
    csmParametersFile: azuredeploy.parameters.json 

  • Teffaform

1、创建Teffaform配置文件。请参阅示例here

有关更多信息,请查看terraform-azurerm-network-security-group module

2 .上传Teffaform配置文件到git repo。创建Azure devops管道

3 .使用ARM模板创建类似上面的azure资源管理器服务连接。

4、在azure devops管道中使用Terraform task

代码语言:javascript
复制
steps:
- task: ms-devlabs.custom-terraform-tasks.custom-terraform-installer-task.TerraformInstaller@0
  displayName: 'Install Terraform 0.12.3'

- task: ms-devlabs.custom-terraform-tasks.custom-terraform-release-task.TerraformTaskV1@0
  displayName: 'Terraform : azurerm'
  inputs:
    command: apply
    environmentServiceNameAzureRM: 'azure Resource Manager service connection'

  • Ansible

1,使用插件azure.azcollection.azure_rm_securitygroup创建可分析的攻略

请查看example here

2,上传ansible攻略到git repo。创建Azure devops管道。在你的管道中使用Ansible task

有关如何在azure devops管道中运行ansible playbook的更多信息,请查看this detailed tutorial

  • powershell/Azure命令行界面命令

您可以使用azure powershell或azure cli命令来管理azure nsg。并在Azure devops管道中的azure powershell任务或azure cli任务中运行命令。

有关更多信息,请查看this document

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65912291

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档