github.com/kikitux/packer@v0.10.1-0.20160322154024-6237df566f9f/builder/azure/arm/template.go (about)

     1  // Copyright (c) Microsoft Corporation. All rights reserved.
     2  // Licensed under the MIT License. See the LICENSE file in builder/azure for license information.
     3  
     4  package arm
     5  
     6  // See https://github.com/Azure/azure-quickstart-templates for a extensive list of templates.
     7  
     8  const Linux = `{
     9    "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json",
    10    "contentVersion": "1.0.0.0",
    11    "parameters": {
    12      "adminUsername": {
    13        "type": "string"
    14      },
    15      "adminPassword": {
    16        "type": "string"
    17      },
    18      "dnsNameForPublicIP": {
    19        "type": "string"
    20      },
    21      "imagePublisher": {
    22        "type": "string"
    23      },
    24      "imageOffer": {
    25        "type": "string"
    26      },
    27      "imageSku": {
    28        "type": "string"
    29      },
    30      "osDiskName": {
    31        "type": "string"
    32      },
    33      "sshAuthorizedKey": {
    34        "type": "string"
    35      },
    36      "storageAccountName": {
    37        "type": "string"
    38      },
    39      "vmSize": {
    40        "type": "string"
    41      },
    42      "vmName": {
    43        "type": "string"
    44      }
    45    },
    46    "variables": {
    47      "addressPrefix": "10.0.0.0/16",
    48      "apiVersion": "2015-06-15",
    49      "location": "[resourceGroup().location]",
    50      "nicName": "packerNic",
    51      "publicIPAddressName": "packerPublicIP",
    52      "publicIPAddressType": "Dynamic",
    53      "sshKeyPath": "[concat('/home/',parameters('adminUsername'),'/.ssh/authorized_keys')]",
    54      "subnetName": "packerSubnet",
    55      "subnetAddressPrefix": "10.0.0.0/24",
    56      "subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]",
    57      "virtualNetworkName": "packerNetwork",
    58      "vmStorageAccountContainerName": "images",
    59      "vnetID": "[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]"
    60    },
    61    "resources": [
    62      {
    63        "apiVersion": "[variables('apiVersion')]",
    64        "type": "Microsoft.Network/publicIPAddresses",
    65        "name": "[variables('publicIPAddressName')]",
    66        "location": "[variables('location')]",
    67        "properties": {
    68          "publicIPAllocationMethod": "[variables('publicIPAddressType')]",
    69          "dnsSettings": {
    70            "domainNameLabel": "[parameters('dnsNameForPublicIP')]"
    71          }
    72        }
    73      },
    74      {
    75        "apiVersion": "[variables('apiVersion')]",
    76        "type": "Microsoft.Network/virtualNetworks",
    77        "name": "[variables('virtualNetworkName')]",
    78        "location": "[variables('location')]",
    79        "properties": {
    80          "addressSpace": {
    81            "addressPrefixes": [
    82              "[variables('addressPrefix')]"
    83            ]
    84          },
    85          "subnets": [
    86            {
    87              "name": "[variables('subnetName')]",
    88              "properties": {
    89                "addressPrefix": "[variables('subnetAddressPrefix')]"
    90              }
    91            }
    92          ]
    93        }
    94      },
    95      {
    96        "apiVersion": "[variables('apiVersion')]",
    97        "type": "Microsoft.Network/networkInterfaces",
    98        "name": "[variables('nicName')]",
    99        "location": "[variables('location')]",
   100        "dependsOn": [
   101          "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]",
   102          "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]"
   103        ],
   104        "properties": {
   105          "ipConfigurations": [
   106            {
   107              "name": "ipconfig",
   108              "properties": {
   109                "privateIPAllocationMethod": "Dynamic",
   110                "publicIPAddress": {
   111                  "id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]"
   112                },
   113                "subnet": {
   114                  "id": "[variables('subnetRef')]"
   115                }
   116              }
   117            }
   118          ]
   119        }
   120      },
   121      {
   122        "apiVersion": "[variables('apiVersion')]",
   123        "type": "Microsoft.Compute/virtualMachines",
   124        "name": "[parameters('vmName')]",
   125        "location": "[variables('location')]",
   126        "dependsOn": [
   127          "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
   128        ],
   129        "properties": {
   130          "hardwareProfile": {
   131            "vmSize": "[parameters('vmSize')]"
   132          },
   133          "osProfile": {
   134            "computerName": "[parameters('vmName')]",
   135            "adminUsername": "[parameters('adminUsername')]",
   136            "adminPassword": "[parameters('adminPassword')]",
   137            "linuxConfiguration": {
   138              "disablePasswordAuthentication": "false",
   139              "ssh": {
   140                "publicKeys": [
   141                  {
   142                    "path": "[variables('sshKeyPath')]",
   143                    "keyData": "[parameters('sshAuthorizedKey')]"
   144                  }
   145                ]
   146              }
   147            }
   148          },
   149          "storageProfile": {
   150            "imageReference": {
   151              "publisher": "[parameters('imagePublisher')]",
   152              "offer": "[parameters('imageOffer')]",
   153              "sku": "[parameters('imageSku')]",
   154              "version": "latest"
   155            },
   156            "osDisk": {
   157              "name": "osdisk",
   158              "vhd": {
   159                "uri": "[concat('http://',parameters('storageAccountName'),'.blob.core.windows.net/',variables('vmStorageAccountContainerName'),'/', parameters('osDiskName'),'.vhd')]"
   160              },
   161              "caching": "ReadWrite",
   162              "createOption": "FromImage"
   163            }
   164          },
   165          "networkProfile": {
   166            "networkInterfaces": [
   167              {
   168                "id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]"
   169              }
   170            ]
   171          },
   172          "diagnosticsProfile": {
   173            "bootDiagnostics": {
   174               "enabled": "false"
   175            }
   176          }
   177        }
   178      }
   179    ]
   180  }`