-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
548 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
simpleazure.template.compile | ||
This module compiles Azure Resource Manager Templates | ||
:copyright: | ||
:license: | ||
""" | ||
|
||
from reader import Reader | ||
from template import Template | ||
|
||
class Compile(object): | ||
"""Constructs a :class:`Compile <NEW>`. | ||
Returns :class:`Compile <NEW>` instance. | ||
Usage:: | ||
""" | ||
|
||
def __init__(self): | ||
self.template = Template() | ||
self.reader = Reader() | ||
|
||
|
||
def main(): | ||
template_deployment = Compile() | ||
temp = template_deployment.reader.get_defaults() | ||
asvm = temp['azuredeploy'] | ||
# read arm class | ||
# set parameter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,203 @@ | ||
{ | ||
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json", | ||
"contentVersion": "1.0.0.0", | ||
"parameters": { | ||
"adminUserName": { | ||
"type": "string", | ||
"defaultValue": "azureuser", | ||
"metadata": { | ||
"description": "User name for the Virtual Machine." | ||
} | ||
}, | ||
"sshKeyData": { | ||
"type": "string", | ||
"metadata": { | ||
"description": "SSH rsa public key file as a string." | ||
} | ||
} | ||
}, | ||
"variables": { | ||
"vmSize": "Standard_DS2", | ||
"vmName": "sshvm", | ||
"ubuntuOSVersion": "14.04.4-LTS", | ||
"storageAccountName": "[concat(uniquestring(resourceGroup().id), 'sasshvm')]", | ||
"uniqueDnsLabelPrefix": "[concat('store', uniquestring(resourceGroup().id))]", | ||
"location": "[resourceGroup().location]", | ||
"imagePublisher": "Canonical", | ||
"imageOffer": "UbuntuServer", | ||
"osDiskName": "osDisk1", | ||
"addressPrefix": "10.0.0.0/16", | ||
"subnet1Name": "Subnet-1", | ||
"subnet1Prefix": "10.0.0.0/24", | ||
"vmStorageAccountContainerName": "vhds", | ||
"nicName": "sshNIC", | ||
"publicIPAddressName": "sshPublicIP", | ||
"publicIPAddressType": "Dynamic", | ||
"storageAccountType": "Premium_LRS", | ||
"virtualNetworkName": "sshVNET", | ||
"networkSecurityGroupName": "networkSecurityGroup1", | ||
"sshKeyPath": "[concat('/home/',parameters('adminUserName'),'/.ssh/authorized_keys')]", | ||
"vnetID": "[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]", | ||
"subnet1Ref": "[concat(variables('vnetID'),'/subnets/',variables('subnet1Name'))]", | ||
"apiVersion": "2015-06-15" | ||
}, | ||
"resources": [ | ||
{ | ||
"type": "Microsoft.Storage/storageAccounts", | ||
"name": "[variables('storageAccountName')]", | ||
"apiVersion": "[variables('apiVersion')]", | ||
"location": "[variables('location')]", | ||
"properties": { | ||
"accountType": "[variables('storageAccountType')]" | ||
} | ||
}, | ||
{ | ||
"apiVersion": "[variables('apiVersion')]", | ||
"type": "Microsoft.Network/networkSecurityGroups", | ||
"name": "[variables('networkSecurityGroupName')]", | ||
"location": "[variables('location')]", | ||
"properties": { | ||
"securityRules": [ | ||
{ | ||
"name": "ssh_rule", | ||
"properties": { | ||
"description": "Locks inbound down to ssh default port 22.", | ||
"protocol": "Tcp", | ||
"sourcePortRange": "*", | ||
"destinationPortRange": "22", | ||
"sourceAddressPrefix": "*", | ||
"destinationAddressPrefix": "*", | ||
"access": "Allow", | ||
"priority": 123, | ||
"direction": "Inbound" | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"apiVersion": "[variables('apiVersion')]", | ||
"type": "Microsoft.Network/publicIPAddresses", | ||
"name": "[variables('publicIPAddressName')]", | ||
"location": "[variables('location')]", | ||
"properties": { | ||
"publicIPAllocationMethod": "[variables('publicIPAddressType')]", | ||
"dnsSettings": { | ||
"domainNameLabel": "[variables('uniqueDnsLabelPrefix')]" | ||
} | ||
} | ||
}, | ||
{ | ||
"apiVersion": "[variables('apiVersion')]", | ||
"type": "Microsoft.Network/virtualNetworks", | ||
"name": "[variables('virtualNetworkName')]", | ||
"location": "[variables('location')]", | ||
"dependsOn": [ | ||
"[concat('Microsoft.Network/networkSecurityGroups/', variables('networkSecurityGroupName'))]" | ||
], | ||
"properties": { | ||
"addressSpace": { | ||
"addressPrefixes": [ | ||
"[variables('addressPrefix')]" | ||
] | ||
}, | ||
"subnets": [ | ||
{ | ||
"name": "[variables('subnet1Name')]", | ||
"properties": { | ||
"addressPrefix": "[variables('subnet1Prefix')]", | ||
"networkSecurityGroup": { | ||
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName'))]" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"apiVersion": "[variables('apiVersion')]", | ||
"type": "Microsoft.Network/networkInterfaces", | ||
"name": "[variables('nicName')]", | ||
"location": "[variables('location')]", | ||
"dependsOn": [ | ||
"[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]", | ||
"[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]" | ||
], | ||
"properties": { | ||
"ipConfigurations": [ | ||
{ | ||
"name": "ipconfig1", | ||
"properties": { | ||
"privateIPAllocationMethod": "Dynamic", | ||
"publicIPAddress": { | ||
"id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]" | ||
}, | ||
"subnet": { | ||
"id": "[variables('subnet1Ref')]" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"apiVersion": "[variables('apiVersion')]", | ||
"type": "Microsoft.Compute/virtualMachines", | ||
"name": "[variables('vmName')]", | ||
"location": "[variables('location')]", | ||
"dependsOn": [ | ||
"[concat('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]", | ||
"[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]" | ||
], | ||
"properties": { | ||
"hardwareProfile": { | ||
"vmSize": "[variables('vmSize')]" | ||
}, | ||
"osProfile": { | ||
"computerName": "[variables('vmName')]", | ||
"adminUsername": "[parameters('adminUserName')]", | ||
"linuxConfiguration": { | ||
"disablePasswordAuthentication": "true", | ||
"ssh": { | ||
"publicKeys": [ | ||
{ | ||
"path": "[variables('sshKeyPath')]", | ||
"keyData": "[parameters('sshKeyData')]" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"storageProfile": { | ||
"imageReference": { | ||
"publisher": "[variables('imagePublisher')]", | ||
"offer": "[variables('imageOffer')]", | ||
"sku": "[variables('ubuntuOSVersion')]", | ||
"version": "latest" | ||
}, | ||
"osDisk": { | ||
"name": "osdisk", | ||
"vhd": { | ||
"uri": "[concat('http://',variables('storageAccountName'),'.blob.core.windows.net/',variables('vmStorageAccountContainerName'),'/', variables('osDiskName'),'.vhd')]" | ||
}, | ||
"caching": "ReadWrite", | ||
"createOption": "FromImage" | ||
} | ||
}, | ||
"networkProfile": { | ||
"networkInterfaces": [ | ||
{ | ||
"id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
], | ||
"outputs": { | ||
"sshCommand": { | ||
"type": "string", | ||
"value": "[concat('ssh ', parameters('adminUsername'), '@', variables('uniqueDnsLabelPrefix'), '.', resourceGroup().location, '.cloudapp.azure.com')]" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"apiVersion": "[variables('apiVersion')]", | ||
"type": "Microsoft.Network/networkSecurityGroups", | ||
"name": "[variables('networkSecurityGroupName')]", | ||
"location": "[variables('location')]", | ||
"properties": { | ||
"securityRules": [ | ||
{ | ||
"name": "ssh_rule", | ||
"properties": { | ||
"description": "Locks inbound down to ssh default port 22.", | ||
"protocol": "Tcp", | ||
"sourcePortRange": "*", | ||
"destinationPortRange": "22", | ||
"sourceAddressPrefix": "*", | ||
"destinationAddressPrefix": "*", | ||
"access": "Allow", | ||
"priority": 123, | ||
"direction": "Inbound" | ||
} | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"apiVersion": "[variables('apiVersion')]", | ||
"type": "Microsoft.Network/networkInterfaces", | ||
"name": "[variables('nicName')]", | ||
"location": "[variables('location')]", | ||
"dependsOn": [ | ||
"[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]", | ||
"[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]" | ||
], | ||
"properties": { | ||
"ipConfigurations": [ | ||
{ | ||
"name": "ipconfig1", | ||
"properties": { | ||
"privateIPAllocationMethod": "Dynamic", | ||
"publicIPAddress": { | ||
"id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]" | ||
}, | ||
"subnet": { | ||
"id": "[variables('subnet1Ref')]" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"apiVersion": "[variables('apiVersion')]", | ||
"type": "Microsoft.Network/publicIPAddresses", | ||
"name": "[variables('publicIPAddressName')]", | ||
"location": "[variables('location')]", | ||
"properties": { | ||
"publicIPAllocationMethod": "[variables('publicIPAddressType')]", | ||
"dnsSettings": { | ||
"domainNameLabel": "[variables('uniqueDnsLabelPrefix')]" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"type": "Microsoft.Storage/storageAccounts", | ||
"name": "[variables('storageAccountName')]", | ||
"apiVersion": "[variables('apiVersion')]", | ||
"location": "[variables('location')]", | ||
"properties": { | ||
"accountType": "[variables('storageAccountType')]" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"apiVersion": "[variables('apiVersion')]", | ||
"type": "Microsoft.Network/virtualNetworks", | ||
"name": "[variables('virtualNetworkName')]", | ||
"location": "[variables('location')]", | ||
"dependsOn": [ | ||
"[concat('Microsoft.Network/networkSecurityGroups/', variables('networkSecurityGroupName'))]" | ||
], | ||
"properties": { | ||
"addressSpace": { | ||
"addressPrefixes": [ | ||
"[variables('addressPrefix')]" | ||
] | ||
}, | ||
"subnets": [ | ||
{ | ||
"name": "[variables('subnet1Name')]", | ||
"properties": { | ||
"addressPrefix": "[variables('subnet1Prefix')]", | ||
"networkSecurityGroup": { | ||
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName'))]" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} |
Oops, something went wrong.