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:
Zim Kalinowski 2018-03-22 07:30:42 +08:00 committed by Jordan Borean
commit 0b828ee830
2 changed files with 38 additions and 6 deletions

View file

@ -222,6 +222,35 @@
- assert:
that: azure_publicipaddresses | length == 0
- name: Create virtual machine without public ip address
register: output
azure_rm_virtualmachine:
resource_group: "{{ resource_group }}"
name: testvmnoip
vm_size: Standard_A0
admin_username: adminuser
admin_password: Password123!
short_hostname: testvm
os_type: Linux
public_ip_allocation_method: Disabled
availability_set: "avbs{{ resource_group | hash('md5') | truncate(7, True, '') }}"
image:
offer: UbuntuServer
publisher: Canonical
sku: 16.04-LTS
version: latest
- assert:
that:
- not 'publicIPAddress' in output.ansible_facts.azure_vm.properties.networkProfile.networkInterfaces[0].properties.ipConfigurations[0].properties
- name: Delete VM with no public ip
azure_rm_virtualmachine:
resource_group: "{{ resource_group }}"
name: testvmnoip
state: absent
vm_size: Standard_A0
# TODO: Until we have a module to create/delete images this is the best tests
# I can do
- name: assert error thrown with invalid image dict