fixed crash in facts (#50120)

pull/4420/head
Zim Kalinowski 2018-12-19 11:01:45 +08:00 committed by ansibot
parent f761cc4077
commit 756ad176cc
1 changed files with 3 additions and 1 deletions

View File

@ -317,7 +317,9 @@ class AzureRMVirtualMachineFacts(AzureRMModuleBase):
new_result['state'] = 'present'
new_result['location'] = vm.location
new_result['vm_size'] = result['properties']['hardwareProfile']['vmSize']
new_result['admin_username'] = result['properties']['osProfile']['adminUsername']
os_profile = result['properties'].get('osProfile')
if os_profile is not None:
new_result['admin_username'] = os_profile.get('adminUsername')
image = result['properties']['storageProfile'].get('imageReference')
if image is not None:
if image.get('publisher', None) is not None: