-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit add39dd
Showing
36 changed files
with
1,977 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
{ | ||
"$schema":"http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json", | ||
"contentVersion":"1.0.0.0", | ||
"parameters":{}, | ||
"variables":{}, | ||
"resources":[], | ||
|
||
"outputs":{ | ||
"aliases":{ | ||
"type":"object", | ||
"value":{ | ||
|
||
"Linux":{ | ||
"CentOS":{ | ||
"publisher":"OpenLogic", | ||
"offer":"CentOS", | ||
"sku":"7.3", | ||
"version":"latest" | ||
}, | ||
"CoreOS":{ | ||
"publisher":"CoreOS", | ||
"offer":"CoreOS", | ||
"sku":"Stable", | ||
"version":"latest" | ||
}, | ||
"Debian":{ | ||
"publisher":"credativ", | ||
"offer":"Debian", | ||
"sku":"8", | ||
"version":"latest" | ||
}, | ||
"openSUSE-Leap": { | ||
"publisher":"SUSE", | ||
"offer":"openSUSE-Leap", | ||
"sku":"42.2", | ||
"version": "latest" | ||
}, | ||
"RHEL":{ | ||
"publisher":"RedHat", | ||
"offer":"RHEL", | ||
"sku":"7.3", | ||
"version":"latest" | ||
}, | ||
"SLES":{ | ||
"publisher":"SUSE", | ||
"offer":"SLES", | ||
"sku":"12-SP2", | ||
"version":"latest" | ||
}, | ||
"UbuntuLTS":{ | ||
"publisher":"Canonical", | ||
"offer":"UbuntuServer", | ||
"sku":"16.04-LTS", | ||
"version":"latest" | ||
} | ||
}, | ||
|
||
"Windows":{ | ||
"Win2016Datacenter":{ | ||
"publisher":"MicrosoftWindowsServer", | ||
"offer":"WindowsServer", | ||
"sku":"2016-Datacenter", | ||
"version":"latest" | ||
}, | ||
"Win2012R2Datacenter":{ | ||
"publisher":"MicrosoftWindowsServer", | ||
"offer":"WindowsServer", | ||
"sku":"2012-R2-Datacenter", | ||
"version":"latest" | ||
}, | ||
"Win2012Datacenter":{ | ||
"publisher":"MicrosoftWindowsServer", | ||
"offer":"WindowsServer", | ||
"sku":"2012-Datacenter", | ||
"version":"latest" | ||
}, | ||
"Win2008R2SP1":{ | ||
"publisher":"MicrosoftWindowsServer", | ||
"offer":"WindowsServer", | ||
"sku":"2008-R2-SP1", | ||
"version":"latest" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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,93 @@ | ||
local network = { | ||
LoadBalancer: import 'network/LoadBalancer/loadBalancer.libsonnet', | ||
PublicIpAddress: import 'network/PublicIpAddress/module.libsonnet', | ||
VirtualNetwork: import 'network/VirtualNetwork/module.libsonnet', | ||
}; | ||
local compute = { | ||
VirtualMachineScaleSet: import 'compute/VirtualMachineScaleSet/virtualMachineScaleSet.libsonnet' | ||
}; | ||
|
||
local core = import 'core/module.libsonnet'; | ||
local Module = import 'core/moduledef.libsonnet'; | ||
|
||
Module { | ||
|
||
parameterMetadata:: import 'parameters.libsonnet', | ||
|
||
imageFromAlias(aliasOrImage):: | ||
// | ||
// extract display name from the content/vm_aliases.json file. The content/vm_aliases file | ||
// can be found at: | ||
// https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/arm-compute/quickstart-templates/aliases.json | ||
// | ||
assert std.type(aliasOrImage) == 'object' || std.type(aliasOrImage) == 'string' : "imageFromAlias parameter expected 'object' or 'string' type parameter - got %s" % [ std.type(aliasOrImage) ]; | ||
local vmImages = (import 'cli/content/vm_alisases.json').outputs.aliases.value; | ||
if std.type(aliasOrImage) == 'string' && std.objectHas(vmImages.Linux, aliasOrImage) then | ||
vmImages.Linux[aliasOrImage] | ||
else if std.type(aliasOrImage) == 'string' && std.objectHas(vmImages.Windows, aliasOrImage) then | ||
vmImages.Windows[aliasOrImage] | ||
else | ||
assert std.type(aliasOrImage) == 'object' : "Unable to find image '%s'" % [ aliasOrImage ]; | ||
aliasOrImage, | ||
|
||
// Build a virtual network if one is not provided. | ||
virtualNetwork:: | ||
// Optionally build a virtual network. | ||
local shouldCreateVnet = $.arguments.virtualNetwork == '[new]'; | ||
if shouldCreateVnet then | ||
network.VirtualNetwork.new( | ||
'%sVNET' % [ $.arguments.name ], | ||
addressPrefix='10.0.0.0/16') | ||
.withSubnet('%sSubnet' % [ $.arguments.name ], addressPrefix='10.0.0.0/24') | ||
else | ||
$.arguments.virtualNetwork, | ||
|
||
// Build a public IP Address unless on is provided, or the parameters | ||
// indicate that one is not wanted... | ||
publicIpAddress:: | ||
// Optionally build a public ip address | ||
local shouldCreatePublicIpAddress = $.arguments.publicIpAddress == null; | ||
if shouldCreatePublicIpAddress then | ||
network.PublicIpAddress.new('%sLBPublicIP' % [ $.arguments.name ]) | ||
.withAllocationMethod($.arguments.publicIpAllocationMethod) | ||
else | ||
$.arguments.publicIpAddress, | ||
|
||
// Build a front facing load balancer unless on is provided, or the | ||
// parameters indicate that one is not wanted... | ||
loadBalancer:: | ||
local shouldCreateLoadBalancer = $.arguments.loadBalancer == null; | ||
if shouldCreateLoadBalancer then | ||
network.LoadBalancer.new('%sLB' % [ $.arguments.name ], sku= $.arguments.loadBalancerSku) | ||
.withIpConfiguration('loadBalancerFrontEnd') | ||
.withPublicIpAddress($.publicIpAddress) | ||
.withBackendAddressPool($.arguments.backendPoolName) | ||
.withNatRule($.arguments.authenticationType), | ||
|
||
// Build all resources created by the module... | ||
virtualMachineScaleSet:: | ||
compute.VirtualMachineScaleSet.new( | ||
name= $.arguments.name, | ||
osType = 'linux', // UNDONE - support windows again | ||
imageReference = self.imageFromAlias($.arguments.imageReference), | ||
overProvision = ! $.arguments.disableOverprovision, | ||
capacity = $.arguments.instanceCount, | ||
upgradePolicy = $.arguments.upgradePolicy, | ||
skuName = $.arguments.vmSku | ||
) | ||
.withAuth($.arguments.adminUserName, $.arguments.adminPassword, $.arguments.sshPublicKeys) | ||
.withIdentity($.arguments.identity) | ||
.behindLoadBalancer($.loadBalancer, $.virtualNetwork, $.arguments.subnet) | ||
.withDataDisks($.arguments.dataDiskSizes, $.arguments.dataDiskCaching), | ||
|
||
outputs: { | ||
virtualMachineScaleSet: { | ||
type: 'string', | ||
value: $.virtualMachineScaleSet.id | ||
}, | ||
[if $.virtualNetwork != null then 'virtualNetwork']: { | ||
type: 'string', | ||
value: core.resourceId($.virtualNetwork) | ||
} | ||
} | ||
} |
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,13 @@ | ||
local m = import './module.libsonnet'; | ||
|
||
function(params) | ||
m { | ||
parameters: { | ||
[k]: ((params.parameters)[k]).value | ||
for k in std.objectFieldsAll(params.parameters) | ||
}, | ||
} { | ||
'$schema': 'https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#', | ||
contentVersion: '0.0.0.1' | ||
} | ||
|
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,118 @@ | ||
{ | ||
name: { | ||
type: 'string' | ||
}, | ||
imageReference: { | ||
type: ['string', 'object'], | ||
}, | ||
adminUserName: { | ||
type: 'string' | ||
}, | ||
location: { | ||
type: 'string' | ||
}, | ||
disableOverprovision: { | ||
type: 'boolean', | ||
defaultValue: false, | ||
}, | ||
instanceCount: { | ||
type: 'integer', | ||
defaultValue: 2, | ||
}, | ||
upgradePolicy: { | ||
type: 'string', | ||
defaultValue: 'manual', | ||
}, | ||
adminPassword: { | ||
type: 'string', | ||
defaultValue: null | ||
}, | ||
authenticationType: { | ||
type: 'string', | ||
defaultValue: if $.osType == 'Windows' then 'rdp' else 'ssh', | ||
}, | ||
vmSku: { | ||
type: 'string', | ||
defaultValue: 'Standard_D1_v2', | ||
}, | ||
sshPublicKeys: { | ||
type: 'string', | ||
defaultValue: [], | ||
}, | ||
loadBalancer: { | ||
type: ['object', 'string'], | ||
defaultValue: null, // { sku: null }, | ||
}, | ||
loadBalancerSku: { | ||
type: 'string', | ||
defaultValue: null, | ||
}, | ||
virtualNetwork: { | ||
type: [ 'object', 'string' ], | ||
defaultValue: '[new]', | ||
}, | ||
backendPoolName: { | ||
type: 'string', | ||
defaultValue: null, | ||
}, | ||
natPoolName: { | ||
type: 'string', | ||
defaultValue: null, | ||
}, | ||
backendPort: { | ||
type: 'string', | ||
defaultValue: null, | ||
}, | ||
publicIpAllocationMethod: { | ||
type: 'string', | ||
defaultValue: 'dynamic', | ||
}, | ||
dataDiskSizes: { | ||
type: ['array', 'number' ], | ||
defaultValue: [], | ||
}, | ||
osType: { | ||
type: 'string', | ||
defaultValue: null, // error "'osType' is a required parameters", | ||
}, | ||
subnet: { | ||
type: [ 'string', 'object' ], | ||
defaultValue: null, | ||
}, | ||
customData: { | ||
type: 'string', | ||
defaultValue: null, | ||
}, | ||
licenseType: { | ||
type: 'string', | ||
defaultValue: null, | ||
}, | ||
singlePlacementGroup: { | ||
type: 'boolean', | ||
defaultValue: $.instanceCount <= 100, | ||
}, | ||
publicIpAddress: { | ||
type: [ 'string', 'object' ], | ||
defaultValue: null, | ||
}, | ||
publicIpAddressDnsName: { | ||
type: 'string', | ||
defaultValue: null, | ||
}, | ||
publicIpAddressPerVm: { | ||
type: 'boolean', | ||
defaultValue: false, | ||
}, | ||
zones: { | ||
type: 'array', | ||
defaultValue: [], | ||
}, | ||
dataDiskCaching: { | ||
type: 'string', | ||
defaultValue: null, | ||
}, | ||
identity: { | ||
type: [ 'array', 'string' ], | ||
defaultValue:null | ||
} | ||
} |
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,60 @@ | ||
{ | ||
"$schema":"http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json", | ||
"contentVersion":"1.0.0.0", | ||
"parameters":{}, | ||
"variables":{}, | ||
"resources":[ | ||
{ | ||
"name": "TheVnet", | ||
"type": "Microsoft.JohanSte/modules", | ||
"apiVersion": "1971-11--01", | ||
"properties": { | ||
"module": "network/VirtualNetwork/module.libsonnet", | ||
"name": "vnet" | ||
} | ||
}, | ||
{ | ||
"name": "PublicIpAddress", | ||
"type": "Microsoft.JohanSte/modules", | ||
"apiVersion": "1971-11-01", | ||
"properties": { | ||
"name": "pip", | ||
"module": "network/PublicIpAddress/module.libsonnet" | ||
} | ||
}, | ||
{ | ||
"name": "FirstVmssModule", | ||
"type": "Microsoft.JohanSte/modules", | ||
"apiVersion": "1971-11-01", | ||
"properties": { | ||
"module": "cli/vmss/module.libsonnet", | ||
"name": "thisIsSoMuchSimpler", | ||
"adminUserName": "johanste", | ||
"imageReference": "UbuntuLTS", | ||
"sshPublicKeys": [ "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCXwbIlLS57sL6S7LKplMtT1UJLZXkKNaWmLum1r+MMqncIFVdWbqsjSB1hHYxjFP5VxR/cK5Kq1jmAq57S6JeOlC1JC86Ka+S5EHrboZo1t/zNbAFRcQXxdLgqSB3767Q24W48fhhKngCKuVJ8bvvwTC0WskgY2ePlwlG1Erfzc0twnVkHOYISM0zFGEdKcjqYR1PaYXmaPzaZsFMQAv3ymUd1hM4mj3ZfHm34M4rxjlUaTrhxVdN5z2TBHFjJa6YLulmex9g4MRaaHQU9xDL5BXpWHRmyepQ+P1KBjOd9VUam789+BCYaQ5ZC/9XaPDVvwOUkQaF7PinNgI98Nx+T [email protected]\n" ], | ||
"dataDiskSizes": 1023, | ||
"identity": "[system]", | ||
"publicIpAddress": "[reference('PublicIpAddress').outputs.id.value]" | ||
} | ||
}, | ||
{ | ||
"name": "SecondVmssModule", | ||
"type": "Microsoft.JohanSte/modules", | ||
"apiVersion": "1971-11-01", | ||
"dependsOn": ["TheVnet"], | ||
"properties": { | ||
"module": "cli/vmss/module.libsonnet", | ||
"name": "othevmms", | ||
"adminUserName": "johanste", | ||
"imageReference": "UbuntuLTS", | ||
"sshPublicKeys": [ "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCXwbIlLS57sL6S7LKplMtT1UJLZXkKNaWmLum1r+MMqncIFVdWbqsjSB1hHYxjFP5VxR/cK5Kq1jmAq57S6JeOlC1JC86Ka+S5EHrboZo1t/zNbAFRcQXxdLgqSB3767Q24W48fhhKngCKuVJ8bvvwTC0WskgY2ePlwlG1Erfzc0twnVkHOYISM0zFGEdKcjqYR1PaYXmaPzaZsFMQAv3ymUd1hM4mj3ZfHm34M4rxjlUaTrhxVdN5z2TBHFjJa6YLulmex9g4MRaaHQU9xDL5BXpWHRmyepQ+P1KBjOd9VUam789+BCYaQ5ZC/9XaPDVvwOUkQaF7PinNgI98Nx+T [email protected]\n" ], | ||
"dataDiskSizes": 1023, | ||
"identity": "[system]", | ||
"virtualNetwork": "vnet", | ||
"subnet": "default" | ||
} | ||
} | ||
], | ||
|
||
"outputs":{} | ||
} |
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,11 @@ | ||
(import 'cli/vmss/module.libsonnet') | ||
{ | ||
parameters:: { | ||
name: 'complex', | ||
adminUserName: 'johanste', | ||
imageReference: 'UbuntuLTS', | ||
adminPassword: 'super$ecret3611', | ||
dataDiskSizes: [1024, 2024, 2048], | ||
publicIpAddress: null, | ||
} | ||
} |
Oops, something went wrong.