From 36311633299fe9af67214ff8027f21e63c84467a Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Sat, 12 Aug 2017 01:03:42 -0700 Subject: [PATCH] Clean up and migrate Azure tests. (#28103) * Remove placeholder Azure test. * Migrate Azure tests to ansible-test. * Initial cleanup on remaining legacy Azure tests. --- .../roles/azure_rm_deployment/tasks/main.yml | 4 - .../azure_rm_networkinterface/tasks/main.yml | 88 -------- .../azure_rm_resourcegroup/tasks/main.yml | 55 ++--- .../azure_rm_securitygroup/tasks/main.yml | 32 --- .../azure_rm_virtualmachine/tasks/main.yml | 4 +- .../tasks/virtualmachine.yml | 59 ++---- .../tasks/virtualmachine_with_defaults.yml | 66 +++--- .../tasks/main.yml | 13 -- .../azure_rm_virtualnetwork/tasks/main.yml | 196 ------------------ .../targets/azure_rm_publicipaddress/aliases | 2 + .../azure_rm_publicipaddress/meta/main.yml | 2 + .../azure_rm_publicipaddress/tasks/main.yml | 45 +--- .../targets/azure_rm_storageaccount/aliases | 2 + .../azure_rm_storageaccount/meta/main.yml | 2 + .../azure_rm_storageaccount/tasks/main.yml | 61 ++---- .../targets/azure_rm_storageblob/aliases | 2 + .../azure_rm_storageblob/files/Ratings.png | Bin .../azure_rm_storageblob/meta/main.yml | 2 + .../azure_rm_storageblob/tasks/main.yml | 69 ++---- .../targets/azure_rm_subnet/aliases | 2 + .../targets/azure_rm_subnet/meta/main.yml | 2 + .../azure_rm_subnet/tasks/main.yml | 39 ---- .../azure_rm_virtualnetwork/tasks/main.yml | 155 +++++++++++++- 23 files changed, 264 insertions(+), 638 deletions(-) delete mode 100644 test/integration/roles/azure_rm_virtualnetwork/tasks/main.yml create mode 100644 test/integration/targets/azure_rm_publicipaddress/aliases create mode 100644 test/integration/targets/azure_rm_publicipaddress/meta/main.yml rename test/integration/{roles => targets}/azure_rm_publicipaddress/tasks/main.yml (75%) create mode 100644 test/integration/targets/azure_rm_storageaccount/aliases create mode 100644 test/integration/targets/azure_rm_storageaccount/meta/main.yml rename test/integration/{roles => targets}/azure_rm_storageaccount/tasks/main.yml (74%) create mode 100644 test/integration/targets/azure_rm_storageblob/aliases rename test/integration/{roles => targets}/azure_rm_storageblob/files/Ratings.png (100%) create mode 100644 test/integration/targets/azure_rm_storageblob/meta/main.yml rename test/integration/{roles => targets}/azure_rm_storageblob/tasks/main.yml (62%) create mode 100644 test/integration/targets/azure_rm_subnet/aliases create mode 100644 test/integration/targets/azure_rm_subnet/meta/main.yml rename test/integration/{roles => targets}/azure_rm_subnet/tasks/main.yml (76%) diff --git a/test/integration/roles/azure_rm_deployment/tasks/main.yml b/test/integration/roles/azure_rm_deployment/tasks/main.yml index b4049b565c6..5d2f63edc48 100644 --- a/test/integration/roles/azure_rm_deployment/tasks/main.yml +++ b/test/integration/roles/azure_rm_deployment/tasks/main.yml @@ -11,12 +11,8 @@ value: testvm9910001 ubuntuOSVersion: value: "14.04.2-LTS" - # debug: "{{ playbook_debug }}" register: output -- debug: var=output - when: playbook_debug - - name: Add new instance to host group add_host: hostname: "{{ item.vm_name }}" diff --git a/test/integration/roles/azure_rm_networkinterface/tasks/main.yml b/test/integration/roles/azure_rm_networkinterface/tasks/main.yml index eae12ab5abd..ba5428075ba 100644 --- a/test/integration/roles/azure_rm_networkinterface/tasks/main.yml +++ b/test/integration/roles/azure_rm_networkinterface/tasks/main.yml @@ -1,12 +1,3 @@ -- name: Create resource group - azure_rm_resourcegroup: - name: "{{ resource_group }}" - location: "{{ location }}" - register: output - -- debug: var=output - when: playbook_debug - - name: Create virtual network azure_rm_virtualnetwork: name: vnet001 @@ -14,9 +5,6 @@ address_prefixes_cidr: "10.10.0.0/16" register: output -- debug: var=output - when: playbook_debug - - name: Create subnet azure_rm_subnet: name: subnet001 @@ -25,9 +13,6 @@ address_prefix_cidr: "10.10.0.0/24" register: output -- debug: var=output - when: playbook_debug - - name: Create second virtual network azure_rm_virtualnetwork: name: vnet002 @@ -35,9 +20,6 @@ address_prefixes_cidr: "10.20.0.0/16" register: output -- debug: var=output - when: playbook_debug - - name: Create second subnet azure_rm_subnet: name: subnet002 @@ -46,27 +28,18 @@ address_prefix_cidr: "10.20.0.0/24" register: output -- debug: var=output - when: playbook_debug - - name: Create security group azure_rm_securitygroup: name: secgroup001 resource_group: "{{ resource_group }}" register: output -- debug: var=output - when: playbook_debug - - name: Create second security group azure_rm_securitygroup: name: secgroup002 resource_group: "{{ resource_group }}" register: output -- debug: var=output - when: playbook_debug - - name: Create a public ip azure_rm_publicipaddress: name: publicip001 @@ -74,9 +47,6 @@ allocation_method: "Static" register: output -- debug: var=output - when: playbook_debug - - name: Create second public ip azure_rm_publicipaddress: name: publicip002 @@ -84,9 +54,6 @@ allocation_method: "Static" register: output -- debug: var=output - when: playbook_debug - - name: Delete network interface, if it exists azure_rm_networkinterface: name: nic003 @@ -94,9 +61,6 @@ state: absent register: output -- debug: var=output - when: playbook_debug - - name: Should require subnet when creating nic azure_rm_networkinterface: name: nic003 @@ -107,9 +71,6 @@ register: output ignore_errors: yes -- debug: var=output - when: playbook_debug - - assert: that: - output.failed @@ -125,9 +86,6 @@ register: output ignore_errors: yes -- debug: var=output - when: playbook_debug - - assert: that: - output.failed @@ -143,9 +101,6 @@ public_ip_address_name: publicip001 register: output -- debug: var=output - when: playbook_debug - - name: Should be idempotent azure_rm_networkinterface: name: nic003 @@ -156,9 +111,6 @@ public_ip_address_name: publicip001 register: output -- debug: var=output - when: playbook_debug - - assert: that: not output.changed @@ -174,9 +126,6 @@ public_ip_address_name: publicip001 register: output -- debug: var=output - when: playbook_debug - - assert: that: - output.changed @@ -194,9 +143,6 @@ public_ip_address_name: publicip002 register: output -- debug: var=output - when: playbook_debug - - assert: that: - output.changed @@ -214,9 +160,6 @@ foo: bar register: output -- debug: var=output - when: playbook_debug - - assert: that: - output.state.tags | length == 2 @@ -260,9 +203,6 @@ testing: testing register: output -- debug: var=output - when: playbook_debug - - assert: that: - output.changed @@ -275,9 +215,6 @@ tags: {} register: output -- debug: var=output - when: playbook_debug - - assert: that: - output.changed @@ -293,10 +230,6 @@ - nic004 - nic005 - -- debug: var=output - when: playbook_debug - - name: Remove publicip, if it exists azure_rm_publicipaddress: name: "{{ item }}" @@ -323,9 +256,6 @@ subnet: subnet001 register: output -- debug: var=output - when: playbook_debug - - assert: that: - output.state.ip_configuration.public_ip_address.name == 'nic00401' @@ -337,9 +267,6 @@ name: nic00401 register: output -- debug: var=output - when: playbook_debug - - assert: that: - azure_securitygroups[0].properties.securityRules[0].properties.destinationPortRange == '22' @@ -356,9 +283,6 @@ - '9005-9010' register: output -- debug: var=output - when: playbook_debug - - assert: that: - output.state.ip_configuration.public_ip_address.name == 'nic00501' @@ -370,9 +294,6 @@ name: nic00501 register: output -- debug: var=output - when: playbook_debug - - name: Security group should allow RDP access on custom port assert: that: @@ -385,9 +306,6 @@ name: nic003 register: output -- debug: var=output - when: playbook_debug - - assert: that: - azure_networkinterfaces | length == 1 @@ -397,9 +315,6 @@ resource_group: "{{ resource_group }}" register: output -- debug: var=output - when: playbook_debug - - assert: that: - azure_networkinterfaces | length >= 3 @@ -408,9 +323,6 @@ azure_rm_networkinterface_facts: register: output -- debug: var=output - when: playbook_debug - - assert: that: - azure_networkinterfaces | length >= 3 diff --git a/test/integration/roles/azure_rm_resourcegroup/tasks/main.yml b/test/integration/roles/azure_rm_resourcegroup/tasks/main.yml index 7c61e037842..90d5f03eef1 100644 --- a/test/integration/roles/azure_rm_resourcegroup/tasks/main.yml +++ b/test/integration/roles/azure_rm_resourcegroup/tasks/main.yml @@ -1,15 +1,16 @@ +- name: Get resource group + azure_rm_resourcegroup_facts: + name: "{{ resource_group }}" + - name: Create resource group azure_rm_resourcegroup: - name: "{{ resource_group }}" - location: "{{ location }}" + name: "{{ resource_prefix }}" + location: "{{ azure_resourcegroups[0].location }}" tags: testing: testing delete: never register: output -- debug: var=output - when: playbook_debug - - assert: that: - output.state.tags.testing == 'testing' @@ -18,30 +19,24 @@ - name: Should be idempotent azure_rm_resourcegroup: - name: Testing - location: "{{ location }}" + name: "{{ resource_prefix }}" tags: testing: testing delete: never register: output -- debug: var=output - when: playbook_debug - - assert: that: not output.changed - name: Change resource group tags azure_rm_resourcegroup: - name: "{{ resource_group }}" + name: "{{ resource_prefix }}" tags: testing: 'no' delete: 'on-exit' foo: 'bar' register: output -- debug: var=output - - assert: that: - output.state.tags | length == 3 @@ -56,23 +51,18 @@ - foo:bar register: output -- debug: var=output - when: playbook_debug - - assert: that: azure_resourcegroups | length == 1 - name: Purge one tag azure_rm_resourcegroup: - name: "{{ resource_group }}" + name: "{{ resource_prefix }}" tags: testing: 'no' delete: 'on-exit' debug: yes register: output -- debug: var=output - - assert: that: - output.state.tags | length == 2 @@ -81,37 +71,33 @@ - name: Purge no tags azure_rm_resourcegroup: - name: "{{ resource_group }}" + name: "{{ resource_prefix }}" register: output -- debug: var=output - - assert: that: - output.state.tags | length == 2 - name: Purge all tags azure_rm_resourcegroup: - name: "{{ resource_group }}" + name: "{{ resource_prefix }}" tags: {} register: output -- debug: var=output - - assert: that: - output.state.tags | length == 0 - name: Add a resource azure_rm_virtualnetwork: - resource_group: "{{ resource_group }}" + resource_group: "{{ resource_prefix }}" name: "virtualnet01" address_prefixes_cidr: '10.1.0.0/16' register: output - name: Remove resource group should fail azure_rm_resourcegroup: - name: "{{ resource_group }}" + name: "{{ resource_prefix }}" state: absent register: output ignore_errors: yes @@ -127,17 +113,11 @@ location: "{{ location }}" register: output -- debug: var=output - when: playbook_debug - - name: Gather facts for a resource group azure_rm_resourcegroup_facts: name: "{{ resource_group }}" register: output -- debug: var=output - when: playbook_debug - - assert: that: azure_resourcegroups | length == 1 @@ -145,9 +125,6 @@ azure_rm_resourcegroup_facts: register: output -- debug: var=output - when: playbook_debug - - assert: that: azure_resourcegroups | length > 1 @@ -158,14 +135,8 @@ force: yes register: output -- debug: var=output - when: playbook_debug - - name: Remove second resource group azure_rm_resourcegroup: name: Testing2 state: absent register: output - -- debug: var=output - when: playbook_debug diff --git a/test/integration/roles/azure_rm_securitygroup/tasks/main.yml b/test/integration/roles/azure_rm_securitygroup/tasks/main.yml index 58d5121e6d6..82aed4269d5 100644 --- a/test/integration/roles/azure_rm_securitygroup/tasks/main.yml +++ b/test/integration/roles/azure_rm_securitygroup/tasks/main.yml @@ -1,8 +1,3 @@ -- name: Create resource group - azure_rm_resourcegroup: - name: "{{ resource_group }}" - location: "{{ location }}" - - name: Create security group azure_rm_securitygroup: resource_group: "{{ resource_group }}" @@ -28,9 +23,6 @@ direction: Inbound register: output -- debug: var=output - when: playbook_debug - - assert: { that: "{{ output.state.rules | length }} == 2" } - name: Gather facts by tags @@ -41,9 +33,6 @@ - foo:bar register: output -- debug: var=output - when: playbook_debug - - assert: that: azure_securitygroups | length == 1 @@ -64,9 +53,6 @@ priority: 102 register: output -- debug: var=output - when: playbook_debug - - assert: { that: "{{ output.state.rules | length }} == 3" } - name: Test idempotence @@ -86,9 +72,6 @@ priority: 102 register: output -- debug: var=output - when: playbook_debug - - assert: that: not output.changed @@ -102,9 +85,6 @@ baz: bar register: output -- debug: var=output - when: playbook_debug - - assert: that: - output.state.tags | length == 3 @@ -119,9 +99,6 @@ delete: on-exit register: output -- debug: var=output - when: playbook_debug - - assert: that: - output.state.tags | length == 2 @@ -133,9 +110,6 @@ name: mysecgroup register: output -- debug: var=output - when: playbook_debug - - assert: that: - azure_securitygroups | length == 1 @@ -145,9 +119,6 @@ resource_group: "{{ resource_group }}" register: output -- debug: var=output - when: playbook_debug - - assert: that: - azure_securitygroups | length > 0 @@ -164,9 +135,6 @@ resource_group: "{{ resource_group }}" register: output -- debug: var=output - when: playbook_debug - - assert: that: - azure_securitygroups | length == 0 diff --git a/test/integration/roles/azure_rm_virtualmachine/tasks/main.yml b/test/integration/roles/azure_rm_virtualmachine/tasks/main.yml index f8aba05cb83..f1f1c7e3dab 100644 --- a/test/integration/roles/azure_rm_virtualmachine/tasks/main.yml +++ b/test/integration/roles/azure_rm_virtualmachine/tasks/main.yml @@ -1,2 +1,2 @@ -# - include: virtualmachine.yml -- include: virtualmachine_with_defaults.yml +- include: virtualmachine.yml +#- include: virtualmachine_with_defaults.yml diff --git a/test/integration/roles/azure_rm_virtualmachine/tasks/virtualmachine.yml b/test/integration/roles/azure_rm_virtualmachine/tasks/virtualmachine.yml index cf7794714ce..3b1e8d2a3a2 100644 --- a/test/integration/roles/azure_rm_virtualmachine/tasks/virtualmachine.yml +++ b/test/integration/roles/azure_rm_virtualmachine/tasks/virtualmachine.yml @@ -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 diff --git a/test/integration/roles/azure_rm_virtualmachine/tasks/virtualmachine_with_defaults.yml b/test/integration/roles/azure_rm_virtualmachine/tasks/virtualmachine_with_defaults.yml index 9d26caf0790..46e85048008 100644 --- a/test/integration/roles/azure_rm_virtualmachine/tasks/virtualmachine_with_defaults.yml +++ b/test/integration/roles/azure_rm_virtualmachine/tasks/virtualmachine_with_defaults.yml @@ -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']" diff --git a/test/integration/roles/azure_rm_virtualmachineimage_facts/tasks/main.yml b/test/integration/roles/azure_rm_virtualmachineimage_facts/tasks/main.yml index ab326074ae6..c5bc82e3ccd 100644 --- a/test/integration/roles/azure_rm_virtualmachineimage_facts/tasks/main.yml +++ b/test/integration/roles/azure_rm_virtualmachineimage_facts/tasks/main.yml @@ -7,9 +7,6 @@ version: '7.1.20150731' register: output -- debug: var=output - when: playbook_debug - - assert: that: azure_vmimages | length == 1 @@ -21,9 +18,6 @@ sku: '7.1' register: output -- debug: var=output - when: playbook_debug - - assert: that: azure_vmimages | length > 0 @@ -33,20 +27,13 @@ publisher: OpenLogic register: output -- debug: var=output - when: playbook_debug - - assert: that: azure_vmimages | length > 0 - - name: List available publishers azure_rm_virtualmachineimage_facts: location: "{{ location }}" register: output -- debug: var=output - when: playbook_debug - - assert: that: azure_vmimages | length > 0 diff --git a/test/integration/roles/azure_rm_virtualnetwork/tasks/main.yml b/test/integration/roles/azure_rm_virtualnetwork/tasks/main.yml deleted file mode 100644 index a401b522ce7..00000000000 --- a/test/integration/roles/azure_rm_virtualnetwork/tasks/main.yml +++ /dev/null @@ -1,196 +0,0 @@ -- name: Create resource group - azure_rm_resourcegroup: - name: "{{ resource_group }}" - location: westus - register: output - -- debug: var=output - when: playbook_debug - -- name: Delete virtual network, if it exists - azure_rm_virtualnetwork: - name: my_test_network - resource_group: "{{ resource_group }}" - state: absent - register: output - -- debug: var=output - when: playbook_debug - -- name: Create virtual network - azure_rm_virtualnetwork: - name: my_test_network - address_prefixes_cidr: - - 10.1.0.0/16 - - 172.100.0.0/16 - dns_servers: - - 127.0.0.1 - - 127.0.0.3 - tags: - testing: testing - delete: on-exit - resource_group: "{{ resource_group }}" - register: output - -- debug: var=output - when: playbook_debug - -- assert: - that: - - "output.state.address_prefixes | length == 2" - - "output.state.dns_servers | length == 2" - - "output.state.tags.delete == 'on-exit'" - - "output.state.tags | length == 2" - -- name: Gather facts by name, tags - azure_rm_virtualnetwork_facts: - resource_group: "{{ resource_group }}" - name: my_test_network - tags: - - testing - register: output - -- debug: var=output - when: playbook_debug - -- assert: - that: "azure_virtualnetworks | length == 1" - -- name: Gather facts by resource group, tags - azure_rm_virtualnetwork_facts: - resource_group: "{{ resource_group }}" - tags: - - testing - register: output - -- debug: var=output - when: playbook_debug - -- assert: - that: "azure_virtualnetworks | length == 1" - -- name: Gather facts by tags - azure_rm_virtualnetwork_facts: - tags: - - testing - register: output - -- debug: var=output - when: playbook_debug - -- assert: - that: "azure_virtualnetworks | length >= 1" - -- name: Should be idempotent - azure_rm_virtualnetwork: - name: my_test_network - address_prefixes_cidr: - - 10.1.0.0/16 - - 172.100.0.0/16 - dns_servers: - - 127.0.0.1 - - 127.0.0.3 - tags: - testing: testing - delete: on-exit - resource_group: "{{ resource_group }}" - register: output - -- debug: var=output - when: playbook_debug - -- assert: - that: not output.changed - -- name: Update tags - azure_rm_virtualnetwork: - name: my_test_network - tags: - testing: 'no' - delete: never - foo: bar - resource_group: "{{ resource_group }}" - register: output - -- debug: var=output - when: playbook_debug - -- assert: - that: output.state.tags | length == 3 - -- name: Purge tags - azure_rm_virtualnetwork: - name: my_test_network - tags: - testing: 'always' - resource_group: "{{ resource_group }}" - register: output - -- debug: var=output - when: playbook_debug - -- assert: - that: - - output.state.tags | length == 1 - - output.state.tags.testing == 'always' - -- name: Should require address_prefixes_cidr when purge_address_prefixes - azure_rm_virtualnetwork: - name: my_test_network - purge_address_prefixes: true - resource_group: "{{ resource_group }}" - register: output - ignore_errors: yes - -- debug: var=output - when: playbook_debug - -- assert: - that: output.failed - -- name: Purge address prefixes - azure_rm_virtualnetwork: - name: my_test_network - address_prefixes_cidr: 10.1.0.0/16 - purge_address_prefixes: true - resource_group: "{{ resource_group }}" - register: output - -- debug: var=output - when: playbook_debug - -- assert: - that: - - output.state.address_prefixes | length == 1 - - output.state.address_prefixes[0] == '10.1.0.0/16' - - output.state.dns_servers | length == 2 - - output.state.dns_servers[0] == '127.0.0.1' - -- name: Purge DNS servers - azure_rm_virtualnetwork: - name: my_test_network - purge_dns_servers: true - resource_group: "{{ resource_group }}" - register: output - -- debug: var=output - when: playbook_debug - -- assert: - that: output.state['dns_servers'] is undefined - -- name: Gather facts - azure_rm_virtualnetwork_facts: - resource_group: "{{ resource_group }}" - name: my_test_network - register: output - -- assert: - that: "azure_virtualnetworks | length == 1" - -- name: Delete virtual network - azure_rm_virtualnetwork: - name: my_test_network - resource_group: "{{ resource_group }}" - state: absent - register: output diff --git a/test/integration/targets/azure_rm_publicipaddress/aliases b/test/integration/targets/azure_rm_publicipaddress/aliases new file mode 100644 index 00000000000..b1cd4a5978c --- /dev/null +++ b/test/integration/targets/azure_rm_publicipaddress/aliases @@ -0,0 +1,2 @@ +cloud/azure +destructive diff --git a/test/integration/targets/azure_rm_publicipaddress/meta/main.yml b/test/integration/targets/azure_rm_publicipaddress/meta/main.yml new file mode 100644 index 00000000000..95e1952f989 --- /dev/null +++ b/test/integration/targets/azure_rm_publicipaddress/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_azure diff --git a/test/integration/roles/azure_rm_publicipaddress/tasks/main.yml b/test/integration/targets/azure_rm_publicipaddress/tasks/main.yml similarity index 75% rename from test/integration/roles/azure_rm_publicipaddress/tasks/main.yml rename to test/integration/targets/azure_rm_publicipaddress/tasks/main.yml index 95cdd0392bc..96d3ed8fe12 100644 --- a/test/integration/roles/azure_rm_publicipaddress/tasks/main.yml +++ b/test/integration/targets/azure_rm_publicipaddress/tasks/main.yml @@ -1,17 +1,8 @@ -- name: Create resource group - azure_rm_resourcegroup: - name: "{{ resource_group }}" - location: "{{ location }}" - - name: Remove public ip azure_rm_publicipaddress: resource_group: "{{ resource_group }}" name: testing01 state: absent - register: output - -- debug: var=output - when: playbook_debug - name: Create public ip azure_rm_publicipaddress: @@ -24,9 +15,6 @@ delete: on-exit register: output -- debug: var=output - when: playbook_debug - - assert: that: - output.state.public_ip_allocation_method == 'Static' @@ -45,9 +33,6 @@ delete: on-exit register: output -- debug: var=output - when: playbook_debug - - assert: that: not output.changed @@ -61,9 +46,6 @@ foo: bar register: output -- debug: var=output - when: playbook_debug - - assert: that: - output.state.tags | length == 3 @@ -75,10 +57,6 @@ tags: - testing - foo:bar - register: output - -- debug: var=output - when: playbook_debug - assert: that: azure_publicipaddresses | length == 1 @@ -90,9 +68,6 @@ tags: {} register: output -- debug: var=output - when: playbook_debug - - assert: that: - output.state.tags | length == 0 @@ -101,10 +76,6 @@ azure_rm_publicipaddress_facts: resource_group: "{{ resource_group }}" name: testing01 - register: output - -- debug: var=output - when: playbook_debug - assert: that: azure_publicipaddresses | length == 1 @@ -112,28 +83,20 @@ - name: Gather facts for all public ips azure_rm_publicipaddress_facts: resource_group: "{{ resource_group }}" - register: output - -- debug: var=output - when: playbook_debug - assert: that: azure_publicipaddresses | length > 0 -- name: Remove all public ips +- name: Remove public ip azure_rm_publicipaddress: resource_group: "{{ resource_group }}" - name: "{{ item.name }}" + name: testing01 state: absent - with_items: "{{ azure_publicipaddresses }}" -- name: Gather facts for all public ips +- name: Gather facts for a public ip azure_rm_publicipaddress_facts: resource_group: "{{ resource_group }}" - register: output - -- debug: var=output - when: playbook_debug + name: testing01 - assert: that: azure_publicipaddresses | length == 0 diff --git a/test/integration/targets/azure_rm_storageaccount/aliases b/test/integration/targets/azure_rm_storageaccount/aliases new file mode 100644 index 00000000000..b1cd4a5978c --- /dev/null +++ b/test/integration/targets/azure_rm_storageaccount/aliases @@ -0,0 +1,2 @@ +cloud/azure +destructive diff --git a/test/integration/targets/azure_rm_storageaccount/meta/main.yml b/test/integration/targets/azure_rm_storageaccount/meta/main.yml new file mode 100644 index 00000000000..95e1952f989 --- /dev/null +++ b/test/integration/targets/azure_rm_storageaccount/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_azure diff --git a/test/integration/roles/azure_rm_storageaccount/tasks/main.yml b/test/integration/targets/azure_rm_storageaccount/tasks/main.yml similarity index 74% rename from test/integration/roles/azure_rm_storageaccount/tasks/main.yml rename to test/integration/targets/azure_rm_storageaccount/tasks/main.yml index 7a479cca5e3..ec1dc70c4d8 100644 --- a/test/integration/roles/azure_rm_storageaccount/tasks/main.yml +++ b/test/integration/targets/azure_rm_storageaccount/tasks/main.yml @@ -1,8 +1,7 @@ - - name: Create resource group - azure_rm_resourcegroup: - name: "{{ resource_group }}" - location: "{{ location }}" - + - name: Create storage account name + set_fact: + storage_account: "{{ resource_group | hash('md5') | truncate(24, True, '') }}" + - name: Test invalid account name azure_rm_storageaccount: resource_group: "{{ resource_group }}" @@ -17,26 +16,19 @@ - name: Delete storage account azure_rm_storageaccount: resource_group: "{{ resource_group }}" - name: teststorageacct002 + name: "{{ storage_account }}" state: absent - register: output - - - debug: var=output - when: playbook_debug - name: Create new storage account azure_rm_storageaccount: resource_group: "{{ resource_group }}" - name: teststorageacct002 + name: "{{ storage_account }}" account_type: Standard_LRS tags: test: test galaxy: galaxy register: output - - debug: var=output - when: playbook_debug - - name: Assert status succeeded and results include an Id value assert: that: @@ -49,10 +41,6 @@ tags: - test - galaxy - register: output - - - debug: var=output - when: playbook_debug - assert: that: azure_storageaccounts | length >= 1 @@ -60,46 +48,36 @@ - name: Change account type azure_rm_storageaccount: resource_group: "{{ resource_group }}" - name: teststorageacct002 + name: "{{ storage_account }}" account_type: Premium_LRS register: change_account ignore_errors: yes - - debug: var=change_account - when: playbook_debug - - name: Assert account type change failed assert: { that: "change_account['failed'] == True" } - name: Change account type and add custom domain azure_rm_storageaccount: resource_group: "{{ resource_group }}" - name: teststorageacct002 + name: "{{ storage_account }}" account_type: Standard_GRS custom_domain: { name: ansible.com, use_sub_domain: no } register: change_account ignore_errors: yes - - name: Debug - debug: var=change_account - when: playbook_debug - - name: Assert CNAME failure assert: { that: "'custom domain name could not be verified' in change_account['msg']" } - name: Update account tags azure_rm_storageaccount: resource_group: "{{ resource_group }}" - name: teststorageacct002 + name: "{{ storage_account }}" tags: testing: testing delete: never galaxy: 'no' register: output - - debug: var=output - when: playbook_debug - - assert: that: - "output.state.tags | length == 3" @@ -108,15 +86,12 @@ - name: Update account tags azure_rm_storageaccount: resource_group: "{{ resource_group }}" - name: teststorageacct002 + name: "{{ storage_account }}" tags: testing: testing delete: never register: output - - debug: var=output - when: playbook_debug - - assert: that: - "output.state.tags | length == 2" @@ -126,11 +101,7 @@ - name: Gather facts azure_rm_storageaccount_facts: resource_group: "{{ resource_group }}" - name: teststorageacct002 - register: output - - - debug: var=output - when: playbook_debug + name: "{{ storage_account }}" - assert: that: @@ -139,10 +110,6 @@ - name: Gather facts azure_rm_storageaccount_facts: resource_group: "{{ resource_group }}" - register: output - - - debug: var=output - when: playbook_debug - assert: that: @@ -151,9 +118,5 @@ - name: Delete acccount azure_rm_storageaccount: resource_group: "{{ resource_group }}" - name: teststorageacct002 + name: "{{ storage_account }}" state: absent - register: output - - - debug: var=output - when: playbook_debug diff --git a/test/integration/targets/azure_rm_storageblob/aliases b/test/integration/targets/azure_rm_storageblob/aliases new file mode 100644 index 00000000000..b1cd4a5978c --- /dev/null +++ b/test/integration/targets/azure_rm_storageblob/aliases @@ -0,0 +1,2 @@ +cloud/azure +destructive diff --git a/test/integration/roles/azure_rm_storageblob/files/Ratings.png b/test/integration/targets/azure_rm_storageblob/files/Ratings.png similarity index 100% rename from test/integration/roles/azure_rm_storageblob/files/Ratings.png rename to test/integration/targets/azure_rm_storageblob/files/Ratings.png diff --git a/test/integration/targets/azure_rm_storageblob/meta/main.yml b/test/integration/targets/azure_rm_storageblob/meta/main.yml new file mode 100644 index 00000000000..95e1952f989 --- /dev/null +++ b/test/integration/targets/azure_rm_storageblob/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_azure diff --git a/test/integration/roles/azure_rm_storageblob/tasks/main.yml b/test/integration/targets/azure_rm_storageblob/tasks/main.yml similarity index 62% rename from test/integration/roles/azure_rm_storageblob/tasks/main.yml rename to test/integration/targets/azure_rm_storageblob/tasks/main.yml index 4e47f3b742c..796376bbb45 100644 --- a/test/integration/roles/azure_rm_storageblob/tasks/main.yml +++ b/test/integration/targets/azure_rm_storageblob/tasks/main.yml @@ -1,73 +1,58 @@ -- name: Create resource group - azure_rm_resourcegroup: - name: "{{ resource_group }}" - location: "{{ location }}" - +- 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: testgroup03blobs + name: "{{ storage_account }}" account_type: Standard_LRS state: present - name: Create container azure_rm_storageblob: - resource_group: "{{ resource_group }}" - account_name: testgroup03blobs + resource_group: "{{ resource_group }}" + account_name: "{{ storage_account }}" container_name: my-blobs - register: create_facts - -- debug: var=create_facts - when: playbook_debug - name: Force upload blob azure_rm_storageblob: resource_group: "{{ resource_group }}" - account_name: testgroup03blobs + account_name: "{{ storage_account }}" container_name: my-blobs blob: 'Ratings.png' - src: './roles/azure_rm_storageblob/files/Ratings.png' + src: './targets/azure_rm_storageblob/files/Ratings.png' content_type: image/png tags: val1: foo val2: bar force: yes - register: upload_facts - -- debug: var=upload_facts - when: playbook_debug - name: Upload blob idempotence azure_rm_storageblob: resource_group: "{{ resource_group }}" - account_name: testgroup03blobs + account_name: "{{ storage_account }}" container_name: my-blobs blob: 'Ratings.png' - src: './roles/azure_rm_storageblob/files/Ratings.png' + src: './targets/azure_rm_storageblob/files/Ratings.png' content_type: image/png tags: val1: foo val2: bar register: upload_facts -- debug: var=upload_facts - when: playbook_debug - - assert: that: "not upload_facts.changed" - name: Download file idempotence azure_rm_storageblob: resource_group: "{{ resource_group }}" - account_name: testgroup03blobs + account_name: "{{ storage_account }}" container_name: my-blobs blob: 'Ratings.png' - dest: './roles/azure_rm_storageblob/files/Ratings.png' + dest: './targets/azure_rm_storageblob/files/Ratings.png' register: download_results -- debug: var=download_results - when: playbook_debug - - assert: that: not download_results.changed @@ -76,7 +61,7 @@ - name: Download file azure_rm_storageblob: resource_group: "{{ resource_group }}" - account_name: testgroup03blobs + account_name: "{{ storage_account }}" container_name: my-blobs blob: 'Ratings.png' dest: '/tmp/Ratings.png' @@ -92,54 +77,40 @@ - name: Do not delete container that has blobs azure_rm_storageblob: - resource_group: "{{ resource_group }}" - account_name: testgroup03blobs + resource_group: "{{ resource_group }}" + account_name: "{{ storage_account }}" container_name: my-blobs state: absent register: output -- debug: var=output - when: playbook_debug - - assert: that: "not output.changed" - name: Delete blob object azure_rm_storageblob: resource_group: "{{ resource_group }}" - account_name: testgroup03blobs + account_name: "{{ storage_account }}" container_name: my-blobs blob: "Ratings.png" state: absent register: output -- debug: var=output - when: playbook_debug - - assert: that: "output.changed" - name: Delete container azure_rm_storageblob: - resource_group: "{{ resource_group }}" - account_name: testgroup03blobs + resource_group: "{{ resource_group }}" + account_name: "{{ storage_account }}" container_name: my-blobs state: absent register: output -- debug: var=output - when: playbook_debug - - assert: that: "output.changed" - name: Delete storage account azure_rm_storageaccount: resource_group: "{{ resource_group }}" - location: "{{ location }}" - name: testgroup03blobs + name: "{{ storage_account }}" state: absent - register: output - -- debug: var=output - when: playbook_debug diff --git a/test/integration/targets/azure_rm_subnet/aliases b/test/integration/targets/azure_rm_subnet/aliases new file mode 100644 index 00000000000..b1cd4a5978c --- /dev/null +++ b/test/integration/targets/azure_rm_subnet/aliases @@ -0,0 +1,2 @@ +cloud/azure +destructive diff --git a/test/integration/targets/azure_rm_subnet/meta/main.yml b/test/integration/targets/azure_rm_subnet/meta/main.yml new file mode 100644 index 00000000000..95e1952f989 --- /dev/null +++ b/test/integration/targets/azure_rm_subnet/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_azure diff --git a/test/integration/roles/azure_rm_subnet/tasks/main.yml b/test/integration/targets/azure_rm_subnet/tasks/main.yml similarity index 76% rename from test/integration/roles/azure_rm_subnet/tasks/main.yml rename to test/integration/targets/azure_rm_subnet/tasks/main.yml index 4185fb54a7d..9a32ee37661 100644 --- a/test/integration/roles/azure_rm_subnet/tasks/main.yml +++ b/test/integration/targets/azure_rm_subnet/tasks/main.yml @@ -1,15 +1,3 @@ -- name: Create resource group - azure_rm_resourcegroup: - name: "{{ resource_group }}" - location: "{{ location }}" - tags: - testing: 'subnet' - delete: 'on-exit' - register: output - -- debug: var=output - when: playbook_debug - - name: Create virtual network azure_rm_virtualnetwork: name: My_Virtual_Network @@ -23,10 +11,6 @@ testing: testing delete: on-exit resource_group: "{{ resource_group }}" - register: output - -- debug: var=output - when: playbook_debug - name: Remove subnet azure_rm_subnet: @@ -34,10 +18,6 @@ name: foobar virtual_network_name: My_Virtual_Network resource_group: "{{ resource_group }}" - register: output - -- debug: var=output - when: playbook_debug - name: Catch invalid cidr azure_rm_subnet: @@ -48,9 +28,6 @@ register: output ignore_errors: yes -- debug: var=output - when: playbook_debug - - assert: that: output.failed @@ -62,9 +39,6 @@ address_prefix_cidr: "10.1.0.0/24" register: output -- debug: var=output - when: playbook_debug - - assert: that: output.changed @@ -74,10 +48,6 @@ resource_group: "{{ resource_group }}" tags: testing: testing - register: output - -- debug: var=output - when: playbook_debug - name: Update the subnet azure_rm_subnet: @@ -89,10 +59,6 @@ tags: testing: testing delete: on-fini - register: output - -- debug: var=output - when: playbook_debug - name: Should be idempotent azure_rm_subnet: @@ -106,9 +72,6 @@ delete: on-fini register: output -- debug: var=output - when: playbook_debug - - assert: that: not output.changed @@ -118,7 +81,6 @@ name: foobar virtual_network_name: My_Virtual_Network resource_group: "{{ resource_group }}" - register: output - name: Remove security group azure_rm_securitygroup: @@ -131,4 +93,3 @@ name: My_Virtual_Network resource_group: "{{ resource_group }}" state: absent - register: output diff --git a/test/integration/targets/azure_rm_virtualnetwork/tasks/main.yml b/test/integration/targets/azure_rm_virtualnetwork/tasks/main.yml index 19a3eacb92e..a978aff4f70 100644 --- a/test/integration/targets/azure_rm_virtualnetwork/tasks/main.yml +++ b/test/integration/targets/azure_rm_virtualnetwork/tasks/main.yml @@ -1,7 +1,148 @@ -- block: - - name: create a virtual network - azure_rm_virtualnetwork: - resource_group: '{{ resource_group }}' - name: test - address_prefixes_cidr: - - "10.1.0.0/16" +- name: Delete virtual network, if it exists + azure_rm_virtualnetwork: + name: my_test_network + resource_group: "{{ resource_group }}" + state: absent + +- name: Create virtual network + azure_rm_virtualnetwork: + name: my_test_network + address_prefixes_cidr: + - 10.1.0.0/16 + - 172.100.0.0/16 + dns_servers: + - 127.0.0.1 + - 127.0.0.3 + tags: + testing: testing + delete: on-exit + resource_group: "{{ resource_group }}" + register: output + +- assert: + that: + - "output.state.address_prefixes | length == 2" + - "output.state.dns_servers | length == 2" + - "output.state.tags.delete == 'on-exit'" + - "output.state.tags | length == 2" + +- name: Gather facts by name, tags + azure_rm_virtualnetwork_facts: + resource_group: "{{ resource_group }}" + name: my_test_network + tags: + - testing + +- assert: + that: "azure_virtualnetworks | length == 1" + +- name: Gather facts by resource group, tags + azure_rm_virtualnetwork_facts: + resource_group: "{{ resource_group }}" + tags: + - testing + +- assert: + that: "azure_virtualnetworks | length == 1" + +- name: Gather facts by tags + azure_rm_virtualnetwork_facts: + tags: + - testing + +- assert: + that: "azure_virtualnetworks | length >= 1" + +- name: Should be idempotent + azure_rm_virtualnetwork: + name: my_test_network + address_prefixes_cidr: + - 10.1.0.0/16 + - 172.100.0.0/16 + dns_servers: + - 127.0.0.1 + - 127.0.0.3 + tags: + testing: testing + delete: on-exit + resource_group: "{{ resource_group }}" + register: output + +- assert: + that: not output.changed + +- name: Update tags + azure_rm_virtualnetwork: + name: my_test_network + tags: + testing: 'no' + delete: never + foo: bar + resource_group: "{{ resource_group }}" + register: output + +- assert: + that: output.state.tags | length == 3 + +- name: Purge tags + azure_rm_virtualnetwork: + name: my_test_network + tags: + testing: 'always' + resource_group: "{{ resource_group }}" + register: output + +- assert: + that: + - output.state.tags | length == 1 + - output.state.tags.testing == 'always' + +- name: Should require address_prefixes_cidr when purge_address_prefixes + azure_rm_virtualnetwork: + name: my_test_network + purge_address_prefixes: true + resource_group: "{{ resource_group }}" + register: output + ignore_errors: yes + +- assert: + that: output.failed + +- name: Purge address prefixes + azure_rm_virtualnetwork: + name: my_test_network + address_prefixes_cidr: 10.1.0.0/16 + purge_address_prefixes: true + resource_group: "{{ resource_group }}" + register: output + +- assert: + that: + - output.state.address_prefixes | length == 1 + - output.state.address_prefixes[0] == '10.1.0.0/16' + - output.state.dns_servers | length == 2 + - output.state.dns_servers[0] == '127.0.0.1' + +- name: Purge DNS servers + azure_rm_virtualnetwork: + name: my_test_network + purge_dns_servers: true + resource_group: "{{ resource_group }}" + register: output + +- assert: + that: output.state['dns_servers'] is undefined + +- name: Gather facts + azure_rm_virtualnetwork_facts: + resource_group: "{{ resource_group }}" + name: my_test_network + +- assert: + that: "azure_virtualnetworks | length == 1" + +- name: Delete virtual network + azure_rm_virtualnetwork: + name: my_test_network + resource_group: "{{ resource_group }}" + state: absent