Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vm change to support specialized #62586

Merged
merged 1 commit into from
Sep 19, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 8 additions & 9 deletions lib/ansible/modules/cloud/azure/azure_rm_virtualmachine.py
Original file line number Diff line number Diff line change
Expand Up @@ -1204,10 +1204,6 @@ def exec_module(self, **kwargs):
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.")
Expand Down Expand Up @@ -1272,13 +1268,16 @@ def exec_module(self, **kwargs):
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
),
Expand Down Expand Up @@ -1354,7 +1353,7 @@ def exec_module(self, **kwargs):
# 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
)
Expand Down