From 13c0b0b3700aaa554396f921c05adfd543137dfe Mon Sep 17 00:00:00 2001 From: Hariharan Jayaraman Date: Thu, 10 May 2018 13:15:35 -0700 Subject: [PATCH] Added warning for VHD creation and updated samples --- builder/azure/arm/builder.go | 3 ++ examples/azure/centos.json | 10 ++---- examples/azure/debian.json | 8 ++--- examples/azure/freebsd.json | 10 ++---- examples/azure/marketplace_plan_info.json | 8 ++--- examples/azure/rhel.json | 11 +++--- examples/azure/suse.json | 15 ++++----- examples/azure/ubuntu.json | 14 +++----- examples/azure/ubuntu_managed_image.json | 41 ----------------------- examples/azure/windows.json | 10 ++---- 10 files changed, 32 insertions(+), 98 deletions(-) delete mode 100644 examples/azure/ubuntu_managed_image.json diff --git a/builder/azure/arm/builder.go b/builder/azure/arm/builder.go index 5603f0e52..d539a8c81 100644 --- a/builder/azure/arm/builder.go +++ b/builder/azure/arm/builder.go @@ -115,6 +115,9 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe return nil, fmt.Errorf("the managed image named %s already exists in the resource group %s, use the -force option to automatically delete it.", b.config.ManagedImageName, b.config.ManagedImageResourceGroupName) } } + } else { + // User is not using Managed Images to build, warning message here that this path is being deprecated + ui.Error("Warning: You are using Azure Packer Builder to create VHDs which is being deprecated, consider using Managed Images. Learn more http://aka.ms/packermanagedimage") } if b.config.BuildResourceGroupName != "" { diff --git a/examples/azure/centos.json b/examples/azure/centos.json index 1b0e7a633..9570ce7e9 100644 --- a/examples/azure/centos.json +++ b/examples/azure/centos.json @@ -2,25 +2,21 @@ "variables": { "client_id": "{{env `ARM_CLIENT_ID`}}", "client_secret": "{{env `ARM_CLIENT_SECRET`}}", - "resource_group": "{{env `ARM_RESOURCE_GROUP`}}", - "storage_account": "{{env `ARM_STORAGE_ACCOUNT`}}", "subscription_id": "{{env `ARM_SUBSCRIPTION_ID`}}", "tenant_id": "{{env `ARM_TENANT_ID`}}", "ssh_user": "centos", - "ssh_pass": null + "ssh_pass": "{{env `ARM_SSH_PASS`}}" }, "builders": [{ "type": "azure-arm", "client_id": "{{user `client_id`}}", "client_secret": "{{user `client_secret`}}", - "resource_group_name": "{{user `resource_group`}}", - "storage_account": "{{user `storage_account`}}", "subscription_id": "{{user `subscription_id`}}", "tenant_id": "{{user `tenant_id`}}", - "capture_container_name": "images", - "capture_name_prefix": "packer", + "managed_image_resource_group_name": "packertest", + "managed_image_name": "MyCentOSImage", "ssh_username": "{{user `ssh_user`}}", "ssh_password": "{{user `ssh_pass`}}", diff --git a/examples/azure/debian.json b/examples/azure/debian.json index 112ca4993..c16774623 100644 --- a/examples/azure/debian.json +++ b/examples/azure/debian.json @@ -2,11 +2,9 @@ "variables": { "client_id": "{{env `ARM_CLIENT_ID`}}", "client_secret": "{{env `ARM_CLIENT_SECRET`}}", - "resource_group": "{{env `ARM_RESOURCE_GROUP`}}", - "storage_account": "{{env `ARM_STORAGE_ACCOUNT`}}", "subscription_id": "{{env `ARM_SUBSCRIPTION_ID`}}", "ssh_user": "packer", - "ssh_pass": null + "ssh_pass": "{{env `ARM_SSH_PASS`}}" }, "builders": [{ "type": "azure-arm", @@ -17,8 +15,8 @@ "storage_account": "{{user `storage_account`}}", "subscription_id": "{{user `subscription_id`}}", - "capture_container_name": "images", - "capture_name_prefix": "packer", + "managed_image_resource_group_name": "packertest", + "managed_image_name": "MyDebianOSImage", "ssh_username": "{{user `ssh_user`}}", "ssh_password": "{{user `ssh_pass`}}", diff --git a/examples/azure/freebsd.json b/examples/azure/freebsd.json index 33f90c9a6..eedad52ea 100644 --- a/examples/azure/freebsd.json +++ b/examples/azure/freebsd.json @@ -2,23 +2,19 @@ "variables": { "client_id": "{{env `ARM_CLIENT_ID`}}", "client_secret": "{{env `ARM_CLIENT_SECRET`}}", - "resource_group": "{{env `ARM_RESOURCE_GROUP`}}", - "storage_account": "{{env `ARM_STORAGE_ACCOUNT`}}", "subscription_id": "{{env `ARM_SUBSCRIPTION_ID`}}", "ssh_user": "packer", - "ssh_pass": null + "ssh_pass": "{{env `ARM_SSH_PASS`}}" }, "builders": [{ "type": "azure-arm", "client_id": "{{user `client_id`}}", "client_secret": "{{user `client_secret`}}", - "resource_group_name": "{{user `resource_group`}}", - "storage_account": "{{user `storage_account`}}", "subscription_id": "{{user `subscription_id`}}", - "capture_container_name": "images", - "capture_name_prefix": "packer", + "managed_image_resource_group_name": "packertest", + "managed_image_name": "MyFreeBsdOSImage", "ssh_username": "{{user `ssh_user`}}", "ssh_password": "{{user `ssh_pass`}}", diff --git a/examples/azure/marketplace_plan_info.json b/examples/azure/marketplace_plan_info.json index 710dda8ee..5cf58e280 100644 --- a/examples/azure/marketplace_plan_info.json +++ b/examples/azure/marketplace_plan_info.json @@ -2,8 +2,6 @@ "variables": { "client_id": "{{env `ARM_CLIENT_ID`}}", "client_secret": "{{env `ARM_CLIENT_SECRET`}}", - "resource_group": "{{env `ARM_RESOURCE_GROUP`}}", - "storage_account": "{{env `ARM_STORAGE_ACCOUNT`}}", "subscription_id": "{{env `ARM_SUBSCRIPTION_ID`}}" }, "builders": [{ @@ -11,12 +9,10 @@ "client_id": "{{user `client_id`}}", "client_secret": "{{user `client_secret`}}", - "resource_group_name": "{{user `resource_group`}}", - "storage_account": "{{user `storage_account`}}", "subscription_id": "{{user `subscription_id`}}", - "capture_container_name": "images", - "capture_name_prefix": "packer", + "managed_image_resource_group_name": "packertest", + "managed_image_name": "MyMarketplaceOSImage", "os_type": "Linux", "image_publisher": "bitnami", diff --git a/examples/azure/rhel.json b/examples/azure/rhel.json index 7c4160268..895d4079b 100644 --- a/examples/azure/rhel.json +++ b/examples/azure/rhel.json @@ -2,25 +2,22 @@ "variables": { "client_id": "{{env `ARM_CLIENT_ID`}}", "client_secret": "{{env `ARM_CLIENT_SECRET`}}", - "resource_group": "{{env `ARM_RESOURCE_GROUP`}}", - "storage_account": "{{env `ARM_STORAGE_ACCOUNT`}}", "subscription_id": "{{env `ARM_SUBSCRIPTION_ID`}}", "tenant_id": "{{env `ARM_TENANT_ID`}}", "ssh_user": "centos", - "ssh_pass": null + "ssh_pass": "{{env `ARM_SSH_PASS`}}" }, "builders": [{ "type": "azure-arm", "client_id": "{{user `client_id`}}", "client_secret": "{{user `client_secret`}}", - "resource_group_name": "{{user `resource_group`}}", - "storage_account": "{{user `storage_account`}}", "subscription_id": "{{user `subscription_id`}}", "tenant_id": "{{user `tenant_id`}}", - "capture_container_name": "images", - "capture_name_prefix": "packer", + "managed_image_resource_group_name": "packertest", + "managed_image_name": "MyRedHatOSImage", + "ssh_username": "{{user `ssh_user`}}", "ssh_password": "{{user `ssh_pass`}}", diff --git a/examples/azure/suse.json b/examples/azure/suse.json index c99b364ec..4c6ff8e9e 100644 --- a/examples/azure/suse.json +++ b/examples/azure/suse.json @@ -2,23 +2,19 @@ "variables": { "client_id": "{{env `ARM_CLIENT_ID`}}", "client_secret": "{{env `ARM_CLIENT_SECRET`}}", - "resource_group": "{{env `ARM_RESOURCE_GROUP`}}", - "storage_account": "{{env `ARM_STORAGE_ACCOUNT`}}", "subscription_id": "{{env `ARM_SUBSCRIPTION_ID`}}", "ssh_user": "packer", - "ssh_pass": null + "ssh_pass": "{{env `ARM_SSH_PASS`}}" }, "builders": [{ "type": "azure-arm", "client_id": "{{user `client_id`}}", "client_secret": "{{user `client_secret`}}", - "resource_group_name": "{{user `resource_group`}}", - "storage_account": "{{user `storage_account`}}", "subscription_id": "{{user `subscription_id`}}", - - "capture_container_name": "images", - "capture_name_prefix": "packer", + + "managed_image_resource_group_name": "packertest", + "managed_image_name": "MySuseOSImage", "ssh_username": "{{user `ssh_user`}}", "ssh_password": "{{user `ssh_pass`}}", @@ -26,7 +22,7 @@ "os_type": "Linux", "image_publisher": "SUSE", "image_offer": "SLES", - "image_sku": "12-SP2", + "image_sku": "12-SP3", "ssh_pty": "true", "location": "South Central US", @@ -40,6 +36,7 @@ "/usr/sbin/waagent -force -deprovision+user && export HISTSIZE=0 && sync" ], "inline_shebang": "/bin/sh -x", + "skip_clean": true, "type": "shell" }] } diff --git a/examples/azure/ubuntu.json b/examples/azure/ubuntu.json index a9c657d06..f6cc815bc 100644 --- a/examples/azure/ubuntu.json +++ b/examples/azure/ubuntu.json @@ -2,8 +2,6 @@ "variables": { "client_id": "{{env `ARM_CLIENT_ID`}}", "client_secret": "{{env `ARM_CLIENT_SECRET`}}", - "resource_group": "{{env `ARM_RESOURCE_GROUP`}}", - "storage_account": "{{env `ARM_STORAGE_ACCOUNT`}}", "subscription_id": "{{env `ARM_SUBSCRIPTION_ID`}}" }, "builders": [{ @@ -11,24 +9,22 @@ "client_id": "{{user `client_id`}}", "client_secret": "{{user `client_secret`}}", - "resource_group_name": "{{user `resource_group`}}", - "storage_account": "{{user `storage_account`}}", "subscription_id": "{{user `subscription_id`}}", - "capture_container_name": "images", - "capture_name_prefix": "packer", - "os_type": "Linux", "image_publisher": "Canonical", "image_offer": "UbuntuServer", - "image_sku": "16.04-LTS", + "image_sku": "16.04-LTS", + + "managed_image_resource_group_name": "packertest", + "managed_image_name": "MyUbuntuImage", "azure_tags": { "dept": "engineering", "task": "image deployment" }, - "location": "West US", + "location": "South Central US", "vm_size": "Standard_DS2_v2" }], "provisioners": [{ diff --git a/examples/azure/ubuntu_managed_image.json b/examples/azure/ubuntu_managed_image.json deleted file mode 100644 index ddb4a49c9..000000000 --- a/examples/azure/ubuntu_managed_image.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "variables": { - "client_id": "{{env `ARM_CLIENT_ID`}}", - "client_secret": "{{env `ARM_CLIENT_SECRET`}}", - "subscription_id": "{{env `ARM_SUBSCRIPTION_ID`}}" - }, - "builders": [{ - "type": "azure-arm", - - "client_id": "{{user `client_id`}}", - "client_secret": "{{user `client_secret`}}", - "subscription_id": "{{user `subscription_id`}}", - - "os_type": "Linux", - "image_publisher": "Canonical", - "image_offer": "UbuntuServer", - "image_sku": "16.04-LTS", - - "managed_image_resource_group_name": "PackerImages", - "managed_image_name": "MyUbuntuImage", - - "azure_tags": { - "dept": "engineering", - "task": "image deployment" - }, - - "location": "West US", - "vm_size": "Standard_DS2_v2" - }], - "provisioners": [{ - "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'", - "inline": [ - "apt-get update", - "apt-get upgrade -y", - - "/usr/sbin/waagent -force -deprovision+user && export HISTSIZE=0 && sync" - ], - "inline_shebang": "/bin/sh -x", - "type": "shell" - }] -} diff --git a/examples/azure/windows.json b/examples/azure/windows.json index 23bd66b26..b2e0e49fd 100644 --- a/examples/azure/windows.json +++ b/examples/azure/windows.json @@ -2,8 +2,6 @@ "variables": { "client_id": "{{env `ARM_CLIENT_ID`}}", "client_secret": "{{env `ARM_CLIENT_SECRET`}}", - "resource_group": "{{env `ARM_RESOURCE_GROUP`}}", - "storage_account": "{{env `ARM_STORAGE_ACCOUNT`}}", "subscription_id": "{{env `ARM_SUBSCRIPTION_ID`}}", "object_id": "{{env `ARM_OBJECT_ID`}}" }, @@ -12,13 +10,11 @@ "client_id": "{{user `client_id`}}", "client_secret": "{{user `client_secret`}}", - "resource_group_name": "{{user `resource_group`}}", - "storage_account": "{{user `storage_account`}}", "subscription_id": "{{user `subscription_id`}}", "object_id": "{{user `object_id`}}", - "capture_container_name": "images", - "capture_name_prefix": "packer", + "managed_image_resource_group_name": "packertest", + "managed_image_name": "MyWindowsOSImage", "os_type": "Windows", "image_publisher": "MicrosoftWindowsServer", @@ -31,7 +27,7 @@ "winrm_timeout": "3m", "winrm_username": "packer", - "location": "West US", + "location": "South Central US", "vm_size": "Standard_DS2_v2" }], "provisioners": [{