Clean up and migrate Azure tests. (#28103)

* Remove placeholder Azure test.
* Migrate Azure tests to ansible-test.
* Initial cleanup on remaining legacy Azure tests.
This commit is contained in:
Matt Clay
2017-08-12 01:03:42 -07:00
committed by GitHub
parent ac56a2f138
commit 3631163329
23 changed files with 264 additions and 638 deletions

View File

@@ -1,2 +1,2 @@
# - include: virtualmachine.yml
- include: virtualmachine_with_defaults.yml
- include: virtualmachine.yml
#- include: virtualmachine_with_defaults.yml

View File

@@ -1,23 +1,19 @@
- name: Create resource group
azure_rm_resourcegroup:
name: Testing
location: "{{ location }}"
- name: Delete virtual machine
azure_rm_virtualmachine:
resource_group: "{{ resource_group }}"
name: testvm002
state: absent
vm_size: Standard_A0
register: output
when: remove_vm
- debug: var=output
when: playbook_debug
- name: Create storage account name
set_fact:
storage_account: "{{ resource_group | hash('md5') | truncate(24, True, '') }}"
- name: Create storage account
azure_rm_storageaccount:
resource_group: "{{ resource_group }}"
name: testingstorageacct001
name: "{{ storage_account }}"
account_type: Standard_LRS
- name: Create virtual network
@@ -57,8 +53,8 @@
azure_rm_virtualmachine:
resource_group: "{{ resource_group }}"
name: testvm002
vm_size: Standard_D1
storage_account: testingstorageacct001
vm_size: Standard_A0
storage_account: "{{ storage_account }}"
storage_container: testvm001
storage_blob: testvm001.vhd
admin_username: adminuser
@@ -66,22 +62,21 @@
short_hostname: testvm
os_type: Linux
network_interfaces: testvm001
image: "{{ image }}"
image:
offer: UbuntuServer
publisher: Canonical
sku: 16.04-LTS
version: latest
register: output
- debug: var=output
when: playbook_debug
- name: Restart the virtual machine
azure_rm_virtualmachine:
resource_group: "{{ resource_group }}"
name: testvm002
restarted: yes
vm_size: Standard_A0
register: output
- debug: var=output
when: playbook_debug
- assert:
that:
- "azure_vm.powerstate in ['starting', 'running']"
@@ -92,11 +87,9 @@
resource_group: "{{ resource_group }}"
name: testvm002
allocated: no
vm_size: Standard_A0
register: output
- debug: var=output
when: playbook_debug
- assert:
that:
- azure_vm.powerstate == 'deallocated'
@@ -106,11 +99,9 @@
azure_rm_virtualmachine:
resource_group: "{{ resource_group }}"
name: testvm002
vm_size: Standard_A0
register: output
- debug: var=output
when: playbook_debug
- assert:
that:
- "azure_vm.powerstate in ['starting', 'running']"
@@ -120,8 +111,8 @@
azure_rm_virtualmachine:
resource_group: "{{ resource_group }}"
name: testvm002
vm_size: Standard_D1
storage_account: testingstorageacct001
vm_size: Standard_A0
storage_account: "{{ storage_account }}"
storage_container: testvm001
storage_blob: testvm001.vhd
admin_username: adminuser
@@ -129,7 +120,11 @@
short_hostname: testvm
os_type: Linux
network_interfaces: testvm001
image: "{{ image }}"
image:
offer: UbuntuServer
publisher: Canonical
sku: 16.04-LTS
version: latest
register: output
- assert:
@@ -140,20 +135,15 @@
resource_group: "{{ resource_group }}"
name: testvm002
state: absent
vm_size: Standard_A0
register: output
- debug: var=output
when: playbook_debug
- name: NIC should be gone
azure_rm_networkinterface_facts:
resource_group: "{{ resource_group }}"
name: testvm001
register: output
- debug: var=output
when: playbook_debug
- assert:
that: azure_networkinterfaces | length == 0
@@ -163,8 +153,5 @@
name: testvm001
register: output
- debug: var=output
when: playbook_debug
- assert:
that: azure_publicipaddresses | length == 0

View File

@@ -1,51 +1,37 @@
- name: Create resource group
azure_rm_resourcegroup:
name: "{{ resource_group }}"
location: "{{ location }}"
register: output
- debug: var=output
when: playbook_debug
- name: Remove VM
azure_rm_virtualmachine:
resource_group: "{{ resource_group }}"
name: testvm10
state: absent
vm_size: Standard_A0
register: output
when: remove_vm
- debug: var=output
when: playbook_debug
- name: Remove VM
azure_rm_virtualmachine:
resource_group: "{{ resource_group }}"
name: testvm20
state: absent
vm_size: Standard_A0
register: output
when: remove_vm
- debug: var=output
when: playbook_debug
- name: Create VM with defaults
azure_rm_virtualmachine:
resource_group: "{{ resource_group }}"
name: testvm10
vm_size: Standard_D1
vm_size: Standard_A0
admin_username: chouseknecht
admin_password: Password123
short_hostname: test10
os_type: Linux
open_ports:
- "22-23"
image: "{{ image }}"
image:
offer: UbuntuServer
publisher: Canonical
sku: 16.04-LTS
version: latest
register: output
- debug: var=output
when: playbook_debug
- name: Add host
add_host:
groups: just_created
@@ -60,30 +46,36 @@
name: testvm20
short_hostname: testvm20
ssh_password_enabled: false
ssh_public_keys: "{{ ssh_keys }}"
vm_size: Standard_D1
ssh_public_keys:
- path: /home/chouseknecht/.ssh/authorized_keys
key_data: "{{ lookup('env', 'HOME') }}/.ssh/id_rsa"
vm_size: Standard_A0
admin_username: chouseknecht
image: "{{ image }}"
image:
offer: UbuntuServer
publisher: Canonical
sku: 16.04-LTS
version: latest
register: output
- debug: var=output
when: playbook_debug
- name: Should be idempotent
azure_rm_virtualmachine:
resource_group: "{{ resource_group }}"
name: testvm20
short_hostname: testvm20
ssh_password_enabled: false
ssh_public_keys: "{{ ssh_keys }}"
vm_size: Standard_D1
ssh_public_keys:
- path: /home/chouseknecht/.ssh/authorized_keys
key_data: "{{ lookup('env', 'HOME') }}/.ssh/id_rsa"
vm_size: Standard_A0
admin_username: chouseknecht
image: "{{ image }}"
image:
offer: UbuntuServer
publisher: Canonical
sku: 16.04-LTS
version: latest
register: output
- debug: var=output
when: playbook_debug
- assert:
that: not output.changed
@@ -101,9 +93,6 @@
started: no
register: output
- debug: var=output
when: playbook_debug
- assert:
that: "azure_vm.powerstate not in ['starting', 'running']"
@@ -113,8 +102,5 @@
name: testvm10
register: output
- debug: var=output
when: playbook_debug
- assert:
that: "azure_vm.powerstate in ['starting', 'running']"