From b7d85b8a238b3df4677e6c08af19004e9e4e004f Mon Sep 17 00:00:00 2001 From: Vaijanath Angadihiremath Date: Mon, 30 Mar 2020 17:15:58 -0700 Subject: [PATCH] Added acceptance tests for DTL. Fixed couple of issues with DTL root resource group not set to new directory --- builder/azure/dtl/acceptancetest.json | 72 +++++ builder/azure/dtl/builder.go | 1 - builder/azure/dtl/builder_acc_test.go | 269 +++--------------- builder/azure/dtl/builder_test.go | 1 - builder/azure/dtl/config.go | 7 +- builder/azure/dtl/config.hcl2spec.go | 2 - builder/azure/dtl/config_test.go | 98 ------- builder/azure/dtl/golog.txt | 102 ------- builder/azure/dtl/step_capture_image.go | 2 +- builder/azure/dtl/step_power_off_compute.go | 2 +- builder/azure/dtl/template_factory.go | 2 +- provisioner/azure-dtlartifact/provisioner.go | 2 +- .../azure-dtlartifact/provisioner.hcl2spec.go | 4 +- .../azure/dtl/_Config-not-required.html.md | 2 - 14 files changed, 124 insertions(+), 442 deletions(-) create mode 100644 builder/azure/dtl/acceptancetest.json delete mode 100644 builder/azure/dtl/golog.txt diff --git a/builder/azure/dtl/acceptancetest.json b/builder/azure/dtl/acceptancetest.json new file mode 100644 index 000000000..d1618e00d --- /dev/null +++ b/builder/azure/dtl/acceptancetest.json @@ -0,0 +1,72 @@ +{ + "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "name": { + "type": "string", + "defaultValue": "packer-acceptance-test" + }, + "regionId": { + "type": "string", + "defaultValue": "southcentralus" + } + }, + "resources": [ + { + "apiVersion": "2018-10-15-preview", + "name": "[parameters('name')]", + "type": "Microsoft.DevTestLab/labs", + "location": "[parameters('regionId')]", + "tags": { + "env": "packer" + }, + "properties": { + "labStorageType": "Premium" + }, + "resources": [ + { + "apiVersion": "2018-10-15-preview", + "name": "LabVmsShutdown", + "location": "[parameters('regionId')]", + "type": "schedules", + "dependsOn": [ + "[resourceId('Microsoft.DevTestLab/labs', parameters('name'))]" + ], + "properties": { + "status": "Enabled", + "timeZoneId": "Pacific Standard Time", + "dailyRecurrence": { + "time": "1900" + }, + "taskType": "LabVmsShutdownTask", + "notificationSettings": { + "status": "Disabled", + "timeInMinutes": 30 + } + } + }, + { + "apiVersion": "2018-10-15-preview", + "name": "[concat('Dtl', parameters('name'))]", + "type": "virtualNetworks", + "location": "[parameters('regionId')]", + "dependsOn": [ + "[resourceId('Microsoft.DevTestLab/labs', parameters('name'))]" + ] + }, + { + "apiVersion": "2018-10-15-preview", + "name": "Public Environment Repo", + "type": "artifactSources", + "location": "[parameters('regionId')]", + "dependsOn": [ + "[resourceId('Microsoft.DevTestLab/labs', parameters('name'))]" + ], + "properties": { + "status": "Enabled" + } + } + ] + } + ] +} \ No newline at end of file diff --git a/builder/azure/dtl/builder.go b/builder/azure/dtl/builder.go index 421188b48..272fcfa65 100644 --- a/builder/azure/dtl/builder.go +++ b/builder/azure/dtl/builder.go @@ -301,7 +301,6 @@ func (b *Builder) configureStateBag(stateBag multistep.StateBag) { stateBag.Put(constants.ArmIsManagedImage, b.config.isManagedImage()) stateBag.Put(constants.ArmManagedImageResourceGroupName, b.config.ManagedImageResourceGroupName) stateBag.Put(constants.ArmManagedImageName, b.config.ManagedImageName) - stateBag.Put(constants.ArmAsyncResourceGroupDelete, b.config.AsyncResourceGroupDelete) if b.config.isManagedImage() && b.config.SharedGalleryDestination.SigDestinationGalleryName != "" { stateBag.Put(constants.ArmManagedImageSigPublishResourceGroup, b.config.SharedGalleryDestination.SigDestinationResourceGroup) stateBag.Put(constants.ArmManagedImageSharedGalleryName, b.config.SharedGalleryDestination.SigDestinationGalleryName) diff --git a/builder/azure/dtl/builder_acc_test.go b/builder/azure/dtl/builder_acc_test.go index 4cd0f7bbb..2255319c5 100644 --- a/builder/azure/dtl/builder_acc_test.go +++ b/builder/azure/dtl/builder_acc_test.go @@ -7,13 +7,18 @@ package dtl // * ARM_CLIENT_SECRET // * ARM_SUBSCRIPTION_ID // * ARM_OBJECT_ID -// * ARM_STORAGE_ACCOUNT // // The subscription in question should have a resource group -// called "packer-acceptance-test" in "South Central US" region. The -// storage account refered to in the above variable should -// be inside this resource group and in "South Central US" as well. -// +// called "packer-acceptance-test" in "South Central US" region. +// This also requires a Devtest lab to be created with "packer-acceptance-test" +// name in "South Central US region. This can be achieved using the following +// az cli commands " +// az group create --name packer-acceptance-test --location "South Central US" +// az deployment group create \ +// --name ExampleDeployment \ +// --resource-group packer-acceptance-test \ +// --template-file acceptancetest.json \ + // In addition, the PACKER_ACC variable should also be set to // a non-empty value to enable Packer acceptance tests and the // options "-v -timeout 90m" should be provided to the test @@ -23,9 +28,6 @@ package dtl import ( "testing" - "fmt" - "os" - builderT "github.com/hashicorp/packer/helper/builder/testing" ) @@ -38,30 +40,7 @@ func TestBuilderAcc_ManagedDisk_Windows(t *testing.T) { Template: testBuilderAccManagedDiskWindows, }) } - -func TestBuilderAcc_ManagedDisk_Windows_Build_Resource_Group(t *testing.T) { - builderT.Test(t, builderT.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Builder: &Builder{}, - Template: testBuilderAccManagedDiskWindowsBuildResourceGroup, - }) -} - -func TestBuilderAcc_ManagedDisk_Windows_DeviceLogin(t *testing.T) { - if os.Getenv(DeviceLoginAcceptanceTest) == "" { - t.Skip(fmt.Sprintf( - "Device Login Acceptance tests skipped unless env '%s' set, as its requires manual step during execution", - DeviceLoginAcceptanceTest)) - return - } - builderT.Test(t, builderT.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Builder: &Builder{}, - Template: testBuilderAccManagedDiskWindowsDeviceLogin, - }) -} - -func TestBuilderAcc_ManagedDisk_Linux(t *testing.T) { +func TestBuilderAcc_ManagedDisk_Linux_Artifacts(t *testing.T) { builderT.Test(t, builderT.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Builder: &Builder{}, @@ -69,36 +48,6 @@ func TestBuilderAcc_ManagedDisk_Linux(t *testing.T) { }) } -func TestBuilderAcc_ManagedDisk_Linux_DeviceLogin(t *testing.T) { - if os.Getenv(DeviceLoginAcceptanceTest) == "" { - t.Skip(fmt.Sprintf( - "Device Login Acceptance tests skipped unless env '%s' set, as its requires manual step during execution", - DeviceLoginAcceptanceTest)) - return - } - builderT.Test(t, builderT.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Builder: &Builder{}, - Template: testBuilderAccManagedDiskLinuxDeviceLogin, - }) -} - -func TestBuilderAcc_Blob_Windows(t *testing.T) { - builderT.Test(t, builderT.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Builder: &Builder{}, - Template: testBuilderAccBlobWindows, - }) -} - -func TestBuilderAcc_Blob_Linux(t *testing.T) { - builderT.Test(t, builderT.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Builder: &Builder{}, - Template: testBuilderAccBlobLinux, - }) -} - func testAccPreCheck(*testing.T) {} const testBuilderAccManagedDiskWindows = ` @@ -106,7 +55,8 @@ const testBuilderAccManagedDiskWindows = ` "variables": { "client_id": "{{env ` + "`ARM_CLIENT_ID`" + `}}", "client_secret": "{{env ` + "`ARM_CLIENT_SECRET`" + `}}", - "subscription_id": "{{env ` + "`ARM_SUBSCRIPTION_ID`" + `}}" + "subscription_id": "{{env ` + "`ARM_SUBSCRIPTION_ID`" + `}}", + "tenant_id": "{{env ` + "`ARM_TENANT_ID`" + `}}" }, "builders": [{ "type": "test", @@ -114,6 +64,11 @@ const testBuilderAccManagedDiskWindows = ` "client_id": "{{user ` + "`client_id`" + `}}", "client_secret": "{{user ` + "`client_secret`" + `}}", "subscription_id": "{{user ` + "`subscription_id`" + `}}", + "tenant_id": "{{user ` + "`tenant_id`" + `}}", + + "lab_name": "packer-acceptance-test", + "lab_resource_group_name": "packer-acceptance-test", + "lab_virtual_network_name": "dtlpacker-acceptance-test", "managed_image_resource_group_name": "packer-acceptance-test", "managed_image_name": "testBuilderAccManagedDiskWindows-{{timestamp}}", @@ -128,72 +83,7 @@ const testBuilderAccManagedDiskWindows = ` "winrm_insecure": "true", "winrm_timeout": "3m", "winrm_username": "packer", - "async_resourcegroup_delete": "true", - - "location": "South Central US", - "vm_size": "Standard_DS2_v2" - }] -} -` -const testBuilderAccManagedDiskWindowsBuildResourceGroup = ` -{ - "variables": { - "client_id": "{{env ` + "`ARM_CLIENT_ID`" + `}}", - "client_secret": "{{env ` + "`ARM_CLIENT_SECRET`" + `}}", - "subscription_id": "{{env ` + "`ARM_SUBSCRIPTION_ID`" + `}}" - }, - "builders": [{ - "type": "test", - - "client_id": "{{user ` + "`client_id`" + `}}", - "client_secret": "{{user ` + "`client_secret`" + `}}", - "subscription_id": "{{user ` + "`subscription_id`" + `}}", - - "build_resource_group_name" : "packer-acceptance-test", - "managed_image_resource_group_name": "packer-acceptance-test", - "managed_image_name": "testBuilderAccManagedDiskWindows-{{timestamp}}", - - "os_type": "Windows", - "image_publisher": "MicrosoftWindowsServer", - "image_offer": "WindowsServer", - "image_sku": "2012-R2-Datacenter", - - "communicator": "winrm", - "winrm_use_ssl": "true", - "winrm_insecure": "true", - "winrm_timeout": "3m", - "winrm_username": "packer", - "async_resourcegroup_delete": "true", - - "vm_size": "Standard_DS2_v2" - }] -} -` - -const testBuilderAccManagedDiskWindowsDeviceLogin = ` -{ - "variables": { - "subscription_id": "{{env ` + "`ARM_SUBSCRIPTION_ID`" + `}}" - }, - "builders": [{ - "type": "test", - - "subscription_id": "{{user ` + "`subscription_id`" + `}}", - - "managed_image_resource_group_name": "packer-acceptance-test", - "managed_image_name": "testBuilderAccManagedDiskWindowsDeviceLogin-{{timestamp}}", - - "os_type": "Windows", - "image_publisher": "MicrosoftWindowsServer", - "image_offer": "WindowsServer", - "image_sku": "2012-R2-Datacenter", - - "communicator": "winrm", - "winrm_use_ssl": "true", - "winrm_insecure": "true", - "winrm_timeout": "3m", - "winrm_username": "packer", - + "location": "South Central US", "vm_size": "Standard_DS2_v2" }] @@ -205,7 +95,8 @@ const testBuilderAccManagedDiskLinux = ` "variables": { "client_id": "{{env ` + "`ARM_CLIENT_ID`" + `}}", "client_secret": "{{env ` + "`ARM_CLIENT_SECRET`" + `}}", - "subscription_id": "{{env ` + "`ARM_SUBSCRIPTION_ID`" + `}}" + "subscription_id": "{{env ` + "`ARM_SUBSCRIPTION_ID`" + `}}", + "tenant_id": "{{env ` + "`ARM_TENANT_ID`" + `}}" }, "builders": [{ "type": "test", @@ -214,6 +105,10 @@ const testBuilderAccManagedDiskLinux = ` "client_secret": "{{user ` + "`client_secret`" + `}}", "subscription_id": "{{user ` + "`subscription_id`" + `}}", + "lab_name": "packer-acceptance-test", + "lab_resource_group_name": "packer-acceptance-test", + "lab_virtual_network_name": "dtlpacker-acceptance-test", + "managed_image_resource_group_name": "packer-acceptance-test", "managed_image_name": "testBuilderAccManagedDiskLinux-{{timestamp}}", @@ -223,101 +118,25 @@ const testBuilderAccManagedDiskLinux = ` "image_sku": "16.04-LTS", "location": "South Central US", - "vm_size": "Standard_DS2_v2" - }] -} -` -const testBuilderAccManagedDiskLinuxDeviceLogin = ` -{ - "variables": { - "subscription_id": "{{env ` + "`ARM_SUBSCRIPTION_ID`" + `}}" - }, - "builders": [{ - "type": "test", - - "subscription_id": "{{user ` + "`subscription_id`" + `}}", - - "managed_image_resource_group_name": "packer-acceptance-test", - "managed_image_name": "testBuilderAccManagedDiskLinuxDeviceLogin-{{timestamp}}", - - "os_type": "Linux", - "image_publisher": "Canonical", - "image_offer": "UbuntuServer", - "image_sku": "16.04-LTS", - "async_resourcegroup_delete": "true", - - "location": "South Central US", - "vm_size": "Standard_DS2_v2" - }] -} -` - -const testBuilderAccBlobWindows = ` -{ - "variables": { - "client_id": "{{env ` + "`ARM_CLIENT_ID`" + `}}", - "client_secret": "{{env ` + "`ARM_CLIENT_SECRET`" + `}}", - "subscription_id": "{{env ` + "`ARM_SUBSCRIPTION_ID`" + `}}", - "object_id": "{{env ` + "`ARM_OBJECT_ID`" + `}}", - "storage_account": "{{env ` + "`ARM_STORAGE_ACCOUNT`" + `}}" - }, - "builders": [{ - "type": "test", - - "client_id": "{{user ` + "`client_id`" + `}}", - "client_secret": "{{user ` + "`client_secret`" + `}}", - "subscription_id": "{{user ` + "`subscription_id`" + `}}", - "object_id": "{{user ` + "`object_id`" + `}}", - - "storage_account": "{{user ` + "`storage_account`" + `}}", - "resource_group_name": "packer-acceptance-test", - "capture_container_name": "test", - "capture_name_prefix": "testBuilderAccBlobWin", - - "os_type": "Windows", - "image_publisher": "MicrosoftWindowsServer", - "image_offer": "WindowsServer", - "image_sku": "2012-R2-Datacenter", - - "communicator": "winrm", - "winrm_use_ssl": "true", - "winrm_insecure": "true", - "winrm_timeout": "3m", - "winrm_username": "packer", - - "location": "South Central US", - "vm_size": "Standard_DS2_v2" - }] -} -` - -const testBuilderAccBlobLinux = ` -{ - "variables": { - "client_id": "{{env ` + "`ARM_CLIENT_ID`" + `}}", - "client_secret": "{{env ` + "`ARM_CLIENT_SECRET`" + `}}", - "subscription_id": "{{env ` + "`ARM_SUBSCRIPTION_ID`" + `}}", - "storage_account": "{{env ` + "`ARM_STORAGE_ACCOUNT`" + `}}" - }, - "builders": [{ - "type": "test", - - "client_id": "{{user ` + "`client_id`" + `}}", - "client_secret": "{{user ` + "`client_secret`" + `}}", - "subscription_id": "{{user ` + "`subscription_id`" + `}}", - - "storage_account": "{{user ` + "`storage_account`" + `}}", - "resource_group_name": "packer-acceptance-test", - "capture_container_name": "test", - "capture_name_prefix": "testBuilderAccBlobLinux", - - "os_type": "Linux", - "image_publisher": "Canonical", - "image_offer": "UbuntuServer", - "image_sku": "16.04-LTS", - - "location": "South Central US", - "vm_size": "Standard_DS2_v2" + "vm_size": "Standard_DS2_v2", + + + "dtl_artifacts": [{ + "artifact_name": "linux-apt-package", + "parameters" : [{ + "name": "packages", + "value": "vim" + }, + { + "name":"update", + "value": "true" + }, + { + "name": "options", + "value": "--fix-broken" + }] + }] + }] } ` diff --git a/builder/azure/dtl/builder_test.go b/builder/azure/dtl/builder_test.go index c3318e7ab..5120ebd40 100644 --- a/builder/azure/dtl/builder_test.go +++ b/builder/azure/dtl/builder_test.go @@ -23,7 +23,6 @@ func TestStateBagShouldBePopulatedExpectedValues(t *testing.T) { constants.ArmResourceGroupName, constants.ArmVirtualMachineCaptureParameters, constants.ArmPublicIPAddressName, - constants.ArmAsyncResourceGroupDelete, } for _, v := range expectedStateBagKeys { diff --git a/builder/azure/dtl/config.go b/builder/azure/dtl/config.go index 59011aa3f..48b307586 100644 --- a/builder/azure/dtl/config.go +++ b/builder/azure/dtl/config.go @@ -302,9 +302,6 @@ type Config struct { Comm communicator.Config `mapstructure:",squash"` ctx interpolate.Context - - //Cleanup - AsyncResourceGroupDelete bool `mapstructure:"async_resourcegroup_delete"` } type keyVaultCertificate struct { @@ -693,10 +690,10 @@ func assertRequiredParametersSet(c *Config, errs *packer.MultiError) { } if c.LabVirtualNetworkName == "" && c.LabResourceGroupName != "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("If virtual_network_resource_group_name is specified, so must virtual_network_name")) + errs = packer.MultiErrorAppend(errs, fmt.Errorf("If lab_resource_group_name is specified, so must lab_virtual_network_name")) } if c.LabVirtualNetworkName == "" && c.LabSubnetName != "" { - errs = packer.MultiErrorAppend(errs, fmt.Errorf("If virtual_network_subnet_name is specified, so must virtual_network_name")) + errs = packer.MultiErrorAppend(errs, fmt.Errorf("If virtual_network_subnet_name is specified, so must lab_virtual_network_name")) } ///////////////////////////////////////////// diff --git a/builder/azure/dtl/config.hcl2spec.go b/builder/azure/dtl/config.hcl2spec.go index 7c35f28b2..c410061a2 100644 --- a/builder/azure/dtl/config.hcl2spec.go +++ b/builder/azure/dtl/config.hcl2spec.go @@ -125,7 +125,6 @@ type FlatConfig struct { WinRMUseSSL *bool `mapstructure:"winrm_use_ssl" cty:"winrm_use_ssl"` WinRMInsecure *bool `mapstructure:"winrm_insecure" cty:"winrm_insecure"` WinRMUseNTLM *bool `mapstructure:"winrm_use_ntlm" cty:"winrm_use_ntlm"` - AsyncResourceGroupDelete *bool `mapstructure:"async_resourcegroup_delete" cty:"async_resourcegroup_delete"` } // FlatMapstructure returns a new FlatConfig. @@ -229,7 +228,6 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { "winrm_use_ssl": &hcldec.AttrSpec{Name: "winrm_use_ssl", Type: cty.Bool, Required: false}, "winrm_insecure": &hcldec.AttrSpec{Name: "winrm_insecure", Type: cty.Bool, Required: false}, "winrm_use_ntlm": &hcldec.AttrSpec{Name: "winrm_use_ntlm", Type: cty.Bool, Required: false}, - "async_resourcegroup_delete": &hcldec.AttrSpec{Name: "async_resourcegroup_delete", Type: cty.Bool, Required: false}, } return s } diff --git a/builder/azure/dtl/config_test.go b/builder/azure/dtl/config_test.go index b260f1de3..5690ffe68 100644 --- a/builder/azure/dtl/config_test.go +++ b/builder/azure/dtl/config_test.go @@ -424,30 +424,6 @@ func TestConfigShouldAcceptDiskCachingTypes(t *testing.T) { } } -func TestConfigShouldRejectTempAndBuildResourceGroupName(t *testing.T) { - config := map[string]interface{}{ - "capture_name_prefix": "ignore", - "capture_container_name": "ignore", - "image_offer": "ignore", - "image_publisher": "ignore", - "image_sku": "ignore", - "location": "ignore", - "subscription_id": "ignore", - "communicator": "none", - "lab_resource_group_name": "ignore", - "lab_virtual_network_name": "ignore", - - // custom may define one or the other, but not both - "temp_resource_group_name": "rgn00", - "build_resource_group_name": "rgn00", - } - - _, _, err := newConfig(config, getPackerConfiguration()) - if err == nil { - t.Fatal("expected config to reject the use of both temp_resource_group_name and build_resource_group_name") - } -} - func TestConfigAdditionalDiskDefaultIsNil(t *testing.T) { c, _, _ := newConfig(getDtlBuilderConfiguration(), getPackerConfiguration()) if c.AdditionalDiskSize != nil { @@ -487,78 +463,6 @@ func TestConfigAdditionalDiskOverrideDefault(t *testing.T) { } } -func TestConfigShouldAllowAsyncResourceGroupOverride(t *testing.T) { - config := map[string]interface{}{ - "image_offer": "ignore", - "image_publisher": "ignore", - "image_sku": "ignore", - "location": "ignore", - "subscription_id": "ignore", - "communicator": "none", - "os_type": "linux", - "managed_image_name": "ignore", - "managed_image_resource_group_name": "ignore", - "async_resourcegroup_delete": "true", - "lab_resource_group_name": "ignore", - "lab_virtual_network_name": "ignore", - } - - c, _, err := newConfig(config, getPackerConfiguration()) - if err != nil { - t.Errorf("newConfig failed with %q", err) - } - - if c.AsyncResourceGroupDelete != true { - t.Errorf("expected async_resourcegroup_delete to be %q, but got %t", "async_resourcegroup_delete", c.AsyncResourceGroupDelete) - } -} -func TestConfigShouldAllowAsyncResourceGroupOverrideNoValue(t *testing.T) { - config := map[string]interface{}{ - "image_offer": "ignore", - "image_publisher": "ignore", - "image_sku": "ignore", - "location": "ignore", - "subscription_id": "ignore", - "communicator": "none", - "os_type": "linux", - "managed_image_name": "ignore", - "managed_image_resource_group_name": "ignore", - "lab_resource_group_name": "ignore", - "lab_virtual_network_name": "ignore", - } - - c, _, err := newConfig(config, getPackerConfiguration()) - if err != nil { - t.Errorf("newConfig failed with %q", err) - } - - if c.AsyncResourceGroupDelete != false { - t.Errorf("expected async_resourcegroup_delete to be %q, but got %t", "async_resourcegroup_delete", c.AsyncResourceGroupDelete) - } -} -func TestConfigShouldAllowAsyncResourceGroupOverrideBadValue(t *testing.T) { - config := map[string]interface{}{ - "image_offer": "ignore", - "image_publisher": "ignore", - "image_sku": "ignore", - "location": "ignore", - "subscription_id": "ignore", - "communicator": "none", - "os_type": "linux", - "managed_image_name": "ignore", - "managed_image_resource_group_name": "ignore", - "async_resourcegroup_delete": "asdasda", - "lab_resource_group_name": "ignore", - "lab_virtual_network_name": "ignore", - } - - c, _, err := newConfig(config, getPackerConfiguration()) - if err != nil && c == nil { - t.Log("newConfig failed which is expected ", err) - - } - -} func TestConfigShouldAllowSharedImageGalleryOptions(t *testing.T) { config := map[string]interface{}{ "location": "ignore", @@ -594,8 +498,6 @@ func TestConfigShouldRejectSharedImageGalleryWithVhdTarget(t *testing.T) { "image_name": "ignore", "image_version": "ignore", }, - "resource_group_name": "ignore", - "storage_account": "ignore", "capture_container_name": "ignore", "capture_name_prefix": "ignore", "lab_resource_group_name": "ignore", diff --git a/builder/azure/dtl/golog.txt b/builder/azure/dtl/golog.txt deleted file mode 100644 index 461f48b75..000000000 --- a/builder/azure/dtl/golog.txt +++ /dev/null @@ -1,102 +0,0 @@ -(2020-01-03T11:14:50.7650470-08:00) INFO: REQUEST: GET https://management.azure.com/subscriptions/cba4e087-aceb-44f0-970e-65e96eff4081?api-version=2016-06-01 -User-Agent: Go/go1.13.1 (amd64-darwin) go-autorest/v12.0.0 Azure-SDK-For-Go/v30.0.0 subscriptions/2016-06-01 -(2020-01-03T11:14:51.1254910-08:00) INFO: RESPONSE: 401 https://management.azure.com/subscriptions/cba4e087-aceb-44f0-970e-65e96eff4081?api-version=2016-06-01 -X-Ms-Failure-Cause: gateway -X-Ms-Routing-Request-Id: WESTUS:20200103T191448Z:cfef32b3-e72f-4b06-849e-aedf98a3baf0 -Date: Fri, 03 Jan 2020 19:14:48 GMT -Cache-Control: no-cache -Expires: -1 -Content-Length: 115 -X-Ms-Request-Id: cfef32b3-e72f-4b06-849e-aedf98a3baf0 -X-Ms-Correlation-Request-Id: cfef32b3-e72f-4b06-849e-aedf98a3baf0 -Strict-Transport-Security: max-age=31536000; includeSubDomains -Pragma: no-cache -Content-Type: application/json; charset=utf-8 -Www-Authenticate: Bearer authorization_uri="https://login.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47", error="invalid_token", error_description="The authentication failed because of missing 'Authorization' header." -X-Content-Type-Options: nosniff -{"error":{"code":"AuthenticationFailed","message":"Authentication failed. The 'Authorization' header is missing."}} -(2020-01-03T11:14:51.3698460-08:00) INFO: REQUEST: GET https://management.azure.com/subscriptions/cba4e087-aceb-44f0-970e-65e96eff4081/resourceGroups/packer-acceptance-test/providers/Microsoft.DevTestLab/labs//customimages/testBuilderAccManagedDiskWindows-1578078890?api-version=2018-09-15 -User-Agent: Packer/1.5.0-dev (+https://www.packer.io/; go1.13.1; darwin/amd64) Go/go1.13.1 (amd64-darwin) go-autorest/v12.0.0 Azure-SDK-For-Go/v30.0.0 dtl/2018-09-15 -Authorization: **REDACTED** -(2020-01-03T11:14:51.5297600-08:00) INFO: RESPONSE: 404 https://management.azure.com/subscriptions/cba4e087-aceb-44f0-970e-65e96eff4081/resourceGroups/packer-acceptance-test/providers/Microsoft.DevTestLab/labs//customimages/testBuilderAccManagedDiskWindows-1578078890?api-version=2018-09-15 -X-Ms-Failure-Cause: gateway -X-Ms-Request-Id: 0464a3f7-cf7e-456e-bffc-451f4fa1e12d -Strict-Transport-Security: max-age=31536000; includeSubDomains -X-Content-Type-Options: nosniff -Content-Length: 114 -Pragma: no-cache -Content-Type: application/json; charset=utf-8 -Expires: -1 -Date: Fri, 03 Jan 2020 19:14:48 GMT -Cache-Control: no-cache -X-Ms-Correlation-Request-Id: 0464a3f7-cf7e-456e-bffc-451f4fa1e12d -X-Ms-Routing-Request-Id: WESTUS:20200103T191449Z:0464a3f7-cf7e-456e-bffc-451f4fa1e12d -{"error":{"code":"ResourceGroupNotFound","message":"Resource group 'packer-acceptance-test' could not be found."}} -(2020-01-03T11:14:51.5392840-08:00) INFO: REQUEST: GET https://management.azure.com/subscriptions/cba4e087-aceb-44f0-970e-65e96eff4081/resourceGroups//providers/Microsoft.DevTestLab/labs/?api-version=2018-09-15 -Authorization: **REDACTED** -User-Agent: Packer/1.5.0-dev (+https://www.packer.io/; go1.13.1; darwin/amd64) Go/go1.13.1 (amd64-darwin) go-autorest/v12.0.0 Azure-SDK-For-Go/v30.0.0 dtl/2018-09-15 -(2020-01-03T11:14:51.5804680-08:00) INFO: RESPONSE: 400 https://management.azure.com/subscriptions/cba4e087-aceb-44f0-970e-65e96eff4081/resourceGroups//providers/Microsoft.DevTestLab/labs/?api-version=2018-09-15 -Strict-Transport-Security: max-age=31536000; includeSubDomains -Date: Fri, 03 Jan 2020 19:14:48 GMT -Cache-Control: no-cache -Pragma: no-cache -Content-Type: application/json; charset=utf-8 -X-Ms-Failure-Cause: gateway -X-Ms-Request-Id: 8b3aeb52-7eea-47d6-b0a1-f58aa0e3bed6 -Expires: -1 -X-Ms-Correlation-Request-Id: 8b3aeb52-7eea-47d6-b0a1-f58aa0e3bed6 -X-Ms-Routing-Request-Id: WESTUS:20200103T191449Z:8b3aeb52-7eea-47d6-b0a1-f58aa0e3bed6 -X-Content-Type-Options: nosniff -Content-Length: 520 -{"error":{"code":"InvalidApiVersionParameter","message":"The api-version '2018-09-15' is invalid. The supported versions are '2019-11-01,2019-10-01,2019-09-01,2019-08-01,2019-07-01,2019-06-01,2019-05-10,2019-05-01,2019-03-01,2018-11-01,2018-09-01,2018-08-01,2018-07-01,2018-06-01,2018-05-01,2018-02-01,2018-01-01,2017-12-01,2017-08-01,2017-06-01,2017-05-10,2017-05-01,2017-03-01,2016-09-01,2016-07-01,2016-06-01,2016-02-01,2015-11-01,2015-01-01,2014-04-01-preview,2014-04-01,2014-01-01,2013-03-01,2014-02-26,2014-04'."}} -(2020-01-03T11:14:52.5925920-08:00) INFO: REQUEST: GET https://management.azure.com/subscriptions/cba4e087-aceb-44f0-970e-65e96eff4081?api-version=2016-06-01 -User-Agent: Go/go1.13.1 (amd64-darwin) go-autorest/v12.0.0 Azure-SDK-For-Go/v30.0.0 subscriptions/2016-06-01 -(2020-01-03T11:14:52.7012490-08:00) INFO: RESPONSE: 401 https://management.azure.com/subscriptions/cba4e087-aceb-44f0-970e-65e96eff4081?api-version=2016-06-01 -Www-Authenticate: Bearer authorization_uri="https://login.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47", error="invalid_token", error_description="The authentication failed because of missing 'Authorization' header." -X-Ms-Failure-Cause: gateway -Content-Length: 115 -Content-Type: application/json; charset=utf-8 -X-Ms-Request-Id: a970f18e-ca06-42ee-b2d0-541640aeaf3f -X-Ms-Correlation-Request-Id: a970f18e-ca06-42ee-b2d0-541640aeaf3f -X-Ms-Routing-Request-Id: WESTUS:20200103T191450Z:a970f18e-ca06-42ee-b2d0-541640aeaf3f -Expires: -1 -Cache-Control: no-cache -Strict-Transport-Security: max-age=31536000; includeSubDomains -X-Content-Type-Options: nosniff -Date: Fri, 03 Jan 2020 19:14:49 GMT -Pragma: no-cache -{"error":{"code":"AuthenticationFailed","message":"Authentication failed. The 'Authorization' header is missing."}} -(2020-01-03T11:14:53.1100660-08:00) INFO: REQUEST: GET https://management.azure.com/subscriptions/cba4e087-aceb-44f0-970e-65e96eff4081/resourceGroups/packer-acceptance-test/providers/Microsoft.DevTestLab/labs//customimages/testBuilderAccManagedDiskLinux-1578078890?api-version=2018-09-15 -User-Agent: Packer/1.5.0-dev (+https://www.packer.io/; go1.13.1; darwin/amd64) Go/go1.13.1 (amd64-darwin) go-autorest/v12.0.0 Azure-SDK-For-Go/v30.0.0 dtl/2018-09-15 -Authorization: **REDACTED** -(2020-01-03T11:14:53.2497970-08:00) INFO: RESPONSE: 404 https://management.azure.com/subscriptions/cba4e087-aceb-44f0-970e-65e96eff4081/resourceGroups/packer-acceptance-test/providers/Microsoft.DevTestLab/labs//customimages/testBuilderAccManagedDiskLinux-1578078890?api-version=2018-09-15 -X-Ms-Request-Id: d9969a0a-be31-424a-b4ad-5006a44590d0 -X-Ms-Correlation-Request-Id: d9969a0a-be31-424a-b4ad-5006a44590d0 -X-Ms-Routing-Request-Id: WESTUS:20200103T191450Z:d9969a0a-be31-424a-b4ad-5006a44590d0 -Cache-Control: no-cache -Pragma: no-cache -Content-Type: application/json; charset=utf-8 -X-Content-Type-Options: nosniff -Date: Fri, 03 Jan 2020 19:14:50 GMT -Content-Length: 114 -Expires: -1 -X-Ms-Failure-Cause: gateway -Strict-Transport-Security: max-age=31536000; includeSubDomains -{"error":{"code":"ResourceGroupNotFound","message":"Resource group 'packer-acceptance-test' could not be found."}} -(2020-01-03T11:14:53.2628590-08:00) INFO: REQUEST: GET https://management.azure.com/subscriptions/cba4e087-aceb-44f0-970e-65e96eff4081/resourceGroups//providers/Microsoft.DevTestLab/labs/?api-version=2018-09-15 -User-Agent: Packer/1.5.0-dev (+https://www.packer.io/; go1.13.1; darwin/amd64) Go/go1.13.1 (amd64-darwin) go-autorest/v12.0.0 Azure-SDK-For-Go/v30.0.0 dtl/2018-09-15 -Authorization: **REDACTED** -(2020-01-03T11:14:53.3067870-08:00) INFO: RESPONSE: 400 https://management.azure.com/subscriptions/cba4e087-aceb-44f0-970e-65e96eff4081/resourceGroups//providers/Microsoft.DevTestLab/labs/?api-version=2018-09-15 -Pragma: no-cache -Content-Type: application/json; charset=utf-8 -Expires: -1 -X-Content-Type-Options: nosniff -Content-Length: 520 -Cache-Control: no-cache -X-Ms-Failure-Cause: gateway -X-Ms-Request-Id: de1644d3-f44e-4639-95ba-f1aeb8f4032d -X-Ms-Correlation-Request-Id: de1644d3-f44e-4639-95ba-f1aeb8f4032d -X-Ms-Routing-Request-Id: WESTUS:20200103T191450Z:de1644d3-f44e-4639-95ba-f1aeb8f4032d -Strict-Transport-Security: max-age=31536000; includeSubDomains -Date: Fri, 03 Jan 2020 19:14:50 GMT -{"error":{"code":"InvalidApiVersionParameter","message":"The api-version '2018-09-15' is invalid. The supported versions are '2019-11-01,2019-10-01,2019-09-01,2019-08-01,2019-07-01,2019-06-01,2019-05-10,2019-05-01,2019-03-01,2018-11-01,2018-09-01,2018-08-01,2018-07-01,2018-06-01,2018-05-01,2018-02-01,2018-01-01,2017-12-01,2017-08-01,2017-06-01,2017-05-10,2017-05-01,2017-03-01,2016-09-01,2016-07-01,2016-06-01,2016-02-01,2015-11-01,2015-01-01,2014-04-01-preview,2014-04-01,2014-01-01,2013-03-01,2014-02-26,2014-04'."}} diff --git a/builder/azure/dtl/step_capture_image.go b/builder/azure/dtl/step_capture_image.go index 03cb19e47..30f726a7d 100644 --- a/builder/azure/dtl/step_capture_image.go +++ b/builder/azure/dtl/step_capture_image.go @@ -75,7 +75,7 @@ func (s *StepCaptureImage) captureImageFromVM(ctx context.Context) error { CustomImageProperties: &customImageProperties, } - f, err := s.client.DtlCustomImageClient.CreateOrUpdate(ctx, s.config.tmpResourceGroupName, s.config.LabName, s.config.ManagedImageName, *customImage) + f, err := s.client.DtlCustomImageClient.CreateOrUpdate(ctx, s.config.LabResourceGroupName, s.config.LabName, s.config.ManagedImageName, *customImage) if err == nil { err = f.WaitForCompletionRef(ctx, s.client.DtlCustomImageClient.Client) } diff --git a/builder/azure/dtl/step_power_off_compute.go b/builder/azure/dtl/step_power_off_compute.go index e02d193df..794c3b751 100644 --- a/builder/azure/dtl/step_power_off_compute.go +++ b/builder/azure/dtl/step_power_off_compute.go @@ -51,7 +51,7 @@ func (s *StepPowerOffCompute) Run(ctx context.Context, state multistep.StateBag) s.say(fmt.Sprintf(" -> ResourceGroupName : '%s'", resourceGroupName)) s.say(fmt.Sprintf(" -> ComputeName : '%s'", computeName)) - err := s.powerOff(ctx, resourceGroupName, s.config.LabName, computeName) + err := s.powerOff(ctx, s.config.LabResourceGroupName, s.config.LabName, computeName) s.say("Powering off machine ...Complete") return processStepResult(err, s.error, state) diff --git a/builder/azure/dtl/template_factory.go b/builder/azure/dtl/template_factory.go index 08faf74ee..821d43a03 100644 --- a/builder/azure/dtl/template_factory.go +++ b/builder/azure/dtl/template_factory.go @@ -81,7 +81,7 @@ func GetVirtualMachineDeployment(config *Config) (*dtl.LabVirtualMachineCreation if strings.ToLower(config.OSType) == "windows" { // Add mandatory Artifact var winrma = "windows-winrm" - var artifactid = fmt.Sprintf("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DevTestLab/labs/%s/artifactSources/privaterepo457/artifacts/%s", + var artifactid = fmt.Sprintf("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DevTestLab/labs/%s/artifactSources/public repo/artifacts/%s", config.ClientConfig.SubscriptionID, config.tmpResourceGroupName, config.LabName, diff --git a/provisioner/azure-dtlartifact/provisioner.go b/provisioner/azure-dtlartifact/provisioner.go index 8baaf7b83..b38d1ab9f 100644 --- a/provisioner/azure-dtlartifact/provisioner.go +++ b/provisioner/azure-dtlartifact/provisioner.go @@ -40,7 +40,7 @@ type Config struct { DtlArtifacts []DtlArtifact `mapstructure:"dtl_artifacts"` LabName string `mapstructure:"lab_name"` - ResourceGroupName string `mapstructure:"resource_group_name"` + ResourceGroupName string `mapstructure:"lab_resource_group_name"` VMName string `mapstructure:"vm_name"` diff --git a/provisioner/azure-dtlartifact/provisioner.hcl2spec.go b/provisioner/azure-dtlartifact/provisioner.hcl2spec.go index e6bec30fa..d60a79dcf 100644 --- a/provisioner/azure-dtlartifact/provisioner.hcl2spec.go +++ b/provisioner/azure-dtlartifact/provisioner.hcl2spec.go @@ -53,7 +53,7 @@ type FlatConfig struct { SubscriptionID *string `mapstructure:"subscription_id" cty:"subscription_id"` DtlArtifacts []FlatDtlArtifact `mapstructure:"dtl_artifacts" cty:"dtl_artifacts"` LabName *string `mapstructure:"lab_name" cty:"lab_name"` - ResourceGroupName *string `mapstructure:"resource_group_name" cty:"resource_group_name"` + ResourceGroupName *string `mapstructure:"lab_resource_group_name" cty:"lab_resource_group_name"` VMName *string `mapstructure:"vm_name" cty:"vm_name"` PollingDurationTimeout *string `mapstructure:"polling_duration_timeout" required:"false" cty:"polling_duration_timeout"` AzureTags map[string]*string `mapstructure:"azure_tags" cty:"azure_tags"` @@ -89,7 +89,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { "subscription_id": &hcldec.AttrSpec{Name: "subscription_id", Type: cty.String, Required: false}, "dtl_artifacts": &hcldec.BlockListSpec{TypeName: "dtl_artifacts", Nested: hcldec.ObjectSpec((*FlatDtlArtifact)(nil).HCL2Spec())}, "lab_name": &hcldec.AttrSpec{Name: "lab_name", Type: cty.String, Required: false}, - "resource_group_name": &hcldec.AttrSpec{Name: "resource_group_name", Type: cty.String, Required: false}, + "lab_resource_group_name": &hcldec.AttrSpec{Name: "lab_resource_group_name", Type: cty.String, Required: false}, "vm_name": &hcldec.AttrSpec{Name: "vm_name", Type: cty.String, Required: false}, "polling_duration_timeout": &hcldec.AttrSpec{Name: "polling_duration_timeout", Type: cty.String, Required: false}, "azure_tags": &hcldec.BlockAttrsSpec{TypeName: "azure_tags", ElementType: cty.String, Required: false}, diff --git a/website/source/partials/builder/azure/dtl/_Config-not-required.html.md b/website/source/partials/builder/azure/dtl/_Config-not-required.html.md index 0b4b26b9a..5c80c6194 100644 --- a/website/source/partials/builder/azure/dtl/_Config-not-required.html.md +++ b/website/source/partials/builder/azure/dtl/_Config-not-required.html.md @@ -183,6 +183,4 @@ } - `vm_name` (string) - Name of the temporary virtual machine that can be optionally specified. - -- `async_resourcegroup_delete` (bool) - Cleanup \ No newline at end of file