Skip to content

Commit

Permalink
Remove dynamic API version resolution in outputs (elastic#144)
Browse files Browse the repository at this point in the history
Remove dynamic API version resolution in outputs (elastic#144)

- Add resource deployment conditions

Use the same resource API version in the output as used in the resource deployment

Closes elastic#143

- Add support for 5.5.2, 5.5.3, 5.6.2
- Simplify references within outputs
- Add output diffs for Kibana and Jumpbox resources
  • Loading branch information
russcam authored Oct 5, 2017
1 parent da4c04e commit 8c5bb10
Show file tree
Hide file tree
Showing 14 changed files with 77 additions and 151 deletions.
9 changes: 9 additions & 0 deletions build/allowedValues.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@
},
"5.5.1": {
"kibana": "5.5.1"
},
"5.5.2": {
"kibana": "5.5.2"
},
"5.5.3": {
"kibana": "5.5.3"
},
"5.6.2": {
"kibana": "5.6.2"
}
},
"numberOfDataNodes" : 50,
Expand Down
36 changes: 29 additions & 7 deletions build/tasks/sanity-checks.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ var filereader = require('./lib/filereader');

function checks(cb) {
var errors = [];
var mainTemplate = require("../../src/mainTemplate.json");
var mainTemplateParams = _.keys(mainTemplate.parameters);

var marketPlaceArmParity = () => {
var mainTemplate = require("../../src/mainTemplate.json");
var uiTemplate = require("../../src/createUiDefinition.json");
var mainTemplateParams = _.keys(mainTemplate.parameters);
var difference = _.difference(mainTemplateParams, _.keys(uiTemplate.parameters.outputs));
if (difference.length == 0) return;
var excludingDefault = [];
Expand All @@ -17,7 +17,7 @@ function checks(cb) {
excludingDefault.push(p);
});
if (excludingDefault.length == 0) return;
errors.push("Main template has different inputs as the ui template outputs" + excludingDefault)
errors.push("Main template has different inputs as the ui template outputs: " + excludingDefault)
}

var outputDiff = (kind, template, empty) => {
Expand All @@ -28,6 +28,30 @@ function checks(cb) {
errors.push("The " + kind +" template differs from its empty variant: " + difference);
}

var parametersParity = () => {
var parameters = [
{
name: "password",
template: require("../../parameters/password.parameters.json")
},
{
name: "ssh",
template: require("../../parameters/ssh.parameters.json")
}];

parameters.forEach(p=> {
var difference = _.difference(mainTemplateParams, _.keys(p.template));
if (difference.length == 0) return;
var excludingDefault = [];
difference.forEach(p=> {
if (mainTemplate.parameters[p] && mainTemplate.parameters[p].defaultValue) return;
excludingDefault.push(p);
});
if (excludingDefault.length == 0) return;
errors.push(p.name + " parameters has different inputs than the main template parameters" + excludingDefault)
});
}

var filter = function(filename) {
return filename.endsWith(".json");
}
Expand Down Expand Up @@ -56,14 +80,12 @@ function checks(cb) {
marketPlaceArmParity();
outputDiff("kibana", "machines/kibana-resources.json", "empty/empty-kibana-resources.json");
outputDiff("jumpbox", "machines/jumpbox-resources.json", "empty/empty-jumpbox-resources.json");
outputDiff("client", "machines/client-nodes-resources.json", "empty/empty-client-nodes-resources.json");
outputDiff("master", "machines/master-nodes-resources.json", "empty/empty-master-nodes-resources.json");
outputDiff("networks", "networks/existing-virtual-network.json", "networks/new-virtual-network.json");
parametersParity();

filereader.readFiles('../src/', filter, resourcesHaveProviderTag);

if (errors.length) {
throw new Error("Sanity checks failed:\n" + errors);
throw new Error("Sanity checks failed:\n" + errors.join('\n'));
}

cb();
Expand Down
2 changes: 1 addition & 1 deletion parameters/password.parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"vmSizeKibana":{"value":"Standard_D1"},
"kibanaCertBlob":{"value":""},
"kibanaKeyBlob":{"value":""},
"kibanaPassphrase":{"value":""},
"kibanaKeyPassphrase":{"value":""},
"jumpbox":{"value":"No"},
"vmHostNamePrefix":{"value":""},
"vmSizeDataNodes":{"value":"Standard_D1"},
Expand Down
2 changes: 1 addition & 1 deletion parameters/ssh.parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"vmSizeKibana":{"value":"Standard_D1"},
"kibanaCertBlob":{"value":""},
"kibanaKeyBlob":{"value":""},
"kibanaPassphrase":{"value":""},
"kibanaKeyPassphrase":{"value":""},
"jumpbox":{"value":"No"},
"vmHostNamePrefix":{"value":""},
"vmSizeDataNodes":{"value":"Standard_D1"},
Expand Down
14 changes: 13 additions & 1 deletion src/createUiDefinition.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"name": "esVersion",
"type": "Microsoft.Common.DropDown",
"label": "Elasticsearch version",
"defaultValue": "v5.5.1",
"defaultValue": "v5.6.2",
"toolTip": "Choose a version of Elasticsearch.",
"constraints": {
"allowedValues": [
Expand Down Expand Up @@ -113,6 +113,18 @@
{
"label": "v5.5.1",
"value": "5.5.1"
},
{
"label": "v5.5.2",
"value": "5.5.2"
},
{
"label": "v5.5.3",
"value": "5.5.3"
},
{
"label": "v5.6.2",
"value": "5.6.2"
}
]
}
Expand Down
30 changes: 0 additions & 30 deletions src/empty/empty-client-nodes-resources.json

This file was deleted.

30 changes: 0 additions & 30 deletions src/empty/empty-master-nodes-resources.json

This file was deleted.

4 changes: 2 additions & 2 deletions src/loadbalancers/external-lb-resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
}
},
{
"apiVersion": "2015-06-15",
"apiVersion": "2016-03-30",
"type": "Microsoft.Network/publicIPAddresses",
"name": "es-external-lb-ip",
"location": "[parameters('networkSettings').location]",
Expand Down Expand Up @@ -180,7 +180,7 @@
],
"outputs" : {
"fqdn": {
"value": "[concat('http://',reference(resourceId('Microsoft.Network/publicIPAddresses','es-external-lb-ip'),providers('Microsoft.Network', 'publicIPAddresses').apiVersions[0]).dnsSettings.fqdn, ':9200')]",
"value": "[concat('http://', reference(resourceId('Microsoft.Network/publicIPAddresses','es-external-lb-ip'), '2016-03-30').dnsSettings.fqdn, ':9200')]",
"type": "string"
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/loadbalancers/waf-application-gateway-resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@
],
"outputs" : {
"fqdn": {
"value": "",
"value": "N/A",
"type": "string"
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/machines/jumpbox-resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
],
"outputs": {
"ssh": {
"value": "[concat(parameters('credentials').adminUsername, '@',reference(resourceId('Microsoft.Network/publicIPAddresses',variables('publicIpName')),providers('Microsoft.Network', 'publicIPAddresses').apiVersions[0]).dnsSettings.fqdn)]",
"value": "[concat(parameters('credentials').adminUsername, '@', reference(variables('publicIpName')).dnsSettings.fqdn)]",
"type": "string"
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/machines/kibana-resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@
],
"outputs": {
"fqdn": {
"value": "[concat(variables('https'), reference(resourceId('Microsoft.Network/publicIPAddresses', variables('publicIpName')),providers('Microsoft.Network', 'publicIPAddresses').apiVersions[0]).dnsSettings.fqdn, ':5601')]",
"value": "[concat(variables('https'), reference(variables('publicIpName')).dnsSettings.fqdn, ':5601')]",
"type": "string"
}
}
Expand Down
56 changes: 15 additions & 41 deletions src/mainTemplate.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"esVersion": {
"type": "string",
"defaultValue": "5.5.1",
"defaultValue": "5.6.2",
"allowedValues": [
"2.0.2",
"2.1.2",
Expand All @@ -35,7 +35,10 @@
"5.4.2",
"5.4.3",
"5.5.0",
"5.5.1"
"5.5.1",
"5.5.2",
"5.5.3",
"5.6.2"
],
"metadata": {
"description": "Elasticsearch version to install"
Expand Down Expand Up @@ -742,31 +745,15 @@
"variables": {
"templateBaseUrl": "[concat(parameters('artifactsBaseUrl'), '/')]",
"sharedTemplateUrl": "[concat(variables('templateBaseUrl'), 'partials/shared-resources.json')]",
"networkOptions": {
"new": {
"internal": "new-virtual-network",
"external": "new-virtual-network",
"gateway": "new-virtual-network-with-gateway"
},
"existing": {
"internal": "existing-virtual-network",
"external": "existing-virtual-network",
"gateway": "existing-virtual-network"
}
},
"networkTemplateUrl": "[concat(variables('templateBaseUrl'), 'networks/', variables('networkOptions')[parameters('vNetNewOrExisting')][parameters('loadBalancerType')],'.json')]",
"networkTemplateUrl": "[concat(variables('templateBaseUrl'), 'networks/', if(equals(parameters('vNetNewOrExisting'), 'new'), if(equals(parameters('loadBalancerType'), 'gateway'), 'new-virtual-network-with-gateway', 'new-virtual-network'), 'existing-virtual-network'), '.json')]",
"loadBalancerOptions": {
"internal": "internal-lb-resources",
"external": "external-lb-resources",
"gateway": "[concat(toLower(parameters('appGatewayTier')),'-application-gateway-resources')]"
},
"loadBalancerTemplateUrl": "[concat(variables('templateBaseUrl'), 'loadbalancers/', variables('loadBalancerOptions')[parameters('loadBalancerType')],'.json')]",
"osSettingsTemplateUrl": "[concat(variables('templateBaseUrl'), 'settings/ubuntuSettings.json')]",
"locationDeployToResourceGroup": {
"true": "[resourceGroup().location]",
"false": "[parameters('location')]"
},
"location": "[variables('locationDeployToResourceGroup')[string(equals('resourcegroup', toLower(parameters('location'))))]]",
"location": "[if(equals('resourcegroup', toLower(parameters('location'))), resourceGroup().location, parameters('location'))]",
"azureCloudStorageAccount": {
"name": "[parameters('azureCloudStorageAccountName')]",
"key": "[parameters('azureCloudStorageAccountKey')]",
Expand All @@ -786,7 +773,10 @@
"5.4.2": "5.4.2",
"5.4.3": "5.4.3",
"5.5.0": "5.5.0",
"5.5.1": "5.5.1"
"5.5.1": "5.5.1",
"5.5.2": "5.5.2",
"5.5.3": "5.5.3",
"5.6.2": "5.6.2"
},
"esSettings": {
"clusterName": "[parameters('esClusterName')]",
Expand All @@ -800,22 +790,14 @@
"securityKibanaServerPwd": "[uniqueString(resourceGroup().id, deployment().name, parameters('securityKibanaPassword'))]",
"kibanaVersion": "[variables('esToKibanaMapping')[parameters('esVersion')]]"
},
"masterNodeCount": {
"No": "3",
"Yes": "0"
},
"kibanajumpboxNodeCount": {
"No": "0",
"Yes": "1"
},
"phoneHomeSettings": {
"email": "[parameters('userEmail')]",
"firstName": "[parameters('userFirstName')]",
"lastName": "[parameters('userLastName')]",
"jobTitle": "[parameters('userJobTitle')]",
"company": "[parameters('userCompany')]",
"country": "[parameters('userCountry')]",
"topology": "[concat('m=', variables('masterNodeCount')[parameters('dataNodesAreMasterEligible')], ' ', parameters('vmSizeMasterNodes'), ',d=', parameters('vmDataNodeCount'), ' ', parameters('vmSizeDataNodes'), ',c=', parameters('vmClientNodeCount'), ' ', parameters('vmSizeClientNodes'), ',k=', variables('kibanajumpboxNodeCount')[parameters('kibana')], ' ', parameters('vmSizeKibana'), ',j=', variables('kibanajumpboxNodeCount')[parameters('jumpbox')], ' Standard_A0', ',l=', parameters('loadBalancerType'))]"
"topology": "[concat('m=', if(equals(parameters('dataNodesAreMasterEligible'), 'No'), '3', '0'), ' ', parameters('vmSizeMasterNodes'), ',d=', parameters('vmDataNodeCount'), ' ', parameters('vmSizeDataNodes'), ',c=', parameters('vmClientNodeCount'), ' ', parameters('vmSizeClientNodes'), ',k=', if(equals(parameters('kibana'), 'Yes'), '1', '0'), ' ', parameters('vmSizeKibana'), ',j=', if(equals(parameters('jumpbox'), 'Yes'), '1', '0'), ' Standard_A0', ',l=', parameters('loadBalancerType'))]"
},
"networkResourceGroupMap": {
"new": "[resourceGroup().name]",
Expand Down Expand Up @@ -1141,16 +1123,7 @@
"nodesPerStorageAccount": "[variables('nodesPerStorageMapping')[concat(variables('resolvedStorageAccountType'), '_', parameters('vmDataDiskSize'), '_', string(variables('numberOfDataDisks')))]]",
"nodesPerStorageAccountDiv": "[div(add(add(1, variables('nodesPerStorageAccount')), int(replace(string(sub(1, variables('nodesPerStorageAccount'))), '-', ''))), 2)]",
"storageAccountsCount": "[add(div(parameters('vmDataNodeCount'), variables('nodesPerStorageAccountDiv')), mod(add(mod(parameters('vmDataNodeCount'), variables('nodesPerStorageAccountDiv')),2), add(mod(parameters('vmDataNodeCount'), variables('nodesPerStorageAccountDiv')),1)))]",
"enableAnonymousAccessOpts": {
"internal": "No",
"external": "No",
"gateway": "Yes"
},
"kibanaHttpsOpts": [
"No",
"Yes"
],
"kibanaHttps": "[variables('kibanaHttpsOpts')[mul(length(take(parameters('kibanaKeyBlob'), 1)), length(take(parameters('kibanaCertBlob'), 1)))]]",
"kibanaHttps": "[if(and(greater(length(parameters('kibanaKeyBlob')), 0), greater(length(parameters('kibanaCertBlob')), 0)), 'Yes', 'No')]",
"topologySettings": {
"dataNodesAreMasterEligible": "[parameters('dataNodesAreMasterEligible')]",
"vmDataNodeCount": "[parameters('vmDataNodeCount')]",
Expand All @@ -1176,7 +1149,7 @@
},
"dataLoadBalancerBackEndPools": "[variables('dataLoadBalancerOptions')[variables('clientResourceIndex')].backendPools]",
"loadBalancerBackEndPools": "[variables('lbBackEndPoolsAdded').backendPools]",
"enableAnonymousAccess": "[variables('enableAnonymousAccessOpts')[parameters('loadBalancerType')]]"
"enableAnonymousAccess": "[if(equals(parameters('loadBalancerType'), 'gateway'), 'Yes', 'No')]"
},
"networkSettings": {
"name": "[parameters('vNetName')]",
Expand Down Expand Up @@ -1241,6 +1214,7 @@
}
},
{
"condition": "[equals(parameters('vNetNewOrExisting'), 'new')]",
"name": "network",
"type": "Microsoft.Resources/deployments",
"apiVersion": "2016-02-01",
Expand Down
22 changes: 0 additions & 22 deletions src/networks/existing-virtual-network.json

This file was deleted.

Loading

0 comments on commit 8c5bb10

Please sign in to comment.