Azure-Samples / ansible-playbooks

Ansible Playbook Samples for Azure
MIT License
224 stars 349 forks source link

Missing example for creating a specialized image version with azure_rm_galleryimageversion using storage_profile #89

Open seflue opened 2 years ago

seflue commented 2 years ago

I really would appreciate an example how to create a specialized image version with Ansible. I'm trying that since two days without any success - but with Azure CLI it works.

This is essentially my ansible declaration:

    - name: Create a gallery image version form a managed image                              |~
      azure_rm_galleryimageversion:
        resource_group: "{{ resource_group }}"
        gallery_name: "{{ image_gallery }}"
        gallery_image_name: "{{ image_name }}"
        name: "{{ image_version }}"
        location: "{{ location }}"
        publishing_profile:
          end_of_life_date: ""
          exclude_from_latest: no
          replica_count: 2
          storage_account_type: Standard_LRS
          target_regions:
            - name: "{{ location }}"
              regional_replica_count: 1
        storage_profile:
          source_image: "/subscriptions/{{ subscription }}/resourceGroups/{{ resource_group }}/providers/Microsoft.Compute/virtualMachines/{{ vm }}"

Especially the following error message is not helpful:

Error creating the GalleryImageVersion instance: Azure Error: InvalidParameter Message: The gallery artifact version source can only be specified either directly under storageProfile or within individual OS or data disks. One and only one source type (user image, snapshot, disk, virtual machine) can be provided. Target: galleryImageVersion.properties.storageProfile.source.id

And the documentation on that does not help at all:

Message: The gallery artifact version source can only be specified either directly under storageProfile or within individual OS or data disks. One and only one source type (user image, snapshot, disk, virtual machine) can be provided. Cause: The source ID is missing. Workaround: Ensure that the source ID of the source is present.

The examples on that are outdated, because they're using "managed_image" which is depricated.