зеркало из https://github.com/microsoft/Atlas.git
Adding arm template deployment subworkflow to library (#118)
* Adding arm template deployment subworkflow to library * Adding to sub-workflow readme file * Updating package description
This commit is contained in:
Родитель
8a66da47d0
Коммит
546c177c7f
|
@ -0,0 +1,155 @@
|
|||
|
||||
# Azure resource manager template deployment
|
||||
|
||||
Deploys an ARM template to Azure.
|
||||
|
||||
Waits until the deployment has succeeded or fails.
|
||||
|
||||
``` yaml
|
||||
info:
|
||||
title: azure-deployment
|
||||
version: 0.1
|
||||
description: Deploys an ARM template to Azure
|
||||
contact:
|
||||
name: Microsoft
|
||||
url: https://github.com/Microsoft/Atlas/issues/new
|
||||
license:
|
||||
name: MIT
|
||||
url: https://github.com/Microsoft/Atlas/blob/master/LICENSE
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Example 1: Invoking as a sub-workflow
|
||||
|
||||
**readme.md**
|
||||
````
|
||||
# My Workflow
|
||||
|
||||
I am importing the following sub-workflows from github.
|
||||
|
||||
It is a good idea to replace 'master' with a sha.
|
||||
|
||||
``` yaml
|
||||
workflows:
|
||||
github-atlas-library:
|
||||
source: https://github.com/Microsoft/Atlas/tree/master/library
|
||||
inputs:
|
||||
- azure-deployment
|
||||
```
|
||||
````
|
||||
|
||||
**values.yaml**
|
||||
```
|
||||
azure:
|
||||
tenant: <YOUR-AAD-TENANT-ID>
|
||||
subscription: <YOUR-SUBSCRIPTION-ID>
|
||||
resourceGroup: <TARGET-RESOURCE-GROUP>
|
||||
location: <TARGET-AZURE-LOCATION>
|
||||
```
|
||||
|
||||
**workflow.yaml**
|
||||
```
|
||||
operations:
|
||||
- message: render arm template and store results
|
||||
template: my/azuredeploy.json
|
||||
output:
|
||||
my-azuredeploy: ( result )
|
||||
|
||||
- message: render parameters and store results
|
||||
template: my/azuredeploy.parameters.json
|
||||
output:
|
||||
my-azuredeploy-parameters: ( result.parameters )
|
||||
|
||||
- workflow: workflows/azure-deployment
|
||||
values:
|
||||
azure: ( azure )
|
||||
deploymentName: my-deployment-{{ guid (datetime add="PT0S") }} # random suffix on deployment name preserves history
|
||||
deployment:
|
||||
parameters: ( my-azuredeploy-parameters )
|
||||
template: ( my-azuredeploy )
|
||||
output:
|
||||
my-outputs: ( result.properties.outputs ) # any arm "outputs" stored here
|
||||
```
|
||||
|
||||
### Example 2: Executing as a standalone workflow
|
||||
|
||||
**my-values.yaml**
|
||||
```
|
||||
azure:
|
||||
tenant: <YOUR-AAD-TENANT-ID>
|
||||
subscription: <YOUR-SUBSCRIPTION-ID>
|
||||
resourceGroup: <TARGET-RESOURCE-GROUP>
|
||||
location: <TARGET-AZURE-LOCATION>
|
||||
|
||||
deployment:
|
||||
template: {
|
||||
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"storageAccountType": {
|
||||
"type": "string",
|
||||
"defaultValue": "Standard_LRS"
|
||||
},
|
||||
"location": {
|
||||
"type": "string",
|
||||
"defaultValue": "[resourceGroup().location]",
|
||||
"metadata": {
|
||||
"description": "Location for all resources."
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
"storageAccountName": "[concat('store', uniquestring(resourceGroup().id))]"
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"type": "Microsoft.Storage/storageAccounts",
|
||||
"name": "[variables('storageAccountName')]",
|
||||
"location": "[parameters('location')]",
|
||||
"apiVersion": "2018-07-01",
|
||||
"sku": {
|
||||
"name": "[parameters('storageAccountType')]"
|
||||
},
|
||||
"kind": "StorageV2",
|
||||
"properties": {}
|
||||
}
|
||||
],
|
||||
"outputs": {
|
||||
"storageAccountName": {
|
||||
"type": "string",
|
||||
"value": "[variables('storageAccountName')]"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Deploying this template:
|
||||
|
||||
```
|
||||
atlas deploy -f my-values.yaml https://github.com/Microsoft/Atlas/tree/master/library/azure-deployment
|
||||
```
|
||||
|
||||
Deploying with debug details:
|
||||
|
||||
```
|
||||
atlas deploy -f my-values.yaml --set deployment.debugSetting.detailLevel=requestContent,responseContent https://github.com/Microsoft/Atlas/tree/master/library/azure-deployment
|
||||
```
|
||||
|
||||
## Dependencies
|
||||
|
||||
This workflow calls the following REST APIs
|
||||
|
||||
``` yaml
|
||||
swagger:
|
||||
resources:
|
||||
target: apis/azure
|
||||
source: https://github.com/Azure/azure-rest-api-specs/tree/8cc682832ab95838806bf080152759c1898063da/specification/resources/resource-manager/
|
||||
inputs:
|
||||
- Microsoft.Resources/stable/2018-05-01/resources.json
|
||||
extra:
|
||||
auth:
|
||||
tenant: "{{ azure.tenant }}"
|
||||
resource: https://management.azure.com/
|
||||
client: 04b07795-8ddb-461a-bbee-02f9e1bf7b46 # Azure CLI
|
||||
```
|
|
@ -0,0 +1,38 @@
|
|||
azure:
|
||||
# tenant: 00000000-0000-0000-0000-000000000000 # Azure AD tenantId
|
||||
# subscription: 00000000-0000-0000-0000-000000000000 # Azure subscriptionId
|
||||
# resourceGroup: YOUR-RESOURCE-GROUP # Resource group name to create or update
|
||||
location: westus2 # Azure location for resource group
|
||||
|
||||
# The name of the deployment, provide a unique value to preserve deployment history
|
||||
# deploymentName:
|
||||
|
||||
# timeout after 45 minutes by default
|
||||
# an exception is thrown at that point though the deployment may eventually succeed
|
||||
timeout: PT45M
|
||||
|
||||
# polling frequency every 10 seconds until complete by default
|
||||
polling: PT10S
|
||||
|
||||
# See https://docs.microsoft.com/en-us/rest/api/resources/deployments/createorupdate#deploymentproperties
|
||||
deployment:
|
||||
# May be 'Incremental' or 'Complete'.
|
||||
# 'Complete' will delete anything in the resource group which is not found in the deployment template
|
||||
mode: Incremental
|
||||
|
||||
# May be 'none' 'requestContent' 'responseContent' or 'requestContent,responseContent'
|
||||
# See documentation for security implications changing this default
|
||||
debugSetting:
|
||||
detailLevel: none
|
||||
|
||||
# All ( deployment.parameters.* ) properties are used to provide template parameter values
|
||||
# parameters: {}
|
||||
|
||||
# template body is passed in as the ( deployment.template ) json object.
|
||||
# template:
|
||||
# $schema: https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#
|
||||
# contentVersion: 1.0.0.0
|
||||
# parameters: []
|
||||
# variables: {}
|
||||
# resources: []
|
||||
# outputs: {}
|
|
@ -0,0 +1,56 @@
|
|||
values:
|
||||
request:
|
||||
parameters:
|
||||
subscriptionId: "{{ azure.subscription }}"
|
||||
resourceGroupName: "{{ azure.resourceGroup }}"
|
||||
deploymentName: {{# if deploymentName }}{{ deploymentName }}{{ else }}atlas-deployment-{{ guid (datetime add="PT0S") }}{{/ if }}
|
||||
|
||||
operations:
|
||||
- message: Deploying ARM template
|
||||
operations:
|
||||
# ensure resource group
|
||||
- request: apis/azure/ResourceManagementClient/ResourceGroups/CreateOrUpdate.yaml
|
||||
values:
|
||||
request:
|
||||
body:
|
||||
location: "{{ azure.location }}"
|
||||
|
||||
# start deployment
|
||||
- request: apis/azure/ResourceManagementClient/Deployments/CreateOrUpdate.yaml
|
||||
values:
|
||||
request:
|
||||
body:
|
||||
properties: ( deployment )
|
||||
|
||||
# wait until complete
|
||||
- request: apis/azure/ResourceManagementClient/Deployments/Get.yaml
|
||||
output:
|
||||
body: ( result.body )
|
||||
repeat:
|
||||
condition: ( contains(['Accepted', 'Running'], body.properties.provisioningState) )
|
||||
delay: {{ polling }}
|
||||
timeout: {{ timeout }}
|
||||
|
||||
- condition: ( body.properties.provisioningState != 'Succeeded' )
|
||||
throw:
|
||||
message: ( body.properties.error.message || 'ARM template failed' )
|
||||
details:
|
||||
provisioningState: ( body.properties.provisioningState )
|
||||
error: ( body.properties.error )
|
||||
|
||||
catch:
|
||||
condition: ( error.response.body.error != null )
|
||||
output:
|
||||
throw:
|
||||
message: "( join(': ', [to_string(error.message), to_string(error.response.body.error.message)]) )"
|
||||
details:
|
||||
status: ( error.response.status )
|
||||
error: ( error.response.body.error )
|
||||
request: ( error.request )
|
||||
|
||||
- condition: ( throw != null )
|
||||
throw:
|
||||
message: ( throw.message )
|
||||
details: ( throw.details )
|
||||
|
||||
output: ( body )
|
Загрузка…
Ссылка в новой задаче