mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
add plan support to azure_rm_virtualmachine (#32401)
* allows third party billing plans to be specified for an instance
This commit is contained in:
parent
d5d4683047
commit
ded023bb3b
1 changed files with 34 additions and 2 deletions
|
@ -230,6 +230,26 @@ options:
|
||||||
- "It can be 'all' or a list with any of the following: ['network_interfaces', 'virtual_storage', 'public_ips']"
|
- "It can be 'all' or a list with any of the following: ['network_interfaces', 'virtual_storage', 'public_ips']"
|
||||||
- Any other input will be ignored
|
- Any other input will be ignored
|
||||||
default: ['all']
|
default: ['all']
|
||||||
|
plan:
|
||||||
|
description:
|
||||||
|
- A dictionary describing a third-party billing plan for an instance
|
||||||
|
version_added: 2.5
|
||||||
|
suboptions:
|
||||||
|
name:
|
||||||
|
description:
|
||||||
|
- billing plan name
|
||||||
|
required: true
|
||||||
|
product:
|
||||||
|
description:
|
||||||
|
- product name
|
||||||
|
required: true
|
||||||
|
publisher:
|
||||||
|
description:
|
||||||
|
- publisher offering the plan
|
||||||
|
required: true
|
||||||
|
promotion_code:
|
||||||
|
description:
|
||||||
|
- optional promotion code
|
||||||
|
|
||||||
extends_documentation_fragment:
|
extends_documentation_fragment:
|
||||||
- azure
|
- azure
|
||||||
|
@ -544,7 +564,7 @@ try:
|
||||||
VirtualHardDisk, ManagedDiskParameters, \
|
VirtualHardDisk, ManagedDiskParameters, \
|
||||||
ImageReference, NetworkProfile, LinuxConfiguration, \
|
ImageReference, NetworkProfile, LinuxConfiguration, \
|
||||||
SshConfiguration, SshPublicKey, VirtualMachineSizeTypes, \
|
SshConfiguration, SshPublicKey, VirtualMachineSizeTypes, \
|
||||||
DiskCreateOptionTypes
|
DiskCreateOptionTypes, Plan
|
||||||
from azure.mgmt.network.models import PublicIPAddress, NetworkSecurityGroup, NetworkInterface, \
|
from azure.mgmt.network.models import PublicIPAddress, NetworkSecurityGroup, NetworkInterface, \
|
||||||
NetworkInterfaceIPConfiguration, Subnet
|
NetworkInterfaceIPConfiguration, Subnet
|
||||||
from azure.mgmt.storage.models import StorageAccountCreateParameters, Sku
|
from azure.mgmt.storage.models import StorageAccountCreateParameters, Sku
|
||||||
|
@ -606,6 +626,7 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
|
||||||
restarted=dict(type='bool', default=False),
|
restarted=dict(type='bool', default=False),
|
||||||
started=dict(type='bool', default=True),
|
started=dict(type='bool', default=True),
|
||||||
data_disks=dict(type='list'),
|
data_disks=dict(type='list'),
|
||||||
|
plan=dict(type='dict')
|
||||||
)
|
)
|
||||||
|
|
||||||
self.resource_group = None
|
self.resource_group = None
|
||||||
|
@ -639,6 +660,7 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
|
||||||
self.started = None
|
self.started = None
|
||||||
self.differences = None
|
self.differences = None
|
||||||
self.data_disks = None
|
self.data_disks = None
|
||||||
|
self.plan = None
|
||||||
|
|
||||||
self.results = dict(
|
self.results = dict(
|
||||||
changed=False,
|
changed=False,
|
||||||
|
@ -698,12 +720,16 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
|
||||||
if self.image:
|
if self.image:
|
||||||
if not self.image.get('publisher') or not self.image.get('offer') or not self.image.get('sku') \
|
if not self.image.get('publisher') or not self.image.get('offer') or not self.image.get('sku') \
|
||||||
or not self.image.get('version'):
|
or not self.image.get('version'):
|
||||||
self.error("parameter error: expecting image to contain publisher, offer, sku and version keys.")
|
self.fail("parameter error: expecting image to contain publisher, offer, sku and version keys.")
|
||||||
image_version = self.get_image_version()
|
image_version = self.get_image_version()
|
||||||
if self.image['version'] == 'latest':
|
if self.image['version'] == 'latest':
|
||||||
self.image['version'] = image_version.name
|
self.image['version'] = image_version.name
|
||||||
self.log("Using image version {0}".format(self.image['version']))
|
self.log("Using image version {0}".format(self.image['version']))
|
||||||
|
|
||||||
|
if self.plan:
|
||||||
|
if not self.plan.get('name') or not self.plan.get('product') or not self.plan.get('publisher'):
|
||||||
|
self.fail("parameter error: plan must include name, product, and publisher")
|
||||||
|
|
||||||
if not self.storage_blob_name and not self.managed_disk_type:
|
if not self.storage_blob_name and not self.managed_disk_type:
|
||||||
self.storage_blob_name = self.name + '.vhd'
|
self.storage_blob_name = self.name + '.vhd'
|
||||||
elif self.managed_disk_type:
|
elif self.managed_disk_type:
|
||||||
|
@ -850,6 +876,11 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
|
||||||
vhd = None
|
vhd = None
|
||||||
managed_disk = ManagedDiskParameters(storage_account_type=self.managed_disk_type)
|
managed_disk = ManagedDiskParameters(storage_account_type=self.managed_disk_type)
|
||||||
|
|
||||||
|
plan = None
|
||||||
|
if self.plan:
|
||||||
|
plan = Plan(name=self.plan.get('name'), product=self.plan.get('product'), publisher=self.plan.get('publisher'),
|
||||||
|
promotion_code=self.product.get('promotion_code'))
|
||||||
|
|
||||||
vm_resource = VirtualMachine(
|
vm_resource = VirtualMachine(
|
||||||
self.location,
|
self.location,
|
||||||
tags=self.tags,
|
tags=self.tags,
|
||||||
|
@ -878,6 +909,7 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
|
||||||
network_profile=NetworkProfile(
|
network_profile=NetworkProfile(
|
||||||
network_interfaces=nics
|
network_interfaces=nics
|
||||||
),
|
),
|
||||||
|
plan=plan
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.admin_password:
|
if self.admin_password:
|
||||||
|
|
Loading…
Reference in a new issue