diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-14 20:03:01 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-14 20:03:01 +0000 |
commit | a453ac31f3428614cceb99027f8efbdb9258a40b (patch) | |
tree | f61f87408f32a8511cbd91799f9cececb53e0374 /collections-debian-merged/ansible_collections/community/azure/tests/integration | |
parent | Initial commit. (diff) | |
download | ansible-upstream.tar.xz ansible-upstream.zip |
Adding upstream version 2.10.7+merged+base+2.10.8+dfsg.upstream/2.10.7+merged+base+2.10.8+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'collections-debian-merged/ansible_collections/community/azure/tests/integration')
48 files changed, 5370 insertions, 0 deletions
diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_automationaccount/aliases b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_automationaccount/aliases new file mode 100644 index 00000000..7bf5a027 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_automationaccount/aliases @@ -0,0 +1,4 @@ +cloud/azure +shippable/azure/group1 +destructive +azure_rm_automationaccount_facts diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_automationaccount/meta/main.yml b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_automationaccount/meta/main.yml new file mode 100644 index 00000000..95e1952f --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_automationaccount/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_azure diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_automationaccount/tasks/main.yml b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_automationaccount/tasks/main.yml new file mode 100644 index 00000000..025bba9a --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_automationaccount/tasks/main.yml @@ -0,0 +1,74 @@ +- name: Prepare random number + set_fact: + rpfx: '{{ resource_group | hash(''md5'') | truncate(7, True, '''') }}{{ 1000 | random }}' + name: account{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }} + run_once: true +- name: Create automation account + check_mode: true + register: output + azure.azcollection.azure_rm_automationaccount: + name: '{{ name }}' + resource_group: '{{ resource_group }}' +- assert: + that: + - output.changed +- name: Create automation account + register: output + azure.azcollection.azure_rm_automationaccount: + name: '{{ name }}' + resource_group: '{{ resource_group }}' +- assert: + that: + - output.changed + - output.id +- name: Create automation account + register: output + azure.azcollection.azure_rm_automationaccount: + name: '{{ name }}' + resource_group: '{{ resource_group }}' +- assert: + that: + - not output.changed +- name: Get automation account + azure_rm_automationaccount_facts: + name: '{{ name }}' + resource_group: '{{ resource_group }}' + list_statistics: true + list_usages: true + list_keys: true + register: facts +- assert: + that: + - facts.automation_accounts | length == 1 + - facts.automation_accounts[0].keys + - facts.automation_accounts[0].usages + - facts.automation_accounts[0].statistics + - facts.automation_accounts[0].state == "Ok" +- name: Delete account + check_mode: true + register: output + azure.azcollection.azure_rm_automationaccount: + name: '{{ name }}' + resource_group: '{{ resource_group }}' + state: absent +- assert: + that: + - output.changed +- name: Delete account + register: output + azure.azcollection.azure_rm_automationaccount: + name: '{{ name }}' + resource_group: '{{ resource_group }}' + state: absent +- assert: + that: + - output.changed +- name: Delete account + register: output + azure.azcollection.azure_rm_automationaccount: + name: '{{ name }}' + resource_group: '{{ resource_group }}' + state: absent +- assert: + that: + - not output.changed diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_devtestlab/aliases b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_devtestlab/aliases new file mode 100644 index 00000000..d8e65689 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_devtestlab/aliases @@ -0,0 +1,17 @@ +cloud/azure +destructive +shippable/azure/group1 +azure_rm_devtestlab_facts +azure_rm_devtestlabarmtemplate +azure_rm_devtestlabartifact +azure_rm_devtestlabartifactsource_facts +azure_rm_devtestlabartifactsource +azure_rm_devtestlabcustomimage +azure_rm_devtestlabpolicy +azure_rm_devtestlabschedule +azure_rm_devtestlabvirtualmachine_facts +azure_rm_devtestlabvirtualmachine_facts +azure_rm_devtestlabvirtualnetwork_facts +azure_rm_devtestlabvirtualnetwork +disabled + diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_devtestlab/meta/main.yml b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_devtestlab/meta/main.yml new file mode 100644 index 00000000..95e1952f --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_devtestlab/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_azure diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_devtestlab/tasks/main.yml b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_devtestlab/tasks/main.yml new file mode 100644 index 00000000..45090966 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_devtestlab/tasks/main.yml @@ -0,0 +1,714 @@ +- name: Prepare random number + set_fact: + lab_name: lab{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }} + vn_name: vn{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }} + vm_name: vn{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }} + artifacts_name: myartifacts + github_token: '{{ lookup(''env'',''GITHUB_ACCESS_TOKEN'') }}' + run_once: true +- name: Create instance of Lab -- check mode + check_mode: true + register: output + azure.azcollection.azure_rm_devtestlab: + resource_group: '{{ resource_group }}' + name: '{{ lab_name }}' + location: eastus + storage_type: standard + premium_data_disks: false +- name: Check if the change was correctly reported + assert: + that: + - output.changed +- name: Create instance of Lab + register: output_lab + azure.azcollection.azure_rm_devtestlab: + resource_group: '{{ resource_group }}' + name: '{{ lab_name }}' + location: eastus + storage_type: standard + premium_data_disks: false +- name: Check if the change was correctly reported + assert: + that: + - output.changed +- name: Create again instance of Lab + register: output + azure.azcollection.azure_rm_devtestlab: + resource_group: '{{ resource_group }}' + name: '{{ lab_name }}' + location: eastus + storage_type: standard + premium_data_disks: false +- name: Assert the state has not changed + assert: + that: + - output.changed == false +- name: Update lab - premium_data_disks + register: output + azure.azcollection.azure_rm_devtestlab: + resource_group: '{{ resource_group }}' + name: '{{ lab_name }}' + location: eastus + storage_type: standard + premium_data_disks: true +- name: Assert the change was registered + assert: + that: + - output.changed +- name: List DevTest Lab in a resource group + azure_rm_devtestlab_facts: + resource_group: '{{ resource_group }}' + register: output_lab +- name: Assert that facts are returned + assert: + that: + - output_lab.changed == False + - output_lab.labs[0]['id'] != None + - output_lab.labs[0]['resource_group'] != None + - output_lab.labs[0]['name'] != None + - output_lab.labs[0]['location'] != None + - output_lab.labs[0]['storage_type'] != None + - output_lab.labs[0]['premium_data_disks'] != None + - output_lab.labs[0]['provisioning_state'] != None + - output_lab.labs[0]['vault_name'] != None +- name: Get DevTest Lab facts + azure_rm_devtestlab_facts: + resource_group: '{{ resource_group }}' + name: '{{ lab_name }}' + register: output_lab +- name: Assert that facts are returned + assert: + that: + - output_lab.changed == False + - output_lab.labs[0]['id'] != None + - output_lab.labs[0]['resource_group'] != None + - output_lab.labs[0]['name'] != None + - output_lab.labs[0]['location'] != None + - output_lab.labs[0]['storage_type'] != None + - output_lab.labs[0]['premium_data_disks'] != None + - output_lab.labs[0]['provisioning_state'] != None + - output_lab.labs[0]['artifacts_storage_account'] != None + - output_lab.labs[0]['default_premium_storage_account'] != None + - output_lab.labs[0]['default_storage_account'] != None + - output_lab.labs[0]['premium_data_disk_storage_account'] != None + - output_lab.labs[0]['vault_name'] != None +- name: Create instance of DevTest Lab Policy + register: output + azure.azcollection.azure_rm_devtestlabpolicy: + resource_group: '{{ resource_group }}' + lab_name: '{{ lab_name }}' + policy_set_name: default + name: myDtlPolicy + fact_name: user_owned_lab_vm_count + threshold: 5 +- debug: + var: output +- name: Assert if the change was correctly reported + assert: + that: + - output.changed +- name: Create instance of DevTest Lab Policy -- idempotent + register: output + azure.azcollection.azure_rm_devtestlabpolicy: + resource_group: '{{ resource_group }}' + lab_name: '{{ lab_name }}' + policy_set_name: default + name: myDtlPolicy + fact_name: user_owned_lab_vm_count + threshold: 5 +- debug: + var: output +- name: Assert if the change was not reported + assert: + that: + - not output.changed +- name: Create instance of DevTest Lab Policy -- change value + register: output + azure.azcollection.azure_rm_devtestlabpolicy: + resource_group: '{{ resource_group }}' + lab_name: '{{ lab_name }}' + policy_set_name: default + name: myDtlPolicy + fact_name: user_owned_lab_vm_count + threshold: 6 +- debug: + var: output +- name: Assert if the change was correctly reported + assert: + that: + - output.changed +- name: Delete instance of DevTest Lab Policy + register: output + azure.azcollection.azure_rm_devtestlabpolicy: + resource_group: '{{ resource_group }}' + lab_name: '{{ lab_name }}' + policy_set_name: default + name: myDtlPolicy + state: absent +- debug: + var: output +- name: Assert if the change was correctly reported + assert: + that: + - output.changed +- name: Create instance of DevTest Lab Schedule + register: output + azure.azcollection.azure_rm_devtestlabschedule: + resource_group: '{{ resource_group }}' + lab_name: '{{ lab_name }}' + name: lab_vms_shutdown + time: '1030' + time_zone_id: UTC+12 +- debug: + var: output +- name: Assert if the change was correctly reported + assert: + that: + - output.changed +- name: Update instance of DevTest Lab Schedule -- idempotent + register: output + azure.azcollection.azure_rm_devtestlabschedule: + resource_group: '{{ resource_group }}' + lab_name: '{{ lab_name }}' + name: lab_vms_shutdown + time: '1030' + time_zone_id: UTC+12 +- debug: + var: output +- name: Assert if the change was correctly reported + assert: + that: + - not output.changed +- name: Update instance of DevTest Lab Schedule -- change time + register: output + azure.azcollection.azure_rm_devtestlabschedule: + resource_group: '{{ resource_group }}' + lab_name: '{{ lab_name }}' + name: lab_vms_shutdown + time: '1130' + time_zone_id: UTC+12 +- debug: + var: output +- name: Assert if the change was correctly reported + assert: + that: + - output.changed +- name: Delete instance of DevTest Lab Schedule + register: output + azure.azcollection.azure_rm_devtestlabschedule: + resource_group: '{{ resource_group }}' + lab_name: '{{ lab_name }}' + name: lab_vms_shutdown + state: absent +- debug: + var: output +- name: Assert if the change was correctly reported + assert: + that: + - output.changed +- name: Create instance of DevTest Labs virtual network + register: output + azure.azcollection.azure_rm_devtestlabvirtualnetwork: + resource_group: '{{ resource_group }}' + lab_name: '{{ lab_name }}' + name: '{{ vn_name }}' + location: eastus + description: My DevTest Lab +- name: Assert the change was registered + assert: + that: + - output.changed +- name: Update instance of DevTest Labs virtual network with same parameters + register: output + azure.azcollection.azure_rm_devtestlabvirtualnetwork: + resource_group: '{{ resource_group }}' + lab_name: '{{ lab_name }}' + name: '{{ vn_name }}' + location: eastus + description: My DevTest Lab +- name: Assert that nothing was changed + assert: + that: + - output.changed == false +- name: Update instance of DevTest Labs virtual network with changed description + register: output + azure.azcollection.azure_rm_devtestlabvirtualnetwork: + resource_group: '{{ resource_group }}' + lab_name: '{{ lab_name }}' + name: '{{ vn_name }}' + location: eastus + description: My DevTest Lab Updated +- name: Assert that nothing was changed + assert: + that: + - output.changed +- name: Get DevTest Lab Virtual Network facts + azure_rm_devtestlabvirtualnetwork_facts: + resource_group: '{{ resource_group }}' + lab_name: '{{ lab_name }}' + name: '{{ vn_name }}' + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.virtualnetworks[0]['id'] != None + - output.virtualnetworks[0]['resource_group'] != None + - output.virtualnetworks[0]['lab_name'] != None + - output.virtualnetworks[0]['name'] != None + - output.virtualnetworks[0]['external_provider_resource_id'] != None + - output.virtualnetworks[0]['description'] != None + - output.virtualnetworks[0]['provisioning_state'] != None +- name: List all Virtual Networks in DevTest Lab + azure_rm_devtestlabvirtualnetwork_facts: + resource_group: '{{ resource_group }}' + lab_name: '{{ lab_name }}' + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.virtualnetworks[0]['id'] != None + - output.virtualnetworks[0]['resource_group'] != None + - output.virtualnetworks[0]['lab_name'] != None + - output.virtualnetworks[0]['name'] != None + - output.virtualnetworks[0]['external_provider_resource_id'] != None + - output.virtualnetworks[0]['description'] != None + - output.virtualnetworks[0]['provisioning_state'] != None +- name: Create instance of DevTest Labs artifacts source + register: output + when: github_token | length > 0 + azure.azcollection.azure_rm_devtestlabartifactsource: + resource_group: '{{ resource_group }}' + lab_name: '{{ lab_name }}' + name: '{{ artifacts_name }}' + uri: https://github.com/Azure/azure_preview_modules.git + source_type: github + folder_path: /tasks + security_token: '{{ github_token }}' +- name: Assert if the change was correctly reported + assert: + that: + - output.changed + when: github_token | length > 0 +- name: Update instance of DevTest Labs artifacts source with same parameters + register: output + when: github_token | length > 0 + azure.azcollection.azure_rm_devtestlabartifactsource: + resource_group: '{{ resource_group }}' + lab_name: '{{ lab_name }}' + name: '{{ artifacts_name }}' + uri: https://github.com/Azure/azure_preview_modules.git + source_type: github + folder_path: /tasks + security_token: '{{ github_token }}' +- name: Assert that nothing was changed + assert: + that: + - output.changed == false + when: github_token | length > 0 +- name: Update instance of DevTest Labs artifacts source, add display name, change folder + register: output + when: github_token | length > 0 + azure.azcollection.azure_rm_devtestlabartifactsource: + resource_group: '{{ resource_group }}' + lab_name: '{{ lab_name }}' + name: '{{ artifacts_name }}' + uri: https://github.com/Azure/azure_preview_modules.git + source_type: github + folder_path: /library + security_token: '{{ github_token }}' + display_name: My Artifacts Source +- name: Assert that nothing was changed + assert: + that: + - output.changed + when: github_token | length > 0 +- name: null + set_fact: + artifact_source: + - source_name: public repo + source_path: /Artifacts/linux-install-mongodb + when: github_token | length > 0 +- name: null + set_fact: + artifact_source: null + when: github_token | length == 0 +- name: Create instance of DTL Virtual Machine + register: output + when: github_token | length > 0 + azure.azcollection.azure_rm_devtestlabvirtualmachine: + resource_group: '{{ resource_group }}' + lab_name: '{{ lab_name }}' + name: '{{ vm_name }}' + notes: Virtual machine notes, just something.... + os_type: linux + vm_size: Standard_A2_v2 + user_name: dtladmin + password: ZSasfovobocu$$21! + lab_subnet: + virtual_network_name: '{{ vn_name }}' + name: '{{ vn_name }}Subnet' + disallow_public_ip_address: false + image: + offer: UbuntuServer + publisher: Canonical + sku: 16.04-LTS + os_type: Linux + version: latest + artifacts: '{{ artifact_source }}' + allow_claim: false + expiration_date: '2029-02-22T01:49:12.117974Z' +- name: Assert that change was registered + assert: + that: + - output.changed + when: github_token | length > 0 +- name: Update instance of DTL Virtual Machine with same parameters + register: output + when: github_token | length > 0 + azure.azcollection.azure_rm_devtestlabvirtualmachine: + resource_group: '{{ resource_group }}' + lab_name: '{{ lab_name }}' + name: '{{ vm_name }}' + notes: Virtual machine notes, just something.... + os_type: linux + vm_size: Standard_A2_v2 + user_name: dtladmin + password: ZSasfovobocu$$21! + lab_subnet: + virtual_network_name: '{{ vn_name }}' + name: '{{ vn_name }}Subnet' + disallow_public_ip_address: false + image: + offer: UbuntuServer + publisher: Canonical + sku: 16.04-LTS + os_type: Linux + version: latest + artifacts: '{{ artifact_source }}' + allow_claim: false + expiration_date: '2029-02-22T01:49:12.117974Z' +- name: Assert that nothing has changed + assert: + that: + - output.changed == false + when: github_token | length > 0 +- name: Update instance of DTL Virtual Machine - change notes + register: output + when: github_token | length > 0 + azure.azcollection.azure_rm_devtestlabvirtualmachine: + resource_group: '{{ resource_group }}' + lab_name: '{{ lab_name }}' + name: '{{ vm_name }}' + notes: Virtual machine notes, just something.... more text + os_type: linux + vm_size: Standard_A2_v2 + user_name: dtladmin + password: ZSasfovobocu$$21! + lab_subnet: + virtual_network_name: '{{ vn_name }}' + name: '{{ vn_name }}Subnet' + disallow_public_ip_address: false + image: + offer: UbuntuServer + publisher: Canonical + sku: 16.04-LTS + os_type: Linux + version: latest + artifacts: '{{ artifact_source }}' + allow_claim: false + expiration_date: '2029-02-22T01:49:12.117974Z' +- name: Assert that change was registered + assert: + that: + - output.changed + when: github_token | length > 0 +- name: Get Facts of DTL Virtual Machine + azure_rm_devtestlabvirtualmachine_facts: + resource_group: '{{ resource_group }}' + lab_name: '{{ lab_name }}' + name: '{{ vm_name }}' + register: output_vm +- name: Assert that facts are returned + assert: + that: + - output_vm.changed == False + - output_vm.virtualmachines[0]['id'] != None + - output_vm.virtualmachines[0]['resource_group'] != None + - output_vm.virtualmachines[0]['lab_name'] != None + - output_vm.virtualmachines[0]['name'] != None + - output_vm.virtualmachines[0]['compute_vm_id'] != None + - output_vm.virtualmachines[0]['compute_vm_resource_group'] != None + - output_vm.virtualmachines[0]['compute_vm_name'] != None + - output_vm.virtualmachines[0]['disallow_public_ip_address'] != None + - output_vm.virtualmachines[0]['expiration_date'] != None + - output_vm.virtualmachines[0]['fqdn'] != None + - output_vm.virtualmachines[0]['id'] != None + - output_vm.virtualmachines[0]['image'] != None + - output_vm.virtualmachines[0]['notes'] != None + - output_vm.virtualmachines[0]['os_type'] != None + - output_vm.virtualmachines[0]['provisioning_state'] != None + - output_vm.virtualmachines[0]['storage_type'] != None + - output_vm.virtualmachines[0]['user_name'] != None + - output_vm.virtualmachines[0]['vm_size'] != None + when: github_token | length > 0 +- name: List Facts of DTL Virtual Machine + azure_rm_devtestlabvirtualmachine_facts: + resource_group: '{{ resource_group }}' + lab_name: '{{ lab_name }}' + register: output_vm +- name: Assert that facts are returned + assert: + that: + - output_vm.changed == False + - output_vm.virtualmachines[0]['id'] != None + - output_vm.virtualmachines[0]['resource_group'] != None + - output_vm.virtualmachines[0]['lab_name'] != None + - output_vm.virtualmachines[0]['name'] != None + - output_vm.virtualmachines[0]['compute_vm_id'] != None + - output_vm.virtualmachines[0]['disallow_public_ip_address'] != None + - output_vm.virtualmachines[0]['expiration_date'] != None + - output_vm.virtualmachines[0]['fqdn'] != None + - output_vm.virtualmachines[0]['id'] != None + - output_vm.virtualmachines[0]['image'] != None + - output_vm.virtualmachines[0]['notes'] != None + - output_vm.virtualmachines[0]['os_type'] != None + - output_vm.virtualmachines[0]['provisioning_state'] != None + - output_vm.virtualmachines[0]['storage_type'] != None + - output_vm.virtualmachines[0]['user_name'] != None + - output_vm.virtualmachines[0]['vm_size'] != None + when: github_token | length > 0 +- name: List all artifact sources + azure_rm_devtestlabartifactsource_facts: + resource_group: '{{ resource_group }}' + lab_name: '{{ lab_name }}' + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.artifactsources[0]['id'] != None + - output.artifactsources[0]['resource_group'] != None + - output.artifactsources[0]['lab_name'] != None + - output.artifactsources[0]['name'] != None + - output.artifactsources[0]['display_name'] != None + - output.artifactsources[0]['source_type'] != None + - output.artifactsources[0]['is_enabled'] != None + - output.artifactsources[0]['uri'] != None + - output.artifactsources[0]['folder_path'] != None + - output.artifactsources[0]['provisioning_state'] != None + - output.artifactsources | length >= 2 +- name: Get artifacts source facts + azure_rm_devtestlabartifactsource_facts: + resource_group: '{{ resource_group }}' + lab_name: '{{ lab_name }}' + name: public repo + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.artifactsources[0]['id'] != None + - output.artifactsources[0]['resource_group'] != None + - output.artifactsources[0]['lab_name'] != None + - output.artifactsources[0]['name'] != None + - output.artifactsources[0]['display_name'] != None + - output.artifactsources[0]['source_type'] != None + - output.artifactsources[0]['is_enabled'] != None + - output.artifactsources[0]['uri'] != None + - output.artifactsources[0]['folder_path'] != None + - output.artifactsources[0]['provisioning_state'] != None +- name: Delete instance of DevTest Labs artifacts source + register: output + when: github_token | length > 0 + azure.azcollection.azure_rm_devtestlabartifactsource: + resource_group: '{{ resource_group }}' + lab_name: '{{ lab_name }}' + name: '{{ artifacts_name }}' + state: absent +- name: Assert that change was correctly registered + assert: + that: + - output.changed + when: github_token | length > 0 +- name: List ARM Template facts + azure_rm_devtestlabarmtemplate_facts: + resource_group: '{{ resource_group }}' + lab_name: '{{ lab_name }}' + artifact_source_name: public environment repo + register: output +- name: Assert that facts are returned + assert: + that: + - output.armtemplates[0]['id'] != None + - output.armtemplates[0]['resource_group'] != None + - output.armtemplates[0]['lab_name'] != None + - output.armtemplates[0]['artifact_source_name'] != None + - output.armtemplates[0]['name'] != None + - output.armtemplates[0]['display_name'] != None + - output.armtemplates[0]['description'] != None + - output.armtemplates[0]['publisher'] != None + - output.armtemplates | length > 1 +- name: Get ARM Template facts + azure_rm_devtestlabarmtemplate_facts: + resource_group: '{{ resource_group }}' + lab_name: '{{ lab_name }}' + artifact_source_name: public environment repo + name: ServiceFabric-LabCluster + register: output +- name: Assert that facts are returned + assert: + that: + - output.armtemplates[0]['id'] != None + - output.armtemplates[0]['resource_group'] != None + - output.armtemplates[0]['lab_name'] != None + - output.armtemplates[0]['artifact_source_name'] != None + - output.armtemplates[0]['name'] != None + - output.armtemplates[0]['display_name'] != None + - output.armtemplates[0]['description'] != None + - output.armtemplates[0]['publisher'] != None + - output.armtemplates | length == 1 +- name: Get Artifact facts + azure_rm_devtestlabartifact_facts: + resource_group: '{{ resource_group }}' + lab_name: '{{ lab_name }}' + artifact_source_name: public repo + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.artifacts[0]['id'] != None + - output.artifacts[0]['resource_group'] != None + - output.artifacts[0]['lab_name'] != None + - output.artifacts[0]['artifact_source_name'] != None + - output.artifacts[0]['name'] != None + - output.artifacts[0]['description'] != None + - output.artifacts[0]['file_path'] != None + - output.artifacts[0]['publisher'] != None + - output.artifacts[0]['target_os_type'] != None + - output.artifacts[0]['publisher'] != None + - output.artifacts | length > 1 +- name: Get Artifact facts + azure_rm_devtestlabartifact_facts: + resource_group: '{{ resource_group }}' + lab_name: '{{ lab_name }}' + artifact_source_name: public repo + name: windows-webdeploy + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.artifacts[0]['id'] != None + - output.artifacts[0]['resource_group'] != None + - output.artifacts[0]['lab_name'] != None + - output.artifacts[0]['artifact_source_name'] != None + - output.artifacts[0]['name'] != None + - output.artifacts[0]['description'] != None + - output.artifacts[0]['file_path'] != None + - output.artifacts[0]['publisher'] != None + - output.artifacts[0]['target_os_type'] != None + - output.artifacts[0]['publisher'] != None + - output.artifacts | length == 1 +- name: Create instance of DevTest Lab Environment + register: output + azure.azcollection.azure_rm_devtestlabenvironment: + resource_group: '{{ resource_group }}' + lab_name: '{{ lab_name }}' + user_name: '@me' + name: myEnvironment + location: eastus + deployment_template: '{{ output_lab.labs[0].id }}/artifactSources/public environment repo/armTemplates/WebApp' +- name: Assert if the change was correctly reported + assert: + that: + - output.changed + when: github_token | length > 0 +- name: Create instance of DevTest Lab Environment - idempotent + register: output + azure.azcollection.azure_rm_devtestlabenvironment: + resource_group: '{{ resource_group }}' + lab_name: '{{ lab_name }}' + user_name: '@me' + name: myEnvironment + location: eastus + deployment_template: + artifact_source_name: public environment repo + name: WebApp +- name: Assert if the change was not detected + assert: + that: + - not output.changed + when: github_token | length > 0 +- name: Delete instance of DevTest Lab Environment + register: output + azure.azcollection.azure_rm_devtestlabenvironment: + resource_group: '{{ resource_group }}' + lab_name: '{{ lab_name }}' + user_name: '@me' + name: myEnvironment + state: absent +- name: Assert that change was detected + assert: + that: + - output.changed + when: github_token | length > 0 +- name: Create instance of DevTest Lab Image + register: output + azure.azcollection.azure_rm_devtestlabcustomimage: + resource_group: '{{ resource_group }}' + lab_name: '{{ lab_name }}' + name: myImage + source_vm: '{{ output_vm.virtualmachines[0][''name''] }}' + linux_os_state: non_deprovisioned +- name: Assert that change was detected + assert: + that: + - output.changed + when: github_token | length > 0 +- name: Create instance of DevTest Lab Image -- idempotent + register: output + azure.azcollection.azure_rm_devtestlabcustomimage: + resource_group: '{{ resource_group }}' + lab_name: '{{ lab_name }}' + name: myImage + source_vm: '{{ output_vm.virtualmachines[0][''name''] }}' + linux_os_state: non_deprovisioned +- name: Assert that change was detected + assert: + that: + - not output.changed + when: github_token | length > 0 +- name: Delete instance of Lab -- check mode + check_mode: true + register: output + azure.azcollection.azure_rm_devtestlab: + resource_group: '{{ resource_group }}' + state: absent + name: '{{ lab_name }}' +- name: Assert if the change was correctly reported in check mode + assert: + that: + - output.changed +- name: Delete instance of Lab + register: output + azure.azcollection.azure_rm_devtestlab: + resource_group: '{{ resource_group }}' + name: '{{ lab_name }}' + state: absent +- name: Assert the change was correctly reported + assert: + that: + - output.changed +- name: Delete unexisting instance of Lab + register: output + azure.azcollection.azure_rm_devtestlab: + resource_group: '{{ resource_group }}' + name: '{{ lab_name }}unexisting' + state: absent +- name: Assert thes state has not changed + assert: + that: + - output.changed == false diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_mariadbserver/aliases b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_mariadbserver/aliases new file mode 100644 index 00000000..e0296d74 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_mariadbserver/aliases @@ -0,0 +1,8 @@ +cloud/azure +destructive +shippable/azure/group1 +azure_rm_mariadbserver_facts +azure_rm_mariadbdatabase +azure_rm_mariadbdatabase_facts +azure_rm_mariadbfirewallrule +azure_rm_mariadbfirewallrule_facts diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_mariadbserver/meta/main.yml b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_mariadbserver/meta/main.yml new file mode 100644 index 00000000..95e1952f --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_mariadbserver/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_azure diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_mariadbserver/tasks/main.yml b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_mariadbserver/tasks/main.yml new file mode 100644 index 00000000..a0f69078 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_mariadbserver/tasks/main.yml @@ -0,0 +1,581 @@ +- name: Prepare random number + set_fact: + rpfx: '{{ resource_group | hash(''md5'') | truncate(7, True, '''') }}{{ 1000 | random }}' + run_once: true +- name: Create instance of MariaDB Server -- check mode + check_mode: true + register: output + azure.azcollection.azure_rm_mariadbserver: + resource_group: '{{ resource_group }}' + name: mariadbsrv{{ rpfx }} + sku: + name: B_Gen5_1 + tier: Basic + location: westus2 + storage_mb: 51200 + version: 10.2 + enforce_ssl: true + admin_username: zimxyz + admin_password: Testpasswordxyz12! +- name: Assert the resource instance is well created + assert: + that: + - output.changed +- name: Create instance of MariaDB Server + register: output + azure.azcollection.azure_rm_mariadbserver: + resource_group: '{{ resource_group }}' + name: mariadbsrv{{ rpfx }} + sku: + name: B_Gen5_1 + tier: Basic + location: westus2 + storage_mb: 51200 + version: 10.2 + enforce_ssl: true + admin_username: zimxyz + admin_password: Testpasswordxyz12! +- name: Assert the resource instance is well created + assert: + that: + - output.changed + - output.state == 'Ready' +- name: Create again instance of MariaDB Server + register: output + azure.azcollection.azure_rm_mariadbserver: + resource_group: '{{ resource_group }}' + name: mariadbsrv{{ rpfx }} + sku: + name: B_Gen5_1 + tier: Basic + location: westus2 + storage_mb: 51200 + version: 10.2 + enforce_ssl: true + admin_username: zimxyz + admin_password: Testpasswordxyz12! +- name: Assert the state has not changed + assert: + that: + - output.changed == false + - output.state == 'Ready' +- name: Update instance of MariaDB Server, change storage size + register: output + azure.azcollection.azure_rm_mariadbserver: + resource_group: '{{ resource_group }}' + name: mariadbsrv{{ rpfx }} + sku: + name: B_Gen5_1 + tier: Basic + location: westus2 + storage_mb: 128000 + version: 10.2 + enforce_ssl: true + admin_username: zimxyz + admin_password: Testpasswordxyz12! +- name: Assert the state has not changed + assert: + that: + - output.changed + - output.state == 'Ready' +- debug: + var: output +- name: Gather facts MariaDB Server + azure_rm_mariadbserver_facts: + resource_group: '{{ resource_group }}' + name: mariadbsrv{{ rpfx }} + register: output +- name: Assert that storage size is correct + assert: + that: + - output.servers[0]['storage_mb'] == 128000 +- name: Create second instance of MariaDB Server + azure.azcollection.azure_rm_mariadbserver: + resource_group: '{{ resource_group }}' + name: mariadbsrv{{ rpfx }}second + sku: + name: B_Gen5_1 + tier: Basic + location: westus2 + storage_mb: 51200 + version: 10.2 + enforce_ssl: true + admin_username: zimxyz + admin_password: Testpasswordxyz12! + tags: + aaa: bbb +- name: Create second instance of MariaDB Server + azure.azcollection.azure_rm_mariadbserver: + resource_group: '{{ resource_group }}' + name: mariadbsrv{{ rpfx }}second + sku: + name: B_Gen5_1 + tier: Basic + location: westus2 + storage_mb: 51200 + version: 10.2 + enforce_ssl: true + admin_username: zimxyz + admin_password: Testpasswordxyz12! + tags: + ccc: ddd +- name: Gather facts MariaDB Server + azure_rm_mariadbserver_facts: + resource_group: '{{ resource_group }}' + name: mariadbsrv{{ rpfx }}second + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.servers[0]['id'] != None + - output.servers[0]['name'] != None + - output.servers[0]['location'] != None + - output.servers[0]['sku']['name'] != None + - output.servers[0]['sku']['tier'] != None + - output.servers[0]['sku']['capacity'] != None + - output.servers[0]['version'] != None + - output.servers[0]['user_visible_state'] != None + - output.servers[0]['fully_qualified_domain_name'] != None + - output.servers[0]['tags']['aaa'] == 'bbb' + - output.servers[0]['tags']['ccc'] == 'ddd' +- name: Gather facts MariaDB Server + azure_rm_mariadbserver_facts: + resource_group: '{{ resource_group }}' + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.servers[0]['id'] != None + - output.servers[0]['name'] != None + - output.servers[0]['location'] != None + - output.servers[0]['sku']['name'] != None + - output.servers[0]['sku']['tier'] != None + - output.servers[0]['sku']['capacity'] != None + - output.servers[0]['version'] != None + - output.servers[0]['user_visible_state'] != None + - output.servers[0]['fully_qualified_domain_name'] != None + - output.servers[1]['id'] != None + - output.servers[1]['name'] != None + - output.servers[1]['location'] != None + - output.servers[1]['sku']['name'] != None + - output.servers[1]['sku']['tier'] != None + - output.servers[1]['sku']['capacity'] != None + - output.servers[1]['version'] != None + - output.servers[1]['user_visible_state'] != None + - output.servers[1]['fully_qualified_domain_name'] != None +- name: Create instance of MariaDB Database -- check mode + check_mode: true + register: output + azure.azcollection.azure_rm_mariadbdatabase: + resource_group: '{{ resource_group }}' + server_name: mariadbsrv{{ rpfx }} + name: testdatabase +- name: Assert the resource instance is well created + assert: + that: + - output.changed +- name: Create instance of MariaDB Database + register: output + azure.azcollection.azure_rm_mariadbdatabase: + resource_group: '{{ resource_group }}' + server_name: mariadbsrv{{ rpfx }} + name: testdatabase + collation: latin1_swedish_ci + charset: latin1 +- name: Assert the resource instance is well created + assert: + that: + - output.changed + - output.name == 'testdatabase' +- name: Create again instance of MariaDB Database + register: output + azure.azcollection.azure_rm_mariadbdatabase: + resource_group: '{{ resource_group }}' + server_name: mariadbsrv{{ rpfx }} + name: testdatabase + collation: latin1_swedish_ci + charset: latin1 +- name: Assert the state has not changed + assert: + that: + - output.changed == false + - output.name == 'testdatabase' +- name: Try to update database without force_update + ignore_errors: true + register: output + azure.azcollection.azure_rm_mariadbdatabase: + resource_group: '{{ resource_group }}' + server_name: mariadbsrv{{ rpfx }} + name: testdatabase + collation: latin1_czech_ci + charset: latin1 +- name: Assert that nothing has changed + assert: + that: + - output.changed == False +- name: Update instance of database using force_update + register: output + azure.azcollection.azure_rm_mariadbdatabase: + resource_group: '{{ resource_group }}' + server_name: mariadbsrv{{ rpfx }} + name: testdatabase + collation: latin1_czech_ci + charset: latin1 + force_update: true +- name: Assert the state has changed + assert: + that: + - output.changed + - output.name == 'testdatabase' +- name: Create second instance of MariaDB Database + azure.azcollection.azure_rm_mariadbdatabase: + resource_group: '{{ resource_group }}' + server_name: mariadbsrv{{ rpfx }} + name: testdatabase2 +- name: Gather facts MariaDB Database + azure_rm_mariadbdatabase_facts: + resource_group: '{{ resource_group }}' + server_name: mariadbsrv{{ rpfx }} + name: testdatabase + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.databases[0]['server_name'] != None + - output.databases[0]['name'] != None + - output.databases[0]['charset'] != None + - output.databases[0]['collation'] != None +- name: Gather facts MariaDB Database + azure_rm_mariadbdatabase_facts: + resource_group: '{{ resource_group }}' + server_name: mariadbsrv{{ rpfx }} + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.databases[0]['server_name'] != None + - output.databases[0]['name'] != None + - output.databases[0]['charset'] != None + - output.databases[0]['collation'] != None + - output.databases[1]['server_name'] != None + - output.databases[1]['name'] != None + - output.databases[1]['charset'] != None + - output.databases[1]['collation'] != None +- name: Delete instance of MariaDB Database -- check mode + check_mode: true + register: output + azure.azcollection.azure_rm_mariadbdatabase: + resource_group: '{{ resource_group }}' + server_name: mariadbsrv{{ rpfx }} + name: testdatabase + state: absent +- name: Assert the state has changed + assert: + that: + - output.changed +- name: Delete instance of MariaDB Database + register: output + azure.azcollection.azure_rm_mariadbdatabase: + resource_group: '{{ resource_group }}' + server_name: mariadbsrv{{ rpfx }} + name: testdatabase + state: absent +- name: Assert the state has changed + assert: + that: + - output.changed +- name: Delete unexisting instance of MariaDB Database + register: output + azure.azcollection.azure_rm_mariadbdatabase: + resource_group: '{{ resource_group }}' + server_name: mariadbsrv{{ rpfx }} + name: testdatabase + state: absent +- name: Assert the state has changed + assert: + that: + - output.changed == false +- name: Create instance of Firewall Rule -- check mode + check_mode: true + register: output + azure.azcollection.azure_rm_mariadbfirewallrule: + resource_group: '{{ resource_group }}' + server_name: mariadbsrv{{ rpfx }} + name: firewallrule{{ rpfx }} + start_ip_address: 172.28.10.136 + end_ip_address: 172.28.10.138 +- name: Assert the resource instance is well created + assert: + that: + - output.changed +- name: Create instance of Firewall Rule + register: output + azure.azcollection.azure_rm_mariadbfirewallrule: + resource_group: '{{ resource_group }}' + server_name: mariadbsrv{{ rpfx }} + name: firewallrule{{ rpfx }} + start_ip_address: 172.28.10.136 + end_ip_address: 172.28.10.138 +- name: Assert the resource instance is well created + assert: + that: + - output.changed +- name: Create again instance of Firewall Rule + register: output + azure.azcollection.azure_rm_mariadbfirewallrule: + resource_group: '{{ resource_group }}' + server_name: mariadbsrv{{ rpfx }} + name: firewallrule{{ rpfx }} + start_ip_address: 172.28.10.136 + end_ip_address: 172.28.10.138 +- name: Assert the state has not changed + assert: + that: + - output.changed == false +- name: Delete instance of Firewall Rule -- check mode + check_mode: true + register: output + azure.azcollection.azure_rm_mariadbfirewallrule: + resource_group: '{{ resource_group }}' + server_name: mariadbsrv{{ rpfx }} + name: firewallrule{{ rpfx }} + state: absent +- name: Assert the state has changed + assert: + that: + - output.changed +- name: Create instance of Firewall Rule -- second + register: output + azure.azcollection.azure_rm_mariadbfirewallrule: + resource_group: '{{ resource_group }}' + server_name: mariadbsrv{{ rpfx }} + name: firewallrule{{ rpfx }}second + start_ip_address: 172.28.10.136 + end_ip_address: 172.28.10.138 +- name: Assert the state has changed + assert: + that: + - output.changed +- name: Gather facts MariaDB Firewall Rule + azure_rm_mariadbfirewallrule_facts: + resource_group: '{{ resource_group }}' + server_name: mariadbsrv{{ rpfx }} + name: firewallrule{{ rpfx }} + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.rules[0].id != None + - output.rules[0].server_name != None + - output.rules[0].name != None + - output.rules[0].start_ip_address != None + - output.rules[0].end_ip_address != None + - output.rules | length == 1 +- name: Gather facts MariaDB Firewall Rule + azure_rm_mariadbfirewallrule_facts: + resource_group: '{{ resource_group }}' + server_name: mariadbsrv{{ rpfx }} + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.rules[0].id != None + - output.rules[0].server_name != None + - output.rules[0].name != None + - output.rules[0].start_ip_address != None + - output.rules[0].end_ip_address != None + - output.rules[1].id != None + - output.rules[1].name != None + - output.rules[1].start_ip_address != None + - output.rules[1].end_ip_address != None + - output.rules | length == 2 +- name: Delete instance of Firewall Rule + register: output + azure.azcollection.azure_rm_mariadbfirewallrule: + resource_group: '{{ resource_group }}' + server_name: mariadbsrv{{ rpfx }} + name: firewallrule{{ rpfx }} + state: absent +- name: Assert the state has changed + assert: + that: + - output.changed +- name: Delete unexisting instance of Firewall Rule + register: output + azure.azcollection.azure_rm_mariadbfirewallrule: + resource_group: '{{ resource_group }}' + server_name: mariadbsrv{{ rpfx }} + name: firewallrule{{ rpfx }} + state: absent +- name: Assert the state has changed + assert: + that: + - output.changed == false +- name: Delete instance of Firewall Rule - second + azure.azcollection.azure_rm_mariadbfirewallrule: + resource_group: '{{ resource_group }}' + server_name: mariadbsrv{{ rpfx }} + name: firewallrule{{ rpfx }}second + state: absent +- name: Gather facts MariaDB Firewall Rule + azure_rm_mariadbfirewallrule_facts: + resource_group: '{{ resource_group }}' + server_name: mariadbsrv{{ rpfx }} + name: firewallrule{{ rpfx }} + register: output +- name: Assert that empty list was returned + assert: + that: + - output.changed == False + - output.rules | length == 0 +- name: Create instance of Configuration -- check mode + check_mode: true + register: output + azure.azcollection.azure_rm_mariadbconfiguration: + resource_group: '{{ resource_group }}' + server_name: mariadbsrv{{ rpfx }} + name: event_scheduler + value: 'ON' +- name: Assert that change was registered + assert: + that: + - output.changed +- name: Try to delete default configuraion + azure_rm_mariadbconfiguration_facts: + resource_group: '{{ resource_group }}' + server_name: mariadbsrv{{ rpfx }} + name: event_scheduler + register: output +- name: Get facts of event_scheduler + debug: + var: output +- name: Try to delete default configuraion + register: output + azure.azcollection.azure_rm_mariadbconfiguration: + resource_group: '{{ resource_group }}' + server_name: mariadbsrv{{ rpfx }} + name: event_scheduler + state: absent +- name: Assert that change was registered + assert: + that: + - not output.changed +- name: Try to change default configuraion + register: output + azure.azcollection.azure_rm_mariadbconfiguration: + resource_group: '{{ resource_group }}' + server_name: mariadbsrv{{ rpfx }} + name: event_scheduler + value: 'ON' +- name: Assert that change was registered + assert: + that: + - output.changed +- name: Try to change default configuration -- idempotent + register: output + azure.azcollection.azure_rm_mariadbconfiguration: + resource_group: '{{ resource_group }}' + server_name: mariadbsrv{{ rpfx }} + name: event_scheduler + value: 'ON' +- name: Assert that change was registered + assert: + that: + - not output.changed +- name: Try to reset configuration + register: output + azure.azcollection.azure_rm_mariadbconfiguration: + resource_group: '{{ resource_group }}' + server_name: mariadbsrv{{ rpfx }} + name: event_scheduler + state: absent +- name: Assert that change was registered + assert: + that: + - output.changed +- name: Try to reset configuration -- idempotent + register: output + azure.azcollection.azure_rm_mariadbconfiguration: + resource_group: '{{ resource_group }}' + server_name: mariadbsrv{{ rpfx }} + name: event_scheduler + state: absent +- name: Assert that change was registered + assert: + that: + - not output.changed +- name: Gather facts MariaDB Configuration + azure_rm_mariadbconfiguration_facts: + resource_group: '{{ resource_group }}' + server_name: mariadbsrv{{ rpfx }} + name: event_scheduler + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.settings[0].id != None + - output.settings[0].name != None + - output.settings[0].value != None + - output.settings[0].description != None + - output.settings[0].source != None + - output.settings | length == 1 +- name: Gather facts MariaDB Configuration + azure_rm_mariadbconfiguration_facts: + resource_group: '{{ resource_group }}' + server_name: mariadbsrv{{ rpfx }} + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.settings[0].id != None + - output.settings[0].name != None + - output.settings[0].value != None + - output.settings[0].description != None + - output.settings[0].source != None + - output.settings | length > 1 +- name: Delete instance of MariaDB Server -- check mode + check_mode: true + register: output + azure.azcollection.azure_rm_mariadbserver: + resource_group: '{{ resource_group }}' + name: mariadbsrv{{ rpfx }} + state: absent +- name: Assert the state has changed + assert: + that: + - output.changed +- name: Delete instance of MariaDB Server + register: output + azure.azcollection.azure_rm_mariadbserver: + resource_group: '{{ resource_group }}' + name: mariadbsrv{{ rpfx }} + state: absent +- name: Assert the state has changed + assert: + that: + - output.changed +- name: Delete unexisting instance of MariaDB Server + register: output + azure.azcollection.azure_rm_mariadbserver: + resource_group: '{{ resource_group }}' + name: mariadbsrv{{ rpfx }} + state: absent +- name: Assert the state has changed + assert: + that: + - output.changed == false +- name: Delete second instance of MariaDB Server + async: 400 + poll: 0 + azure.azcollection.azure_rm_mariadbserver: + resource_group: '{{ resource_group }}' + name: mariadbsrv{{ rpfx }}second + state: absent diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_mysqlserver/aliases b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_mysqlserver/aliases new file mode 100644 index 00000000..0eedad4b --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_mysqlserver/aliases @@ -0,0 +1,10 @@ +cloud/azure +destructive +shippable/azure/group1 +azure_rm_mysqlserver_facts +azure_rm_mysqldatabase +azure_rm_mysqldatabase_facts +azure_rm_mysqlfirewallrule +azure_rm_mysqlfirewallrule_facts +azure_rm_mysqlconfiguration +azure_rm_mysqlconfiguration_facts diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_mysqlserver/meta/main.yml b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_mysqlserver/meta/main.yml new file mode 100644 index 00000000..95e1952f --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_mysqlserver/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_azure diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_mysqlserver/tasks/main.yml b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_mysqlserver/tasks/main.yml new file mode 100644 index 00000000..a31bef15 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_mysqlserver/tasks/main.yml @@ -0,0 +1,581 @@ +- name: Prepare random number + set_fact: + rpfx: '{{ resource_group | hash(''md5'') | truncate(7, True, '''') }}{{ 1000 | random }}' + run_once: true +- name: Create instance of MySQL Server -- check mode + check_mode: true + register: output + azure.azcollection.azure_rm_mysqlserver: + resource_group: '{{ resource_group }}' + name: mysqlsrv{{ rpfx }} + sku: + name: B_Gen5_1 + tier: Basic + location: westus2 + storage_mb: 51200 + version: 5.6 + enforce_ssl: true + admin_username: zimxyz + admin_password: Testpasswordxyz12! +- name: Assert the resource instance is well created + assert: + that: + - output.changed +- name: Create instance of MySQL Server + register: output + azure.azcollection.azure_rm_mysqlserver: + resource_group: '{{ resource_group }}' + name: mysqlsrv{{ rpfx }} + sku: + name: B_Gen5_1 + tier: Basic + location: westus2 + storage_mb: 51200 + version: 5.6 + enforce_ssl: true + admin_username: zimxyz + admin_password: Testpasswordxyz12! +- name: Assert the resource instance is well created + assert: + that: + - output.changed + - output.state == 'Ready' +- name: Create again instance of MySQL Server + register: output + azure.azcollection.azure_rm_mysqlserver: + resource_group: '{{ resource_group }}' + name: mysqlsrv{{ rpfx }} + sku: + name: B_Gen5_1 + tier: Basic + location: westus2 + storage_mb: 51200 + version: 5.6 + enforce_ssl: true + admin_username: zimxyz + admin_password: Testpasswordxyz12! +- name: Assert the state has not changed + assert: + that: + - output.changed == false + - output.state == 'Ready' +- name: Update instance of MySQL Server, change storage size + register: output + azure.azcollection.azure_rm_mysqlserver: + resource_group: '{{ resource_group }}' + name: mysqlsrv{{ rpfx }} + sku: + name: B_Gen5_1 + tier: Basic + location: westus2 + storage_mb: 128000 + version: 5.6 + enforce_ssl: true + admin_username: zimxyz + admin_password: Testpasswordxyz12! +- name: Assert the state has not changed + assert: + that: + - output.changed + - output.state == 'Ready' +- debug: + var: output +- name: Gather facts MySQL Server + azure_rm_mysqlserver_facts: + resource_group: '{{ resource_group }}' + name: mysqlsrv{{ rpfx }} + register: output +- name: Assert that storage size is correct + assert: + that: + - output.servers[0]['storage_mb'] == 128000 +- name: Create second instance of MySQL Server + azure.azcollection.azure_rm_mysqlserver: + resource_group: '{{ resource_group }}' + name: mysqlsrv{{ rpfx }}second + sku: + name: B_Gen5_1 + tier: Basic + location: westus2 + storage_mb: 51200 + version: 5.6 + enforce_ssl: true + admin_username: zimxyz + admin_password: Testpasswordxyz12! + tags: + aaa: bbb +- name: Create second instance of MySQL Server + azure.azcollection.azure_rm_mysqlserver: + resource_group: '{{ resource_group }}' + name: mysqlsrv{{ rpfx }}second + sku: + name: B_Gen5_1 + tier: Basic + location: westus2 + storage_mb: 51200 + version: 5.6 + enforce_ssl: true + admin_username: zimxyz + admin_password: Testpasswordxyz12! + tags: + ccc: ddd +- name: Gather facts MySQL Server + azure_rm_mysqlserver_facts: + resource_group: '{{ resource_group }}' + name: mysqlsrv{{ rpfx }}second + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.servers[0]['id'] != None + - output.servers[0]['name'] != None + - output.servers[0]['location'] != None + - output.servers[0]['sku']['name'] != None + - output.servers[0]['sku']['tier'] != None + - output.servers[0]['sku']['capacity'] != None + - output.servers[0]['version'] != None + - output.servers[0]['user_visible_state'] != None + - output.servers[0]['fully_qualified_domain_name'] != None + - output.servers[0]['tags']['aaa'] == 'bbb' + - output.servers[0]['tags']['ccc'] == 'ddd' +- name: Gather facts MySQL Server + azure_rm_mysqlserver_facts: + resource_group: '{{ resource_group }}' + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.servers[0]['id'] != None + - output.servers[0]['name'] != None + - output.servers[0]['location'] != None + - output.servers[0]['sku']['name'] != None + - output.servers[0]['sku']['tier'] != None + - output.servers[0]['sku']['capacity'] != None + - output.servers[0]['version'] != None + - output.servers[0]['user_visible_state'] != None + - output.servers[0]['fully_qualified_domain_name'] != None + - output.servers[1]['id'] != None + - output.servers[1]['name'] != None + - output.servers[1]['location'] != None + - output.servers[1]['sku']['name'] != None + - output.servers[1]['sku']['tier'] != None + - output.servers[1]['sku']['capacity'] != None + - output.servers[1]['version'] != None + - output.servers[1]['user_visible_state'] != None + - output.servers[1]['fully_qualified_domain_name'] != None +- name: Create instance of MySQL Database -- check mode + check_mode: true + register: output + azure.azcollection.azure_rm_mysqldatabase: + resource_group: '{{ resource_group }}' + server_name: mysqlsrv{{ rpfx }} + name: testdatabase +- name: Assert the resource instance is well created + assert: + that: + - output.changed +- name: Create instance of MySQL Database + register: output + azure.azcollection.azure_rm_mysqldatabase: + resource_group: '{{ resource_group }}' + server_name: mysqlsrv{{ rpfx }} + name: testdatabase + collation: latin1_swedish_ci + charset: latin1 +- name: Assert the resource instance is well created + assert: + that: + - output.changed + - output.name == 'testdatabase' +- name: Create again instance of MySQL Database + register: output + azure.azcollection.azure_rm_mysqldatabase: + resource_group: '{{ resource_group }}' + server_name: mysqlsrv{{ rpfx }} + name: testdatabase + collation: latin1_swedish_ci + charset: latin1 +- name: Assert the state has not changed + assert: + that: + - output.changed == false + - output.name == 'testdatabase' +- name: Try to update database without force_update + ignore_errors: true + register: output + azure.azcollection.azure_rm_mysqldatabase: + resource_group: '{{ resource_group }}' + server_name: mysqlsrv{{ rpfx }} + name: testdatabase + collation: latin1_czech_ci + charset: latin1 +- name: Assert that nothing has changed + assert: + that: + - output.changed == False +- name: Update instance of database using force_update + register: output + azure.azcollection.azure_rm_mysqldatabase: + resource_group: '{{ resource_group }}' + server_name: mysqlsrv{{ rpfx }} + name: testdatabase + collation: latin1_czech_ci + charset: latin1 + force_update: true +- name: Assert the state has changed + assert: + that: + - output.changed + - output.name == 'testdatabase' +- name: Create second instance of MySQL Database + azure.azcollection.azure_rm_mysqldatabase: + resource_group: '{{ resource_group }}' + server_name: mysqlsrv{{ rpfx }} + name: testdatabase2 +- name: Gather facts MySQL Database + azure_rm_mysqldatabase_facts: + resource_group: '{{ resource_group }}' + server_name: mysqlsrv{{ rpfx }} + name: testdatabase + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.databases[0]['server_name'] != None + - output.databases[0]['name'] != None + - output.databases[0]['charset'] != None + - output.databases[0]['collation'] != None +- name: Gather facts MySQL Database + azure_rm_mysqldatabase_facts: + resource_group: '{{ resource_group }}' + server_name: mysqlsrv{{ rpfx }} + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.databases[0]['server_name'] != None + - output.databases[0]['name'] != None + - output.databases[0]['charset'] != None + - output.databases[0]['collation'] != None + - output.databases[1]['server_name'] != None + - output.databases[1]['name'] != None + - output.databases[1]['charset'] != None + - output.databases[1]['collation'] != None +- name: Delete instance of MySQL Database -- check mode + check_mode: true + register: output + azure.azcollection.azure_rm_mysqldatabase: + resource_group: '{{ resource_group }}' + server_name: mysqlsrv{{ rpfx }} + name: testdatabase + state: absent +- name: Assert the state has changed + assert: + that: + - output.changed +- name: Delete instance of MySQL Database + register: output + azure.azcollection.azure_rm_mysqldatabase: + resource_group: '{{ resource_group }}' + server_name: mysqlsrv{{ rpfx }} + name: testdatabase + state: absent +- name: Assert the state has changed + assert: + that: + - output.changed +- name: Delete unexisting instance of MySQL Database + register: output + azure.azcollection.azure_rm_mysqldatabase: + resource_group: '{{ resource_group }}' + server_name: mysqlsrv{{ rpfx }} + name: testdatabase + state: absent +- name: Assert the state has changed + assert: + that: + - output.changed == false +- name: Create instance of Firewall Rule -- check mode + check_mode: true + register: output + azure.azcollection.azure_rm_mysqlfirewallrule: + resource_group: '{{ resource_group }}' + server_name: mysqlsrv{{ rpfx }} + name: firewallrule{{ rpfx }} + start_ip_address: 172.28.10.136 + end_ip_address: 172.28.10.138 +- name: Assert the resource instance is well created + assert: + that: + - output.changed +- name: Create instance of Firewall Rule + register: output + azure.azcollection.azure_rm_mysqlfirewallrule: + resource_group: '{{ resource_group }}' + server_name: mysqlsrv{{ rpfx }} + name: firewallrule{{ rpfx }} + start_ip_address: 172.28.10.136 + end_ip_address: 172.28.10.138 +- name: Assert the resource instance is well created + assert: + that: + - output.changed +- name: Create again instance of Firewall Rule + register: output + azure.azcollection.azure_rm_mysqlfirewallrule: + resource_group: '{{ resource_group }}' + server_name: mysqlsrv{{ rpfx }} + name: firewallrule{{ rpfx }} + start_ip_address: 172.28.10.136 + end_ip_address: 172.28.10.138 +- name: Assert the state has not changed + assert: + that: + - output.changed == false +- name: Delete instance of Firewall Rule -- check mode + check_mode: true + register: output + azure.azcollection.azure_rm_mysqlfirewallrule: + resource_group: '{{ resource_group }}' + server_name: mysqlsrv{{ rpfx }} + name: firewallrule{{ rpfx }} + state: absent +- name: Assert the state has changed + assert: + that: + - output.changed +- name: Create instance of Firewall Rule -- second + register: output + azure.azcollection.azure_rm_mysqlfirewallrule: + resource_group: '{{ resource_group }}' + server_name: mysqlsrv{{ rpfx }} + name: firewallrule{{ rpfx }}second + start_ip_address: 172.28.10.136 + end_ip_address: 172.28.10.138 +- name: Assert the state has changed + assert: + that: + - output.changed +- name: Gather facts MySQL Firewall Rule + azure_rm_mysqlfirewallrule_facts: + resource_group: '{{ resource_group }}' + server_name: mysqlsrv{{ rpfx }} + name: firewallrule{{ rpfx }} + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.rules[0].id != None + - output.rules[0].server_name != None + - output.rules[0].name != None + - output.rules[0].start_ip_address != None + - output.rules[0].end_ip_address != None + - output.rules | length == 1 +- name: Gather facts MySQL Firewall Rule + azure_rm_mysqlfirewallrule_facts: + resource_group: '{{ resource_group }}' + server_name: mysqlsrv{{ rpfx }} + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.rules[0].id != None + - output.rules[0].server_name != None + - output.rules[0].name != None + - output.rules[0].start_ip_address != None + - output.rules[0].end_ip_address != None + - output.rules[1].id != None + - output.rules[1].name != None + - output.rules[1].start_ip_address != None + - output.rules[1].end_ip_address != None + - output.rules | length == 2 +- name: Delete instance of Firewall Rule + register: output + azure.azcollection.azure_rm_mysqlfirewallrule: + resource_group: '{{ resource_group }}' + server_name: mysqlsrv{{ rpfx }} + name: firewallrule{{ rpfx }} + state: absent +- name: Assert the state has changed + assert: + that: + - output.changed +- name: Delete unexisting instance of Firewall Rule + register: output + azure.azcollection.azure_rm_mysqlfirewallrule: + resource_group: '{{ resource_group }}' + server_name: mysqlsrv{{ rpfx }} + name: firewallrule{{ rpfx }} + state: absent +- name: Assert the state has changed + assert: + that: + - output.changed == false +- name: Delete instance of Firewall Rule - second + azure.azcollection.azure_rm_mysqlfirewallrule: + resource_group: '{{ resource_group }}' + server_name: mysqlsrv{{ rpfx }} + name: firewallrule{{ rpfx }}second + state: absent +- name: Gather facts MySQL Firewall Rule + azure_rm_mysqlfirewallrule_facts: + resource_group: '{{ resource_group }}' + server_name: mysqlsrv{{ rpfx }} + name: firewallrule{{ rpfx }} + register: output +- name: Assert that empty list was returned + assert: + that: + - output.changed == False + - output.rules | length == 0 +- name: Create instance of Configuration -- check mode + check_mode: true + register: output + azure.azcollection.azure_rm_mysqlconfiguration: + resource_group: '{{ resource_group }}' + server_name: mysqlsrv{{ rpfx }} + name: event_scheduler + value: 'ON' +- name: Assert that change was registered + assert: + that: + - output.changed +- name: Try to delete default configuraion + azure_rm_mysqlconfiguration_facts: + resource_group: '{{ resource_group }}' + server_name: mysqlsrv{{ rpfx }} + name: event_scheduler + register: output +- name: Get facts of event_scheduler + debug: + var: output +- name: Try to delete default configuraion + register: output + azure.azcollection.azure_rm_mysqlconfiguration: + resource_group: '{{ resource_group }}' + server_name: mysqlsrv{{ rpfx }} + name: event_scheduler + state: absent +- name: Assert that change was registered + assert: + that: + - not output.changed +- name: Try to change default configuraion + register: output + azure.azcollection.azure_rm_mysqlconfiguration: + resource_group: '{{ resource_group }}' + server_name: mysqlsrv{{ rpfx }} + name: event_scheduler + value: 'ON' +- name: Assert that change was registered + assert: + that: + - output.changed +- name: Try to change default configuration -- idempotent + register: output + azure.azcollection.azure_rm_mysqlconfiguration: + resource_group: '{{ resource_group }}' + server_name: mysqlsrv{{ rpfx }} + name: event_scheduler + value: 'ON' +- name: Assert that change was registered + assert: + that: + - not output.changed +- name: Try to reset configuration + register: output + azure.azcollection.azure_rm_mysqlconfiguration: + resource_group: '{{ resource_group }}' + server_name: mysqlsrv{{ rpfx }} + name: event_scheduler + state: absent +- name: Assert that change was registered + assert: + that: + - output.changed +- name: Try to reset configuration -- idempotent + register: output + azure.azcollection.azure_rm_mysqlconfiguration: + resource_group: '{{ resource_group }}' + server_name: mysqlsrv{{ rpfx }} + name: event_scheduler + state: absent +- name: Assert that change was registered + assert: + that: + - not output.changed +- name: Gather facts MySQL Configuration + azure_rm_mysqlconfiguration_facts: + resource_group: '{{ resource_group }}' + server_name: mysqlsrv{{ rpfx }} + name: event_scheduler + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.settings[0].id != None + - output.settings[0].name != None + - output.settings[0].value != None + - output.settings[0].description != None + - output.settings[0].source != None + - output.settings | length == 1 +- name: Gather facts MySQL Configuration + azure_rm_mysqlconfiguration_facts: + resource_group: '{{ resource_group }}' + server_name: mysqlsrv{{ rpfx }} + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.settings[0].id != None + - output.settings[0].name != None + - output.settings[0].value != None + - output.settings[0].description != None + - output.settings[0].source != None + - output.settings | length > 1 +- name: Delete instance of MySQL Server -- check mode + check_mode: true + register: output + azure.azcollection.azure_rm_mysqlserver: + resource_group: '{{ resource_group }}' + name: mysqlsrv{{ rpfx }} + state: absent +- name: Assert the state has changed + assert: + that: + - output.changed +- name: Delete instance of MySQL Server + register: output + azure.azcollection.azure_rm_mysqlserver: + resource_group: '{{ resource_group }}' + name: mysqlsrv{{ rpfx }} + state: absent +- name: Assert the state has changed + assert: + that: + - output.changed +- name: Delete unexisting instance of MySQL Server + register: output + azure.azcollection.azure_rm_mysqlserver: + resource_group: '{{ resource_group }}' + name: mysqlsrv{{ rpfx }} + state: absent +- name: Assert the state has changed + assert: + that: + - output.changed == false +- name: Delete second instance of MySQL Server + async: 400 + poll: 0 + azure.azcollection.azure_rm_mysqlserver: + resource_group: '{{ resource_group }}' + name: mysqlsrv{{ rpfx }}second + state: absent diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_postgresqlserver/aliases b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_postgresqlserver/aliases new file mode 100644 index 00000000..b5923cc0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_postgresqlserver/aliases @@ -0,0 +1,10 @@ +cloud/azure +destructive +shippable/azure/group1 +azure_rm_postgresqlserver_facts +azure_rm_postgresqldatabase +azure_rm_postgresqldatabase_facts +azure_rm_postgresqlfirewallrule +azure_rm_postgresqlfirewallrule_facts +azure_rm_postgresqlserverconfiguration +azure_rm_postgresqlserverconfiguration_facts diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_postgresqlserver/meta/main.yml b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_postgresqlserver/meta/main.yml new file mode 100644 index 00000000..95e1952f --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_postgresqlserver/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_azure diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_postgresqlserver/tasks/main.yml b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_postgresqlserver/tasks/main.yml new file mode 100644 index 00000000..03a87f65 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_postgresqlserver/tasks/main.yml @@ -0,0 +1,552 @@ +- name: Prepare random number + set_fact: + rpfx: '{{ resource_group | hash(''md5'') | truncate(7, True, '''') }}{{ 1000 | random }}' + run_once: true +- name: Create instance of PostgreSQL Server -- check mode + check_mode: true + register: output + azure.azcollection.azure_rm_postgresqlserver: + resource_group: '{{ resource_group }}' + name: postgresqlsrv{{ rpfx }} + sku: + name: B_Gen5_1 + tier: Basic + location: westus2 + storage_mb: 51200 + enforce_ssl: true + admin_username: zimxyz + admin_password: Testpasswordxyz12! +- name: Assert the resource instance is well created + assert: + that: + - output.changed +- name: Create instance of PostgreSQL Server + register: output + azure.azcollection.azure_rm_postgresqlserver: + resource_group: '{{ resource_group }}' + name: postgresqlsrv{{ rpfx }} + sku: + name: B_Gen5_1 + tier: Basic + location: westus2 + storage_mb: 51200 + enforce_ssl: true + admin_username: zimxyz + admin_password: Testpasswordxyz12! +- name: Assert the resource instance is well created + assert: + that: + - output.changed + - output.state == 'Ready' +- name: Create again instance of PostgreSQL Server + register: output + azure.azcollection.azure_rm_postgresqlserver: + resource_group: '{{ resource_group }}' + name: postgresqlsrv{{ rpfx }} + sku: + name: B_Gen5_1 + tier: Basic + location: westus2 + storage_mb: 51200 + enforce_ssl: true + admin_username: zimxyz + admin_password: Testpasswordxyz12! +- name: Assert the state has not changed + assert: + that: + - output.changed == false + - output.state == 'Ready' +- name: Update instance of PostgreSQL Server, change storage size + register: output + azure.azcollection.azure_rm_postgresqlserver: + resource_group: '{{ resource_group }}' + name: postgresqlsrv{{ rpfx }} + sku: + name: B_Gen5_1 + tier: Basic + location: westus2 + storage_mb: 128000 + enforce_ssl: true + admin_username: zimxyz + admin_password: Testpasswordxyz12! +- name: Assert the state has not changed + assert: + that: + - output.changed + - output.state == 'Ready' +- debug: + var: output +- name: Gather facts postgresql Server + azure_rm_postgresqlserver_facts: + resource_group: '{{ resource_group }}' + name: postgresqlsrv{{ rpfx }} + register: output +- name: Assert that storage size is correct + assert: + that: + - output.servers[0]['storage_mb'] == 128000 +- name: Create second instance of PostgreSQL Server + azure.azcollection.azure_rm_postgresqlserver: + resource_group: '{{ resource_group }}' + name: postgresqlsrv{{ rpfx }}second + sku: + name: B_Gen5_1 + tier: Basic + location: westus2 + storage_mb: 51200 + enforce_ssl: true + admin_username: zimxyz + admin_password: Testpasswordxyz12! + tags: + aaa: bbb +- name: Create second instance of PostgreSQL Server -- add tags + azure.azcollection.azure_rm_postgresqlserver: + resource_group: '{{ resource_group }}' + name: postgresqlsrv{{ rpfx }}second + sku: + name: B_Gen5_1 + tier: Basic + location: westus2 + storage_mb: 51200 + enforce_ssl: true + admin_username: zimxyz + admin_password: Testpasswordxyz12! + tags: + ccc: ddd +- name: Gather facts PostgreSQL Server + azure_rm_postgresqlserver_facts: + resource_group: '{{ resource_group }}' + name: postgresqlsrv{{ rpfx }}second + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.servers[0]['id'] != None + - output.servers[0]['name'] != None + - output.servers[0]['location'] != None + - output.servers[0]['sku']['name'] != None + - output.servers[0]['sku']['tier'] != None + - output.servers[0]['sku']['capacity'] != None + - output.servers[0]['version'] != None + - output.servers[0]['user_visible_state'] != None + - output.servers[0]['fully_qualified_domain_name'] != None + - output.servers[0]['tags']['aaa'] == 'bbb' + - output.servers[0]['tags']['ccc'] == 'ddd' +- name: Gather facts PostgreSQL Server + azure_rm_postgresqlserver_facts: + resource_group: '{{ resource_group }}' + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.servers[0]['id'] != None + - output.servers[0]['name'] != None + - output.servers[0]['location'] != None + - output.servers[0]['sku']['name'] != None + - output.servers[0]['sku']['tier'] != None + - output.servers[0]['sku']['capacity'] != None + - output.servers[0]['version'] != None + - output.servers[0]['user_visible_state'] != None + - output.servers[0]['fully_qualified_domain_name'] != None + - output.servers[1]['id'] != None + - output.servers[1]['name'] != None + - output.servers[1]['location'] != None + - output.servers[1]['sku']['name'] != None + - output.servers[1]['sku']['tier'] != None + - output.servers[1]['sku']['capacity'] != None + - output.servers[1]['version'] != None + - output.servers[1]['user_visible_state'] != None + - output.servers[1]['fully_qualified_domain_name'] != None +- name: Create instance of PostgreSQL Database -- check mode + check_mode: true + register: output + azure.azcollection.azure_rm_postgresqldatabase: + resource_group: '{{ resource_group }}' + server_name: postgresqlsrv{{ rpfx }} + name: testdatabase + charset: UTF8 + collation: English_United States.1252 +- name: Assert the resource instance is well created + assert: + that: + - output.changed +- name: Create instance of PostgreSQL Database + register: output + azure.azcollection.azure_rm_postgresqldatabase: + resource_group: '{{ resource_group }}' + server_name: postgresqlsrv{{ rpfx }} + name: testdatabase + charset: UTF8 + collation: English_United States.1252 +- name: Assert the resource instance is well created + assert: + that: + - output.changed + - output.name == 'testdatabase' +- name: Create again instance of PostgreSQL Database + register: output + azure.azcollection.azure_rm_postgresqldatabase: + resource_group: '{{ resource_group }}' + server_name: postgresqlsrv{{ rpfx }} + name: testdatabase + charset: UTF8 + collation: English_United States.1252 +- name: Assert the state has not changed + assert: + that: + - output.changed == false + - output.name == 'testdatabase' +- name: Try to update PostgreSQL Database without force_update + ignore_errors: true + register: output + azure.azcollection.azure_rm_postgresqldatabase: + resource_group: '{{ resource_group }}' + server_name: postgresqlsrv{{ rpfx }} + name: testdatabase + charset: WIN1252 + collation: SQL_Latin1_General_CP1_CS_AS +- name: Assert that nothing has changed + assert: + that: + - output.changed == False +- name: Try to update PostgreSQL Database with force_update + register: output + azure.azcollection.azure_rm_postgresqldatabase: + resource_group: '{{ resource_group }}' + server_name: postgresqlsrv{{ rpfx }} + name: testdatabase + charset: WIN1252 + collation: SQL_Latin1_General_CP1_CS_AS + force_update: true +- name: Assert the state has changed + assert: + that: + - output.changed + - output.name == 'testdatabase' +- name: Create second instance of PostgreSQL Database + azure.azcollection.azure_rm_postgresqldatabase: + resource_group: '{{ resource_group }}' + server_name: postgresqlsrv{{ rpfx }} + name: testdatabase2 +- name: Gather facts PostgreSQL Database + azure_rm_postgresqldatabase_facts: + resource_group: '{{ resource_group }}' + server_name: postgresqlsrv{{ rpfx }} + name: testdatabase + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.databases[0]['server_name'] != None + - output.databases[0]['name'] != None + - output.databases[0]['charset'] != None + - output.databases[0]['collation'] != None +- name: Gather facts PostgreSQL Database + azure_rm_postgresqldatabase_facts: + resource_group: '{{ resource_group }}' + server_name: postgresqlsrv{{ rpfx }} + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.databases[0]['server_name'] != None + - output.databases[0]['name'] != None + - output.databases[0]['charset'] != None + - output.databases[0]['collation'] != None + - output.databases[1]['server_name'] != None + - output.databases[1]['name'] != None + - output.databases[1]['charset'] != None + - output.databases[1]['collation'] != None +- name: Delete instance of PostgreSQL Database -- check mode + check_mode: true + register: output + azure.azcollection.azure_rm_postgresqldatabase: + resource_group: '{{ resource_group }}' + server_name: postgresqlsrv{{ rpfx }} + name: testdatabase + state: absent +- name: Assert the state has changed + assert: + that: + - output.changed +- name: Delete instance of PostgreSQL Database + register: output + azure.azcollection.azure_rm_postgresqldatabase: + resource_group: '{{ resource_group }}' + server_name: postgresqlsrv{{ rpfx }} + name: testdatabase + state: absent +- name: Assert the state has changed + assert: + that: + - output.changed +- name: Delete unexisting instance of PostgreSQL Database + register: output + azure.azcollection.azure_rm_postgresqldatabase: + resource_group: '{{ resource_group }}' + server_name: postgresqlsrv{{ rpfx }} + name: testdatabase + state: absent +- name: Assert the state has changed + assert: + that: + - output.changed == false +- name: Create instance of Firewall Rule -- check mode + check_mode: true + register: output + azure.azcollection.azure_rm_postgresqlfirewallrule: + resource_group: '{{ resource_group }}' + server_name: postgresqlsrv{{ rpfx }} + name: firewallrule{{ rpfx }} + start_ip_address: 172.28.10.136 + end_ip_address: 172.28.10.138 +- name: Assert the resource instance is well created + assert: + that: + - output.changed +- name: Create instance of Firewall Rule + register: output + azure.azcollection.azure_rm_postgresqlfirewallrule: + resource_group: '{{ resource_group }}' + server_name: postgresqlsrv{{ rpfx }} + name: firewallrule{{ rpfx }} + start_ip_address: 172.28.10.136 + end_ip_address: 172.28.10.138 +- name: Assert the resource instance is well created + assert: + that: + - output.changed +- name: Create again instance of Firewall Rule + register: output + azure.azcollection.azure_rm_postgresqlfirewallrule: + resource_group: '{{ resource_group }}' + server_name: postgresqlsrv{{ rpfx }} + name: firewallrule{{ rpfx }} + start_ip_address: 172.28.10.136 + end_ip_address: 172.28.10.138 +- name: Assert the state has not changed + assert: + that: + - output.changed == false +- name: Create Firewall Rule - second + azure.azcollection.azure_rm_postgresqlfirewallrule: + resource_group: '{{ resource_group }}' + server_name: postgresqlsrv{{ rpfx }} + name: firewallrule{{ rpfx }}second + start_ip_address: 172.28.10.136 + end_ip_address: 172.28.10.138 +- name: Gather facts PostgreSQL Firewall Rule + azure_rm_postgresqlfirewallrule_facts: + resource_group: '{{ resource_group }}' + server_name: postgresqlsrv{{ rpfx }} + name: firewallrule{{ rpfx }} + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.rules[0].id != None + - output.rules[0].server_name != None + - output.rules[0].name != None + - output.rules[0].start_ip_address != None + - output.rules[0].end_ip_address != None + - output.rules | length == 1 +- name: Gather facts PostgreSQL Firewall Rule + azure_rm_postgresqlfirewallrule_facts: + resource_group: '{{ resource_group }}' + server_name: postgresqlsrv{{ rpfx }} + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.rules[0].id != None + - output.rules[0].server_name != None + - output.rules[0].name != None + - output.rules[0].start_ip_address != None + - output.rules[0].end_ip_address != None + - output.rules[1].id != None + - output.rules[1].name != None + - output.rules[1].start_ip_address != None + - output.rules[1].end_ip_address != None + - output.rules | length == 2 +- name: Delete instance of Firewall Rule -- check mode + check_mode: true + register: output + azure.azcollection.azure_rm_postgresqlfirewallrule: + resource_group: '{{ resource_group }}' + server_name: postgresqlsrv{{ rpfx }} + name: firewallrule{{ rpfx }} + state: absent +- name: Assert the state has changed + assert: + that: + - output.changed +- name: Delete instance of Firewall Rule + register: output + azure.azcollection.azure_rm_postgresqlfirewallrule: + resource_group: '{{ resource_group }}' + server_name: postgresqlsrv{{ rpfx }} + name: firewallrule{{ rpfx }} + state: absent +- name: Assert the state has changed + assert: + that: + - output.changed +- name: Delete unexisting instance of Firewall Rule + register: output + azure.azcollection.azure_rm_postgresqlfirewallrule: + resource_group: '{{ resource_group }}' + server_name: postgresqlsrv{{ rpfx }} + name: firewallrule{{ rpfx }} + state: absent +- name: Assert the state has changed + assert: + that: + - output.changed == false +- name: Delete instance of Firewall Rule - second + azure.azcollection.azure_rm_postgresqlfirewallrule: + resource_group: '{{ resource_group }}' + server_name: postgresqlsrv{{ rpfx }} + name: firewallrule{{ rpfx }}second + state: absent +- name: Gather facts PostgreSQL Firewall Rule + azure_rm_postgresqlfirewallrule_facts: + resource_group: '{{ resource_group }}' + server_name: postgresqlsrv{{ rpfx }} + name: firewallrule{{ rpfx }} + register: output +- name: Assert that empty list was returned + assert: + that: + - output.changed == False + - output.rules | length == 0 +- name: Create instance of Configuration -- check mode + check_mode: true + register: output + azure.azcollection.azure_rm_postgresqlconfiguration: + resource_group: '{{ resource_group }}' + server_name: postgresqlsrv{{ rpfx }} + name: deadlock_timeout + value: 2000 +- name: Assert that change was registered + assert: + that: + - output.changed +- name: Try to change default configuration + register: output + azure.azcollection.azure_rm_postgresqlconfiguration: + resource_group: '{{ resource_group }}' + server_name: postgresqlsrv{{ rpfx }} + name: deadlock_timeout + value: 2000 +- name: Assert that change was registered + assert: + that: + - output.changed +- name: Try to change default configuration -- idempotent + register: output + azure.azcollection.azure_rm_postgresqlconfiguration: + resource_group: '{{ resource_group }}' + server_name: postgresqlsrv{{ rpfx }} + name: deadlock_timeout + value: 2000 +- name: Assert that change was not registered + assert: + that: + - not output.changed +- name: Try to reset configuration + register: output + azure.azcollection.azure_rm_postgresqlconfiguration: + resource_group: '{{ resource_group }}' + server_name: postgresqlsrv{{ rpfx }} + name: deadlock_timeout + state: absent +- name: Assert that change was registered + assert: + that: + - output.changed +- name: Try to reset configuration -- idempotent + register: output + azure.azcollection.azure_rm_postgresqlconfiguration: + resource_group: '{{ resource_group }}' + server_name: postgresqlsrv{{ rpfx }} + name: deadlock_timeout + state: absent +- name: Assert that change was registered + assert: + that: + - not output.changed +- name: Gather facts PostgreSQL Configuration + azure_rm_postgresqlconfiguration_facts: + resource_group: '{{ resource_group }}' + server_name: postgresqlsrv{{ rpfx }} + name: deadlock_timeout + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.settings[0].id != None + - output.settings[0].name != None + - output.settings[0].value != None + - output.settings[0].description != None + - output.settings[0].source != None + - output.settings | length == 1 +- name: Gather facts PostgreSQL Configuration + azure_rm_postgresqlconfiguration_facts: + resource_group: '{{ resource_group }}' + server_name: postgresqlsrv{{ rpfx }} + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.settings[0].id != None + - output.settings[0].name != None + - output.settings[0].value != None + - output.settings[0].description != None + - output.settings[0].source != None + - output.settings | length > 1 +- name: Delete instance of PostgreSQL Server -- check mode + check_mode: true + register: output + azure.azcollection.azure_rm_postgresqlserver: + resource_group: '{{ resource_group }}' + name: postgresqlsrv{{ rpfx }} + state: absent +- name: Assert the state has changed + assert: + that: + - output.changed +- name: Delete instance of PostgreSQL Server + register: output + azure.azcollection.azure_rm_postgresqlserver: + resource_group: '{{ resource_group }}' + name: postgresqlsrv{{ rpfx }} + state: absent +- name: Assert the state has changed + assert: + that: + - output.changed +- name: Delete unexisting instance of PostgreSQL Server + register: output + azure.azcollection.azure_rm_postgresqlserver: + resource_group: '{{ resource_group }}' + name: postgresqlsrv{{ rpfx }} + state: absent +- name: Assert the state has changed + assert: + that: + - output.changed == false +- name: Delete second instance of PostgreSQL Server + async: 400 + poll: 0 + azure.azcollection.azure_rm_postgresqlserver: + resource_group: '{{ resource_group }}' + name: postgresqlsrv{{ rpfx }}second + state: absent diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_publicipaddress/aliases b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_publicipaddress/aliases new file mode 100644 index 00000000..eed0eb55 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_publicipaddress/aliases @@ -0,0 +1,4 @@ +cloud/azure +shippable/azure/group1 +destructive +azure_rm_publicipaddress_facts diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_publicipaddress/meta/main.yml b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_publicipaddress/meta/main.yml new file mode 100644 index 00000000..95e1952f --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_publicipaddress/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_azure diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_publicipaddress/tasks/main.yml b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_publicipaddress/tasks/main.yml new file mode 100644 index 00000000..6d9ef050 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_publicipaddress/tasks/main.yml @@ -0,0 +1,95 @@ +- name: Create domain name + set_fact: + domain_name: ansible-{{ resource_group | hash('md5') | truncate(24, True, '') }} + rpfx: '{{ resource_group | hash(''md5'') | truncate(7, True, '''') }}{{ 1000 | random }}' +- name: Remove public ip + azure.azcollection.azure_rm_publicipaddress: + resource_group: '{{ resource_group }}' + name: pip{{ rpfx }} + state: absent +- name: Create public ip + register: output + azure.azcollection.azure_rm_publicipaddress: + resource_group: '{{ resource_group }}' + name: pip{{ rpfx }} + allocation_method: Static + domain_name: '{{ domain_name }}' + tags: + testing: testing + delete: on-exit +- assert: + that: + - output.state.public_ip_allocation_method == 'static' + - output.state.dns_settings.domain_name_label == domain_name + - output.state.tags | length == 2 + - output.state.tags.testing == 'testing' +- name: Should be idempotent + register: output + azure.azcollection.azure_rm_publicipaddress: + resource_group: '{{ resource_group }}' + name: pip{{ rpfx }} + allocation_method: static + domain_name: '{{ domain_name }}' +- assert: + that: not output.changed +- name: Update tags + register: output + azure.azcollection.azure_rm_publicipaddress: + resource_group: '{{ resource_group }}' + name: pip{{ rpfx }} + allocation_method: static + domain_name: '{{ domain_name }}' + append_tags: true + tags: + delete: never + foo: bar +- assert: + that: + - output.state.tags | length == 3 + - output.state.tags.delete == 'never' +- name: Gather facts, filtering by tag + azure_rm_publicipaddress_facts: + resource_group: '{{ resource_group }}' + tags: + - testing + - foo:bar +- assert: + that: azure_publicipaddresses | length == 1 +- name: Purge all tags + register: output + azure.azcollection.azure_rm_publicipaddress: + resource_group: '{{ resource_group }}' + name: pip{{ rpfx }} + allocation_method: static + domain_name: '{{ domain_name }}' + append_tags: false +- assert: + that: + - output.state.tags | length == 0 +- name: Gather facts for a public ip + azure_rm_publicipaddress_facts: + resource_group: '{{ resource_group }}' + name: pip{{ rpfx }} + register: pip +- assert: + that: + - pip.publicipaddresses | length == 1 + - pip.publicipaddresses[0].name == "pip{{ rpfx }}" + - pip.publicipaddresses[0].allocation_method == 'static' + - pip.publicipaddresses[0].dns_settings.domain_name_label == domain_name +- name: Gather facts for all public ips + azure_rm_publicipaddress_facts: + resource_group: '{{ resource_group }}' +- assert: + that: azure_publicipaddresses | length > 0 +- name: Remove public ip + azure.azcollection.azure_rm_publicipaddress: + resource_group: '{{ resource_group }}' + name: pip{{ rpfx }} + state: absent +- name: Gather facts for a public ip + azure_rm_publicipaddress_facts: + resource_group: '{{ resource_group }}' + name: pip{{ rpfx }} +- assert: + that: azure_publicipaddresses | length == 0 diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_rediscache/aliases b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_rediscache/aliases new file mode 100644 index 00000000..0e4abdd8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_rediscache/aliases @@ -0,0 +1,5 @@ +cloud/azure +shippable/azure/group1 +destructive +azure_rm_rediscache_facts +azure_rm_rediscachefirewallrule diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_rediscache/meta/main.yml b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_rediscache/meta/main.yml new file mode 100644 index 00000000..95e1952f --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_rediscache/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_azure diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_rediscache/tasks/main.yml b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_rediscache/tasks/main.yml new file mode 100644 index 00000000..ba5e62e8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_rediscache/tasks/main.yml @@ -0,0 +1,269 @@ +- name: Fix resource prefix + set_fact: + redis_name: redis-{{ resource_group | hash('md5') | truncate(7, True, '') }}-{{ 1000 | random }} + vnet_name: vnet-{{ resource_group | hash('md5') | truncate(7, True, '') }}-{{ 1000 | random }} + subnet_name: subnet-{{ resource_group | hash('md5') | truncate(7, True, '') }}-{{ 1000 | random }} + rule_name: rule1 + run_once: true +- name: Create a redis cache (Check Mode) + check_mode: true + register: output + azure.azcollection.azure_rm_rediscache: + resource_group: '{{ resource_group }}' + name: '{{ redis_name }}' + sku: + name: basic + size: C1 + wait_for_provisioning: false +- name: Assert creating redis cache check mode + assert: + that: + - output.changed +- name: Create a redis cache + register: output + azure.azcollection.azure_rm_rediscache: + resource_group: '{{ resource_group }}' + name: '{{ redis_name }}' + sku: + name: basic + size: C1 + wait_for_provisioning: false +- name: Assert creating redis cache + assert: + that: + - output.changed + - output.id +- name: Get facts + azure_rm_rediscache_facts: + resource_group: '{{ resource_group }}' + name: '{{ redis_name }}' + register: facts +- name: Assert facts + assert: + that: + - facts.rediscaches | length == 1 + - facts.rediscaches[0].id != None + - facts.rediscaches[0].host_name != None + - facts.rediscaches[0].provisioning_state != None + - facts.rediscaches[0].sku.name == 'basic' + - facts.rediscaches[0].sku.size == 'C1' +- name: Update the redis cache (idempotent) + register: output + azure.azcollection.azure_rm_rediscache: + resource_group: '{{ resource_group }}' + name: '{{ redis_name }}' + sku: + name: basic + size: C1 + wait_for_provisioning: false +- name: assert output not changed + assert: + that: + - not output.changed +- name: long-running rediscache tests [run with `--tags long_run,untagged` to enable] + block: + - name: Wait for Redis provisioning to complete + azure_rm_rediscache_facts: + resource_group: '{{ resource_group }}' + name: '{{ redis_name }}' + register: facts + until: facts.rediscaches[0]['provisioning_state'] == 'Succeeded' + retries: 30 + delay: 60 + - name: (actually) update redis cache + register: output + azure.azcollection.azure_rm_rediscache: + resource_group: '{{ resource_group }}' + name: '{{ redis_name }}' + sku: + name: basic + size: C1 + enable_non_ssl_port: true + tags: + testing: foo + wait_for_provisioning: true + - name: assert output changed + assert: + that: + - output.changed + - name: Update redis cache configuration + register: output + azure.azcollection.azure_rm_rediscache: + resource_group: '{{ resource_group }}' + name: '{{ redis_name }}' + sku: + name: basic + size: C1 + enable_non_ssl_port: true + maxmemory_policy: allkeys_lru + tags: + testing: foo + - name: assert output changed + assert: + that: + - output.changed + - name: Scale up the redis cache + register: output + azure.azcollection.azure_rm_rediscache: + resource_group: '{{ resource_group }}' + name: '{{ redis_name }}' + sku: + name: standard + size: C1 + tags: + testing: foo + wait_for_provisioning: true + - assert: + that: + - output.changed + - name: Force reboot redis cache + register: output + azure.azcollection.azure_rm_rediscache: + resource_group: '{{ resource_group }}' + name: '{{ redis_name }}' + reboot: + reboot_type: all + - assert: + that: + - output.changed + - name: Delete the redis cache (Check Mode) + check_mode: true + register: output + azure.azcollection.azure_rm_rediscache: + resource_group: '{{ resource_group }}' + name: '{{ redis_name }}' + state: absent + - name: assert deleting redis cache check mode + assert: + that: output.changed + - name: Delete the redis cache + register: output + azure.azcollection.azure_rm_rediscache: + resource_group: '{{ resource_group }}' + name: '{{ redis_name }}' + state: absent + - assert: + that: + - output.changed + tags: + - long_run + - never +- name: Create virtual network + azure.azcollection.azure_rm_virtualnetwork: + resource_group: '{{ resource_group }}' + name: '{{ vnet_name }}' + address_prefixes: 10.10.0.0/16 +- name: Add subnet + azure.azcollection.azure_rm_subnet: + resource_group: '{{ resource_group }}' + name: '{{ subnet_name }}' + address_prefix: 10.10.0.0/24 + virtual_network: '{{ vnet_name }}' +- name: Create redis with subnet + register: output + azure.azcollection.azure_rm_rediscache: + resource_group: '{{ resource_group }}' + name: '{{ redis_name }}2' + sku: + name: premium + size: P1 + subnet: + name: '{{ subnet_name }}' + virtual_network_name: '{{ vnet_name }}' + wait_for_provisioning: false +- name: Assert creating redis cache + assert: + that: + - output.changed + - output.id +- name: Get facts + azure_rm_rediscache_facts: + resource_group: '{{ resource_group }}' + name: '{{ redis_name }}2' + return_access_keys: true + register: facts +- name: Assert facts + assert: + that: + - facts.rediscaches | length == 1 + - facts.rediscaches[0].subnet != None + - facts.rediscaches[0].access_keys.primary != None +- name: Create firewall rule (Check mode) + check_mode: true + register: output + azure.azcollection.azure_rm_rediscachefirewallrule: + resource_group: '{{ resource_group }}' + cache_name: '{{ redis_name }}2' + name: '{{ rule_name }}' + start_ip_address: 192.168.1.1 + end_ip_address: 192.168.1.4 +- name: Assert check mode creation + assert: + that: + - output.changed +- name: long-running rediscachefirewallrule tests [run with `--tags long_run,untagged` to enable] + block: + - name: Wait for Redis provisioning to complete + azure_rm_rediscache_facts: + resource_group: '{{ resource_group }}' + name: '{{ redis_name }}2' + register: facts + until: facts.rediscaches[0]['provisioning_state'] == 'Succeeded' + retries: 30 + delay: 60 + - name: Create firewall rule + register: output + azure.azcollection.azure_rm_rediscachefirewallrule: + resource_group: '{{ resource_group }}' + cache_name: '{{ redis_name }}2' + name: '{{ rule_name }}' + start_ip_address: 192.168.1.1 + end_ip_address: 192.168.1.4 + - name: Assert creation + assert: + that: + - output.changed + - output.id + - name: Update firewall rule idempotence + register: output + azure.azcollection.azure_rm_rediscachefirewallrule: + resource_group: '{{ resource_group }}' + cache_name: '{{ redis_name }}2' + name: '{{ rule_name }}' + start_ip_address: 192.168.1.1 + end_ip_address: 192.168.1.4 + - name: Assert idempotence + assert: + that: + - output.changed == False + - name: Update firewall rule + register: output + azure.azcollection.azure_rm_rediscachefirewallrule: + resource_group: '{{ resource_group }}' + cache_name: '{{ redis_name }}2' + name: '{{ rule_name }}' + end_ip_address: 192.168.1.5 + - name: Assert updating + assert: + that: + - output.changed + - name: Delete firewall rule + register: output + azure.azcollection.azure_rm_rediscachefirewallrule: + resource_group: '{{ resource_group }}' + cache_name: '{{ redis_name }}2' + name: '{{ rule_name }}' + state: absent + - name: Assert deletion + assert: + that: + - output.changed + - name: Delete the redis cache + register: output + azure.azcollection.azure_rm_rediscache: + resource_group: '{{ resource_group }}' + name: '{{ redis_name }}2' + state: absent + tags: + - long_run + - never diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_securitygroup/aliases b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_securitygroup/aliases new file mode 100644 index 00000000..69848e3b --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_securitygroup/aliases @@ -0,0 +1,4 @@ +cloud/azure +shippable/azure/group1 +destructive +azure_rm_securitygroup1 diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_securitygroup/meta/main.yml b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_securitygroup/meta/main.yml new file mode 100644 index 00000000..95e1952f --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_securitygroup/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_azure diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_securitygroup/tasks/main.yml b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_securitygroup/tasks/main.yml new file mode 100644 index 00000000..d44c0286 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_securitygroup/tasks/main.yml @@ -0,0 +1,269 @@ +- name: Prepare random number + set_fact: + secgroupname: sg{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }} + asg_name1: asg1{{ resource_group | hash('md5') | truncate(7, True, '') }} + asg_name2: asg2{{ resource_group | hash('md5') | truncate(7, True, '') }} + sg_name1: sgasg{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }} + run_once: true +- name: Create security group + register: output + azure.azcollection.azure_rm_securitygroup: + resource_group: '{{ resource_group }}' + name: '{{ secgroupname }}' + tags: + testing: testing + delete: on-exit + foo: bar + purge_rules: true + rules: + - name: DenySSH + protocol: Tcp + destination_port_range: 22 + access: Deny + priority: 100 + direction: Inbound + - name: AllowSSH + protocol: Tcp + source_address_prefix: 174.109.158.0/24 + destination_port_range: 22 + access: Allow + priority: 101 + direction: Inbound +- assert: + that: '{{ output.state.rules | length }} == 2' +- name: Gather facts by tags + register: output + azure.azcollection.azure_rm_securitygroup_info: + resource_group: '{{ resource_group }}' + tags: + - testing + - foo:bar +- assert: + that: output.securitygroups | length == 1 +- name: Add/Update rules on existing security group + register: output + azure.azcollection.azure_rm_securitygroup: + resource_group: '{{ resource_group }}' + name: '{{ secgroupname }}' + rules: + - name: AllowSSH + protocol: Tcp + source_address_prefix: 174.108.158.0/24 + destination_port_range: 22 + access: Allow + priority: 101 + - name: AllowSSHFromHome + protocol: Tcp + source_address_prefix: 174.109.158.0/24 + destination_port_range: 22-23 + priority: 102 +- assert: + that: + - '{{ output.state.rules | length }} == 3' + - output.state.rules[0].source_address_prefix == '174.108.158.0/24' +- name: Test idempotence + register: output + azure.azcollection.azure_rm_securitygroup: + resource_group: '{{ resource_group }}' + name: '{{ secgroupname }}' + rules: + - name: AllowSSH + protocol: Tcp + source_address_prefix: 174.108.158.0/24 + destination_port_range: 22 + access: Allow + priority: 101 + - name: AllowSSHFromHome + protocol: Tcp + source_address_prefix: 174.109.158.0/24 + destination_port_range: 22-23 + priority: 102 +- assert: + that: not output.changed +- name: Update tags + register: output + azure.azcollection.azure_rm_securitygroup: + resource_group: '{{ resource_group }}' + name: '{{ secgroupname }}' + tags: + testing: testing + delete: never + baz: bar + append_tags: false +- assert: + that: + - output.state.tags | length == 3 + - output.state.tags.delete == 'never' +- name: Purge tags + register: output + azure.azcollection.azure_rm_securitygroup: + resource_group: '{{ resource_group }}' + name: '{{ secgroupname }}' + append_tags: false + tags: + testing: testing + delete: on-exit +- assert: + that: + - output.state.tags | length == 2 + - output.state.tags.delete == 'on-exit' +- name: Gather facts for one accounts + register: output + azure.azcollection.azure_rm_securitygroup_info: + resource_group: '{{ resource_group }}' + name: '{{ secgroupname }}' +- assert: + that: + - output.securitygroups | length == 1 +- name: Gather facts for all accounts + register: output_groups + azure.azcollection.azure_rm_securitygroup_info: + resource_group: '{{ resource_group }}' +- assert: + that: + - output_groups.securitygroups | length > 0 +- name: Create security group with source_address_prefixes + register: output + azure.azcollection.azure_rm_securitygroup: + resource_group: '{{ resource_group }}' + name: '{{ secgroupname }}' + tags: + testing: testing + delete: on-exit + foo: bar + purge_rules: true + rules: + - name: AllowSSH + protocol: Tcp + source_address_prefix: + - 52.100.120.240 + - 53.100.250.190 + - 54.110.200.200 + destination_port_range: 22 + access: Allow + priority: 101 + direction: Inbound +- assert: + that: + - '{{ output.state.rules | length }} == 1' + - '{{ output.state.rules[0].source_address_prefixes | length }} == 3' + - not output.state.rules[0].source_address_prefix +- name: Create security group with source_address_prefixes(idempontent) + register: output + azure.azcollection.azure_rm_securitygroup: + resource_group: '{{ resource_group }}' + name: '{{ secgroupname }}' + tags: + testing: testing + delete: on-exit + foo: bar + purge_rules: true + rules: + - name: AllowSSH + protocol: Tcp + source_address_prefix: + - 52.100.120.240 + - 53.100.250.190 + - 54.110.200.200 + destination_port_range: 22 + access: Allow + priority: 101 + direction: Inbound +- assert: + that: not output.changed +- name: Add a single one group + register: output + azure.azcollection.azure_rm_securitygroup: + resource_group: '{{ resource_group }}' + name: '{{ secgroupname }}' + tags: + testing: testing + delete: on-exit + foo: bar + rules: + - name: DenySSH + protocol: Tcp + source_address_prefix: + - 54.120.120.240 + destination_port_range: 22 + access: Deny + priority: 102 + direction: Inbound +- assert: + that: + - output.changed + - '{{ output.state.rules | length }} == 2' +- name: Create Application security group 1 + register: asg1 + azure.azcollection.azure_rm_applicationsecuritygroup: + resource_group: '{{ resource_group }}' + name: '{{ asg_name1 }}' + tags: + testing: testing +- name: Create Application security group 2 + register: asg2 + azure.azcollection.azure_rm_applicationsecuritygroup: + resource_group: '{{ resource_group_secondary }}' + name: '{{ asg_name2 }}' + tags: + testing: testing +- name: Create security group with application security group + register: output + azure.azcollection.azure_rm_securitygroup: + resource_group: '{{ resource_group }}' + name: '{{ sg_name1 }}' + purge_rules: true + rules: + - name: AsgToAsg + protocol: Tcp + source_application_security_groups: + - '{{ asg1.id }}' + destination_application_security_groups: + - resource_group: '{{ resource_group_secondary }}' + name: '{{ asg_name2 }}' + destination_port_range: 22 + access: Allow + priority: 101 + direction: Inbound +- assert: + that: + - output.changed +- name: Create security group with application security group - Idempotent + register: output + azure.azcollection.azure_rm_securitygroup: + resource_group: '{{ resource_group }}' + name: '{{ sg_name1 }}' + purge_rules: true + rules: + - name: AsgToAsg + protocol: Tcp + source_application_security_groups: + - '{{ asg_name1 }}' + destination_application_security_groups: + - resource_group: '{{ resource_group_secondary }}' + name: '{{ asg_name2 }}' + destination_port_range: 22 + access: Allow + priority: 101 + direction: Inbound +- assert: + that: + - not output.changed +- name: Delete security group + azure.azcollection.azure_rm_securitygroup: + resource_group: '{{ resource_group }}' + name: '{{ sg_name1 }}' + state: absent +- name: Delete all security groups + with_items: '{{ output_groups.securitygroups }}' + azure.azcollection.azure_rm_securitygroup: + resource_group: '{{ resource_group }}' + name: '{{ item.name }}' + state: absent +- name: Should have no security groups remaining + register: output + azure.azcollection.azure_rm_securitygroup_info: + resource_group: '{{ resource_group }}' +- assert: + that: + - output.securitygroups | length == 0 diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_sqlserver/aliases b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_sqlserver/aliases new file mode 100644 index 00000000..74b30b7f --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_sqlserver/aliases @@ -0,0 +1,8 @@ +cloud/azure +destructive +shippable/azure/group1 +azure_rm_sqlserver_facts +azure_rm_sqldatabase +azure_rm_sqldatabase_facts +azure_rm_sqlfirewallrule +azure_rm_sqlfirewallrule_facts diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_sqlserver/meta/main.yml b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_sqlserver/meta/main.yml new file mode 100644 index 00000000..95e1952f --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_sqlserver/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_azure diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_sqlserver/tasks/main.yml b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_sqlserver/tasks/main.yml new file mode 100644 index 00000000..c0c3c309 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_sqlserver/tasks/main.yml @@ -0,0 +1,375 @@ +- name: Prepare random number + set_fact: + random_postfix: '{{ 1000 | random }}{{ resource_group | hash(''md5'') | truncate(7, True, '''') }}' + run_once: true +- name: Create instance of SQL Server -- check mode + check_mode: true + register: output + azure.azcollection.azure_rm_sqlserver: + resource_group: '{{ resource_group }}' + name: sqlsrv{{ random_postfix }} + location: eastus + admin_username: mylogin + admin_password: Testpasswordxyz12! +- name: Assert the resource instance is well created + assert: + that: + - output.changed +- name: Create instance of SQL Server + register: output + azure.azcollection.azure_rm_sqlserver: + resource_group: '{{ resource_group }}' + name: sqlsrv{{ random_postfix }} + location: eastus + admin_username: mylogin + admin_password: Testpasswordxyz12! + tags: + aaa: bbb +- name: Assert the resource instance is well created + assert: + that: + - output.changed + - output.state == 'Ready' +- name: Create again instance of SQL Server + register: output + azure.azcollection.azure_rm_sqlserver: + resource_group: '{{ resource_group }}' + name: sqlsrv{{ random_postfix }} + location: eastus + admin_username: mylogin + admin_password: Testpasswordxyz12! +- name: Assert the state has not changed + assert: + that: + - output.changed == false + - output.state == 'Ready' +- name: Gather facts SQL Server + azure_rm_sqlserver_facts: + resource_group: '{{ resource_group }}' + server_name: sqlsrv{{ random_postfix }} + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.servers.sqlsrv{{ random_postfix }}.id != None + - output.servers.sqlsrv{{ random_postfix }}.name == "sqlsrv{{ random_postfix }}" + - output.servers.sqlsrv{{ random_postfix }}.type != None + - output.servers.sqlsrv{{ random_postfix }}.location != None + - output.servers.sqlsrv{{ random_postfix }}.kind != None + - output.servers.sqlsrv{{ random_postfix }}.version != None + - output.servers.sqlsrv{{ random_postfix }}.state != None + - output.servers.sqlsrv{{ random_postfix }}.fully_qualified_domain_name != None + - output.servers.sqlsrv{{ random_postfix }}.tags.aaa == 'bbb' +- name: Gather facts SQL Server - unexisting + azure_rm_sqlserver_facts: + resource_group: '{{ resource_group }}' + server_name: unexisting + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.servers == {} +- name: Gather facts SQL Server - list + azure_rm_sqlserver_facts: + resource_group: '{{ resource_group }}' + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.servers.sqlsrv{{ random_postfix }}.id != None + - output.servers.sqlsrv{{ random_postfix }}.name == "sqlsrv{{ random_postfix }}" + - output.servers.sqlsrv{{ random_postfix }}.type != None + - output.servers.sqlsrv{{ random_postfix }}.location != None + - output.servers.sqlsrv{{ random_postfix }}.kind != None + - output.servers.sqlsrv{{ random_postfix }}.version != None + - output.servers.sqlsrv{{ random_postfix }}.state != None + - output.servers.sqlsrv{{ random_postfix }}.fully_qualified_domain_name != None +- name: Create instance of SQL Database -- check mode + check_mode: true + register: output + azure.azcollection.azure_rm_sqldatabase: + resource_group: '{{ resource_group }}' + server_name: sqlsrv{{ random_postfix }} + name: database{{ random_postfix }} + location: eastus +- name: Assert the resource instance is well created + assert: + that: + - output.changed +- name: Create instance of SQL Database + register: output + azure.azcollection.azure_rm_sqldatabase: + resource_group: '{{ resource_group }}' + server_name: sqlsrv{{ random_postfix }} + name: database{{ random_postfix }} + location: eastus + tags: + aaa: bbb +- name: Assert the resource instance is well created + assert: + that: + - output.changed + - output.status == 'Online' +- name: Create again instance of SQL Database + register: output + azure.azcollection.azure_rm_sqldatabase: + resource_group: '{{ resource_group }}' + server_name: sqlsrv{{ random_postfix }} + name: database{{ random_postfix }} + location: eastus + tags: + aaa: bbb +- name: Assert the state has not changed + assert: + that: + - output.changed == false + - output.status == 'Online' +- name: Create second SQL Database + azure.azcollection.azure_rm_sqldatabase: + resource_group: '{{ resource_group }}' + server_name: sqlsrv{{ random_postfix }} + name: database{{ random_postfix }}second + location: eastus +- name: Gather facts SQL Database + azure_rm_sqldatabase_facts: + resource_group: '{{ resource_group }}' + server_name: sqlsrv{{ random_postfix }} + name: database{{ random_postfix }} + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.databases[0].id != None + - output.databases[0].name != None + - output.databases[0].location != None + - output.databases[0].sku.name != None + - output.databases[0].sku.tier != None + - output.databases[0].sku.capacity != None + - output.databases[0].kind != None + - output.databases[0].status != None +- name: Gather facts SQL Database + azure_rm_sqldatabase_facts: + resource_group: '{{ resource_group }}' + server_name: sqlsrv{{ random_postfix }} + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.databases[0].id != None + - output.databases[0].name != None + - output.databases[0].location != None + - output.databases[0].sku.name != None + - output.databases[0].sku.tier != None + - output.databases[0].sku.capacity != None + - output.databases[0].kind != None + - output.databases[0].status != None + - output.databases[1].id != None + - output.databases[1].name != None + - output.databases[1].location != None + - output.databases[1].sku.name != None + - output.databases[1].sku.tier != None + - output.databases[1].sku.capacity != None + - output.databases[1].kind != None + - output.databases[1].status != None +- name: Delete instance of secondary database + azure.azcollection.azure_rm_sqldatabase: + resource_group: '{{ resource_group }}' + server_name: sqlsrv{{ random_postfix }} + name: database{{ random_postfix }}second + state: absent +- name: Delete instance of SQL Database -- check mode + check_mode: true + register: output + azure.azcollection.azure_rm_sqldatabase: + resource_group: '{{ resource_group }}' + server_name: sqlsrv{{ random_postfix }} + name: database{{ random_postfix }} + state: absent +- name: Assert the state has changed + assert: + that: + - output.changed +- name: Delete instance of SQL Database + register: output + azure.azcollection.azure_rm_sqldatabase: + resource_group: '{{ resource_group }}' + server_name: sqlsrv{{ random_postfix }} + name: database{{ random_postfix }} + state: absent +- name: Assert the state has changed + assert: + that: + - output.changed +- name: Delete unexisting instance of SQL Database + register: output + azure.azcollection.azure_rm_sqldatabase: + resource_group: '{{ resource_group }}' + server_name: sqlsrv{{ random_postfix }} + name: database{{ random_postfix }} + state: absent +- name: Assert the state has changed + assert: + that: + - output.changed == false +- name: Gather facts SQL Database + azure_rm_sqldatabase_facts: + resource_group: '{{ resource_group }}' + server_name: sqlsrv{{ random_postfix }} + name: database{{ random_postfix }} + register: output +- name: Assert that empty dictionary was returned + assert: + that: + - output.changed == False + - output.databases | length == 0 +- name: Gather facts SQL Database + azure_rm_sqldatabase_facts: + resource_group: '{{ resource_group }}' + server_name: sqlsrv{{ random_postfix }} + register: output +- name: Assert that empty dictionary was returned (one database is there by default) + assert: + that: + - output.changed == False + - output.databases | length == 1 +- name: Create instance of Firewall Rule -- check mode + check_mode: true + register: output + azure.azcollection.azure_rm_sqlfirewallrule: + resource_group: '{{ resource_group }}' + server_name: sqlsrv{{ random_postfix }} + name: firewallrule{{ random_postfix }} + start_ip_address: 172.28.10.136 + end_ip_address: 172.28.10.138 +- name: Assert the resource instance is well created + assert: + that: + - output.changed +- name: Create instance of Firewall Rule + register: output + azure.azcollection.azure_rm_sqlfirewallrule: + resource_group: '{{ resource_group }}' + server_name: sqlsrv{{ random_postfix }} + name: firewallrule{{ random_postfix }} + start_ip_address: 172.28.10.136 + end_ip_address: 172.28.10.138 +- name: Assert the resource instance is well created + assert: + that: + - output.changed +- name: Create again instance of Firewall Rule + register: output + azure.azcollection.azure_rm_sqlfirewallrule: + resource_group: '{{ resource_group }}' + server_name: sqlsrv{{ random_postfix }} + name: firewallrule{{ random_postfix }} + start_ip_address: 172.28.10.136 + end_ip_address: 172.28.10.138 +- name: Assert the state has not changed + assert: + that: + - output.changed == false +- name: Create Firewall Rule - second + azure.azcollection.azure_rm_sqlfirewallrule: + resource_group: '{{ resource_group }}' + server_name: sqlsrv{{ random_postfix }} + name: firewallrule{{ random_postfix }}second + start_ip_address: 172.28.10.136 + end_ip_address: 172.28.10.138 +- name: Gather facts SQL Firewall Rule + azure_rm_sqlfirewallrule_facts: + resource_group: '{{ resource_group }}' + server_name: sqlsrv{{ random_postfix }} + name: firewallrule{{ random_postfix }} + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.rules[0].id != None + - output.rules[0].resource_group != None + - output.rules[0].server_name != None + - output.rules[0].name != None + - output.rules[0].start_ip_address != None + - output.rules[0].end_ip_address != None +- name: Gather facts SQL Firewall Rule + azure_rm_sqlfirewallrule_facts: + resource_group: '{{ resource_group }}' + server_name: sqlsrv{{ random_postfix }} + register: output +- name: Assert that facts are returned + assert: + that: + - output.changed == False + - output.rules[0].id != None + - output.rules[0].id != None + - output.rules[0].resource_group != None + - output.rules[0].server_name != None + - output.rules[0].name != None + - output.rules[0].start_ip_address != None + - output.rules[0].end_ip_address != None + - output.rules[1].id != None + - output.rules[1].resource_group != None + - output.rules[1].server_name != None + - output.rules[1].name != None + - output.rules[1].start_ip_address != None + - output.rules[1].end_ip_address != None +- name: Delete instance of Firewall Rule + azure.azcollection.azure_rm_sqlfirewallrule: + resource_group: '{{ resource_group }}' + server_name: sqlsrv{{ random_postfix }} + name: firewallrule{{ random_postfix }} + state: absent +- name: Delete instance of Firewall Rule + azure.azcollection.azure_rm_sqlfirewallrule: + resource_group: '{{ resource_group }}' + server_name: sqlsrv{{ random_postfix }} + name: firewallrule{{ random_postfix }}second + state: absent +- name: Gather facts SQL Firewall Rule + azure_rm_sqlfirewallrule_facts: + resource_group: '{{ resource_group }}' + server_name: sqlsrv{{ random_postfix }} + name: firewallrule{{ random_postfix }} + register: output +- name: Assert that empty dictionary was returned + assert: + that: + - output.changed == False + - output.rules | length == 0 +- name: Delete instance of SQL Server -- check mode + check_mode: true + register: output + azure.azcollection.azure_rm_sqlserver: + resource_group: '{{ resource_group }}' + name: sqlsrv{{ random_postfix }} + state: absent +- name: Assert the state has changed + assert: + that: + - output.changed +- name: Delete instance of SQL Server + register: output + azure.azcollection.azure_rm_sqlserver: + resource_group: '{{ resource_group }}' + name: sqlsrv{{ random_postfix }} + state: absent +- name: Assert the state has changed + assert: + that: + - output.changed +- name: Delete unexisting instance of SQL Server + register: output + azure.azcollection.azure_rm_sqlserver: + resource_group: '{{ resource_group }}' + name: sqlsrv{{ random_postfix }} + state: absent +- name: Assert the state has changed + assert: + that: + - output.changed == false diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachine/aliases b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachine/aliases new file mode 100644 index 00000000..218b8261 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachine/aliases @@ -0,0 +1,4 @@ +cloud/azure +shippable/azure/group1 +destructive +azure_rm_virtualmachine_facts diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachine/inventory.yml b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachine/inventory.yml new file mode 100644 index 00000000..acd98ebf --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachine/inventory.yml @@ -0,0 +1,66 @@ +all: + hosts: + azure_test_invalid: + azure_test_public_ip: + network: 10.42.0.0/24 + subnet: 10.42.0.0/28 + + azure_test_no_public_ip: + network: 10.42.1.0/24 + subnet: 10.42.1.0/28 + + azure_test_deallocate: + network: 10.42.2.0/24 + subnet: 10.42.2.0/28 + + azure_test_minimal: + network: 10.42.3.0/24 + subnet: 10.42.3.0/28 + + azure_test_dual_nic: + network: 10.42.4.0/24 + subnet: 10.42.4.0/28 + secondary_network: 10.42.5.0/24 + secondary_subnet: 10.42.5.0/28 + nic_list: + - name: "{{ 'int' ~ uid_short ~ '-1' }}" + resource_group: "{{ resource_group_secondary }}" + - name: "{{ 'int' ~ uid_short ~ '-2' }}" + resource_group: "{{ resource_group_secondary }}" + + vars: + ansible_connection: local + ansible_python_interpreter: "{{ ansible_playbook_python }}" + + uid: "{{ (resource_group ~ inventory_hostname) | hash('md5') | truncate(18, True, '') }}" + uid_short: "{{ (resource_group ~ inventory_hostname) | hash('md5') | truncate(10, True, '') }}" + + storage_account: "{{ 'stor' ~ uid }}" + availability_set: "{{ 'avbs' ~ uid_short }}" + vm_name: "{{ 'vm' ~ uid_short }}" + network_name: "{{ 'vnet' ~ uid_short }}" + subnet_name: "{{ 'snet' ~ uid_short }}" + security_group: "{{ 'sg' ~ uid_short }}" + public_ip_name: "{{ 'ip' ~ uid_short }}" + interface_name: "{{ 'int' ~ uid_short }}" + + ssh_keys: + - path: '/home/chouseknecht/.ssh/authorized_keys' + key_data: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC1igsIlcmTa/yfsJnTtnrEX7PP/a01gwbXcig6JOKyrUmJB8E6c/wtZwP115VSyDRTO6TEL/sBFUpkSw01zM8ydNATErh8meBlAlbnDq5NLhDXnMizgG0VNn0iLc/WplFTqkefsHXa8NtIxAtyEVIj/fKbK3XfBOdEpE3+MJYNtGlWyaod28W+5qmQPZDQys+YnE4OjSwN7D3g85/7dtLFvDH+lEC4ooJOaxVFr9VSMXUIkaRF6oI+R1Zu803LFSCTb4BfFOYOHPuQ/rEMP0KuUzggvP+TEBY14PEA2FoHOn+oRsT0ZR2+loGRaxSVqCQKaEHbNbkm+6Rllx2NQRO0BJxCSKRU1iifInLPxmSc4gvsHCKMAWy/tGkmKHPWIfN8hvwyDMK5MNBp/SJ1pVx4xuFDQjVWNbll0yk2+72uJgtFHHwEPK9QsOz45gX85vS3yhYCKrscS/W9h2l36SWwQXuGy4fXotE7esPsvNGAzBndHX1O8RMPg47qJXz059RyoGforoa9TnzIs3hIv+ts7ESx3OEq3HNk0FJ+wDka7IM7WQpGrVToJ0vfDy9Q46nw54vv5Zc/u4OZF3F5twHmyf3rLYKXRDuCvZQKT2iWQKVX6j63bq6orA5hwl22zndxWZNtOwtq8Sd0Ns0K/Fo/ggYDDGBtr68DwhA+MrxrHw== chouseknecht@ansible.com" + + image: + offer: CentOS + publisher: OpenLogic + sku: '7.1' + version: latest + + image_paid: + publisher: cognosys + offer: ubuntu-14-04-lts + sku: hardened-ubuntu-14-04 + version: latest + + plan_paid: + name: hardened-ubuntu-14-04 + product: ubuntu-14-04-lts + publisher: cognosys diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachine/main.yml b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachine/main.yml new file mode 100644 index 00000000..7722487b --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachine/main.yml @@ -0,0 +1,7 @@ +- name: Run Azurue VM tests in parallel + hosts: all + gather_facts: no + strategy: free + tasks: + - name: Include tasks based on inventory hostname + include_tasks: tasks/{{ inventory_hostname }}.yml diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachine/runme.sh b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachine/runme.sh new file mode 100755 index 00000000..c7895c9d --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachine/runme.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -eux + +ansible-playbook -i inventory.yml main.yml "$@" diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_deallocate.yml b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_deallocate.yml new file mode 100644 index 00000000..80dc5946 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_deallocate.yml @@ -0,0 +1,78 @@ +- include_tasks: setup.yml +- name: Create minimal VM with defaults + register: vm_output + azure.azcollection.azure_rm_virtualmachine: + resource_group: '{{ resource_group }}' + name: '{{ vm_name }}' + admin_username: testuser + admin_password: Pass123$$$abx! + vm_size: Standard_A0 + virtual_network: '{{ network_name }}' + image: + offer: UbuntuServer + publisher: Canonical + sku: 16.04-LTS + version: latest +- name: Restart the virtual machine + register: restart_result + azure.azcollection.azure_rm_virtualmachine: + resource_group: '{{ resource_group }}' + name: '{{ vm_name }}' + restarted: true + vm_size: Standard_A0 +- name: Ensue VM was restarted + assert: + that: + - azure_vm.powerstate in ['starting', 'running'] + - restart_result is changed +- name: Deallocate the virtual machine + register: deallocate_result + azure.azcollection.azure_rm_virtualmachine: + resource_group: '{{ resource_group }}' + name: '{{ vm_name }}' + allocated: false + vm_size: Standard_A0 +- name: Ensure VM was deallocated + assert: + that: + - azure_vm.powerstate == 'deallocated' + - deallocate_result is changed +- name: Start the virtual machine + register: start_result + azure.azcollection.azure_rm_virtualmachine: + resource_group: '{{ resource_group }}' + name: '{{ vm_name }}' + vm_size: Standard_A0 +- name: Ensure VM was started + assert: + that: + - azure_vm.powerstate in ['starting', 'running'] + - start_result is changed +- name: Delete VM + azure.azcollection.azure_rm_virtualmachine: + resource_group: '{{ resource_group }}' + name: '{{ vm_name }}' + state: absent + remove_on_absent: all_autocreated +- name: Destroy subnet + azure.azcollection.azure_rm_subnet: + resource_group: '{{ resource_group }}' + virtual_network: '{{ network_name }}' + name: '{{ subnet_name }}' + state: absent +- name: Destroy virtual network + azure.azcollection.azure_rm_virtualnetwork: + resource_group: '{{ resource_group }}' + name: '{{ network_name }}' + state: absent +- name: Destroy availability set + azure.azcollection.azure_rm_availabilityset: + resource_group: '{{ resource_group }}' + name: '{{ availability_set }}' + state: absent +- name: Destroy storage account + azure.azcollection.azure_rm_storageaccount: + resource_group: '{{ resource_group }}' + name: '{{ storage_account }}' + force_delete_nonempty: true + state: absent diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_dual_nic.yml b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_dual_nic.yml new file mode 100644 index 00000000..64e5b54b --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_dual_nic.yml @@ -0,0 +1,116 @@ +- include_tasks: setup.yml +- name: Create virtual network in secondary resource group + register: create_virt_net_result + azure.azcollection.azure_rm_virtualnetwork: + resource_group: '{{ resource_group_secondary }}' + name: '{{ network_name ~ ''-2'' }}' + address_prefixes: '{{ secondary_network }}' +- name: Create subnet in secondary resource group + azure.azcollection.azure_rm_subnet: + resource_group: '{{ resource_group_secondary }}' + name: '{{ subnet_name ~ ''-2'' }}' + address_prefix: '{{ secondary_subnet }}' + virtual_network: '{{ network_name ~ ''-2'' }}' +- name: Create NICs for dual NIC VM in secondary resource group + loop: '{{ nic_list }}' + azure.azcollection.azure_rm_networkinterface: + resource_group: '{{ item.resource_group }}' + name: '{{ item.name }}' + virtual_network: '{{ network_name ~ ''-2'' }}' + subnet: '{{ subnet_name ~ ''-2'' }}' +- name: Create virtual machine with two NICs + azure.azcollection.azure_rm_virtualmachine: + resource_group: '{{ resource_group }}' + name: '{{ vm_name }}' + vm_size: Standard_A0 + storage_account: '{{ storage_account }}' + storage_container: '{{ vm_name }}' + storage_blob: '{{ vm_name }}.vhd' + admin_username: adminuser + admin_password: Password123! + short_hostname: testvm + os_type: Linux + os_disk_size_gb: 64 + os_disk_name: testosdiskxx + network_interfaces: '{{ nic_list }}' + availability_set: '{{ availability_set }}' + image: + offer: UbuntuServer + publisher: Canonical + sku: 16.04-LTS + version: latest + tags: + abc: def +- name: Ensure VM was created properly + assert: + that: + - azure_vm.properties.availabilitySet.id + - azure_vm.properties.storageProfile.osDisk.name == 'testosdiskxx' +- name: Retrieve VM facts (filtering by name) + azure_rm_virtualmachine_facts: + resource_group: '{{ resource_group }}' + name: '{{ vm_name }}' + register: vm_facts_results +- name: Ensure facts module returned the second VM + assert: + that: + - vm_facts_results.vms | length == 1 + - vm_facts_results.vms[0].name == "{{ vm_name }}" + - vm_facts_results.vms[0].location + - vm_facts_results.vms[0].admin_username == 'adminuser' + - vm_facts_results.vms[0].resource_group == "{{ resource_group }}" + - vm_facts_results.vms[0].power_state != None +- name: Retrieve facts by tags + azure_rm_virtualmachine_facts: + tags: + - abc:def + register: facts_by_tags_results +- name: Assert that facts module returned the second VM + assert: + that: + - facts_by_tags_results.vms | length >= 1 +- name: Should be idempotent with a dual NICs + register: dual_nics_result + azure.azcollection.azure_rm_virtualmachine: + resource_group: '{{ resource_group }}' + name: '{{ vm_name }}' + vm_size: Standard_A0 + storage_account: '{{ storage_account }}' + storage_container: '{{ vm_name }}' + storage_blob: '{{ vm_name }}.vhd' + admin_username: adminuser + admin_password: Password123! + short_hostname: testvm + os_type: Linux + os_disk_size_gb: 64 + network_interfaces: '{{ nic_list }}' + availability_set: '{{ availability_set }}' + image: + offer: UbuntuServer + publisher: Canonical + sku: 16.04-LTS + version: latest +- name: Ensure nothing changed + assert: + that: dual_nics_result is not changed +- name: Generalize VM + azure.azcollection.azure_rm_virtualmachine: + resource_group: '{{ resource_group }}' + name: '{{ vm_name }}' + generalized: true +- name: Gather facts and check if machine is generalized + azure_rm_virtualmachine_facts: + resource_group: '{{ resource_group }}' + name: '{{ vm_name }}' + register: generalized_output +- name: Ensure power state is generalized + assert: + that: generalized_output.vms[0].power_state == 'generalized' +- name: Delete dual NIC VM + async: 5000 + poll: 0 + azure.azcollection.azure_rm_virtualmachine: + resource_group: '{{ resource_group }}' + name: '{{ vm_name }}' + state: absent + vm_size: Standard_A0 diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_invalid.yml b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_invalid.yml new file mode 100644 index 00000000..8b1979a9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_invalid.yml @@ -0,0 +1,31 @@ +- name: Assert error thrown with invalid image dict + register: fail_invalid_image_dict + failed_when: 'fail_invalid_image_dict.msg != "parameter error: expecting image to contain [publisher, offer, sku, version], [name, resource_group] or [id]"' + azure.azcollection.azure_rm_virtualmachine: + resource_group: '{{ resource_group }}' + name: '{{ vm_name }}' + image: + offer: UbuntuServer +- name: Assert error thrown with invalid image type + register: fail_invalid_image_type + failed_when: 'fail_invalid_image_type.msg != "parameter error: expecting image to be a string or dict not list"' + azure.azcollection.azure_rm_virtualmachine: + resource_group: '{{ resource_group }}' + name: '{{ vm_name }}' + image: + - testing +- name: Assert error finding missing custom image + register: fail_missing_custom_image + failed_when: fail_missing_custom_image.msg != "Error could not find image with name invalid-image" + azure.azcollection.azure_rm_virtualmachine: + resource_group: '{{ resource_group }}' + name: '{{ vm_name }}' + image: invalid-image +- name: Assert error finding missing custom image (dict style) + register: fail_missing_custom_image_dict + failed_when: fail_missing_custom_image_dict.msg != "Error could not find image with name invalid-image" + azure.azcollection.azure_rm_virtualmachine: + resource_group: '{{ resource_group }}' + name: '{{ vm_name }}' + image: + name: invalid-image diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_minimal.yml b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_minimal.yml new file mode 100644 index 00000000..74446055 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_minimal.yml @@ -0,0 +1,64 @@ +- include_tasks: setup.yml +- name: Create minimal VM with defaults + register: vm_output + azure.azcollection.azure_rm_virtualmachine: + resource_group: '{{ resource_group }}' + name: '{{ vm_name }}' + admin_username: testuser + admin_password: Pass123$$$abx! + vm_size: Standard_B1ms + virtual_network: '{{ network_name }}' + image: + offer: UbuntuServer + publisher: Canonical + sku: 16.04-LTS + version: latest +- name: Delete VM + azure.azcollection.azure_rm_virtualmachine: + resource_group: '{{ resource_group }}' + name: '{{ vm_name }}' + remove_on_absent: all_autocreated + state: absent +- name: Query auto created NIC + register: nic_result + azure.azcollection.azure_rm_networkinterface_info: + resource_group: '{{ resource_group }}' + name: '{{ vm_name }}01' +- name: Query auto created security group + register: nsg_result + azure.azcollection.azure_rm_securitygroup_info: + resource_group: '{{ resource_group }}' + name: '{{ vm_name }}01' +- name: Query auto created public IP + register: pip_result + azure.azcollection.azure_rm_publicipaddress_info: + resource_group: '{{ resource_group }}' + name: '{{ vm_name }}01' +- name: Assert that autocreated resources were deleted + assert: + that: + - nic_result.networkinterfaces | length == 0 + - nsg_result.securitygroups | length == 0 + - pip_result.publicipaddresses | length == 0 +- name: Destroy subnet + azure.azcollection.azure_rm_subnet: + resource_group: '{{ resource_group }}' + virtual_network: '{{ network_name }}' + name: '{{ subnet_name }}' + state: absent +- name: Destroy virtual network + azure.azcollection.azure_rm_virtualnetwork: + resource_group: '{{ resource_group }}' + name: '{{ network_name }}' + state: absent +- name: Destroy availability set + azure.azcollection.azure_rm_availabilityset: + resource_group: '{{ resource_group }}' + name: '{{ availability_set }}' + state: absent +- name: Destroy storage account + azure.azcollection.azure_rm_storageaccount: + resource_group: '{{ resource_group }}' + name: '{{ storage_account }}' + force_delete_nonempty: true + state: absent diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_no_public_ip.yml b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_no_public_ip.yml new file mode 100644 index 00000000..e9b81b08 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_no_public_ip.yml @@ -0,0 +1,38 @@ +- include_tasks: setup.yml +- name: Create virtual machine without public ip address and with boot diagnostics enabled + register: create_vm_public_result + azure.azcollection.azure_rm_virtualmachine: + resource_group: '{{ resource_group }}' + name: '{{ vm_name }}' + vm_size: Standard_A0 + admin_username: adminuser + admin_password: Password123! + short_hostname: testvm + os_type: Linux + public_ip_allocation_method: Disabled + storage_account_name: '{{ storage_account }}' + availability_set: '{{ availability_set }}' + virtual_network: '{{ network_name }}' + boot_diagnostics: + enabled: true + image: + offer: UbuntuServer + publisher: Canonical + sku: 16.04-LTS + version: latest +- name: Ensure VM was created properly + assert: + that: + - azure_vm.properties.diagnosticsProfile.bootDiagnostics.enabled + - azure_vm.properties.diagnosticsProfile.bootDiagnostics.storageUri is defined + - azure_vm.properties.instanceView.bootDiagnostics.consoleScreenshotBlobUri is defined + - azure_vm.properties.instanceView.bootDiagnostics.serialConsoleLogBlobUri is defined + - not 'publicIPAddress' in create_vm_public_result.ansible_facts.azure_vm.properties.networkProfile.networkInterfaces[0].properties.ipConfigurations[0].properties +- name: Delete VM with no public ip + async: 5000 + poll: 0 + azure.azcollection.azure_rm_virtualmachine: + resource_group: '{{ resource_group }}' + name: '{{ vm_name }}' + state: absent + remove_on_absent: all_autocreated diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_public_ip.yml b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_public_ip.yml new file mode 100644 index 00000000..ef89fbf7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_public_ip.yml @@ -0,0 +1,236 @@ +- include_tasks: setup.yml +- name: Create public ip + azure.azcollection.azure_rm_publicipaddress: + resource_group: '{{ resource_group }}' + allocation_method: Static + name: '{{ public_ip_name }}' +- name: Create security group + azure.azcollection.azure_rm_securitygroup: + resource_group: '{{ resource_group }}' + name: '{{ security_group }}' + purge_rules: true + rules: + - name: ALLOW_SSH + protocol: Tcp + destination_port_range: 22 + access: Allow + priority: 100 + direction: Inbound + - name: ALLOW_HTTP + protocol: Tcp + destination_port_range: 80 + access: Allow + priority: 110 + direction: Inbound +- name: Create network interface + azure.azcollection.azure_rm_networkinterface: + resource_group: '{{ resource_group }}' + name: '{{ interface_name }}' + virtual_network: '{{ network_name }}' + subnet: '{{ subnet_name }}' + public_ip_name: '{{ public_ip_name }}' + security_group: '{{ security_group }}' +- name: Create virtual machine with a single NIC and no boot diagnostics + register: output + azure.azcollection.azure_rm_virtualmachine: + resource_group: '{{ resource_group }}' + name: '{{ vm_name }}' + vm_size: Standard_A0 + storage_account: '{{ storage_account }}' + storage_container: '{{ vm_name }}' + storage_blob: '{{ vm_name }}.vhd' + admin_username: adminuser + admin_password: Password123! + short_hostname: testvm + os_type: Linux + network_interfaces: '{{ interface_name }}' + availability_set: '{{ availability_set }}' + image: + offer: UbuntuServer + publisher: Canonical + sku: 16.04-LTS + version: latest + custom_data: '#!/bin/sh + + echo "custom_data was executed" > /tmp/custom_data.txt + + ' +- name: Ensure VM was created properly + assert: + that: + - azure_vm.properties.provisioningState == 'Succeeded' + - azure_vm.properties.availabilitySet.id + - '''diagnosticsProfile'' not in azure_vm.properties or not azure_vm.properties.diagnosticsProfile.bootDiagnostics.enabled' +- name: Get facts for virtual machine without boot diagnostics disabled + azure_rm_virtualmachine_facts: + resource_group: '{{ resource_group }}' + name: '{{ vm_name }}' + register: vm_facts_no_boot_diag_result +- name: Ensure VM facts are correct + assert: + that: + - vm_facts_no_boot_diag_result.vms != [] + - not vm_facts_no_boot_diag_result.vms[0].boot_diagnostics.enabled + - not vm_facts_no_boot_diag_result.vms[0].boot_diagnostics.storage_uri +- name: Enable boot diagnostics on an existing VM for the first time without specifying a storage account + azure.azcollection.azure_rm_virtualmachine: + resource_group: '{{ resource_group }}' + name: '{{ vm_name }}' + boot_diagnostics: + enabled: true +- name: Ensure VM properties are correct + assert: + that: + - azure_vm.properties.diagnosticsProfile.bootDiagnostics.enabled + - azure_vm.properties.diagnosticsProfile.bootDiagnostics.storageUri is defined + - azure_vm.properties.instanceView.bootDiagnostics.consoleScreenshotBlobUri is defined + - azure_vm.properties.instanceView.bootDiagnostics.serialConsoleLogBlobUri is defined +- name: Get facts for virtual machine with boot diagnostics enabled + azure_rm_virtualmachine_facts: + resource_group: '{{ resource_group }}' + name: '{{ vm_name }}' + register: vm_facts_boot_diag_result +- name: Ensure VM facts were returned + assert: + that: + - vm_facts_boot_diag_result.vms != [] + - vm_facts_boot_diag_result.vms[0].boot_diagnostics.enabled + - vm_facts_boot_diag_result.vms[0].boot_diagnostics.storage_uri is defined + - vm_facts_boot_diag_result.vms[0].boot_diagnostics.console_screenshot_uri is defined + - vm_facts_boot_diag_result.vms[0].boot_diagnostics.serial_console_log_uri is defined +- name: Change the boot diagnostics storage account while enabled + ignore_errors: true + azure.azcollection.azure_rm_virtualmachine: + resource_group: '{{ resource_group }}' + name: '{{ vm_name }}' + boot_diagnostics: + enabled: true + storage_account: '{{ storage_account }}' +- name: Disable boot diagnostics and change the storage account at the same time + azure.azcollection.azure_rm_virtualmachine: + resource_group: '{{ resource_group }}' + name: '{{ vm_name }}' + boot_diagnostics: + enabled: false + storage_account: '{{ storage_account }}' +- name: Ensure boot diagnostics was disabled + assert: + that: + - not azure_vm.properties.diagnosticsProfile.bootDiagnostics.enabled +- name: Re-enable boot diagnostics on an existing VM where it was previously configured + register: reenable_boot_diag_result + azure.azcollection.azure_rm_virtualmachine: + resource_group: '{{ resource_group }}' + name: '{{ vm_name }}' + boot_diagnostics: + enabled: true +- name: Ensure boot diagnostics was reenabled + assert: + that: + - azure_vm.properties.diagnosticsProfile.bootDiagnostics.enabled + - azure_vm.properties.diagnosticsProfile.bootDiagnostics.storageUri is defined + - azure_vm.properties.instanceView.bootDiagnostics.consoleScreenshotBlobUri is defined + - azure_vm.properties.instanceView.bootDiagnostics.serialConsoleLogBlobUri is defined +- name: Should be idempotent with a single NIC + register: single_nic_result + azure.azcollection.azure_rm_virtualmachine: + resource_group: '{{ resource_group }}' + name: '{{ vm_name }}' + vm_size: Standard_A0 + storage_account: '{{ storage_account }}' + storage_container: '{{ vm_name }}' + storage_blob: '{{ vm_name }}.vhd' + admin_username: adminuser + admin_password: Password123! + short_hostname: testvm + os_type: Linux + network_interfaces: '{{ interface_name }}' + image: + offer: UbuntuServer + publisher: Canonical + sku: 16.04-LTS + version: latest +- name: Ensure nothing changed + assert: + that: single_nic_result is not changed +- name: Resize VM + register: resize_result + azure.azcollection.azure_rm_virtualmachine: + resource_group: '{{ resource_group }}' + name: '{{ vm_name }}' + vm_size: Standard_A1 + storage_account: '{{ storage_account }}' + storage_container: '{{ vm_name }}' + storage_blob: '{{ vm_name }}.vhd' + admin_username: adminuser + admin_password: Password123! + short_hostname: testvm + os_type: Linux + network_interfaces: '{{ interface_name }}' + image: + offer: UbuntuServer + publisher: Canonical + sku: 16.04-LTS + version: latest +- name: Esure VM was resized + assert: + that: + - resize_result is changed + - resize_result.ansible_facts.azure_vm.properties.hardwareProfile.vmSize == "Standard_A1" +- name: Delete VM + azure.azcollection.azure_rm_virtualmachine: + resource_group: '{{ resource_group }}' + name: '{{ vm_name }}' + state: absent + vm_size: Standard_A0 +- name: NIC should be gone + azure_rm_networkinterface_facts: + resource_group: '{{ resource_group }}' + name: '{{ interface_name }}' +- name: Ensure NIC was removed + assert: + that: azure_networkinterfaces | length == 0 +- name: Public IP should be gone + azure_rm_publicipaddress_facts: + resource_group: '{{ resource_group }}' + name: '{{ public_ip_name }}' +- name: Ensure public IP was removed + assert: + that: azure_publicipaddresses | length == 0 +- name: Destroy NIC + azure.azcollection.azure_rm_networkinterface: + resource_group: '{{ resource_group }}' + name: '{{ interface_name }}' + state: absent +- name: Destroy security group + azure.azcollection.azure_rm_securitygroup: + resource_group: '{{ resource_group }}' + name: '{{ security_group }}' + state: absent +- name: Destroy subnet + azure.azcollection.azure_rm_subnet: + resource_group: '{{ resource_group }}' + virtual_network: '{{ network_name }}' + name: '{{ subnet_name }}' + state: absent +- name: Destroy virtual network + azure.azcollection.azure_rm_virtualnetwork: + resource_group: '{{ resource_group }}' + name: '{{ network_name }}' + state: absent +- name: Destroy public ip + azure.azcollection.azure_rm_publicipaddress: + resource_group: '{{ resource_group }}' + name: '{{ public_ip_name }}' + state: absent +- name: Destroy availability set + azure.azcollection.azure_rm_availabilityset: + resource_group: '{{ resource_group }}' + name: '{{ availability_set }}' + state: absent +- name: Destroy storage account + azure.azcollection.azure_rm_storageaccount: + resource_group: '{{ resource_group }}' + name: '{{ storage_account }}' + force_delete_nonempty: true + state: absent diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachine/tasks/setup.yml b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachine/tasks/setup.yml new file mode 100644 index 00000000..2d4f19c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachine/tasks/setup.yml @@ -0,0 +1,22 @@ +- debug: + msg: UID is {{ uid_short }} +- name: SETUP | Create storage account + azure.azcollection.azure_rm_storageaccount: + resource_group: '{{ resource_group }}' + name: '{{ storage_account }}' + account_type: Standard_LRS +- name: SETUP | Create availability set + azure.azcollection.azure_rm_availabilityset: + name: '{{ availability_set }}' + resource_group: '{{ resource_group }}' +- name: SETUP | Create virtual network + azure.azcollection.azure_rm_virtualnetwork: + resource_group: '{{ resource_group }}' + name: '{{ network_name }}' + address_prefixes: '{{ network }}' +- name: SETUP | Create subnet + azure.azcollection.azure_rm_subnet: + resource_group: '{{ resource_group }}' + name: '{{ subnet_name }}' + address_prefix: '{{ subnet }}' + virtual_network: '{{ network_name }}' diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachineextension/aliases b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachineextension/aliases new file mode 100644 index 00000000..6c772d71 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachineextension/aliases @@ -0,0 +1,4 @@ +cloud/azure +shippable/azure/group1 +destructive +azure_rm_virtualmachineextension_facts diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachineextension/meta/main.yml b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachineextension/meta/main.yml new file mode 100644 index 00000000..95e1952f --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachineextension/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_azure diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachineextension/tasks/main.yml b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachineextension/tasks/main.yml new file mode 100644 index 00000000..390c0cb6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachineextension/tasks/main.yml @@ -0,0 +1,167 @@ +- name: Create Random Storage Account Name + set_fact: + storage_account: '{{ resource_group | hash(''md5'') | truncate(24, True, '''') }}' +- name: Create virtual network + azure.azcollection.azure_rm_virtualnetwork: + resource_group: '{{ resource_group }}' + name: testVnet + address_prefixes: 10.0.0.0/16 +- name: Add subnet + azure.azcollection.azure_rm_subnet: + resource_group: '{{ resource_group }}' + name: testSubnet + address_prefix: 10.0.1.0/24 + virtual_network: testVnet +- name: Create public IP address + azure.azcollection.azure_rm_publicipaddress: + resource_group: '{{ resource_group }}' + allocation_method: Dynamic + name: testPublicIP +- name: Create Network Security Group that allows SSH + azure.azcollection.azure_rm_securitygroup: + resource_group: '{{ resource_group }}' + name: testNetworkSecurityGroup + rules: + - name: SSH + protocol: Tcp + destination_port_range: 22 + access: Allow + priority: 1001 + direction: Inbound +- name: Create virtual network interface card + azure.azcollection.azure_rm_networkinterface: + resource_group: '{{ resource_group }}' + name: testNIC + virtual_network: testVnet + subnet: testSubnet + public_ip_name: testPublicIP + security_group_name: testNetworkSecurityGroup +- name: create a storage account + azure.azcollection.azure_rm_storageaccount: + resource_group: '{{ resource_group }}' + name: '{{ storage_account }}' + type: Standard_LRS +- name: Create VM + azure.azcollection.azure_rm_virtualmachine: + resource_group: '{{ resource_group }}' + name: testVM + vm_size: Standard_DS1_v2 + admin_username: testuser + ssh_password_enabled: true + admin_password: Password1234! + network_interfaces: testNIC + storage_account_name: '{{ storage_account }}' + storage_container: osdisk + storage_blob: osdisk.vhd + os_disk_caching: ReadWrite + image: + offer: CoreOS + publisher: CoreOS + sku: Stable + version: latest +- name: Create VM Extension + register: results + azure.azcollection.azure_rm_virtualmachineextension: + resource_group: '{{ resource_group }}' + name: testVMExtension + virtual_machine_name: testVM + publisher: Microsoft.Azure.Extensions + virtual_machine_extension_type: CustomScript + type_handler_version: 2.0 + auto_upgrade_minor_version: true + settings: + commandToExecute: hostname +- name: Assert that VM Extension ran + assert: + that: results.changed +- name: Query extension + azure_rm_virtualmachineextension_facts: + resource_group: '{{ resource_group }}' + name: testVMExtension + virtual_machine_name: testVM + register: results +- name: Assert that facts are returned + assert: + that: + - results.changed == False + - results.extensions[0]['id'] != None + - results.extensions[0]['resource_group'] != None + - results.extensions[0]['virtual_machine_name'] != None + - results.extensions[0]['name'] != None + - results.extensions[0]['location'] != None + - results.extensions[0]['publisher'] != None + - results.extensions[0]['type'] != None + - results.extensions[0]['settings'] != None + - results.extensions[0]['auto_upgrade_minor_version'] != None + - results.extensions[0]['provisioning_state'] != None +- name: List extensions + azure_rm_virtualmachineextension_facts: + resource_group: '{{ resource_group }}' + virtual_machine_name: testVM + register: results +- name: Assert that facts are returned + assert: + that: + - results.changed == False + - results.extensions[0]['id'] != None + - results.extensions[0]['resource_group'] != None + - results.extensions[0]['virtual_machine_name'] != None + - results.extensions[0]['name'] != None + - results.extensions[0]['location'] != None + - results.extensions[0]['publisher'] != None + - results.extensions[0]['type'] != None + - results.extensions[0]['settings'] != None + - results.extensions[0]['auto_upgrade_minor_version'] != None + - results.extensions[0]['provisioning_state'] != None +- name: Delete VM Extension + register: results + azure.azcollection.azure_rm_virtualmachineextension: + resource_group: '{{ resource_group }}' + name: testVMExtension + virtual_machine_name: testVM + state: absent + publisher: Microsoft.Azure.Extensions + virtual_machine_extension_type: CustomScript + type_handler_version: 2.0 + auto_upgrade_minor_version: true + settings: + commandToExecute: hostname +- name: Assert that VM Extension deleted + assert: + that: results.changed +- name: Delete VM + azure.azcollection.azure_rm_virtualmachine: + resource_group: '{{ resource_group }}' + name: testVM + state: absent + remove_on_absent: + - all + vm_size: Standard_DS1_v2 + admin_username: testuser + network_interfaces: testNIC + storage_container: osdisk + storage_blob: osdisk.vhd + os_disk_caching: ReadWrite + image: + offer: CoreOS + publisher: CoreOS + sku: Stable + version: latest +- name: Delete a storage account + azure.azcollection.azure_rm_storageaccount: + resource_group: '{{ resource_group }}' + name: '{{ storage_account }}' + type: Standard_LRS + state: absent + force_delete_nonempty: true +- name: Delete Network Security Group that allows SSH + azure.azcollection.azure_rm_securitygroup: + resource_group: '{{ resource_group }}' + name: testNetworkSecurityGroup + state: absent +- name: Delete virtual network + azure.azcollection.azure_rm_virtualnetwork: + resource_group: '{{ resource_group }}' + name: testVnet + state: absent + address_prefixes: 10.0.0.0/16 diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachinescaleset/aliases b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachinescaleset/aliases new file mode 100644 index 00000000..01c44d5e --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachinescaleset/aliases @@ -0,0 +1,7 @@ +cloud/azure +shippable/azure/group1 +destructive +azure_rm_virtualmachinescaleset_facts +azure_rm_virtualmachinescalesetinstance_facts +azure_rm_virtualmachinescalesetextension +azure_rm_virtualmachinescalesetextension_facts diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachinescaleset/meta/main.yml b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachinescaleset/meta/main.yml new file mode 100644 index 00000000..95e1952f --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachinescaleset/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_azure diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachinescaleset/tasks/main.yml b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachinescaleset/tasks/main.yml new file mode 100644 index 00000000..434eb2e9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_virtualmachinescaleset/tasks/main.yml @@ -0,0 +1,547 @@ +- name: Prepare random number + set_fact: + rpfx: '{{ resource_group | hash(''md5'') | truncate(7, True, '''') }}{{ 1000 | random }}' + run_once: true +- name: Create virtual network + azure.azcollection.azure_rm_virtualnetwork: + resource_group: '{{ resource_group }}' + name: testVnet + address_prefixes: 10.0.0.0/16 +- name: Add subnet + azure.azcollection.azure_rm_subnet: + resource_group: '{{ resource_group }}' + name: testSubnet + address_prefix: 10.0.1.0/24 + virtual_network: testVnet +- name: Create public IP address + azure.azcollection.azure_rm_publicipaddress: + resource_group: '{{ resource_group }}' + allocation_method: Static + name: testPublicIP +- name: Create load balancer + azure.azcollection.azure_rm_loadbalancer: + resource_group: '{{ resource_group }}' + name: testLB + public_ip_address_name: testPublicIP +- name: Create public IP address 1 + azure.azcollection.azure_rm_publicipaddress: + resource_group: '{{ resource_group }}' + allocation_method: Static + name: testPublicIP1 +- name: Create load balancer 1 + azure.azcollection.azure_rm_loadbalancer: + resource_group: '{{ resource_group }}' + name: testLB1 + public_ip_address_name: testPublicIP1 +- name: Create network security group within same resource group of VMSS. + azure.azcollection.azure_rm_securitygroup: + resource_group: '{{ resource_group }}' + name: testNetworkSecurityGroup +- name: Create network security group in different resource group of VMSS. + azure.azcollection.azure_rm_securitygroup: + resource_group: '{{ resource_group_secondary }}' + name: testNetworkSecurityGroup2 +- name: Create virtual network inteface cards for VM A and B + azure.azcollection.azure_rm_networkinterface: + resource_group: '{{ resource_group }}' + name: vmforimage{{ rpfx }}nic + virtual_network: testVnet + subnet: testSubnet +- name: Create VM + azure.azcollection.azure_rm_virtualmachine: + resource_group: '{{ resource_group }}' + name: vmforimage{{ rpfx }} + admin_username: testuser + admin_password: Password1234! + vm_size: Standard_B1ms + network_interfaces: vmforimage{{ rpfx }}nic + image: + offer: UbuntuServer + publisher: Canonical + sku: 16.04-LTS + version: latest +- name: Generalize VM + azure.azcollection.azure_rm_virtualmachine: + resource_group: '{{ resource_group }}' + name: vmforimage{{ rpfx }} + generalized: true +- name: Create image A + azure.azcollection.azure_rm_image: + resource_group: '{{ resource_group }}' + name: testimagea + source: vmforimage{{ rpfx }} +- name: Create image B + azure.azcollection.azure_rm_image: + resource_group: '{{ resource_group }}' + name: testimageb + source: vmforimage{{ rpfx }} +- name: Delete VM + azure.azcollection.azure_rm_virtualmachine: + resource_group: '{{ resource_group }}' + name: vmforimage{{ rpfx }} + state: absent +- name: Create VMSS (check mode) + register: results + check_mode: true + azure.azcollection.azure_rm_virtualmachinescaleset: + resource_group: '{{ resource_group }}' + name: testVMSS{{ rpfx }} + vm_size: Standard_B1s + admin_username: testuser + ssh_password_enabled: true + admin_password: Password1234! + capacity: 1 + virtual_network_name: testVnet + subnet_name: testSubnet + load_balancer: testLB + upgrade_policy: Manual + tier: Standard + managed_disk_type: Standard_LRS + os_disk_caching: ReadWrite + image: + offer: CoreOS + publisher: CoreOS + sku: Stable + version: latest + data_disks: + - lun: 0 + disk_size_gb: 64 + caching: ReadWrite + managed_disk_type: Standard_LRS +- name: Assert that VMSS can be created + assert: + that: results.changed +- name: Get VMSS to assert no VMSS is created in check mode + azure_rm_virtualmachinescaleset_facts: + resource_group: '{{ resource_group }}' + name: testVMSS{{ rpfx }} + format: curated + register: output_scaleset +- name: Assert no VMSS created in check mode + assert: + that: + - output_scaleset.ansible_facts.azure_vmss | length == 0 +- name: Create VMSS + register: results + azure.azcollection.azure_rm_virtualmachinescaleset: + resource_group: '{{ resource_group }}' + name: testVMSS{{ rpfx }} + vm_size: Standard_B1s + admin_username: testuser + ssh_password_enabled: true + admin_password: Password1234! + capacity: 1 + virtual_network_name: testVnet + subnet_name: testSubnet + upgrade_policy: Manual + load_balancer: testLB + tier: Standard + managed_disk_type: Standard_LRS + os_disk_caching: ReadWrite + custom_data: '#cloud-config' + image: + offer: CoreOS + publisher: CoreOS + sku: Stable + version: latest + data_disks: + - lun: 0 + disk_size_gb: 64 + caching: ReadWrite + managed_disk_type: Standard_LRS + scale_in_policy: NewestVM +- name: Assert that VMSS was created + assert: + that: results.changed +- name: Create VMSS -- test upgrade_policy idempotence and load balancer + register: results + azure.azcollection.azure_rm_virtualmachinescaleset: + resource_group: '{{ resource_group }}' + name: testVMSS{{ rpfx }} + vm_size: Standard_B1s + admin_username: testuser + ssh_password_enabled: true + admin_password: Password1234! + capacity: 1 + virtual_network_name: testVnet + subnet_name: testSubnet + upgrade_policy: Automatic + load_balancer: testLB1 + tier: Standard + managed_disk_type: Standard_LRS + os_disk_caching: ReadWrite + custom_data: '#cloud-config' + image: + offer: CoreOS + publisher: CoreOS + sku: Stable + version: latest + data_disks: + - lun: 0 + disk_size_gb: 64 + caching: ReadWrite + managed_disk_type: Standard_LRS +- name: Assert that VMSS was created + assert: + that: results.changed +- name: Retrieve scaleset facts + azure_rm_virtualmachinescaleset_facts: + resource_group: '{{ resource_group }}' + name: testVMSS{{ rpfx }} + format: curated + register: output_scaleset +- assert: + that: + - output_scaleset.vmss[0].load_balancer == "testLB1" +- name: Retrieve scaleset VMs facts + azure_rm_virtualmachinescalesetinstance_facts: + resource_group: '{{ resource_group }}' + vmss_name: testVMSS{{ rpfx }} + register: instances +- name: Assert that facts returned correctly + assert: + that: + - instances.instances | length == 1 + - instances.instances[0].id != None + - instances.instances[0].name != None + - instances.instances[0].instance_id != None + - instances.instances[0].provisioning_state != None + - instances.instances[0].vm_id != None + - instances.instances[0].latest_model != None + - instances.instances[0].power_state != None +- name: Get scaleset body + set_fact: + body: '{{ output_scaleset.vmss[0] }}' +- name: Try to update VMSS using output as input + register: results + azure.azcollection.azure_rm_virtualmachinescaleset: + resource_group: '{{ body.resource_group }}' + name: '{{ body.name }}' + vm_size: '{{ body.vm_size }}' + admin_username: '{{ body.admin_username }}' + ssh_password_enabled: '{{ body.ssh_password_enabled }}' + admin_password: Password1234! + capacity: '{{ body.capacity }}' + virtual_network_name: '{{ body.virtual_network_name }}' + subnet_name: '{{ body.subnet_name }}' + upgrade_policy: '{{ body.upgrade_policy }}' + load_balancer: '{{ body.load_balancer }}' + tier: '{{ body.tier }}' + managed_disk_type: '{{ body.managed_disk_type }}' + os_disk_caching: '{{ body.os_disk_caching }}' + image: '{{ body.image }}' + data_disks: '{{ body.data_disks }}' + overprovision: '{{ body.overprovision }}' +- name: Assert that nothing was changed + assert: + that: not results.changed +- name: Install VMSS Extension + register: results + azure.azcollection.azure_rm_virtualmachinescalesetextension: + resource_group: '{{ resource_group }}' + vmss_name: testVMSS{{ rpfx }} + name: testExtension + publisher: Microsoft.Azure.Extensions + type: CustomScript + type_handler_version: 2.0 + auto_upgrade_minor_version: true + settings: + commandToExecute: sudo apt-get -y install apache2 +- name: Assert that something was changed + assert: + that: results.changed +- name: Install Again VMSS Extension - again + register: results + azure.azcollection.azure_rm_virtualmachinescalesetextension: + resource_group: '{{ resource_group }}' + vmss_name: testVMSS{{ rpfx }} + name: testExtension + publisher: Microsoft.Azure.Extensions + type: CustomScript + type_handler_version: 2.0 + auto_upgrade_minor_version: true + settings: + commandToExecute: sudo apt-get -y install apache2 +- name: Assert that nothing was changed + assert: + that: not results.changed +- name: Query extension + azure_rm_virtualmachinescalesetextension_facts: + resource_group: '{{ resource_group }}' + vmss_name: testVMSS{{ rpfx }} + name: testExtension + register: results +- name: Assert that facts are returned + assert: + that: + - results.changed == False + - results.extensions[0]['id'] != None + - results.extensions[0]['resource_group'] != None + - results.extensions[0]['vmss_name'] != None + - results.extensions[0]['name'] != None + - results.extensions[0]['publisher'] != None + - results.extensions[0]['type'] != None + - results.extensions[0]['settings'] != None + - results.extensions[0]['auto_upgrade_minor_version'] != None + - results.extensions[0]['provisioning_state'] != None +- name: List extensions + azure_rm_virtualmachinescalesetextension_facts: + resource_group: '{{ resource_group }}' + vmss_name: testVMSS{{ rpfx }} + register: results +- name: Assert that facts are returned + assert: + that: + - results.changed == False + - results.extensions[0]['id'] != None + - results.extensions[0]['resource_group'] != None + - results.extensions[0]['vmss_name'] != None + - results.extensions[0]['name'] != None + - results.extensions[0]['publisher'] != None + - results.extensions[0]['type'] != None + - results.extensions[0]['settings'] != None + - results.extensions[0]['auto_upgrade_minor_version'] != None + - results.extensions[0]['provisioning_state'] != None +- name: Delete VMSS Extension + register: results + azure.azcollection.azure_rm_virtualmachinescalesetextension: + resource_group: '{{ resource_group }}' + vmss_name: testVMSS{{ rpfx }} + name: testExtension + state: absent +- name: Assert that change was reported + assert: + that: results.changed +- name: Upgrade instance to the latest image + register: results + azure.azcollection.azure_rm_virtualmachinescalesetinstance: + resource_group: '{{ resource_group }}' + vmss_name: testVMSS{{ rpfx }} + instance_id: '{{ instances.instances[0].instance_id }}' + latest_model: true +- name: Assert that something has changed + assert: + that: results.changed +- name: Stop virtual machine + register: results + azure.azcollection.azure_rm_virtualmachinescalesetinstance: + resource_group: '{{ resource_group }}' + vmss_name: testVMSS{{ rpfx }} + instance_id: '{{ instances.instances[0].instance_id }}' + power_state: stopped +- name: Assert that something has changed + assert: + that: results.changed +- name: Delete instance + register: results + azure.azcollection.azure_rm_virtualmachinescalesetinstance: + resource_group: '{{ resource_group }}' + vmss_name: testVMSS{{ rpfx }} + instance_id: '{{ instances.instances[0].instance_id }}' + state: absent +- name: Assert that something has changed + assert: + that: results.changed +- name: Delete VMSS + azure.azcollection.azure_rm_virtualmachinescaleset: + resource_group: '{{ resource_group }}' + name: testVMSS{{ rpfx }} + state: absent +- name: Create VMSS with security group in same resource group, with accelerated networking(check mode). + register: results + check_mode: true + azure.azcollection.azure_rm_virtualmachinescaleset: + resource_group: '{{ resource_group }}' + name: testVMSS{{ rpfx }}2 + vm_size: Standard_D3_v2 + capacity: 0 + virtual_network_name: testVnet + subnet_name: testSubnet + admin_username: testuser + ssh_password_enabled: true + admin_password: Password1234! + image: + name: testimagea + resource_group: '{{ resource_group }}' + upgrade_policy: Manual + security_group: testNetworkSecurityGroup + enable_accelerated_networking: true +- name: Assert that VMSS can be created + assert: + that: results.changed +- name: Create VMSS with security group in same resource group, with accelerated networking. + register: results + azure.azcollection.azure_rm_virtualmachinescaleset: + resource_group: '{{ resource_group }}' + name: testVMSS{{ rpfx }}2 + vm_size: Standard_D3_v2 + capacity: 0 + virtual_network_name: testVnet + subnet_name: testSubnet + admin_username: testuser + ssh_password_enabled: true + admin_password: Password1234! + image: + name: testimagea + resource_group: '{{ resource_group }}' + upgrade_policy: Manual + security_group: testNetworkSecurityGroup + enable_accelerated_networking: true +- name: Assert that VMSS ran + assert: + that: + - results.changed + - results.ansible_facts.azure_vmss.properties.virtualMachineProfile.networkProfile.networkInterfaceConfigurations.0.properties.enableAcceleratedNetworking == true + - results.ansible_facts.azure_vmss.properties.virtualMachineProfile.networkProfile.networkInterfaceConfigurations.0.properties.networkSecurityGroup != {} +- name: Create VMSS with security group in same resource group, with accelerated networking. + register: results + azure.azcollection.azure_rm_virtualmachinescaleset: + resource_group: '{{ resource_group }}' + name: testVMSS{{ rpfx }}2 + vm_size: Standard_D3_v2 + capacity: 0 + virtual_network_name: testVnet + subnet_name: testSubnet + admin_username: testuser + ssh_password_enabled: true + admin_password: Password1234! + image: + name: testimagea + resource_group: '{{ resource_group }}' + upgrade_policy: Manual + security_group: testNetworkSecurityGroup + enable_accelerated_networking: true +- name: Assert that nothing has changed + assert: + that: + - not results.changed +- name: Create VMSS with security group in same resource group, with accelerated networking. + register: results + azure.azcollection.azure_rm_virtualmachinescaleset: + resource_group: '{{ resource_group }}' + name: testVMSS{{ rpfx }}2 + vm_size: Standard_D3_v2 + capacity: 0 + virtual_network_name: testVnet + subnet_name: testSubnet + admin_username: testuser + ssh_password_enabled: true + admin_password: Password1234! + image: + name: testimageb + resource_group: '{{ resource_group }}' + upgrade_policy: Manual + security_group: testNetworkSecurityGroup + enable_accelerated_networking: true +- name: Assert that something has changed + assert: + that: + - results.changed +- name: update VMSS with security group in different resource group. + register: results + azure.azcollection.azure_rm_virtualmachinescaleset: + resource_group: '{{ resource_group }}' + name: testVMSS{{ rpfx }}2 + vm_size: Standard_B1s + capacity: 0 + virtual_network_name: testVnet + subnet_name: testSubnet + admin_username: testuser + ssh_password_enabled: true + admin_password: Password1234! + image: + name: testimageb + resource_group: '{{ resource_group }}' + upgrade_policy: Manual + security_group: + name: testNetworkSecurityGroup2 + resource_group: '{{ resource_group_secondary }}' +- name: Delete VMSS + azure.azcollection.azure_rm_virtualmachinescaleset: + resource_group: '{{ resource_group }}' + name: testVMSS{{ rpfx }}2 + state: absent +- name: Fail when instance type is not supported to enable accelerated networking + register: results + ignore_errors: true + azure.azcollection.azure_rm_virtualmachinescaleset: + resource_group: '{{ resource_group }}' + name: testVMSS{{ rpfx }}4 + vm_size: Standard_B1s + virtual_network_name: testVnet + subnet_name: testSubnet + admin_username: testuser + ssh_password_enabled: true + admin_password: Password1234! + image: + offer: CoreOS + publisher: CoreOS + sku: Stable + version: latest + upgrade_policy: Manual + enable_accelerated_networking: true +- name: Assert failure to show that accelerated networking is enabled only with supported instance types. + assert: + that: + - '"VMSizeIsNotPermittedToEnableAcceleratedNetworkingForVmss" in results.msg' +- name: Delete network security group + azure.azcollection.azure_rm_securitygroup: + resource_group: '{{ resource_group }}' + name: testNetworkSecurityGroup + state: absent +- name: Delete network security group + azure.azcollection.azure_rm_securitygroup: + resource_group: '{{ resource_group_secondary }}' + name: testNetworkSecurityGroup2 + state: absent +- name: Delete load balancer + azure.azcollection.azure_rm_loadbalancer: + resource_group: '{{ resource_group }}' + name: testLB + state: absent +- name: Delete public IP address + azure.azcollection.azure_rm_publicipaddress: + resource_group: '{{ resource_group }}' + state: absent + name: testPublicIP +- name: Delete virtual network + azure.azcollection.azure_rm_virtualnetwork: + resource_group: '{{ resource_group }}' + name: testVnet + state: absent + address_prefixes: 10.0.0.0/16 +- name: assert error thrown with invalid image dict + register: fail_invalid_image_dict + failed_when: 'fail_invalid_image_dict.msg != "parameter error: expecting image to contain [publisher, offer, sku, version], [name, resource_group] or [id]"' + azure.azcollection.azure_rm_virtualmachinescaleset: + resource_group: '{{ resource_group }}' + name: testvm002 + vm_size: Standard_B1s + image: + offer: UbuntuServer +- name: assert error thrown with invalid image type + register: fail_invalid_image_type + failed_when: 'fail_invalid_image_type.msg != "parameter error: expecting image to be a string or dict not list"' + azure.azcollection.azure_rm_virtualmachinescaleset: + resource_group: '{{ resource_group }}' + name: testvm002 + vm_size: Standard_B1s + image: + - testing +- name: assert error finding missing custom image + register: fail_missing_custom_image + failed_when: fail_missing_custom_image.msg != "Error could not find image with name invalid-image" + azure.azcollection.azure_rm_virtualmachinescaleset: + resource_group: '{{ resource_group }}' + name: testvm002 + vm_size: Standard_B1s + image: invalid-image +- name: assert error finding missing custom image (dict style) + register: fail_missing_custom_image_dict + failed_when: fail_missing_custom_image_dict.msg != "Error could not find image with name invalid-image" + azure.azcollection.azure_rm_virtualmachinescaleset: + resource_group: '{{ resource_group }}' + name: testvm002 + vm_size: Standard_B1s + image: + name: invalid-image diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_webapp/aliases b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_webapp/aliases new file mode 100644 index 00000000..fc534017 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_webapp/aliases @@ -0,0 +1,5 @@ +cloud/azure +shippable/azure/group1 +destructive +azure_rm_webapp_facts +azure_rm_webappslot diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_webapp/meta/main.yml b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_webapp/meta/main.yml new file mode 100644 index 00000000..95e1952f --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_webapp/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_azure diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_webapp/tasks/main.yml b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_webapp/tasks/main.yml new file mode 100644 index 00000000..af995af0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/azure_rm_webapp/tasks/main.yml @@ -0,0 +1,369 @@ +- name: Fix resource prefix + set_fact: + linux_app_plan_resource_group: '{{ resource_group_secondary }}' + win_app_name: '{{ (resource_prefix | replace(''-'',''x''))[-8:] }}{{ 1000 | random}}winapp' + win_plan_name: '{{ (resource_prefix | replace(''-'',''x''))[-8:] }}winplan' + linux_plan_name: '{{ (resource_group_secondary | replace(''-'',''x''))[-8:] }}linplan' + slot1_name: stage1 +- name: Create a windows web app with non-exist app service plan + azure.azcollection.azure_rm_webapp: + resource_group: '{{ resource_group }}' + name: '{{ win_app_name }}1' + plan: + resource_group: '{{ resource_group }}' + name: '{{ win_plan_name }}' + is_linux: false + sku: S1 +- name: Create a windows web app with existing app service plan + register: output + azure.azcollection.azure_rm_webapp: + resource_group: '{{ resource_group }}' + name: '{{ win_app_name }}2' + plan: '{{ win_plan_name }}' +- name: stop the web app + register: output + azure.azcollection.azure_rm_webapp: + resource_group: '{{ resource_group }}' + name: '{{ win_app_name }}2' + plan: '{{ win_plan_name }}' + app_state: stopped +- name: assert output changed + assert: + that: output.changed +- name: Create a windows web app with existing app service plan, try to update some root level params + register: output + azure.azcollection.azure_rm_webapp: + resource_group: '{{ resource_group }}' + name: '{{ win_app_name }}3' + plan: '{{ win_plan_name }}' + dns_registration: true + https_only: true + tags: + testwebapptag: test +- name: get web app with resource group and tag + azure_rm_webapp_facts: + resource_group: '{{ resource_group }}' + name: '{{ win_app_name }}3' + tags: + - testwebapptag + register: output +- assert: + that: + - output.webapps | length == 1 +- name: Create a win web app with java run time specific + register: output + azure.azcollection.azure_rm_webapp: + resource_group: '{{ resource_group }}' + name: '{{ win_app_name }}4' + plan: '{{ win_plan_name }}' + frameworks: + - name: java + version: '1.8' + settings: + java_container: Tomcat + java_container_version: '8.0' + app_settings: + testkey: testvalue +- name: assert the web app was created + assert: + that: output.changed +- name: get web app with name + azure_rm_webapp_facts: + resource_group: '{{ resource_group }}' + name: '{{ win_app_name }}4' + register: output +- assert: + that: + - output.webapps | length == 1 + - output.webapps[0].app_settings | length == 1 + - output.webapps[0].frameworks | length > 1 +- name: Update app settings and framework + register: output + azure.azcollection.azure_rm_webapp: + resource_group: '{{ resource_group }}' + name: '{{ win_app_name }}4' + plan: '{{ win_plan_name }}' + frameworks: + - name: java + version: '1.7' + settings: + java_container: Tomcat + java_container_version: '8.5' + app_settings: + testkey2: testvalue2 +- name: Assert the web app was updated + assert: + that: + - output.changed +- name: get web app with name + azure_rm_webapp_facts: + resource_group: '{{ resource_group }}' + name: '{{ win_app_name }}4' + register: output +- name: Assert updating + assert: + that: + - output.webapps[0].app_settings | length == 2 + - output.webapps[0].app_settings['testkey'] == 'testvalue' + - output.webapps[0].app_settings['testkey2'] == 'testvalue2' +- name: get web app with return publishing profile + azure_rm_webapp_facts: + resource_group: '{{ resource_group }}' + name: '{{ win_app_name }}4' + return_publish_profile: true + register: output +- assert: + that: + - output.webapps | length == 1 + - output.webapps[0].publishing_username != "" + - output.webapps[0].publishing_password != "" +- name: Purge all existing app settings + register: output + azure.azcollection.azure_rm_webapp: + resource_group: '{{ resource_group }}' + name: '{{ win_app_name }}4' + plan: '{{ win_plan_name }}' + purge_app_settings: true +- name: Assert the web app was updated + assert: + that: output.changed +- name: Create a win web app with python run time and php run time + register: output + azure.azcollection.azure_rm_webapp: + resource_group: '{{ resource_group }}' + name: '{{ win_app_name }}5' + plan: '{{ win_plan_name }}' + frameworks: + - name: python + version: '2.7' + - name: node + version: '6.6' + - name: php + version: '7.0' +- name: Assert the web app was created + assert: + that: output.changed +- name: Create a docker web app with some app settings + register: output + azure.azcollection.azure_rm_webapp: + resource_group: '{{ resource_group }}' + name: '{{ win_app_name }}6' + plan: + resource_group: '{{ linux_app_plan_resource_group }}' + name: '{{ linux_plan_name }}' + is_linux: true + sku: S1 + number_of_workers: 1 + container_settings: + name: ansible/ansible:ubuntu1404 +- name: Assert the web app was created + assert: + that: output.changed +- name: Create a docker web app with private acr registry + register: output + azure.azcollection.azure_rm_webapp: + resource_group: '{{ resource_group }}' + name: '{{ win_app_name }}7' + plan: + resource_group: '{{ linux_app_plan_resource_group }}' + name: '{{ linux_plan_name }}' + container_settings: + name: ansible/ansible:ubuntu1404 + registry_server_url: test.io + registry_server_user: user + registry_server_password: password +- name: Assert the web app was created + assert: + that: output.changed +- name: Create a linux web app with nodejs framework + register: output + azure.azcollection.azure_rm_webapp: + resource_group: '{{ resource_group }}' + name: '{{ win_app_name }}8' + plan: + resource_group: '{{ linux_app_plan_resource_group }}' + name: '{{ linux_plan_name }}' + frameworks: + - name: node + version: '6.6' +- name: Should be idempotent with linux web app created + register: output + azure.azcollection.azure_rm_webapp: + resource_group: '{{ resource_group }}' + name: '{{ win_app_name }}8' + plan: + resource_group: '{{ linux_app_plan_resource_group }}' + name: '{{ linux_plan_name }}' + frameworks: + - name: node + version: '6.6' +- assert: + that: not output.changed +- name: Update nodejs framework + register: output + azure.azcollection.azure_rm_webapp: + resource_group: '{{ resource_group }}' + name: '{{ win_app_name }}8' + plan: + resource_group: '{{ linux_app_plan_resource_group }}' + name: '{{ linux_plan_name }}' + frameworks: + - name: node + version: '6.9' +- name: Assert the web app was created + assert: + that: output.changed +- name: Create a linux web app with deployment source github + register: output + azure.azcollection.azure_rm_webapp: + resource_group: '{{ resource_group }}' + name: '{{ win_app_name }}10' + plan: + resource_group: '{{ linux_app_plan_resource_group }}' + name: '{{ linux_plan_name }}' + deployment_source: + url: https://github.com/test/test + branch: master + scm_type: GitHub +- name: Assert the web app was created + assert: + that: output.changed +- name: Delete web app + register: output + azure.azcollection.azure_rm_webapp: + resource_group: '{{ resource_group }}' + name: '{{ win_app_name }}8' + state: absent +- name: Assert the web app was deleted + assert: + that: output.changed +- name: assert error that java is mutually exclusive with frameworks + register: fail_win_java_version_mutual_exclusive + failed_when: fail_win_java_version_mutual_exclusive.msg != "Java is mutually exclusive with other frameworks." + azure.azcollection.azure_rm_webapp: + resource_group: '{{ resource_group }}' + name: '{{ win_app_name }}11' + plan: '{{ win_plan_name }}' + frameworks: + - name: python + version: '2.7' + - name: java + version: '1.8' +- name: assert error when linux web app, only can specify one framework + register: fail_linux_one_framework_only + failed_when: fail_linux_one_framework_only.msg != "Can specify one framework only for Linux web app." + azure.azcollection.azure_rm_webapp: + resource_group: '{{ resource_group }}' + name: '{{ linux_plan_name }}12' + plan: + resource_group: '{{ linux_app_plan_resource_group }}' + name: '{{ linux_plan_name }}' + frameworks: + - name: python + version: '2.7' + - name: node + version: '6.6' +- name: Create a linux web app with java tomcat container + register: output + azure.azcollection.azure_rm_webapp: + resource_group: '{{ resource_group }}' + name: '{{ win_app_name }}13' + plan: + resource_group: '{{ linux_app_plan_resource_group }}' + name: '{{ linux_plan_name }}' + frameworks: + - name: java + version: '8' + settings: + java_container: tomcat + java_container_version: '8.5' +- name: Assert the web app was created + assert: + that: output.changed +- name: Get facts with publish profile + azure_rm_webapp_facts: + resource_group: '{{ resource_group }}' + name: '{{ win_app_name }}13' + no_log: true + register: facts +- name: Assert publish profile returned + assert: + that: + - facts.webapps[0].ftp_publish_url != '' +- name: Create a webapp slot (Check mode) + check_mode: true + register: output + azure.azcollection.azure_rm_webappslot: + resource_group: '{{ resource_group }}' + webapp_name: '{{ win_app_name }}13' + name: '{{ slot1_name }}' + configuration_source: '{{ win_app_name }}13' + app_settings: + testkey: testvalue +- name: Assert slot check mode creation + assert: + that: + - output.changed +- name: Create a webapp slot + register: output + azure.azcollection.azure_rm_webappslot: + resource_group: '{{ resource_group }}' + webapp_name: '{{ win_app_name }}13' + name: '{{ slot1_name }}' + configuration_source: '{{ win_app_name }}13' + app_settings: + testkey: testvalueslot +- name: Assert slot creation + assert: + that: + - output.changed +- name: Update webapp slot (idempotence) + register: output + azure.azcollection.azure_rm_webappslot: + resource_group: '{{ resource_group }}' + webapp_name: '{{ win_app_name }}13' + name: '{{ slot1_name }}' + app_settings: + testkey: testvalueslot +- name: Assert idempotence + assert: + that: + - not output.changed +- name: Update webapp slot + register: output + azure.azcollection.azure_rm_webappslot: + resource_group: '{{ resource_group }}' + webapp_name: '{{ win_app_name }}13' + name: '{{ slot1_name }}' + frameworks: + - name: node + version: '10.1' + app_settings: + testkey: testvalue2 +- name: Assert updating + assert: + that: + - output.changed +- name: Swap webapp slot + register: output + azure.azcollection.azure_rm_webappslot: + resource_group: '{{ resource_group }}' + webapp_name: '{{ win_app_name }}13' + name: '{{ slot1_name }}' + swap: + action: swap +- name: Assert swap + assert: + that: + - output.changed +- name: Stop webapp slot + register: output + azure.azcollection.azure_rm_webappslot: + resource_group: '{{ resource_group }}' + webapp_name: '{{ win_app_name }}13' + name: '{{ slot1_name }}' + app_state: stopped +- name: Assert stopped + assert: + that: + - output.changed diff --git a/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/setup_azure/aliases b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/setup_azure/aliases new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/community/azure/tests/integration/targets/setup_azure/aliases |