Added license_type, vm_identety and win_rm attributes to azure_rm_virtualmachine module (#42400)

pull/55130/head
Christopher Perrin 5 years ago committed by Zim Kalinowski
parent 5145473451
commit 6e5165b4fb

@ -314,6 +314,43 @@ options:
- A list of Availability Zones for your virtual machine
type: list
version_added: "2.8"
license_type:
description:
- Specifies that the image or disk that is being used was licensed on-premises. This element is only
used for images that contain the Windows Server operating system.
- "Note: To unset this value, it has to be set to the string 'None'."
version_added: 2.8
choices:
- Windows_Server
- Windows_Client
vm_identity:
description:
- Identity for the virtual machine.
version_added: 2.8
choices:
- SystemAssigned
winrm:
description:
- List of Windows Remote Management configurations of the VM.
version_added: 2.8
suboptions:
protocol:
description:
- Specifies the protocol of listener
required: true
choices:
- http
- https
source_vault:
description:
- The relative URL of the Key Vault containing the certificate
certificate_url:
description:
- This is the URL of a certificate that has been uploaded to Key Vault as a secret.
certificate_store:
description:
- Specifies the certificate store on the Virtual Machine to which the certificate
should be added. The specified certificate store is implicitly in the LocalMachine account.
extends_documentation_fragment:
- azure
@ -322,6 +359,8 @@ extends_documentation_fragment:
author:
- "Chris Houseknecht (@chouseknecht)"
- "Matt Davis (@nitzmahone)"
- "Christopher Perrin (@cperrin88)"
'''
EXAMPLES = '''
@ -754,8 +793,11 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
generalized=dict(type='bool', default=False),
data_disks=dict(type='list'),
plan=dict(type='dict'),
zones=dict(type='list'),
accept_terms=dict(type='bool', default=False),
zones=dict(type='list')
license_type=dict(type='str', choices=['Windows_Server', 'Windows_Client']),
vm_identity=dict(type='str', choices=['SystemAssigned']),
winrm=dict(type='list')
)
self.resource_group = None
@ -797,6 +839,8 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
self.plan = None
self.accept_terms = None
self.zones = None
self.license_type = None
self.vm_identity = None
self.results = dict(
changed=False,
@ -996,6 +1040,9 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
differences.append('Zones')
changed = True
if self.license_type is not None and vm_dict['properties'].get('licenseType') != self.license_type:
differences.append('License Type')
changed = True
self.differences = differences
elif self.state == 'absent':
@ -1087,6 +1134,8 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
publisher=self.plan.get('publisher'),
promotion_code=self.plan.get('promotion_code'))
license_type = self.license_type
vm_resource = self.compute_models.VirtualMachine(
location=self.location,
tags=self.tags,
@ -1116,6 +1165,46 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
zones=self.zones,
)
if self.license_type is not None:
vm_resource.license_type = self.license_type
if self.vm_identity:
vm_resource.identity = self.compute_models.VirtualMachineIdentity(type=self.vm_identity)
if self.winrm:
winrm_listeners = list()
for winrm_listener in self.winrm:
winrm_listeners.append(self.compute_models.WinRMListener(
protocol=winrm_listener.get('protocol'),
certificate_url=winrm_listener.get('certificate_url')
))
if winrm_listener.get('source_vault'):
if not vm_resource.os_profile.secrets:
vm_resource.os_profile.secrets = list()
vm_resource.os_profile.secrets.append(self.compute_models.VaultSecretGroup(
source_vault=self.compute_models.SubResource(
id=winrm_listener.get('source_vault')
),
vault_certificates=[
self.compute_models.VaultCertificate(
certificate_url=winrm_listener.get('certificate_url'),
certificate_store=winrm_listener.get('certificate_store')
),
]
))
winrm = self.compute_models.WinRMConfiguration(
listeners=winrm_listeners
)
if not vm_resource.os_profile.windows_configuration:
vm_resource.os_profile.windows_configuration = self.compute_models.WindowsConfiguration(
win_rm=winrm
)
elif not vm_resource.os_profile.windows_configuration.win_rm:
vm_resource.os_profile.windows_configuration.win_rm = winrm
if self.admin_password:
vm_resource.os_profile.admin_password = self.admin_password
@ -1263,6 +1352,9 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
)
else:
os_profile = None
license_type = None
if self.license_type is None:
license_type = "None"
vm_resource = self.compute_models.VirtualMachine(
location=vm_dict['location'],
@ -1285,9 +1377,12 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
availability_set=availability_set_resource,
network_profile=self.compute_models.NetworkProfile(
network_interfaces=nics
),
)
)
if self.license_type is not None:
vm_resource.license_type = self.license_type
if vm_dict.get('tags'):
vm_resource.tags = vm_dict['tags']

Loading…
Cancel
Save