mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 13:20:23 -07:00
azure_rm_virtualmachine: adding possibility of disabling public ip address (#36766)
* adding possibility of disabling public ip address * fixed indent * fixed whitespace * fixed mistake * try to create test with vm without public ip address * try to fix test * another attempt for test * fixing test * create vm with no ip with different name and delete it immediately * a few additional fixes * another attempt to pass test * must be deleted * simplified no ip test * reorganised tests * Wrapped choice in C()
This commit is contained in:
parent
89a80e0591
commit
0b828ee830
2 changed files with 38 additions and 6 deletions
|
@ -202,9 +202,11 @@ options:
|
|||
- If a public IP address is created when creating the VM (because a Network Interface was not provided),
|
||||
determines if the public IP address remains permanently associated with the Network Interface. If set
|
||||
to 'Dynamic' the public IP address may change any time the VM is rebooted or power cycled.
|
||||
- The C(Disabled) choice was added in Ansible 2.6.
|
||||
choices:
|
||||
- Dynamic
|
||||
- Static
|
||||
- Disabled
|
||||
default:
|
||||
- Static
|
||||
aliases:
|
||||
|
@ -646,7 +648,7 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
|
|||
default='ReadOnly'),
|
||||
managed_disk_type=dict(type='str', choices=['Standard_LRS', 'Premium_LRS']),
|
||||
os_type=dict(type='str', choices=['Linux', 'Windows'], default='Linux'),
|
||||
public_ip_allocation_method=dict(type='str', choices=['Dynamic', 'Static'], default='Static',
|
||||
public_ip_allocation_method=dict(type='str', choices=['Dynamic', 'Static', 'Disabled'], default='Static',
|
||||
aliases=['public_ip_allocation']),
|
||||
open_ports=dict(type='list'),
|
||||
network_interface_names=dict(type='list', aliases=['network_interfaces']),
|
||||
|
@ -1641,8 +1643,11 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
|
|||
if not subnet_id:
|
||||
self.fail(no_subnets_msg)
|
||||
|
||||
self.results['actions'].append('Created default public IP {0}'.format(self.name + '01'))
|
||||
pip = self.create_default_pip(self.resource_group, self.location, self.name + '01', self.public_ip_allocation_method)
|
||||
pip = None
|
||||
if self.public_ip_allocation_method != 'Disabled':
|
||||
self.results['actions'].append('Created default public IP {0}'.format(self.name + '01'))
|
||||
pip_info = self.create_default_pip(self.resource_group, self.location, self.name + '01', self.public_ip_allocation_method)
|
||||
pip = self.network_models.PublicIPAddress(id=pip_info.id, location=pip_info.location, resource_guid=pip_info.resource_guid)
|
||||
|
||||
self.results['actions'].append('Created default security group {0}'.format(self.name + '01'))
|
||||
group = self.create_default_securitygroup(self.resource_group, self.location, self.name + '01', self.os_type,
|
||||
|
@ -1661,9 +1666,7 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
|
|||
parameters.network_security_group = self.network_models.NetworkSecurityGroup(id=group.id,
|
||||
location=group.location,
|
||||
resource_guid=group.resource_guid)
|
||||
parameters.ip_configurations[0].public_ip_address = self.network_models.PublicIPAddress(id=pip.id,
|
||||
location=pip.location,
|
||||
resource_guid=pip.resource_guid)
|
||||
parameters.ip_configurations[0].public_ip_address = pip
|
||||
|
||||
self.log("Creating NIC {0}".format(network_interface_name))
|
||||
self.log(self.serialize_obj(parameters, 'NetworkInterface'), pretty_print=True)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue