azure_rm_virtualmachine module causing error to start or stop VM

Hi

I am getting the following error whenever I try to control an Azure VM to start or stop:

The full traceback is:
Traceback (most recent call last):
File “/tmp/ansible-tmp-1559657705.67-271285273530579/AnsiballZ_azure_rm_virtualmachine.py”, line 114, in
_ansiballz_main()
File “/tmp/ansible-tmp-1559657705.67-271285273530579/AnsiballZ_azure_rm_virtualmachine.py”, line 106, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File “/tmp/ansible-tmp-1559657705.67-271285273530579/AnsiballZ_azure_rm_virtualmachine.py”, line 49, in invoke_module
imp.load_module(‘main’, mod, module, MOD_DESC)
File “/tmp/ansible_azure_rm_virtualmachine_payload_I72j_4/main.py”, line 2045, in
File “/tmp/ansible_azure_rm_virtualmachine_payload_I72j_4/main.py”, line 2041, in main
File “/tmp/ansible_azure_rm_virtualmachine_payload_I72j_4/main.py”, line 853, in init
File “/tmp/ansible_azure_rm_virtualmachine_payload_I72j_4/ansible_azure_rm_virtualmachine_payload.zip/ansible/module_utils/azure_rm_common.py”, line 325, in init
File “/tmp/ansible_azure_rm_virtualmachine_payload_I72j_4/main.py”, line 1434, in exec_module
KeyError: ‘diskSizeGB’
fatal: [localhost]: FAILED! => {
“changed”: false,
“module_stderr”: “Traceback (most recent call last):\n File "/tmp/ansible-tmp-1559657705.67-271285273530579/AnsiballZ_azure_rm_virtualmachine.py", line 114, in \n _ansiballz_main()\n File "/tmp/ansible-tmp-1559657705.67-271285273530579/AnsiballZ_azure_rm_virtualmachine.py", line 106, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File "/tmp/ansible-tmp-1559657705.67-271285273530579/AnsiballZ_azure_rm_virtualmachine.py", line 49, in invoke_module\n imp.load_module(‘main’, mod, module, MOD_DESC)\n File "/tmp/ansible_azure_rm_virtualmachine_payload_I72j_4/main.py", line 2045, in \n File "/tmp/ansible_azure_rm_virtualmachine_payload_I72j_4/main.py", line 2041, in main\n File "/tmp/ansible_azure_rm_virtualmachine_payload_I72j_4/main.py", line 853, in init\n File "/tmp/ansible_azure_rm_virtualmachine_payload_I72j_4/ansible_azure_rm_virtualmachine_payload.zip/ansible/module_utils/azure_rm_common.py", line 325, in init\n File "/tmp/ansible_azure_rm_virtualmachine_payload_I72j_4/main.py", line 1434, in exec_module\nKeyError: ‘diskSizeGB’\n”,
“module_stdout”: “”,
“msg”: “MODULE FAILURE\nSee stdout/stderr for the exact error”,
“rc”: 1
}

In the playbook, I have it configured as follows:

  • azure_rm_virtualmachine:
    resource_group: RESOURCEGROUP
    name:
    started: yes
    allocated: yes

or

  • azure_rm_virtualmachine:
    resource_group: RESOURCEGROUP
    name:
    started: no
    allocated: no

Somehow I got it to work for one of my VMs, but it is not working others.

An update on this is that if the VM is already on, and I use the playbook to turn off the VM, then after that all subsequent requests to manage that VM to turn on or off the VM will always work.

What version of Ansible and Python are you running?

I have seen odd errors like your
`
KeyError: ‘diskSizeGB’

`
with the azure_rm_devtestlabvirtualmachine - seems almost like it isnt properly determining what fields are required and whats not. I was seeing things like the virtual network being a required field, even if I set state = absent which doesnt seem to make sense if all is wanted is to delete a VM.