Moved discover private ip template
This commit is contained in:
Родитель
4e0e3b69ce
Коммит
a67893094d
|
@ -0,0 +1,7 @@
|
|||
# Discover Private IP dynamically
|
||||
|
||||
<a href="https://azuredeploy.net" target="_blank">
|
||||
<img src="http://azuredeploy.net/deploybutton.png"/>
|
||||
</a>
|
||||
|
||||
This template allows you to discover a private IP for a NIC dynamically. It passes the private IP of NIC0 to VM1 using custom script extensions which writes it to a file on VM1.
|
|
@ -0,0 +1,269 @@
|
|||
{
|
||||
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"scaleNumber": {
|
||||
"type": "int",
|
||||
"defaultValue": 2,
|
||||
"metadata": {
|
||||
"Description": "Number of VMs to deploy"
|
||||
}
|
||||
},
|
||||
"location": {
|
||||
"type": "string",
|
||||
"allowedValues": [
|
||||
"West US",
|
||||
"East US",
|
||||
"West Europe",
|
||||
"East Asia",
|
||||
"Southeast Asia"
|
||||
],
|
||||
"metadata": {
|
||||
"Description": "Location of resources"
|
||||
}
|
||||
},
|
||||
"newStorageAccountName": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"Description": "Name of new storage account"
|
||||
}
|
||||
},
|
||||
"storageAccountType": {
|
||||
"type": "string",
|
||||
"defaultValue": "Standard_LRS",
|
||||
"metadata": {
|
||||
"Description": "Type of storage account"
|
||||
}
|
||||
},
|
||||
"vmName": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"Description": "Name of the VM"
|
||||
}
|
||||
},
|
||||
"vmSize": {
|
||||
"type": "string",
|
||||
"defaultValue": "Standard_D1",
|
||||
"metadata": {
|
||||
"Description": "Size of the VM"
|
||||
}
|
||||
},
|
||||
"imagePublisher": {
|
||||
"type": "string",
|
||||
"defaultValue": "Canonical",
|
||||
"metadata": {
|
||||
"description": "Image Publisher"
|
||||
}
|
||||
},
|
||||
"imageOffer": {
|
||||
"type": "string",
|
||||
"defaultValue": "UbuntuServer",
|
||||
"metadata": {
|
||||
"description": "Image Offer"
|
||||
}
|
||||
},
|
||||
"imageSKU": {
|
||||
"type": "string",
|
||||
"defaultValue": "14.04.2-LTS",
|
||||
"metadata": {
|
||||
"description": "Image SKU"
|
||||
}
|
||||
},
|
||||
"adminUserName": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"Description": "VM Admin Username"
|
||||
}
|
||||
},
|
||||
"adminPassword": {
|
||||
"type": "securestring",
|
||||
"metadata": {
|
||||
"Description": "VM Password"
|
||||
}
|
||||
},
|
||||
"customScriptFilePath": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"Description": "Path to the download the custom script from"
|
||||
}
|
||||
},
|
||||
"customScriptCommandToExecute": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"Description": "Command to execute on the VM"
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
"availabilitySetName": "myAVSet",
|
||||
"publicIPAddressType": "Dynamic",
|
||||
"virtualNetworkName": "myVNET",
|
||||
"vnetID": "[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]",
|
||||
"addressPrefix": "10.0.0.0/16",
|
||||
"subnet1Name": "Subnet-1",
|
||||
"subnet1Prefix": "10.0.0.0/24",
|
||||
"subnet1Ref": "[concat(variables('vnetID'),'/subnets/', variables('subnet1Name'))]",
|
||||
"nicName": "myNic",
|
||||
"vmExtensionName": "myCustomScriptExtension",
|
||||
"vmStorageAccountContainerName" : "vhds"
|
||||
},
|
||||
"resources": [{
|
||||
"type": "Microsoft.Storage/storageAccounts",
|
||||
"name": "[parameters('newStorageAccountName')]",
|
||||
"apiVersion": "2015-05-01-preview",
|
||||
"location": "[parameters('location')]",
|
||||
"properties": {
|
||||
"accountType": "[parameters('storageAccountType')]"
|
||||
}
|
||||
}, {
|
||||
"type": "Microsoft.Compute/availabilitySets",
|
||||
"name": "[variables('availabilitySetName')]",
|
||||
"apiVersion": "2015-05-01-preview",
|
||||
"location": "[parameters('location')]",
|
||||
"properties": {}
|
||||
}, {
|
||||
"apiVersion": "2015-05-01-preview",
|
||||
"type": "Microsoft.Network/publicIPAddresses",
|
||||
"name": "[concat('publicIP', copyIndex())]",
|
||||
"location": "[parameters('location')]",
|
||||
"copy": {
|
||||
"name": "foo",
|
||||
"count": "[parameters('scaleNumber')]"
|
||||
},
|
||||
"properties": {
|
||||
"publicIPAllocationMethod": "[variables('publicIPAddressType')]"
|
||||
}
|
||||
}, {
|
||||
"apiVersion": "2015-05-01-preview",
|
||||
"type": "Microsoft.Network/virtualNetworks",
|
||||
"name": "[variables('virtualNetworkName')]",
|
||||
"location": "[parameters('location')]",
|
||||
"properties": {
|
||||
"addressSpace": {
|
||||
"addressPrefixes": [
|
||||
"[variables('addressPrefix')]"
|
||||
]
|
||||
},
|
||||
"subnets": [{
|
||||
"name": "[variables('subnet1Name')]",
|
||||
"properties": {
|
||||
"addressPrefix": "[variables('subnet1Prefix')]"
|
||||
}
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"apiVersion": "2015-05-01-preview",
|
||||
"type": "Microsoft.Network/networkInterfaces",
|
||||
"name": "[concat(variables('nicName'), 0)]",
|
||||
"location": "[parameters('location')]",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Network/publicIPAddresses/', 'publicIP0')]",
|
||||
"[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]"
|
||||
],
|
||||
"properties": {
|
||||
"ipConfigurations": [{
|
||||
"name": "ipconfig1",
|
||||
"properties": {
|
||||
"privateIPAllocationMethod": "Dynamic",
|
||||
"publicIPAddress": {
|
||||
"id": "[resourceId('Microsoft.Network/publicIPAddresses', 'publicIP0')]"
|
||||
},
|
||||
"subnet": {
|
||||
"id": "[variables('subnet1Ref')]"
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"apiVersion": "2015-05-01-preview",
|
||||
"type": "Microsoft.Network/networkInterfaces",
|
||||
"name": "[concat(variables('nicName'), 1)]",
|
||||
"location": "[parameters('location')]",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Network/publicIPAddresses/', 'publicIP1')]",
|
||||
"[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]"
|
||||
],
|
||||
"properties": {
|
||||
"ipConfigurations": [{
|
||||
"name": "ipconfig1",
|
||||
"properties": {
|
||||
"privateIPAllocationMethod": "Dynamic",
|
||||
"publicIPAddress": {
|
||||
"id": "[resourceId('Microsoft.Network/publicIPAddresses', 'publicIP1')]"
|
||||
},
|
||||
"subnet": {
|
||||
"id": "[variables('subnet1Ref')]"
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"apiVersion": "2015-05-01-preview",
|
||||
"type": "Microsoft.Compute/virtualMachines",
|
||||
"name": "[concat(parameters('vmName'), copyIndex())]",
|
||||
"location": "[parameters('location')]",
|
||||
"copy": {
|
||||
"name": "foo",
|
||||
"count": "[parameters('scaleNumber')]"
|
||||
},
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Storage/storageAccounts/', parameters('newStorageAccountName'))]",
|
||||
"[concat('Microsoft.Network/networkInterfaces/', variables('nicName'), copyindex())]",
|
||||
"[concat('Microsoft.Compute/availabilitySets/', variables('availabilitySetName'))]"
|
||||
],
|
||||
"properties": {
|
||||
"availabilitySet": {
|
||||
"id": "[resourceId('Microsoft.Compute/availabilitySets', variables('availabilitySetName'))]"
|
||||
},
|
||||
"hardwareProfile": {
|
||||
"vmSize": "[parameters('vmSize')]"
|
||||
},
|
||||
"osProfile": {
|
||||
"computername": "[concat(parameters('vmName'), copyIndex())]",
|
||||
"adminUsername": "[parameters('adminUserName')]",
|
||||
"adminPassword": "[parameters('adminPassword')]"
|
||||
},
|
||||
"storageProfile": {
|
||||
"imageReference": {
|
||||
"publisher": "[parameters('imagePublisher')]",
|
||||
"offer": "[parameters('imageOffer')]",
|
||||
"sku": "[parameters('imageSKU')]",
|
||||
"version": "latest"
|
||||
},
|
||||
"osDisk": {
|
||||
"name": "osdisk",
|
||||
"vhd": {
|
||||
"uri": "[concat('http://',parameters('newStorageAccountName'),'.blob.core.windows.net/vhds/','osdisk', copyIndex(), '.vhd')]"
|
||||
},
|
||||
"caching": "ReadWrite",
|
||||
"createOption": "FromImage"
|
||||
}
|
||||
},
|
||||
"networkProfile": {
|
||||
"networkInterfaces": [{
|
||||
"id": "[resourceId('Microsoft.Network/networkInterfaces', concat(variables('nicName'), copyIndex()))]"
|
||||
}]
|
||||
}
|
||||
}
|
||||
}, {
|
||||
"type": "Microsoft.Compute/virtualMachines/extensions",
|
||||
"name": "[concat(parameters('vmName'), '1/', variables('vmExtensionName'))]",
|
||||
"apiVersion": "2015-05-01-preview",
|
||||
"location": "[parameters('location')]",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Compute/virtualMachines/', parameters('vmName'), '1')]",
|
||||
"[concat('Microsoft.Network/networkInterfaces/', variables('nicName'), '0')]"
|
||||
],
|
||||
"properties": {
|
||||
"publisher": "Microsoft.OSTCExtensions",
|
||||
"type": "CustomScriptForLinux",
|
||||
"typeHandlerVersion": "1.2",
|
||||
"settings": {
|
||||
"fileUris": [
|
||||
"[parameters('customScriptFilePath')]"
|
||||
],
|
||||
"commandToExecute": "[concat(parameters('customScriptCommandToExecute'), reference(concat(variables('nicName'), '0')).ipConfigurations[0].properties.privateIPAddress)]"
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentParameters.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"newStorageAccountName": {
|
||||
"value": ""
|
||||
},
|
||||
"location": {
|
||||
"value": ""
|
||||
},
|
||||
"vmName": {
|
||||
"value": ""
|
||||
},
|
||||
"vmSize": {
|
||||
"value": "Standard_D1"
|
||||
},
|
||||
"adminUserName": {
|
||||
"value": ""
|
||||
},
|
||||
"adminPassword": {
|
||||
"value": ""
|
||||
},
|
||||
"customScriptFilePath": {
|
||||
"value": "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/tree/master/master/201-discover-private-ip-dynamically/privateip.sh"
|
||||
},
|
||||
"customScriptCommandToExecute": {
|
||||
"value": "sh privateip.sh "
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"itemDisplayName": "Discover Private IP dynamically",
|
||||
"description": "This template allows you to discover a private IP for a NIC dynamically. It passes the private IP of NIC0 to VM1 using custom script extensions which writes it to a file on VM1.",
|
||||
"summary": "Discover Private IP dynamically",
|
||||
"githubUsername": "singhkay",
|
||||
"dateUpdated": "2015-04-28"
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
cd /usr/local
|
||||
touch privateIP.txt
|
||||
|
||||
echo $1 >> privateIP.txt
|
|
@ -1,20 +1,20 @@
|
|||
{
|
||||
"newStorageAccountName" : {
|
||||
"value":""
|
||||
"value":"kaystore4d"
|
||||
},
|
||||
"adminUsername": {
|
||||
"value": ""
|
||||
"value": "kay"
|
||||
},
|
||||
"adminPassword": {
|
||||
"value": ""
|
||||
"value": "Azure12345"
|
||||
},
|
||||
"numberOfInstances": {
|
||||
"value": 2
|
||||
},
|
||||
"region": {
|
||||
"value": ""
|
||||
"location": {
|
||||
"value": "West US"
|
||||
},
|
||||
"vmSize": {
|
||||
"value": ""
|
||||
"value": "Standard_D1"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,18 +27,23 @@
|
|||
"description": "Number of VMs to deploy"
|
||||
}
|
||||
},
|
||||
"region": {
|
||||
"location": {
|
||||
"type": "string",
|
||||
"defaultValue": "West US",
|
||||
"allowedValues": [
|
||||
"West US",
|
||||
"East US",
|
||||
"West Europe",
|
||||
"East Asia",
|
||||
"Southeast Asia"
|
||||
],
|
||||
"metadata": {
|
||||
"description": "Regions to deploy the VM in"
|
||||
"description": "Location to deploy the VM in"
|
||||
}
|
||||
},
|
||||
"vmSize": {
|
||||
"type": "string",
|
||||
"defaultValue": "Standard_A0",
|
||||
"metadata": {
|
||||
"description": "Password for the Virtual Machine."
|
||||
"description": "Size of the Virtual Machine."
|
||||
}
|
||||
},
|
||||
"imagePublisher": {
|
||||
|
@ -64,9 +69,6 @@
|
|||
},
|
||||
},
|
||||
"variables": {
|
||||
"imagePublisher": "Canonical",
|
||||
"imageOffer": "UbuntuServer",
|
||||
"OSDiskName": "osdiskforlinuxsimple",
|
||||
"virtualNetworkName": "myVNET",
|
||||
"vnetID": "[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]",
|
||||
"addressPrefix": "10.0.0.0/16",
|
||||
|
@ -80,7 +82,7 @@
|
|||
"type": "Microsoft.Storage/storageAccounts",
|
||||
"name": "[parameters('newStorageAccountName')]",
|
||||
"apiVersion": "2015-05-01-preview",
|
||||
"location": "[parameters('region')]",
|
||||
"location": "[parameters('location')]",
|
||||
"properties": {
|
||||
"accountType": "Standard_LRS"
|
||||
}
|
||||
|
@ -89,7 +91,7 @@
|
|||
"apiVersion": "2015-05-01-preview",
|
||||
"type": "Microsoft.Network/virtualNetworks",
|
||||
"name": "[variables('virtualNetworkName')]",
|
||||
"location": "[parameters('region')]",
|
||||
"location": "[parameters('location')]",
|
||||
"properties": {
|
||||
"addressSpace": {
|
||||
"addressPrefixes": [
|
||||
|
@ -110,7 +112,7 @@
|
|||
"apiVersion": "2015-05-01-preview",
|
||||
"type": "Microsoft.Network/publicIPAddresses",
|
||||
"name": "[concat('publicIP', copyIndex())]",
|
||||
"location": "[parameters('region')]",
|
||||
"location": "[parameters('location')]",
|
||||
"copy": {
|
||||
"name": "publicIPLoop",
|
||||
"count": "[parameters('numberOfInstances')]"
|
||||
|
@ -123,7 +125,7 @@
|
|||
"apiVersion": "2015-05-01-preview",
|
||||
"type": "Microsoft.Network/networkInterfaces",
|
||||
"name": "[concat('nic', copyindex())]",
|
||||
"location": "[parameters('region')]",
|
||||
"location": "[parameters('location')]",
|
||||
"copy": {
|
||||
"name": "nicLoop",
|
||||
"count": "[parameters('numberOfInstances')]"
|
||||
|
@ -153,7 +155,7 @@
|
|||
"apiVersion": "2015-05-01-preview",
|
||||
"type": "Microsoft.Compute/virtualMachines",
|
||||
"name": "[concat('myvm', copyIndex())]",
|
||||
"location": "[parameters('region')]",
|
||||
"location": "[parameters('location')]",
|
||||
"copy": {
|
||||
"name": "virtualMachineLoop",
|
||||
"count": "[parameters('numberOfInstances')]"
|
||||
|
|
Загрузка…
Ссылка в новой задаче