I am trying to automate the process of updating an image in the scale set. So, I wrote an Ansible playbook to create a VM from a custom image and then, later, make some changes in that VM, capture an image of the said VM and change the image reference in the scale set. But I am getting the following error:
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Error creating or updating virtual machine vmss_update_vm - (InvalidParameter) Parameter 'osProfile' is not allowed.\nCode: InvalidParameter\nMessage: Parameter 'osProfile' is not allowed.\nTarget: osProfile"}
The play looks like this:
- name:
hosts: localhost
connection: local
gather_facts: false
vars:
resource_group: {{resource_group }}
shared_gallery_name: linux_build
shared_image_name: linux_build
shared_image_version: 0.0.1
admin_username: ubuntuadmin
admin_password: Ubuntuadmin@123
vm_name: vmss_update_vm
vmss_name: testbuild2
tasks:
- name: Create VM using shared image
azure_rm_virtualmachine:
resource_group: "{{ resource_group }}"
name: "{{ vm_name }}"
vm_size: Standard_D2s_v3
managed_disk_type: Standard_LRS
admin_username: testadmin
admin_password: Pass123@
image:
id: "/subscriptions/{{subscription_id}}/resourceGroups/{{resource_group}}/providers/Microsoft.Compute/galleries/linux_build/images/linux-build/versions/0.0.1"
# name: linux-build
On further research, I found out that I was providing the admin_user
and admin_password
along with a custom image which is not allowed.
So, I removed the admin_user
and admin_password
and ran the playbook again:
- name:
hosts: localhost
connection: local
gather_facts: false
vars:
resource_group: {{resource_group }}
shared_gallery_name: linux_build
shared_image_name: linux_build
shared_image_version: 0.0.1
vm_name: vmss_update_vm
vmss_name: testbuild2
tasks:
- name: Create VM using shared image
azure_rm_virtualmachine:
resource_group: "{{ resource_group }}"
name: "{{ vm_name }}"
vm_size: Standard_D2s_v3
managed_disk_type: Standard_LRS
admin_username: testadmin
admin_password: Pass123@
image:
id: "/subscriptions/{{subscription_id}}/resourceGroups/{{resource_group}}/providers/Microsoft.Compute/galleries/linux_build/images/linux-build/versions/0.0.1"
# name: linux-build
But after that I am getting the following error:
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Parameter error: admin_username required when creating a virtual machine."}
Do you have any idea how can I deal with this?