diff options
author | Zim Kalinowski <zikalino@microsoft.com> | 2019-09-20 00:45:24 +0800 |
---|---|---|
committer | Matt Davis <nitzmahone@users.noreply.github.com> | 2019-09-19 09:45:24 -0700 |
commit | c8e220a62e85dc817a17d0e1037c14a7a551cdff (patch) | |
tree | cdb0b0f38a2c0acb0169bee78973225da4258203 | |
parent | 9a43a8fcfcf9f075011a577395584024e4dc22d1 (diff) | |
download | ansible-c8e220a62e85dc817a17d0e1037c14a7a551cdff.tar.gz |
vm change to support specialized (#62586)
-rw-r--r-- | lib/ansible/modules/cloud/azure/azure_rm_virtualmachine.py | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine.py b/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine.py index 61468a84c4..dbc94ecd0a 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine.py @@ -1204,10 +1204,6 @@ class AzureRMVirtualMachine(AzureRMModuleBase): self.log("Create virtual machine {0}".format(self.name)) self.results['actions'].append('Created VM {0}'.format(self.name)) - # Validate parameters - if not self.admin_username: - self.fail("Parameter error: admin_username required when creating a virtual machine.") - if self.os_type == 'Linux': if disable_ssh_password and not self.ssh_public_keys: self.fail("Parameter error: ssh_public_keys required when disabling SSH password.") @@ -1272,13 +1268,16 @@ class AzureRMVirtualMachine(AzureRMModuleBase): if self.boot_diagnostics_present and self.boot_diagnostics['enabled']: boot_diag_storage_account = self.get_boot_diagnostics_storage_account() + os_profile = None + if self.admin_username: + os_profile = self.compute_models.OSProfile( + admin_username=self.admin_username, + computer_name=self.short_hostname, + ) vm_resource = self.compute_models.VirtualMachine( location=self.location, tags=self.tags, - os_profile=self.compute_models.OSProfile( - admin_username=self.admin_username, - computer_name=self.short_hostname, - ), + os_profile=os_profile, hardware_profile=self.compute_models.HardwareProfile( vm_size=self.vm_size ), @@ -1354,7 +1353,7 @@ class AzureRMVirtualMachine(AzureRMModuleBase): # Azure SDK (erroneously?) wants native string type for this vm_resource.os_profile.custom_data = to_native(base64.b64encode(to_bytes(self.custom_data))) - if self.os_type == 'Linux': + if self.os_type == 'Linux' and os_profile: vm_resource.os_profile.linux_configuration = self.compute_models.LinuxConfiguration( disable_password_authentication=disable_ssh_password ) |