adding jenkins deployment template files
This commit is contained in:
Родитель
5d71fa9788
Коммит
9b1369ee72
274
Labfiles/DevOps200.3x-CIandCD/CDwithJenkins/env/ContinuousDeploymentPartsUnlimitedMRP.json
поставляемый
Normal file
274
Labfiles/DevOps200.3x-CIandCD/CDwithJenkins/env/ContinuousDeploymentPartsUnlimitedMRP.json
поставляемый
Normal file
|
@ -0,0 +1,274 @@
|
|||
{
|
||||
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"mrpAdminUsername": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"metadata": {
|
||||
"description": "User name for the MRP Virtual Machine."
|
||||
}
|
||||
},
|
||||
"mrpDnsNameForPublicIP": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"metadata": {
|
||||
"description": "Globally unique DNS Name for the Public IP used to access the MRP Virtual Machine."
|
||||
}
|
||||
},
|
||||
"adminPublicKey": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"description": "SSH rsa public key file as a string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
"apiVersion": "2015-05-01-preview",
|
||||
"mrpImagePublisher": "Canonical",
|
||||
"mrpImageOffer": "UbuntuServer",
|
||||
"mrpImageSku": "16.04.0-LTS",
|
||||
"mrpOSDiskName": "mrpOsdisk",
|
||||
"mrpNicName": "mrpNic",
|
||||
"addressPrefix": "10.0.0.0/16",
|
||||
"subnetName": "Subnet",
|
||||
"subnetPrefix": "10.0.0.0/24",
|
||||
"storageType": "Standard_LRS",
|
||||
"publicIPAddressType": "Dynamic",
|
||||
"vhdStorageContainerName": "vhds",
|
||||
"mrpNsgName": "mrpNSG",
|
||||
"mrpVmSize": "Standard_D1_V2",
|
||||
"mrpVmName": "[toLower(parameters('mrpDnsNameForPublicIP'))]",
|
||||
"virtualNetworkName": "mrpVNET",
|
||||
"vnetId": "[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]",
|
||||
"subnetRef": "[concat(variables('vnetId'), '/subnets/', variables('subnetName'))]",
|
||||
"storageName": "[concat('vhdstorage', uniqueString(resourceGroup().id))]",
|
||||
"sshKeyPath": "[concat('/home/',parameters('mrpAdminUsername'),'/.ssh/authorized_keys')]",
|
||||
"customScript": {
|
||||
"fileUris": "https://raw.githubusercontent.com/Microsoft/PartsUnlimitedMRP/master/docs/assets/jenkins/env/install_mrp_dependencies.sh",
|
||||
"commandToExecute": "bash install_mrp_dependencies.sh"
|
||||
}
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"type": "Microsoft.Storage/storageAccounts",
|
||||
"name": "[variables('storageName')]",
|
||||
"apiVersion": "2015-06-15",
|
||||
"location": "[resourceGroup().location]",
|
||||
"tags": {
|
||||
"displayName": "StorageAccount"
|
||||
},
|
||||
"properties": {
|
||||
"accountType": "[variables('storageType')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"apiVersion": "2015-06-15",
|
||||
"type": "Microsoft.Network/publicIPAddresses",
|
||||
"name": "[parameters('mrpDnsNameForPublicIP')]",
|
||||
"location": "[resourceGroup().location]",
|
||||
"tags": {
|
||||
"displayName": "PublicIPAddress-mrp"
|
||||
},
|
||||
"properties": {
|
||||
"publicIPAllocationMethod": "[variables('publicIPAddressType')]",
|
||||
"dnsSettings": {
|
||||
"domainNameLabel": "[parameters('mrpDnsNameForPublicIP')]"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"apiVersion": "2015-06-15",
|
||||
"type": "Microsoft.Network/virtualNetworks",
|
||||
"name": "[variables('virtualNetworkName')]",
|
||||
"location": "[resourceGroup().location]",
|
||||
"tags": {
|
||||
"displayName": "VirtualNetwork"
|
||||
},
|
||||
"properties": {
|
||||
"addressSpace": {
|
||||
"addressPrefixes": [
|
||||
"[variables('addressPrefix')]"
|
||||
]
|
||||
},
|
||||
"subnets": [
|
||||
{
|
||||
"name": "[variables('subnetName')]",
|
||||
"properties": {
|
||||
"addressPrefix": "[variables('subnetPrefix')]"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"apiVersion": "2015-06-15",
|
||||
"type": "Microsoft.Network/networkSecurityGroups",
|
||||
"name": "[variables('mrpNsgName')]",
|
||||
"location": "[resourceGroup().location]",
|
||||
"tags": {
|
||||
"displayName": "NSG-mrp"
|
||||
},
|
||||
"properties": {
|
||||
"securityRules": [
|
||||
{
|
||||
"name": "SSH",
|
||||
"properties": {
|
||||
"description": "SSH port",
|
||||
"protocol": "Tcp",
|
||||
"sourcePortRange": "*",
|
||||
"destinationPortRange": "22",
|
||||
"sourceAddressPrefix": "*",
|
||||
"destinationAddressPrefix": "*",
|
||||
"access": "Allow",
|
||||
"priority": 1000,
|
||||
"direction": "Inbound"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "MRP",
|
||||
"properties": {
|
||||
"description": "MRP port",
|
||||
"protocol": "Tcp",
|
||||
"sourcePortRange": "*",
|
||||
"destinationPortRange": "9080",
|
||||
"sourceAddressPrefix": "*",
|
||||
"destinationAddressPrefix": "*",
|
||||
"access": "Allow",
|
||||
"priority": 1100,
|
||||
"direction": "Inbound"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "OrderingSvc",
|
||||
"properties": {
|
||||
"description": "OrderingService port",
|
||||
"protocol": "Tcp",
|
||||
"sourcePortRange": "*",
|
||||
"destinationPortRange": "8080",
|
||||
"sourceAddressPrefix": "*",
|
||||
"destinationAddressPrefix": "*",
|
||||
"access": "Allow",
|
||||
"priority": 1200,
|
||||
"direction": "Inbound"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"apiVersion": "2015-06-15",
|
||||
"type": "Microsoft.Network/networkInterfaces",
|
||||
"name": "[variables('mrpNicName')]",
|
||||
"location": "[resourceGroup().location]",
|
||||
"tags": {
|
||||
"displayName": "NIC-mrp"
|
||||
},
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Network/publicIPAddresses/', parameters('mrpDnsNameForPublicIP'))]",
|
||||
"[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]",
|
||||
"[concat('Microsoft.Network/networkSecurityGroups/', variables('mrpNSGName'))]"
|
||||
],
|
||||
"properties": {
|
||||
"networkSecurityGroup": {
|
||||
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('mrpNSGName'))]"
|
||||
},
|
||||
"ipConfigurations": [
|
||||
{
|
||||
"name": "ipconfig1",
|
||||
"properties": {
|
||||
"privateIPAllocationMethod": "Dynamic",
|
||||
"publicIPAddress": {
|
||||
"id": "[resourceId('Microsoft.Network/publicIPAddresses', parameters('mrpDnsNameForPublicIP'))]"
|
||||
},
|
||||
"subnet": {
|
||||
"id": "[variables('subnetRef')]"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"apiVersion": "2015-06-15",
|
||||
"type": "Microsoft.Compute/virtualMachines",
|
||||
"name": "[variables('mrpVmName')]",
|
||||
"location": "[resourceGroup().location]",
|
||||
"tags": {
|
||||
"displayName": "VM-mrp"
|
||||
},
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Storage/storageAccounts/', variables('storageName'))]",
|
||||
"[concat('Microsoft.Network/networkInterfaces/', variables('mrpNicName'))]"
|
||||
],
|
||||
"properties": {
|
||||
"hardwareProfile": {
|
||||
"vmSize": "[variables('mrpVmSize')]"
|
||||
},
|
||||
"osProfile": {
|
||||
"computerName": "[variables('mrpVmName')]",
|
||||
"adminUsername": "[parameters('mrpAdminUsername')]",
|
||||
"linuxConfiguration": {
|
||||
"disablePasswordAuthentication": "true",
|
||||
"ssh": {
|
||||
"publicKeys": [
|
||||
{
|
||||
"path": "[variables('sshKeyPath')]",
|
||||
"keyData": "[parameters('adminPublicKey')]"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"storageProfile": {
|
||||
"imageReference": {
|
||||
"publisher": "[variables('mrpImagePublisher')]",
|
||||
"offer": "[variables('mrpImageOffer')]",
|
||||
"sku": "[variables('mrpImageSku')]",
|
||||
"version": "latest"
|
||||
},
|
||||
"osDisk": {
|
||||
"name": "osdisk",
|
||||
"vhd": {
|
||||
"uri": "[concat('http://', variables('storageName'), '.blob.core.windows.net/', variables('vhdStorageContainerName'), '/', variables('mrpOSDiskName'), '.vhd')]"
|
||||
},
|
||||
"caching": "ReadWrite",
|
||||
"createOption": "FromImage"
|
||||
}
|
||||
},
|
||||
"networkProfile": {
|
||||
"networkInterfaces": [
|
||||
{
|
||||
"id": "[resourceId('Microsoft.Network/networkInterfaces', variables('mrpNicName'))]"
|
||||
}
|
||||
]
|
||||
},
|
||||
"diagnosticsProfile": {
|
||||
"bootDiagnostics": {
|
||||
"enabled": "true",
|
||||
"storageUri": "[concat('http://', variables('storageName'), '.blob.core.windows.net')]"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Compute/virtualMachines/extensions",
|
||||
"name": "[concat(variables('mrpVmName'),'/mrpsetup')]",
|
||||
"apiVersion": "[variables('apiVersion')]",
|
||||
"location": "[resourceGroup().location]",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Compute/virtualMachines/', variables('mrpVmName'))]"
|
||||
],
|
||||
"properties": {
|
||||
"publisher": "Microsoft.Azure.Extensions",
|
||||
"type": "CustomScript",
|
||||
"typeHandlerVersion": "2.0",
|
||||
"autoUpgradeMinorVersion": true,
|
||||
"settings": {
|
||||
"fileUris": "[split(variables('customScript').fileUris, ' ')]",
|
||||
"commandToExecute": "[variables('customScript').commandToExecute]"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,195 @@
|
|||
{
|
||||
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"jenkinsDnsNameForPublicIP": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"metadata": {
|
||||
"description": "Globally unique DNS Name for the Public IP used to access the MRP Virtual Machine."
|
||||
}
|
||||
},
|
||||
"jenkinsAdminPassword": {
|
||||
"type": "securestring",
|
||||
"defaultValue": "MyComplexPassw0rd",
|
||||
"metadata": {
|
||||
"description": "Password used to ssh to the vm with the user 'jenkins' "
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
"vnetId": "[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]",
|
||||
"subnetRef": "[concat(variables('vnetId'), '/subnets/', variables('subnetName'))]",
|
||||
"jenkinsVmSize" : "Standard_DS2_v2",
|
||||
"jenkinsVmName" : "[toLower(parameters('jenkinsDnsNameForPublicIP'))]",
|
||||
"jenkinsNsgName" : "jenkinsNSG",
|
||||
"storageAccountType" : "Premium_LRS",
|
||||
"addressPrefix" : "172.16.2.0/24",
|
||||
"subnetPrefix" : "172.16.2.0/24",
|
||||
"publicIPAddressType" : "Dynamic",
|
||||
"subnetName": "default",
|
||||
"virtualNetworkName" : "jenkins-test-vnet",
|
||||
"storageAccountName" : "[concat('vhdstorage', uniqueString(resourceGroup().id))]",
|
||||
"networkInterfaceName" : "jenkinsNic",
|
||||
"jenkinsAdminUsername" : "jenkinsadmin"
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"name": "[variables('jenkinsVmName')]",
|
||||
"type": "Microsoft.Compute/virtualMachines",
|
||||
"apiVersion": "2015-06-15",
|
||||
"location": "[resourceGroup().location]",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Network/networkInterfaces/', variables('networkInterfaceName'))]",
|
||||
"[concat('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]"
|
||||
],
|
||||
"properties": {
|
||||
"osProfile": {
|
||||
"computerName": "[variables('jenkinsVmName')]",
|
||||
"adminUsername": "[variables('jenkinsAdminUsername')]",
|
||||
"adminPassword": "[parameters('jenkinsAdminPassword')]"
|
||||
},
|
||||
"hardwareProfile": {
|
||||
"vmSize": "[variables('jenkinsVmSize')]"
|
||||
},
|
||||
"storageProfile": {
|
||||
"imageReference": {
|
||||
"publisher": "MicrosoftVisualStudio",
|
||||
"offer": "VisualStudio",
|
||||
"sku": "Azure-Jenkins-012",
|
||||
"version": "latest"
|
||||
},
|
||||
"osDisk": {
|
||||
"name": "[variables('jenkinsVmName')]",
|
||||
"createOption": "fromImage",
|
||||
"vhd": {
|
||||
"uri": "[concat(concat(reference(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2015-06-15').primaryEndpoints['blob'], 'vhds/'), variables('jenkinsVmName'), '20161229184318.vhd')]"
|
||||
}
|
||||
},
|
||||
"dataDisks": []
|
||||
},
|
||||
"networkProfile": {
|
||||
"networkInterfaces": [
|
||||
{
|
||||
"id": "[resourceId('Microsoft.Network/networkInterfaces', variables('networkInterfaceName'))]"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "[variables('storageAccountName')]",
|
||||
"type": "Microsoft.Storage/storageAccounts",
|
||||
"apiVersion": "2015-06-15",
|
||||
"location": "[resourceGroup().location]",
|
||||
"properties": {
|
||||
"accountType": "[variables('storageAccountType')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "[variables('virtualNetworkName')]",
|
||||
"type": "Microsoft.Network/virtualNetworks",
|
||||
"apiVersion": "2016-09-01",
|
||||
"location": "[resourceGroup().location]",
|
||||
"properties": {
|
||||
"addressSpace": {
|
||||
"addressPrefixes": [
|
||||
"[variables('addressPrefix')]"
|
||||
]
|
||||
},
|
||||
"subnets": [
|
||||
{
|
||||
"name": "[variables('subnetName')]",
|
||||
"properties": {
|
||||
"addressPrefix": "[variables('subnetPrefix')]"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "[variables('networkInterfaceName')]",
|
||||
"type": "Microsoft.Network/networkInterfaces",
|
||||
"apiVersion": "2016-09-01",
|
||||
"location": "[resourceGroup().location]",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]",
|
||||
"[concat('Microsoft.Network/publicIpAddresses/', parameters('jenkinsDnsNameForPublicIP'))]",
|
||||
"[concat('Microsoft.Network/networkSecurityGroups/', variables('jenkinsNsgName'))]"
|
||||
],
|
||||
"properties": {
|
||||
"ipConfigurations": [
|
||||
{
|
||||
"name": "ipconfig1",
|
||||
"properties": {
|
||||
"subnet": {
|
||||
"id": "[variables('subnetRef')]"
|
||||
},
|
||||
"privateIPAllocationMethod": "Dynamic",
|
||||
"publicIpAddress": {
|
||||
"id": "[resourceId('Microsoft.Network/publicIpAddresses', parameters('jenkinsDnsNameForPublicIP'))]"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"networkSecurityGroup": {
|
||||
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('jenkinsNsgName'))]"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "[parameters('jenkinsDnsNameForPublicIP')]",
|
||||
"type": "Microsoft.Network/publicIpAddresses",
|
||||
"apiVersion": "2016-09-01",
|
||||
"location": "[resourceGroup().location]",
|
||||
"properties": {
|
||||
"publicIpAllocationMethod": "[variables('publicIpAddressType')]",
|
||||
"dnsSettings" : {
|
||||
"domainNameLabel": "[parameters('jenkinsDnsNameForPublicIP')]"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "[variables('jenkinsNsgName')]",
|
||||
"type": "Microsoft.Network/networkSecurityGroups",
|
||||
"apiVersion": "2016-09-01",
|
||||
"location": "[resourceGroup().location]",
|
||||
"properties": {
|
||||
"securityRules": [
|
||||
{
|
||||
"name": "jenkins",
|
||||
"properties": {
|
||||
"priority": 1010,
|
||||
"sourceAddressPrefix": "*",
|
||||
"protocol": "*",
|
||||
"destinationPortRange": "8080",
|
||||
"access": "Allow",
|
||||
"direction": "Inbound",
|
||||
"sourcePortRange": "*",
|
||||
"destinationAddressPrefix": "*"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "default-allow-ssh",
|
||||
"properties": {
|
||||
"priority": 1000,
|
||||
"sourceAddressPrefix": "*",
|
||||
"protocol": "TCP",
|
||||
"destinationPortRange": "22",
|
||||
"access": "Allow",
|
||||
"direction": "Inbound",
|
||||
"sourcePortRange": "*",
|
||||
"destinationAddressPrefix": "*"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"outputs": {
|
||||
"jenkinsAdminUsername": {
|
||||
"type": "string",
|
||||
"value": "[variables('jenkinsAdminUsername')]"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
# Create deployment directory
|
||||
sudo mkdir -p /var/lib/partsunlimited
|
||||
|
||||
# Kill java to stop current website
|
||||
sudo pkill -9 'java'
|
||||
|
||||
# Remove old artifacts
|
||||
sudo rm -f /var/lib/partsunlimited/MongoRecords.js*
|
||||
sudo rm -f /var/lib/partsunlimited/mrp.war*
|
||||
sudo rm -f /var/lib/partsunlimited/ordering-service-0.1.0.jar*
|
||||
sudo rm -f /var/lib/partsunlimited/integration-service-0.1.0.jar
|
||||
|
||||
# Copy files from the build
|
||||
sudo find . -iname '*.?ar' -exec cp -t /var/lib/partsunlimited {} +;
|
||||
sudo find . -iname 'MongoRecords.js' -exec cp -t /var/lib/partsunlimited {} +;
|
||||
|
||||
# Add the records to ordering database on MongoDB
|
||||
sudo mongo ordering /var/lib/partsunlimited/MongoRecords.js
|
||||
|
||||
# Change Tomcat listening port from 8080 to 9080
|
||||
sudo sed -i s/8080/9080/g /etc/tomcat7/server.xml
|
||||
|
||||
# Remove existing MRP directory and copy WAR file to Tomcat directory for auto-deployment
|
||||
sudo rm -rf /var/lib/tomcat7/webapps/mrp
|
||||
sudo cp /var/lib/partsunlimited/mrp.war /var/lib/tomcat7/webapps
|
||||
|
||||
# Restart Tomcat
|
||||
sudo /etc/init.d/tomcat7 restart
|
||||
|
||||
# Run Ordering Service app
|
||||
sudo java -jar /var/lib/partsunlimited/ordering-service-0.1.0.jar &>/dev/null &
|
||||
|
||||
echo "MRP application successfully deployed. Go to http://<YourDNSname>:9080/mrp"
|
13
Labfiles/DevOps200.3x-CIandCD/CDwithJenkins/env/install_mrp_dependencies.sh
поставляемый
Normal file
13
Labfiles/DevOps200.3x-CIandCD/CDwithJenkins/env/install_mrp_dependencies.sh
поставляемый
Normal file
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Install PartsUnlimitedMRP dependencies
|
||||
apt-get update
|
||||
apt-get install openjdk-8-jdk -y
|
||||
apt-get install openjdk-8-jre -y
|
||||
apt-get install mongodb -y
|
||||
apt-get install tomcat7 -y
|
||||
apt-get install wget -y
|
||||
|
||||
# Set Java environment variables
|
||||
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
|
||||
export PATH=$PATH:/usr/lib/jvm/java-8-openjdk-amd64/bin
|
Загрузка…
Ссылка в новой задаче