我正在使用 ARM 模板将 ELK 堆栈部署到 azure 云(在现有的 vnet、子网、安全组中),但如果我使用https://github.com/elastic/azure-marketplace中的默认模板,它会部署一个网络安全组也适用于 kibana。如何编辑模板以便仅使用已经存在的网络安全组而不创建新的。
问问题
226 次
1 回答
0
要重用现有的网络安全组资源,您可以修改src/machines/kibana-resources.json如下:
- 删除网络安全组资源
使用默认值为网络安全组(securityGroupName)创建一个新参数这样您可以传入现有网络安全组名称的值
删除网络安全组变量
这是修改后的模板,应该满足您的要求。
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"templateBaseUrl": {
"type": "string",
"metadata": {
"description": "Base uri of resources"
}
},
"location": {
"type": "string",
"metadata": {
"description": "Location where resources will be provisioned"
}
},
"namespace": {
"type": "string",
"metadata": {
"description": "The unique namespace for the Kibana VM"
}
},
"securityGroupName": {
"type": "string",
"defaultValue": "[concat(parameters('namespace'), '-nsg')]"
},
"networkSettings": {
"type": "object",
"metadata": {
"description": "Network settings"
}
},
"storageAccountName": {
"type": "string",
"metadata": {
"description": "Existing Storage Account where the Virtual Machine's disks will be placed"
}
},
"credentials": {
"type": "secureObject",
"metadata": {
"description": "Credentials information block"
}
},
"osSettings": {
"type": "object",
"metadata": {
"description": "Platform and OS settings"
}
},
"vmSize": {
"type": "string",
"defaultValue": "Standard_A1",
"metadata": {
"description": "Size of the Kibana VM"
}
}
},
"variables": {
"namespace": "[parameters('namespace')]",
"subnetId": "[concat(resourceId(parameters('networkSettings').resourceGroup, 'Microsoft.Network/virtualNetworks', parameters('networkSettings').name), '/subnets/', parameters('networkSettings').subnet.name)]",
"publicIpName": "[concat(variables('namespace'), '-ip')]",
"nicName": "[concat(variables('namespace'), '-nic')]",
"password_osProfile": {
"computername": "[parameters('namespace')]",
"adminUsername": "[parameters('credentials').adminUsername]",
"adminPassword": "[parameters('credentials').password]"
},
"sshPublicKey_osProfile": {
"computername": "[parameters('namespace')]",
"adminUsername": "[parameters('credentials').adminUsername]",
"linuxConfiguration": {
"disablePasswordAuthentication": "true",
"ssh": {
"publicKeys": [
{
"path": "[concat('/home/', parameters('credentials').adminUsername, '/.ssh/authorized_keys')]",
"keyData": "[parameters('credentials').sshPublicKey]"
}
]
}
}
},
"osProfile": "[variables(concat(parameters('credentials').authenticationType, '_osProfile'))]"
},
"resources": [
{
"apiVersion": "2016-03-30",
"type": "Microsoft.Network/publicIPAddresses",
"name": "[variables('publicIpName')]",
"location": "[parameters('location')]",
"properties": {
"publicIPAllocationMethod": "Dynamic",
"dnsSettings": {
"domainNameLabel": "[concat('kb-', uniqueString(resourceGroup().id))]"
}
}
},
{
"apiVersion": "2016-03-30",
"type": "Microsoft.Network/networkInterfaces",
"name": "[variables('nicName')]",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Network/publicIPAddresses/', variables('publicIpName'))]",
"[concat('Microsoft.Network/networkSecurityGroups/', parameters('securityGroupName'))]"
],
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIpName'))]"
},
"subnet": {
"id": "[variables('subnetId')]"
}
}
}
],
"networkSecurityGroup": {
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', parameters('securityGroupName'))]"
}
}
},
{
"apiVersion": "2016-03-30",
"type": "Microsoft.Compute/virtualMachines",
"name": "[parameters('namespace')]",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
],
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('vmSize')]"
},
"osProfile": "[variables('osProfile')]",
"storageProfile": {
"imageReference": "[parameters('osSettings').imageReference]",
"osDisk": {
"name": "osdisk",
"vhd": {
"uri": "[concat('http://', parameters('storageAccountName'),'.blob.core.windows.net/vhds/', parameters('namespace'), '-osdisk.vhd')]"
},
"caching": "ReadWrite",
"createOption": "FromImage"
}
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]"
}
]
}
},
"resources": [
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(variables('namespace'), '/script')]",
"apiVersion": "2016-03-30",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', parameters('namespace'))]"
],
"properties": "[parameters('osSettings').extensionSettings.kibana]"
}
]
}
],
"outputs": {
"fqdn": {
"value": "[concat('http://',reference(resourceId('Microsoft.Network/publicIPAddresses', variables('publicIpName')),providers('Microsoft.Network', 'publicIPAddresses').apiVersions[0]).dnsSettings.fqdn, ':5601')]",
"type": "string"
}
}
}
于 2017-03-22T14:28:50.600 回答