hashicorp / packer-plugin-azure

Packer plugin for Azure Virtual Machine Image Builders
https://www.packer.io/docs/builders/azure
Mozilla Public License 2.0
50 stars 79 forks source link

Azure: Problems with disk_additional_size on images containg already additional disks #18

Open ghost opened 3 years ago

ghost commented 3 years ago

This issue was originally opened by @loibpet as hashicorp/packer#7042. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.


packer -v: 1.3.2

We are using for our images a "chained" process for on-premis and for all cloud providers, i.e. we create one basis containing all required hardening, company specific setup and cloud specific configuration. Then we use this basis in another step and create the intended image flavor. In step one, we create one additional disk to separate the /var/log tree to a separate disk (company way of doing things which cannot be changed). For certain use cases, we need to use one more data disk in the image (e.g. for local data storage).

Our templates look like this:

Step 1:

    "builders": [
        {
            "type": "azure-arm",
            "client_id": "{{user `client_id`}}",
            "client_secret": "{{user `client_secret`}}",
            "subscription_id": "{{user `subscription_id`}}",
            "tenant_id": "{{user `tenant_id`}}",
            "ssh_username": "azure",
            "ssh_password": "MySecretPassword",
            "os_type": "Linux",
            "image_publisher": "OpenLogic",
            "image_offer": "CentOS",
            "image_sku": "7.5",
            "image_version": "latest",
            "ssh_pty": "true",
            "vm_size": "Standard_B1s",
            "disk_additional_size": [
                5
            ],
            "managed_image_name": "packer-test-step1",
            "managed_image_resource_group_name": "my-rg",
            "location": "West Europe",
            "virtual_network_name": "my-vnet",
            "virtual_network_resource_group_name": "my-rg",
            "virtual_network_subnet_name": "private"
        }

This works fine and the image is created as needed.

Step 2 - Version 1:

    "builders": [
        {
            "type": "azure-arm",
            "client_id": "{{user `client_id`}}",
            "client_secret": "{{user `client_secret`}}",
            "subscription_id": "{{user `subscription_id`}}",
            "tenant_id": "{{user `tenant_id`}}",
            "ssh_username": "azure",
            "ssh_password": "MySecretPassword",
            "os_type": "Linux",
            "custom_managed_image_name": "packer-test-step1",
            "custom_managed_image_resource_group_name": "my-rg",
            "ssh_pty": "true",
            "vm_size": "Standard_B1s",
            "disk_additional_size": [
                10
            ],
            "managed_image_name": "packer-test-step2a",
            "managed_image_resource_group_name": "my-rg",
            "location": "West Europe",
            "virtual_network_name": "my-vnet",
            "virtual_network_resource_group_name": "my-rg",
            "virtual_network_subnet_name": "private"
        }

This one fails with:

==> azure-arm: ERROR: -> BadRequest

==> azure-arm: ERROR: -> InvalidParameter : Cannot specify user image overrides for a disk already defined in the specified image reference.

Step 2 - Version 2:

    "builders": [
        {
            "type": "azure-arm",
            "client_id": "{{user `client_id`}}",
            "client_secret": "{{user `client_secret`}}",
            "subscription_id": "{{user `subscription_id`}}",
            "tenant_id": "{{user `tenant_id`}}",
            "ssh_username": "azure",
            "ssh_password": "MySecretPassword",
            "os_type": "Linux",
            "custom_managed_image_name": "packer-test-step1",
            "custom_managed_image_resource_group_name": "my-rg",
            "ssh_pty": "true",
            "vm_size": "Standard_B1s",
            "disk_additional_size": [
                5, 10
            ],
            "managed_image_name": "packer-test-step2b",
            "managed_image_resource_group_name": "my-rg",
            "location": "West Europe",
            "virtual_network_name": "my-vnet",
            "virtual_network_resource_group_name": "my-rg",
            "virtual_network_subnet_name": "private"
        }

Adding the size of the user disk of step 1 fails as well:

==> azure-arm: ERROR: -> BadRequest

==> azure-arm: ERROR: -> InvalidParameter : Cannot specify user image overrides for a disk already defined in the specified image reference.

ayushtessell commented 1 year ago

Hey everyone I'm getting this error, has anyone found any solution for it , or reason why is it happening with packer ?