summaryrefslogtreecommitdiffstats
path: root/ansible_collections/azure/azcollection/tests/integration/targets
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-18 05:52:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-18 05:52:35 +0000
commit7fec0b69a082aaeec72fee0612766aa42f6b1b4d (patch)
treeefb569b86ca4da888717f5433e757145fa322e08 /ansible_collections/azure/azcollection/tests/integration/targets
parentReleasing progress-linux version 7.7.0+dfsg-3~progress7.99u1. (diff)
downloadansible-7fec0b69a082aaeec72fee0612766aa42f6b1b4d.tar.xz
ansible-7fec0b69a082aaeec72fee0612766aa42f6b1b4d.zip
Merging upstream version 9.4.0+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/azure/azcollection/tests/integration/targets')
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_account_info/tasks/main.yml3
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_acs/tasks/main.yml280
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_adapplication/tasks/main.yml42
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_adgroup/tasks/main.yml165
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_adpassword/tasks/main.yml54
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_adserviceprincipal/tasks/main.yml44
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_aduser/tasks/main.yml64
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_aks/tasks/main.yml1150
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_aks/tasks/minimal-cluster.yml27
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_aksagentpool/tasks/main.yml28
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_apimanagement/tasks/main.yml59
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_apimanagementservice/meta/main.yml2
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_apimanagementservice/tasks/main.yml26
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_appgateway/tasks/main.yml600
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_appserviceplan/tasks/main.yml60
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_automationaccount/tasks/main.yml95
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_automationrunbook/tasks/main.yml50
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_autoscale/tasks/main.yml185
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_availabilityset/tasks/main.yml71
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_azurefirewall/tasks/main.yml61
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_backupazurevm/meta/main.yml2
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_backupazurevm/tasks/main.yml16
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_backuppolicy/tasks/main.yml20
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_bastionhost/tasks/main.yml86
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_batchaccount/tasks/main.yml76
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_cdnprofile/tasks/main.yml257
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_cognitivesearch/tasks/main.yml47
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_containerinstance/tasks/main.yml56
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_containerregistry/tasks/main.yml212
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_containerregistrytag/tasks/main.yml56
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_cosmosdbaccount/tasks/main.yml68
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_datafactory/tasks/main.yml35
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_datalakestore/tasks/main.yml38
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_ddosprotectionplan/meta/main.yml2
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_ddosprotectionplan/tasks/main.yml27
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_deployment/tasks/main.yml14
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_devtestlab/tasks/main.yml44
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_diskencryptionset/lookup_plugins/azure_service_principal_attribute.py6
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_diskencryptionset/tasks/main.yml32
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_dnsrecordset/tasks/main.yml58
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_dnszone/tasks/main.yml99
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_eventhub/tasks/main.yml58
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_expressroute/tasks/main.yml31
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_firewallpolicy/tasks/main.yml15
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_functionapp/tasks/main.yml62
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_gallery/tasks/main.yml115
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_hdinsightcluster/tasks/main.yml52
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_hostgroup/tasks/main.yml15
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_image/tasks/main.yml209
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_iothub/aliases1
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_iothub/tasks/main.yml210
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_ipgroup/tasks/main.yml17
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_keyvault/lookup_plugins/azure_service_principal_attribute.py6
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_keyvault/tasks/main.yml70
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_keyvaultkey/lookup_plugins/azure_service_principal_attribute.py6
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_keyvaultkey/tasks/main.yml78
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_keyvaultsecret/lookup_plugins/azure_service_principal_attribute.py6
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_keyvaultsecret/tasks/main.yml32
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_loadbalancer/tasks/main.yml138
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_loganalyticsworkspace/tasks/main.yml68
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_manageddisk/tasks/main.yml528
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_managementgroup/tasks/main.yml16
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_mariadbserver/tasks/main.yml119
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_monitordiagnosticsetting/tasks/main.yml158
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_monitorlogprofile/tasks/main.yml58
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_multiplemanageddisks/tasks/main.yml6
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_multiplemanageddisks/tasks/test_async.yml47
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_multiplemanageddisks/tasks/test_shared.yml85
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_mysqlserver/tasks/main.yml123
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_natgateway/tasks/main.yml68
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_networkinterface/tasks/main.yml549
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_notificationhub/tasks/main.yml62
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_openshiftmanagedcluster/tasks/main.yml49
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_postgresqlserver/tasks/main.yml113
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_privatednsrecordset/tasks/main.yml61
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_privatednszone/tasks/main.yml21
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_privatednszonelink/tasks/main.yml29
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_privateendpoint/tasks/main.yml25
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_privateendpointdnszonegroup/tasks/main.yml24
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_privatelinkservice/tasks/main.yml92
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_proximityplacementgroup/tasks/main.yml15
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_publicipaddress/tasks/main.yml169
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_recoveryservicesvault/tasks/main.yml22
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_rediscache/tasks/main.yml642
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_registrationassignment/tasks/main.yml33
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_registrationdefinition/tasks/main.yml40
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_resource/tasks/main.yml28
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_resourcegroup/tasks/main.yml49
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_roleassignment/tasks/main.yml62
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_roledefinition/tasks/main.yml96
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_routetable/tasks/main.yml92
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_securitygroup/tasks/main.yml74
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_servicebus/tasks/main.yml226
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_sqlmanagedinstance/tasks/main.yml14
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_sqlserver/tasks/main.yml130
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_storageaccount/tasks/main.yml88
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_storageblob/tasks/main.yml63
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_storageshare/tasks/main.yml22
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_subnet/tasks/main.yml57
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_subscription/tasks/main.yml8
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_trafficmanagerprofile/tasks/main.yml204
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualhub/tasks/main.yml37
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualhubconnection/tasks/main.yml325
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/inventory.yml4
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/main.yml7
-rwxr-xr-x[-rw-r--r--]ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/runme.sh0
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_deallocate.yml24
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_dual_nic.yml30
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_ephemeral_os.yml34
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_image_latest.yml23
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_image_specific.yml17
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_invalid.yml2
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_minimal.yml17
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_minimal_manageddisk.yml7
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_no_nsg.yml13
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_no_public_ip.yml21
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_public_ip.yml95
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_spot.yml9
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_vm_identity.yml209
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/setup.yml3
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachineextension/tasks/main.yml26
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachineimage_info/tasks/main.yml29
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachinescaleset/tasks/main.yml243
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachinesize_info/meta/main.yml2
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachinesize_info/tasks/main.yml14
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualnetwork/tasks/main.yml57
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualnetworkgateway/tasks/main.yml249
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualnetworkpeering/tasks/main.yml23
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualwan/tasks/main.yml126
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_vmbackuppolicy/tasks/main.yml26
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_vpnsite/tasks/main.yml200
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_webapp/tasks/main.yml118
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_webappaccessrestriction/tasks/main.yml26
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_webappvnetconnection/tasks/main.yml18
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_workspace/tasks/main.yml150
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/inventory_azure/playbooks/create_inventory_config.yml10
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/inventory_azure/playbooks/empty_inventory_config.yml10
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/inventory_azure/playbooks/setup.yml83
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/inventory_azure/playbooks/teardown.yml64
-rw-r--r--ansible_collections/azure/azcollection/tests/integration/targets/inventory_azure/playbooks/test_inventory.yml24
-rwxr-xr-x[-rw-r--r--]ansible_collections/azure/azcollection/tests/integration/targets/inventory_azure/runme.sh0
141 files changed, 6455 insertions, 5793 deletions
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_account_info/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_account_info/tasks/main.yml
index 5c010972f..ddc52368e 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_account_info/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_account_info/tasks/main.yml
@@ -2,7 +2,8 @@
azure.azcollection.azure_rm_account_info:
register: result
-- assert:
+- name: Assert the facts
+ ansible.builtin.assert:
that:
- result is not changed
- result is not failed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_acs/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_acs/tasks/main.yml
index a35871c09..a2f3fdafa 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_acs/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_acs/tasks/main.yml
@@ -1,149 +1,149 @@
- - name: Create an ACS instance - DCOS
- azure_rm_acs:
- name: "acsdcos{{ resource_group | hash('md5') | truncate(7, True, '') }}"
- resource_group: "{{ resource_group }}"
- location: eastus
- orchestration_platform: DCOS
- master_profile:
- - count: 1
- dns_prefix: "acsdcos{{ resource_group | hash('md5') | truncate(10, True, '') }}"
- vm_size: Standard_A0
- linux_profile:
- - admin_username: azureuser
- ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCqaZoyiz1qbdOQ8xEf6uEu1cCwYowo5FHtsBhqLoDnnp7KUTEBN+io238wdhjkasndq238e2/983289dasjnasey823/YkUCuzxDpsH7DUDhZcwySLKVVe0Qm3+928dfsjsejk298r/+vAnflKebuypNlmocIvakFWoZda18FOmsOoIVXQ8HWFNCuw9ZCunMSN62QGamCe3dL5cXlkgHYv7ekJE15IA9aOJcM7e90oeTqo+dsajda82e78sdja/llas8tsXY85LFqRnr3gJ02bAscjc477+X+j/gkpFoN1QEmt juliens@msft.com
- agent_pool_profiles:
- - name: default
- count: 1
- dns_prefix: "acsdcos{{ resource_group | hash('md5') | truncate(12, True, '') }}"
- vm_size: Standard_A0
- diagnostics_profile: false
- register: output
+- name: Create an ACS instance - DCOS
+ azure_rm_acs:
+ name: "acsdcos{{ resource_group | hash('md5') | truncate(7, True, '') }}"
+ resource_group: "{{ resource_group }}"
+ location: eastus
+ orchestration_platform: DCOS
+ master_profile:
+ - count: 1
+ dns_prefix: "acsdcos{{ resource_group | hash('md5') | truncate(10, True, '') }}"
+ vm_size: Standard_A0
+ linux_profile:
+ - admin_username: azureuser
+ ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCqaZoyiz1qbdOQ8xEf6uEu1cCwYowo5FHtsBhqLoDnnp7KUTEBN+io238wdhjkasndq238e2/983289dasjnasey823/YkUCuzxDpsH7DUDhZcwySLKVVe0Qm3+928dfsjsejk298r/+vAnflKebuypNlmocIvakFWoZda18FOmsOoIVXQ8HWFNCuw9ZCunMSN62QGamCe3dL5cXlkgHYv7ekJE15IA9aOJcM7e90oeTqo+dsajda82e78sdja/llas8tsXY85LFqRnr3gJ02bAscjc477+X+j/gkpFoN1QEmt juliens@msft.com
+ agent_pool_profiles:
+ - name: default
+ count: 1
+ dns_prefix: "acsdcos{{ resource_group | hash('md5') | truncate(12, True, '') }}"
+ vm_size: Standard_A0
+ diagnostics_profile: false
+ register: output
- - name: Assert the ACS instance is well created
- assert:
- that:
- - output.changed
- - output.state.provisioning_state == 'Succeeded'
+- name: Assert the ACS instance is well created
+ ansible.builtin.assert:
+ that:
+ - output.changed
+ - output.state.provisioning_state == 'Succeeded'
- - name: Scale the ACS instance from 1 to 2 - DCOS
- azure_rm_acs:
- name: "acsdcos{{ resource_group | hash('md5') | truncate(7, True, '') }}"
- resource_group: "{{ resource_group }}"
- location: eastus
- orchestration_platform: DCOS
- master_profile:
- - count: 1
- dns_prefix: "acsdcos{{ resource_group | hash('md5') | truncate(10, True, '') }}"
- vm_size: Standard_A0
- linux_profile:
- - admin_username: azureuser
- ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCqaZoyiz1qbdOQ8xEf6uEu1cCwYowo5FHtsBhqLoDnnp7KUTEBN+io238wdhjkasndq238e2/983289dasjnasey823/YkUCuzxDpsH7DUDhZcwySLKVVe0Qm3+928dfsjsejk298r/+vAnflKebuypNlmocIvakFWoZda18FOmsOoIVXQ8HWFNCuw9ZCunMSN62QGamCe3dL5cXlkgHYv7ekJE15IA9aOJcM7e90oeTqo+dsajda82e78sdja/llas8tsXY85LFqRnr3gJ02bAscjc477+X+j/gkpFoN1QEmt juliens@msft.com
- agent_pool_profiles:
- - name: default
- count: 2
- dns_prefix: "acsdcos{{ resource_group | hash('md5') | truncate(12, True, '') }}"
- vm_size: Standard_A0
- diagnostics_profile: false
- register: output
+- name: Scale the ACS instance from 1 to 2 - DCOS
+ azure_rm_acs:
+ name: "acsdcos{{ resource_group | hash('md5') | truncate(7, True, '') }}"
+ resource_group: "{{ resource_group }}"
+ location: eastus
+ orchestration_platform: DCOS
+ master_profile:
+ - count: 1
+ dns_prefix: "acsdcos{{ resource_group | hash('md5') | truncate(10, True, '') }}"
+ vm_size: Standard_A0
+ linux_profile:
+ - admin_username: azureuser
+ ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCqaZoyiz1qbdOQ8xEf6uEu1cCwYowo5FHtsBhqLoDnnp7KUTEBN+io238wdhjkasndq238e2/983289dasjnasey823/YkUCuzxDpsH7DUDhZcwySLKVVe0Qm3+928dfsjsejk298r/+vAnflKebuypNlmocIvakFWoZda18FOmsOoIVXQ8HWFNCuw9ZCunMSN62QGamCe3dL5cXlkgHYv7ekJE15IA9aOJcM7e90oeTqo+dsajda82e78sdja/llas8tsXY85LFqRnr3gJ02bAscjc477+X+j/gkpFoN1QEmt juliens@msft.com
+ agent_pool_profiles:
+ - name: default
+ count: 2
+ dns_prefix: "acsdcos{{ resource_group | hash('md5') | truncate(12, True, '') }}"
+ vm_size: Standard_A0
+ diagnostics_profile: false
+ register: output
- - name: Assert the ACS instance is well scaled
- assert:
- that:
- - output.changed
- - output.state.agent_pool_profiles[0].count == 2
+- name: Assert the ACS instance is well scaled
+ ansible.builtin.assert:
+ that:
+ - output.changed
+ - output.state.agent_pool_profiles[0].count == 2
- - name: Delete the DCOS ACS instance - DCOS
- azure_rm_acs:
- name: "acsdcos{{ resource_group | hash('md5') | truncate(7, True, '') }}"
- resource_group: "{{ resource_group }}"
- location: eastus
- orchestration_platform: DCOS
- state: absent
- master_profile:
- - count: 1
- dns_prefix: "acsdcos{{ resource_group | hash('md5') | truncate(10, True, '') }}"
- vm_size: Standard_A0
- linux_profile:
- - admin_username: azureuser
- ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCqaZoyiz1qbdOQ8xEf6uEu1cCwYowo5FHtsBhqLoDnnp7KUTEBN+io238wdhjkasndq238e2/983289dasjnasey823/YkUCuzxDpsH7DUDhZcwySLKVVe0Qm3+928dfsjsejk298r/+vAnflKebuypNlmocIvakFWoZda18FOmsOoIVXQ8HWFNCuw9ZCunMSN62QGamCe3dL5cXlkgHYv7ekJE15IA9aOJcM7e90oeTqo+dsajda82e78sdja/llas8tsXY85LFqRnr3gJ02bAscjc477+X+j/gkpFoN1QEmt juliens@msft.com
- agent_pool_profiles:
- - name: default
- count: 2
- dns_prefix: "acsdcos{{ resource_group | hash('md5') | truncate(12, True, '') }}"
- vm_size: Standard_A0
- diagnostics_profile: false
+- name: Delete the DCOS ACS instance - DCOS
+ azure_rm_acs:
+ name: "acsdcos{{ resource_group | hash('md5') | truncate(7, True, '') }}"
+ resource_group: "{{ resource_group }}"
+ location: eastus
+ orchestration_platform: DCOS
+ state: absent
+ master_profile:
+ - count: 1
+ dns_prefix: "acsdcos{{ resource_group | hash('md5') | truncate(10, True, '') }}"
+ vm_size: Standard_A0
+ linux_profile:
+ - admin_username: azureuser
+ ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCqaZoyiz1qbdOQ8xEf6uEu1cCwYowo5FHtsBhqLoDnnp7KUTEBN+io238wdhjkasndq238e2/983289dasjnasey823/YkUCuzxDpsH7DUDhZcwySLKVVe0Qm3+928dfsjsejk298r/+vAnflKebuypNlmocIvakFWoZda18FOmsOoIVXQ8HWFNCuw9ZCunMSN62QGamCe3dL5cXlkgHYv7ekJE15IA9aOJcM7e90oeTqo+dsajda82e78sdja/llas8tsXY85LFqRnr3gJ02bAscjc477+X+j/gkpFoN1QEmt juliens@msft.com
+ agent_pool_profiles:
+ - name: default
+ count: 2
+ dns_prefix: "acsdcos{{ resource_group | hash('md5') | truncate(12, True, '') }}"
+ vm_size: Standard_A0
+ diagnostics_profile: false
- - name: Create an ACS instance - Swarm
- azure_rm_acs:
- name: "acssw{{ resource_group | hash('md5') | truncate(7, True, '') }}"
- resource_group: "{{ resource_group }}"
- location: eastus
- orchestration_platform: Swarm
- master_profile:
- - count: 1
- dns_prefix: "acssw{{ resource_group | hash('md5') | truncate(10, True, '') }}"
- vm_size: Standard_A0
- linux_profile:
- - admin_username: azureuser
- ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCqaZoyiz1qbdOQ8xEf6uEu1cCwYowo5FHtsBhqLoDnnp7KUTEBN+io238wdhjkasndq238e2/983289dasjnasey823/YkUCuzxDpsH7DUDhZcwySLKVVe0Qm3+928dfsjsejk298r/+vAnflKebuypNlmocIvakFWoZda18FOmsOoIVXQ8HWFNCuw9ZCunMSN62QGamCe3dL5cXlkgHYv7ekJE15IA9aOJcM7e90oeTqo+dsajda82e78sdja/llas8tsXY85LFqRnr3gJ02bAscjc477+X+j/gkpFoN1QEmt juliens@msft.com
- agent_pool_profiles:
- - name: default
- count: 1
- dns_prefix: "acssw{{ resource_group | hash('md5') | truncate(12, True, '') }}"
- vm_size: Standard_A0
- diagnostics_profile: false
- register: output
+- name: Create an ACS instance - Swarm
+ azure_rm_acs:
+ name: "acssw{{ resource_group | hash('md5') | truncate(7, True, '') }}"
+ resource_group: "{{ resource_group }}"
+ location: eastus
+ orchestration_platform: Swarm
+ master_profile:
+ - count: 1
+ dns_prefix: "acssw{{ resource_group | hash('md5') | truncate(10, True, '') }}"
+ vm_size: Standard_A0
+ linux_profile:
+ - admin_username: azureuser
+ ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCqaZoyiz1qbdOQ8xEf6uEu1cCwYowo5FHtsBhqLoDnnp7KUTEBN+io238wdhjkasndq238e2/983289dasjnasey823/YkUCuzxDpsH7DUDhZcwySLKVVe0Qm3+928dfsjsejk298r/+vAnflKebuypNlmocIvakFWoZda18FOmsOoIVXQ8HWFNCuw9ZCunMSN62QGamCe3dL5cXlkgHYv7ekJE15IA9aOJcM7e90oeTqo+dsajda82e78sdja/llas8tsXY85LFqRnr3gJ02bAscjc477+X+j/gkpFoN1QEmt juliens@msft.com
+ agent_pool_profiles:
+ - name: default
+ count: 1
+ dns_prefix: "acssw{{ resource_group | hash('md5') | truncate(12, True, '') }}"
+ vm_size: Standard_A0
+ diagnostics_profile: false
+ register: output
- - name: Assert the ACS instance is well created
- assert:
- that:
- - output.changed
- - output.state.provisioning_state == 'Succeeded'
+- name: Assert the ACS instance is well created
+ ansible.builtin.assert:
+ that:
+ - output.changed
+ - output.state.provisioning_state == 'Succeeded'
- - name: Scale the ACS instance from 1 to 2 - Swarm
- azure_rm_acs:
- name: "acssw{{ resource_group | hash('md5') | truncate(7, True, '') }}"
- resource_group: "{{ resource_group }}"
- location: eastus
- orchestration_platform: Swarm
- master_profile:
- - count: 1
- dns_prefix: "acssw{{ resource_group | hash('md5') | truncate(10, True, '') }}"
- vm_size: Standard_A0
- linux_profile:
- - admin_username: azureuser
- ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCqaZoyiz1qbdOQ8xEf6uEu1cCwYowo5FHtsBhqLoDnnp7KUTEBN+io238wdhjkasndq238e2/983289dasjnasey823/YkUCuzxDpsH7DUDhZcwySLKVVe0Qm3+928dfsjsejk298r/+vAnflKebuypNlmocIvakFWoZda18FOmsOoIVXQ8HWFNCuw9ZCunMSN62QGamCe3dL5cXlkgHYv7ekJE15IA9aOJcM7e90oeTqo+dsajda82e78sdja/llas8tsXY85LFqRnr3gJ02bAscjc477+X+j/gkpFoN1QEmt juliens@msft.com
- agent_pool_profiles:
- - name: default
- count: 2
- dns_prefix: "acssw{{ resource_group | hash('md5') | truncate(12, True, '') }}"
- vm_size: Standard_A0
- diagnostics_profile: false
- register: output
+- name: Scale the ACS instance from 1 to 2 - Swarm
+ azure_rm_acs:
+ name: "acssw{{ resource_group | hash('md5') | truncate(7, True, '') }}"
+ resource_group: "{{ resource_group }}"
+ location: eastus
+ orchestration_platform: Swarm
+ master_profile:
+ - count: 1
+ dns_prefix: "acssw{{ resource_group | hash('md5') | truncate(10, True, '') }}"
+ vm_size: Standard_A0
+ linux_profile:
+ - admin_username: azureuser
+ ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCqaZoyiz1qbdOQ8xEf6uEu1cCwYowo5FHtsBhqLoDnnp7KUTEBN+io238wdhjkasndq238e2/983289dasjnasey823/YkUCuzxDpsH7DUDhZcwySLKVVe0Qm3+928dfsjsejk298r/+vAnflKebuypNlmocIvakFWoZda18FOmsOoIVXQ8HWFNCuw9ZCunMSN62QGamCe3dL5cXlkgHYv7ekJE15IA9aOJcM7e90oeTqo+dsajda82e78sdja/llas8tsXY85LFqRnr3gJ02bAscjc477+X+j/gkpFoN1QEmt juliens@msft.com
+ agent_pool_profiles:
+ - name: default
+ count: 2
+ dns_prefix: "acssw{{ resource_group | hash('md5') | truncate(12, True, '') }}"
+ vm_size: Standard_A0
+ diagnostics_profile: false
+ register: output
- - name: Assert the ACS instance is well scaled
- assert:
- that:
- - output.changed
- - output.state.agent_pool_profiles[0].count == 2
+- name: Assert the ACS instance is well scaled
+ ansible.builtin.assert:
+ that:
+ - output.changed
+ - output.state.agent_pool_profiles[0].count == 2
- - name: Delete the ACS instance - Swarm
- azure_rm_acs:
- name: "acssw{{ resource_group | hash('md5') | truncate(7, True, '') }}"
- resource_group: "{{ resource_group }}"
- location: eastus
- orchestration_platform: Swarm
- state: absent
- master_profile:
- - count: 1
- dns_prefix: "acssw{{ resource_group | hash('md5') | truncate(10, True, '') }}"
- vm_size: Standard_A0
- linux_profile:
- - admin_username: azureuser
- ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCqaZoyiz1qbdOQ8xEf6uEu1cCwYowo5FHtsBhqLoDnnp7KUTEBN+io238wdhjkasndq238e2/983289dasjnasey823/YkUCuzxDpsH7DUDhZcwySLKVVe0Qm3+928dfsjsejk298r/+vAnflKebuypNlmocIvakFWoZda18FOmsOoIVXQ8HWFNCuw9ZCunMSN62QGamCe3dL5cXlkgHYv7ekJE15IA9aOJcM7e90oeTqo+dsajda82e78sdja/llas8tsXY85LFqRnr3gJ02bAscjc477+X+j/gkpFoN1QEmt juliens@msft.com
- agent_pool_profiles:
- - name: default
- count: 2
- dns_prefix: "acssw{{ resource_group | hash('md5') | truncate(12, True, '') }}"
- vm_size: Standard_A0
- diagnostics_profile: false \ No newline at end of file
+- name: Delete the ACS instance - Swarm
+ azure_rm_acs:
+ name: "acssw{{ resource_group | hash('md5') | truncate(7, True, '') }}"
+ resource_group: "{{ resource_group }}"
+ location: eastus
+ orchestration_platform: Swarm
+ state: absent
+ master_profile:
+ - count: 1
+ dns_prefix: "acssw{{ resource_group | hash('md5') | truncate(10, True, '') }}"
+ vm_size: Standard_A0
+ linux_profile:
+ - admin_username: azureuser
+ ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCqaZoyiz1qbdOQ8xEf6uEu1cCwYowo5FHtsBhqLoDnnp7KUTEBN+io238wdhjkasndq238e2/983289dasjnasey823/YkUCuzxDpsH7DUDhZcwySLKVVe0Qm3+928dfsjsejk298r/+vAnflKebuypNlmocIvakFWoZda18FOmsOoIVXQ8HWFNCuw9ZCunMSN62QGamCe3dL5cXlkgHYv7ekJE15IA9aOJcM7e90oeTqo+dsajda82e78sdja/llas8tsXY85LFqRnr3gJ02bAscjc477+X+j/gkpFoN1QEmt juliens@msft.com
+ agent_pool_profiles:
+ - name: default
+ count: 2
+ dns_prefix: "acssw{{ resource_group | hash('md5') | truncate(12, True, '') }}"
+ vm_size: Standard_A0
+ diagnostics_profile: false
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_adapplication/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_adapplication/tasks/main.yml
index c8dfcb2b7..99813a48d 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_adapplication/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_adapplication/tasks/main.yml
@@ -1,7 +1,8 @@
-- set_fact:
+- name: Set variables
+ ansible.builtin.set_fact:
tenant_id: "{{ azure_tenant }}"
display_name: "app{{ resource_group | hash('sha1') | truncate(20, True, '') }}"
- run_once: yes
+ run_once: true
- name: Create application
azure_rm_adapplication:
@@ -9,23 +10,25 @@
display_name: "{{ display_name }}"
register: create_output
-- assert:
+- name: Assert create successfully
+ ansible.builtin.assert:
that: create_output.changed
-- name: Create application again (idempotent test)
+- name: Create application again idempotent test
azure_rm_adapplication:
tenant: "{{ tenant_id }}"
app_id: "{{ create_output.app_id }}"
register: output
-- assert:
+- name: Assert the idempotent success
+ ansible.builtin.assert:
that: not output.changed
- name: Create application with more parameter
azure_rm_adapplication:
tenant: "{{ tenant_id }}"
display_name: "{{ display_name }}-01"
- available_to_other_tenants: False
+ available_to_other_tenants: false
credential_description: "for test"
end_date: 2021-10-01
start_date: 2021-05-18
@@ -36,56 +39,61 @@
- User
description: "for app role test"
display_name: "{{ display_name }}_approle"
- is_enabled: True
+ is_enabled: true
value: Password@0329
register: second_output
-- assert:
+- name: Assert secondary resource create success
+ ansible.builtin.assert:
that: second_output.changed
-- name: get ad app info ---- by object ID
+- name: Get ad app info by object id
azure_rm_adapplication_info:
object_id: "{{ create_output.object_id }}"
tenant: "{{ tenant_id }}"
register: output
-- name: get ad app info ---- by app ID
+- name: Get ad app info by app id
azure_rm_adapplication_info:
app_id: "{{ create_output.app_id }}"
tenant: "{{ tenant_id }}"
register: output
-- assert:
+- name: Assert the application facts
+ ansible.builtin.assert:
that:
- output.applications[0].app_display_name == "{{ display_name }}"
- output.applications | length == 1
-- name: delete ad app by app id
+- name: Delete ad app by app id
azure_rm_adapplication:
app_id: "{{ create_output.app_id }}"
tenant: "{{ tenant_id }}"
state: absent
register: output
-- assert:
+- name: Assert the application delete success
+ ansible.builtin.assert:
that: output.changed
-- name: delete ad app by app id
+- name: Delete ad app by app id
azure_rm_adapplication:
app_id: "{{ second_output.app_id }}"
tenant: "{{ tenant_id }}"
state: absent
register: output
-- assert:
+- name: Assert the secondary application delete success
+ ansible.builtin.assert:
that: output.changed
-- name: get ad app info ---- by app id
+- name: Get ad app info by app id
azure_rm_adapplication_info:
app_id: "{{ create_output.app_id }}"
tenant: "{{ tenant_id }}"
register: output
-- assert:
+- name: Assert there is no application
+ ansible.builtin.assert:
that:
- output.applications | length == 0
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_adgroup/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_adgroup/tasks/main.yml
index 09b3f686e..b10580e65 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_adgroup/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_adgroup/tasks/main.yml
@@ -1,16 +1,17 @@
-- set_fact:
+- name: Set variables
+ ansible.builtin.set_fact:
tenant_id: "{{ azure_tenant }}"
resource_prefix: "{{ 999999999999999999994 | random | to_uuid }}"
- run_once: yes
+ run_once: true
- name: Try to return non-existent group using display name
azure_rm_adgroup_info:
attribute_name: "displayName"
attribute_value: "{{ resource_prefix }}-Group-Root"
tenant: "{{ tenant_id }}"
- register: get_nonexistent_group_display_name_ShouldFail
+ register: get_nonexistent_group_display_name_shouldfail
failed_when:
- - get_nonexistent_group_display_name_ShouldFail.ad_groups != []
+ - get_nonexistent_group_display_name_shouldfail.ad_groups != []
- name: Create Group Root
azure_rm_adgroup:
@@ -18,7 +19,7 @@
display_name: "{{ resource_prefix }}-Group-Root"
mail_nickname: "{{ resource_prefix }}-Group-Root"
state: 'present'
- register: group_create_changed_ShouldPass
+ register: group_create_changed_shouldpass
- name: Create Group Should Return Not Changed
azure_rm_adgroup:
@@ -26,29 +27,29 @@
display_name: "{{ resource_prefix }}-Group-Root"
mail_nickname: "{{ resource_prefix }}-Group-Root"
state: 'present'
- register: group_create_unchanged_ShouldPass
+ register: group_create_unchanged_shouldpass
- name: Assert Otherwise Changed Returns are Equal
- assert:
+ ansible.builtin.assert:
that:
- - group_create_changed_ShouldPass.changed == True
- - group_create_unchanged_ShouldPass.changed == False
- - group_create_changed_ShouldPass.display_name == group_create_unchanged_ShouldPass.display_name
- - group_create_changed_ShouldPass.mail_enabled == group_create_unchanged_ShouldPass.mail_enabled
- - group_create_changed_ShouldPass.mail_nickname == group_create_unchanged_ShouldPass.mail_nickname
- - group_create_changed_ShouldPass.object_id == group_create_unchanged_ShouldPass.object_id
- - group_create_changed_ShouldPass.security_enabled == group_create_unchanged_ShouldPass.security_enabled
+ - group_create_changed_shouldpass.changed == True
+ - group_create_unchanged_shouldpass.changed == False
+ - group_create_changed_shouldpass.display_name == group_create_unchanged_shouldpass.display_name
+ - group_create_changed_shouldpass.mail_enabled == group_create_unchanged_shouldpass.mail_enabled
+ - group_create_changed_shouldpass.mail_nickname == group_create_unchanged_shouldpass.mail_nickname
+ - group_create_changed_shouldpass.object_id == group_create_unchanged_shouldpass.object_id
+ - group_create_changed_shouldpass.security_enabled == group_create_unchanged_shouldpass.security_enabled
- name: Return previously created group using object_id
azure_rm_adgroup_info:
- object_id: "{{ group_create_unchanged_ShouldPass.object_id }}"
+ object_id: "{{ group_create_unchanged_shouldpass.object_id }}"
tenant: "{{ tenant_id }}"
- register: get_created_object_id_ShouldPass
+ register: get_created_object_id_shouldpass
- name: Assert Returns are Equal to Created Group
- assert:
+ ansible.builtin.assert:
that:
- - get_created_object_id_ShouldPass.ad_groups[0].object_id == group_create_unchanged_ShouldPass.object_id
+ - get_created_object_id_shouldpass.ad_groups[0].object_id == group_create_unchanged_shouldpass.object_id
- name: Create Group Member 1
azure_rm_adgroup:
@@ -56,7 +57,7 @@
display_name: "{{ resource_prefix }}-Group-Member-1"
mail_nickname: "{{ resource_prefix }}-Group-Member-1"
state: 'present'
- register: create_group_member_1_ShouldPass
+ register: create_pass_first
- name: Create Group Member 2
azure_rm_adgroup:
@@ -64,7 +65,7 @@
display_name: "{{ resource_prefix }}-Group-Member-2"
mail_nickname: "{{ resource_prefix }}-Group-Member-2"
state: 'present'
- register: create_group_member_2_ShouldPass
+ register: create_pass_second
- name: Ensure member is in group using display_name and mail_nickname
azure_rm_adgroup:
@@ -73,44 +74,44 @@
mail_nickname: "{{ resource_prefix }}-Group-Root"
state: 'present'
present_members:
- - "https://graph.windows.net/{{ tenant_id }}/directoryObjects/{{ create_group_member_1_ShouldPass.object_id }}"
- - "https://graph.windows.net/{{ tenant_id }}/directoryObjects/{{ create_group_member_2_ShouldPass.object_id }}"
- register: add_members_to_group_ShouldPass
+ - "https://graph.windows.net/{{ tenant_id }}/directoryObjects/{{ create_pass_first.object_id }}"
+ - "https://graph.windows.net/{{ tenant_id }}/directoryObjects/{{ create_pass_second.object_id }}"
+ register: add_pass
- name: Validate members are in the group
- assert:
+ ansible.builtin.assert:
that:
- - add_members_to_group_ShouldPass.group_members[0].object_id == create_group_member_1_ShouldPass.object_id or add_members_to_group_ShouldPass.group_members[1].object_id == create_group_member_1_ShouldPass.object_id
- - add_members_to_group_ShouldPass.group_members[1].object_id == create_group_member_2_ShouldPass.object_id or add_members_to_group_ShouldPass.group_members[0].object_id == create_group_member_2_ShouldPass.object_id
+ - add_pass.group_members[0].object_id == create_pass_first.object_id or add_pass.group_members[1].object_id == create_pass_first.object_id
+ - add_pass.group_members[1].object_id == create_pass_second.object_id or add_pass.group_members[0].object_id == create_pass_second.object_id
- name: Ensure member is in group that is already present using object_id
azure_rm_adgroup:
tenant: "{{ tenant_id }}"
- object_id: "{{ group_create_changed_ShouldPass.object_id }}"
+ object_id: "{{ group_create_changed_shouldpass.object_id }}"
state: 'present'
present_members:
- - "https://graph.windows.net/{{ tenant_id }}/directoryObjects/{{ create_group_member_1_ShouldPass.object_id }}"
- register: add_already_present_member_to_group_ShouldPass
+ - "https://graph.windows.net/{{ tenant_id }}/directoryObjects/{{ create_pass_first.object_id }}"
+ register: add_already_present_member_to_group_shouldpass
- name: Validate nothing changed from already present member
- assert:
+ ansible.builtin.assert:
that:
- - add_already_present_member_to_group_ShouldPass.changed == false
+ - add_already_present_member_to_group_shouldpass.changed == false
- name: Ensure member is not in group using object_id
azure_rm_adgroup:
tenant: "{{ tenant_id }}"
- object_id: "{{ group_create_changed_ShouldPass.object_id }}"
+ object_id: "{{ group_create_changed_shouldpass.object_id }}"
state: 'present'
absent_members:
- - "{{ create_group_member_2_ShouldPass.object_id }}"
- register: remove_member_from_group_ShouldPass
+ - "{{ create_pass_second.object_id }}"
+ register: remove_member_from_group_shouldpass
- name: Validate Group Member 1 is in the group and Group Member 2 is not
- assert:
+ ansible.builtin.assert:
that:
- - remove_member_from_group_ShouldPass.group_members[0].object_id == create_group_member_1_ShouldPass.object_id
- - remove_member_from_group_ShouldPass.group_members | length == 1
+ - remove_member_from_group_shouldpass.group_members[0].object_id == create_pass_first.object_id
+ - remove_member_from_group_shouldpass.group_members | length == 1
- name: Ensure member is not in group that is already not in group using display_name and mail_nickname
azure_rm_adgroup:
@@ -119,121 +120,121 @@
mail_nickname: "{{ resource_prefix }}-Group-Root"
state: 'present'
absent_members:
- - "{{ create_group_member_2_ShouldPass.object_id }}"
- register: remove_already_absent_member_from_group_ShouldPass
+ - "{{ create_pass_second.object_id }}"
+ register: remove_already_absent_member_from_group_shouldpass
- name: Validate nothing changed from already absent member
- assert:
+ ansible.builtin.assert:
that:
- - remove_already_absent_member_from_group_ShouldPass.changed == false
+ - remove_already_absent_member_from_group_shouldpass.changed == false
- name: Return a specific group using object_id
azure_rm_adgroup_info:
- object_id: "{{ group_create_changed_ShouldPass.object_id }}"
+ object_id: "{{ group_create_changed_shouldpass.object_id }}"
tenant: "{{ tenant_id }}"
- register: object_id_ShouldPass
+ register: object_id_shouldpass
- name: Return a specific group using object_id and return_owners
azure_rm_adgroup_info:
- object_id: "{{ group_create_changed_ShouldPass.object_id }}"
- return_owners: True
+ object_id: "{{ group_create_changed_shouldpass.object_id }}"
+ return_owners: true
tenant: "{{ tenant_id }}"
- register: object_id_return_owners_ShouldPass
+ register: object_id_return_owners_shouldpass
- name: Return a specific group using object_id and return_owners and return_group_members
azure_rm_adgroup_info:
- object_id: "{{ group_create_changed_ShouldPass.object_id }}"
- return_owners: True
- return_group_members: True
+ object_id: "{{ group_create_changed_shouldpass.object_id }}"
+ return_owners: true
+ return_group_members: true
tenant: "{{ tenant_id }}"
- register: object_id_return_owners_and_group_members_ShouldPass
+ register: object_id_return_owners_and_group_members_shouldpass
- name: Return a specific group using object_id and member_groups
azure_rm_adgroup_info:
- object_id: "{{ group_create_changed_ShouldPass.object_id }}"
- return_member_groups: True
+ object_id: "{{ group_create_changed_shouldpass.object_id }}"
+ return_member_groups: true
tenant: "{{ tenant_id }}"
- register: object_id_return_member_groups_ShouldPass
+ register: object_id_return_member_groups_shouldpass
- name: Return a specific group using object_id and check_membership
azure_rm_adgroup_info:
- object_id: "{{ group_create_changed_ShouldPass.object_id }}"
- check_membership: "{{ create_group_member_1_ShouldPass.object_id }}"
+ object_id: "{{ group_create_changed_shouldpass.object_id }}"
+ check_membership: "{{ create_pass_first.object_id }}"
tenant: "{{ tenant_id }}"
- register: object_id_return_check_membership_ShouldPass
+ register: object_id_return_check_membership_shouldpass
- name: Return a specific group using displayName attribute
azure_rm_adgroup_info:
attribute_name: "displayName"
- attribute_value: "{{ group_create_changed_ShouldPass.display_name }}"
+ attribute_value: "{{ group_create_changed_shouldpass.display_name }}"
tenant: "{{ tenant_id }}"
- register: displayName_attribute_ShouldPass
+ register: displayname_attribute_shouldpass
- name: Return a specific group using mailNickname filter
azure_rm_adgroup_info:
- odata_filter: "mailNickname eq '{{ group_create_changed_ShouldPass.mail_nickname }}'"
+ odata_filter: "mailNickname eq '{{ group_create_changed_shouldpass.mail_nickname }}'"
tenant: "{{ tenant_id }}"
- register: mailNickname_filter_ShouldPass
+ register: mailnickname_filter_shouldpass
- name: Return a different group using displayName attribute
azure_rm_adgroup_info:
attribute_name: "displayName"
- attribute_value: "{{ create_group_member_2_ShouldPass.display_name }}"
+ attribute_value: "{{ create_pass_second.display_name }}"
tenant: "{{ tenant_id }}"
- register: displayName_attribute_different_ShouldPass
+ register: displayname_attribute_different_shouldpass
- name: Assert All Returns Are Equal
- assert:
+ ansible.builtin.assert:
that:
- - object_id_ShouldPass == displayName_attribute_ShouldPass
- - object_id_ShouldPass == mailNickname_filter_ShouldPass
+ - object_id_shouldpass == displayname_attribute_shouldpass
+ - object_id_shouldpass == mailnickname_filter_shouldpass
- name: Assert Returns Are Not Equal
- assert:
+ ansible.builtin.assert:
that:
- - object_id_ShouldPass != displayName_attribute_different_ShouldPass
+ - object_id_shouldpass != displayname_attribute_different_shouldpass
- name: Delete group Group Root on object_id
azure_rm_adgroup:
tenant: "{{ tenant_id }}"
- object_id: "{{ group_create_unchanged_ShouldPass.object_id }}"
+ object_id: "{{ group_create_unchanged_shouldpass.object_id }}"
state: 'absent'
- register: group_delete_group_root_ShouldPass
+ register: group_delete_group_root_shouldpass
- name: Try to return now deleted group Group Root using object_id
azure_rm_adgroup_info:
- object_id: "{{ group_create_unchanged_ShouldPass.object_id }}"
+ object_id: "{{ group_create_unchanged_shouldpass.object_id }}"
tenant: "{{ tenant_id }}"
- register: get_deleted_object_group_root_ShouldFail
+ register: get_deleted_object_group_root_shouldfail
failed_when:
- - '"failed to get ad group info Resource" not in get_deleted_object_group_root_ShouldFail.msg'
+ - '"failed to get ad group info Resource" not in get_deleted_object_group_root_shouldfail.msg'
- name: Delete group Group Member 1 on object_id
azure_rm_adgroup:
tenant: "{{ tenant_id }}"
- object_id: "{{ create_group_member_1_ShouldPass.object_id }}"
+ object_id: "{{ create_pass_first.object_id }}"
state: 'absent'
- register: group_delete_group_member_1_ShouldPass
+ register: group_delete_group_member_1_shouldpass
- name: Try to return now deleted group Group Member 1 using object_id
azure_rm_adgroup_info:
- object_id: "{{ create_group_member_1_ShouldPass.object_id }}"
+ object_id: "{{ create_pass_first.object_id }}"
tenant: "{{ tenant_id }}"
- register: get_deleted_object_group_member_1_ShouldFail
+ register: get_deleted_object_group_member_1_shouldfail
failed_when:
- - '"failed to get ad group info Resource" not in get_deleted_object_group_member_1_ShouldFail.msg'
+ - '"failed to get ad group info Resource" not in get_deleted_object_group_member_1_shouldfail.msg'
- name: Delete group Group Member 2 on object_id
azure_rm_adgroup:
tenant: "{{ tenant_id }}"
- object_id: "{{ create_group_member_2_ShouldPass.object_id }}"
+ object_id: "{{ create_pass_second.object_id }}"
state: 'absent'
- register: group_delete_group_member_2_ShouldPass
+ register: group_delete_group_member_2_shouldpass
- name: Try to return now deleted group Group Member 2 using object_id
azure_rm_adgroup_info:
- object_id: "{{ create_group_member_2_ShouldPass.object_id }}"
+ object_id: "{{ create_pass_second.object_id }}"
tenant: "{{ tenant_id }}"
- register: get_deleted_object_group_member_2_ShouldFail
+ register: get_deleted_object_group_member_2_shouldfail
failed_when:
- - '"failed to get ad group info Resource" not in get_deleted_object_group_member_2_ShouldFail.msg'
+ - '"failed to get ad group info Resource" not in get_deleted_object_group_member_2_shouldfail.msg'
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_adpassword/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_adpassword/tasks/main.yml
index 7c3782f17..f430af17f 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_adpassword/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_adpassword/tasks/main.yml
@@ -1,9 +1,10 @@
-- set_fact:
+- name: Set variables
+ ansible.builtin.set_fact:
app_id: "e0a62513-1d81-480e-a6dc-5c99cdd58d9a"
tenant_id: "72f988bf-86f1-41af-91ab-2d7cd011db47"
app_object_id: "b52e8275-a1ee-4c4a-86ff-15992e0920ed"
-- name: create first ad password by app_id
+- name: Create first ad password by app_id
azure_rm_adpassword:
app_id: "{{ app_id }}"
value: "Password@032900001"
@@ -11,11 +12,12 @@
state: present
register: ad_fact
-- assert:
+- name: Assert the password created
+ ansible.builtin.assert:
that:
- - ad_fact.changed
+ - ad_fact.changed
-- name: create second ad password by app_object_id
+- name: Create second ad password by app_object_id
azure_rm_adpassword:
value: "Password@032900002"
tenant: "{{ tenant_id }}"
@@ -23,11 +25,12 @@
state: present
register: ad_fact02
-- assert:
+- name: Assert the secondary password created
+ ansible.builtin.assert:
that:
- - ad_fact02.changed
+ - ad_fact02.changed
-- name: create ad service principal
+- name: Create ad service principal
azure_rm_adserviceprincipal:
app_id: "{{ app_id }}"
tenant: "{{ tenant_id }}"
@@ -38,10 +41,11 @@
tenant: "{{ tenant_id }}"
app_id: "{{ app_id }}"
register: sp_info
-- debug:
+- name: Print Service principals facts
+ ansible.builtin.debug:
var: sp_info
-- name: create third ad password by service_principal_object_id
+- name: Create third ad password by service_principal_object_id
azure_rm_adpassword:
value: "Password@032900003"
tenant: "{{ tenant_id }}"
@@ -49,11 +53,12 @@
state: present
register: ad_fact03
-- assert:
+- name: Assert the third add password created
+ ansible.builtin.assert:
that:
- - ad_fact03.changed
+ - ad_fact03.changed
-- name: can't update ad password
+- name: Can't update ad password
azure_rm_adpassword:
app_id: "{{ app_id }}"
value: "Password@032900003"
@@ -62,7 +67,7 @@
app_object_id: "{{ app_object_id }}"
state: present
register: output
- ignore_errors: True
+ ignore_errors: true
- name: Get ad password info
azure_rm_adpassword_info:
@@ -72,12 +77,13 @@
app_object_id: "{{ app_object_id }}"
register: ad_info
-- assert:
+- name: Assert the ad password facts
+ ansible.builtin.assert:
that:
- - ad_info.passwords[0].start_date == ad_fact.start_date
- - ad_info.passwords[0].end_date == ad_fact.end_date
+ - ad_info.passwords[0].start_date == ad_fact.start_date
+ - ad_info.passwords[0].end_date == ad_fact.end_date
-- name: delete one ad password
+- name: Delete one ad password
azure_rm_adpassword:
app_id: "{{ app_id }}"
key_id: "{{ ad_fact.key_id }}"
@@ -86,11 +92,12 @@
state: absent
register: output
-- assert:
+- name: Assert the ad password deleted
+ ansible.builtin.assert:
that:
- - output.changed
+ - output.changed
-- name: delete all ad password
+- name: Delete all ad password
azure_rm_adpassword:
app_id: "{{ app_id }}"
tenant: "{{ tenant_id }}"
@@ -98,6 +105,7 @@
state: absent
register: output
-- assert:
+- name: Assert the ad password delete
+ ansible.builtin.assert:
that:
- - output.changed
+ - output.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_adserviceprincipal/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_adserviceprincipal/tasks/main.yml
index 4e4b50161..b138740d6 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_adserviceprincipal/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_adserviceprincipal/tasks/main.yml
@@ -1,34 +1,37 @@
-- set_fact:
+- name: Set variables
+ ansible.builtin.set_fact:
app_id: "e0a62513-1d81-480e-a6dc-5c99cdd58d9a"
tenant_id: "72f988bf-86f1-41af-91ab-2d7cd011db47"
-- name: delete ad service principal
+- name: Delete ad service principal
azure_rm_adserviceprincipal:
app_id: "{{ app_id }}"
tenant: "{{ tenant_id }}"
state: absent
-- name: create ad service principal
+- name: Create ad service principal
azure_rm_adserviceprincipal:
app_id: "{{ app_id }}"
tenant: "{{ tenant_id }}"
state: present
register: ad_fact
-- assert:
+- name: Assert the ad service prinicipal created
+ ansible.builtin.assert:
that:
- - ad_fact.changed
+ - ad_fact.changed
-- name: create ad service principal (idempontent)
+- name: Create ad service principal (idempontent)
azure_rm_adserviceprincipal:
app_id: "{{ app_id }}"
tenant: "{{ tenant_id }}"
state: present
register: output
-- assert:
+- name: Assert the ad service principal idempotent
+ ansible.builtin.assert:
that:
- - not output.changed
+ - not output.changed
- name: Get ad service principal info by app_id
azure_rm_adserviceprincipal_info:
@@ -36,16 +39,17 @@
tenant: "{{ tenant_id }}"
register: ad_info
-- assert:
+- name: Assert The ad service principals facts
+ ansible.builtin.assert:
that:
- - ad_info.service_principals[0].app_display_name == ad_fact.app_display_name
- - ad_info.service_principals[0].app_role_assignment_required == False
+ - ad_info.service_principals[0].app_display_name == ad_fact.app_display_name
+ - ad_info.service_principals[0].app_role_assignment_required == False
-- name: update ad service principal app_role_assignmentrequired to True
+- name: Update ad service principal app_role_assignmentrequired to True
azure_rm_adserviceprincipal:
app_id: "{{ app_id }}"
tenant: "{{ tenant_id }}"
- app_role_assignment_required: True
+ app_role_assignment_required: true
state: present
register: output
@@ -55,18 +59,20 @@
object_id: "{{ ad_info.service_principals[0].object_id }}"
register: ad_info
-- assert:
+- name: Assert the ad service principals facts
+ ansible.builtin.assert:
that:
- - ad_info.service_principals[0].app_display_name == ad_fact.app_display_name
- - ad_info.service_principals[0].app_role_assignment_required == True
+ - ad_info.service_principals[0].app_display_name == ad_fact.app_display_name
+ - ad_info.service_principals[0].app_role_assignment_required == True
-- name: delete ad service principal
+- name: Delete ad service principal
azure_rm_adserviceprincipal:
app_id: "{{ app_id }}"
tenant: "{{ tenant_id }}"
state: absent
register: output
-- assert:
+- name: Assert the ad service principals deleted
+ ansible.builtin.assert:
that:
- - output.changed
+ - output.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_aduser/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_aduser/tasks/main.yml
index 98dfc3241..e3c9225e6 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_aduser/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_aduser/tasks/main.yml
@@ -1,17 +1,17 @@
- name: Prepare facts
- set_fact:
+ ansible.builtin.set_fact:
tenant_id: "{{ azure_tenant }}"
user_id: "user{{ 999999999999999999994 | random | to_uuid }}@contoso.com"
object_id: "{{ 999999999999999999994 | random | to_uuid }}"
user_principal_name: "{{ 999999999999999999994 | random | to_uuid }}"
- run_once: yes
+ run_once: true
- name: Create test user
azure_rm_aduser:
user_principal_name: "{{ user_id }}"
tenant: "{{ tenant_id }}"
state: "present"
- account_enabled: "True"
+ account_enabled: true
display_name: "Test_{{ user_principal_name }}_Display_Name"
password_profile: "password"
mail_nickname: "Test_{{ user_principal_name }}_mail_nickname"
@@ -36,18 +36,18 @@
register: attempted_update_with_no_changes_should_pass
- name: Assert Nothing Changed
- assert:
+ ansible.builtin.assert:
that:
- attempted_update_with_no_changes_should_pass["changed"] == False
-- name: user_principal_name Should Pass
+- name: User_principal_name Should Pass
azure_rm_aduser_info:
user_principal_name: "{{ user_id }}"
tenant: "{{ tenant_id }}"
register: get_user_should_pass
- name: Assert user was created and account is enabled
- assert:
+ ansible.builtin.assert:
that:
- "create_user_should_pass['ad_users'][0]['account_enabled'] == True"
- "get_user_should_pass['ad_users'][0]['account_enabled'] == True"
@@ -57,17 +57,17 @@
user_principal_name: "{{ user_id }}"
tenant: "{{ tenant_id }}"
state: "present"
- account_enabled: "False"
+ account_enabled: false
register: update_user_should_pass
-- name: user_principal_name on updated user Should Pass
+- name: User_principal_name on updated user Should Pass
azure_rm_aduser_info:
user_principal_name: "{{ user_id }}"
tenant: "{{ tenant_id }}"
register: get_updated_user_should_pass
- name: Assert user was updated and account is disabled
- assert:
+ ansible.builtin.assert:
that:
- "update_user_should_pass['ad_users'][0]['account_enabled'] == False"
- "get_updated_user_should_pass['ad_users'][0]['account_enabled'] == False"
@@ -79,7 +79,7 @@
state: "absent"
register: delete_user_should_pass
-- name: user_principal_name Should Fail
+- name: User_principal_name Should Fail
azure_rm_aduser_info:
user_principal_name: "{{ user_id }}"
tenant: "{{ tenant_id }}"
@@ -87,30 +87,30 @@
ignore_errors: true
- name: Assert task failed
- assert:
+ ansible.builtin.assert:
that:
- "get_user_should_fail['failed'] == True"
- name: Run with bad tenant Should Fail
azure_rm_aduser_info:
- user_principal_name: "{{user_id}}"
+ user_principal_name: "{{ user_id }}"
tenant: None
register: missing_tenant
- ignore_errors: yes
+ ignore_errors: true
- name: Assert task failed
- assert:
+ ansible.builtin.assert:
that:
- "missing_tenant['failed'] == True"
- name: Missing any identifiers Should Fail
azure_rm_aduser_info:
tenant: "{{ tenant_id }}"
- register: missing_any_identifiers
- ignore_errors: yes
+ register: missing_any_identifiers
+ ignore_errors: true
- name: Assert task failed
- assert:
+ ansible.builtin.assert:
that:
- "missing_any_identifiers is undefined"
@@ -119,11 +119,11 @@
user_principal_name: "{{ user_id }}"
object_id: "{{ object_id }}"
tenant: "{{ tenant_id }}"
- register: too_many_identifiers
- ignore_errors: yes
+ register: too_many_identifiers
+ ignore_errors: true
- name: Assert task failed
- assert:
+ ansible.builtin.assert:
that:
- "too_many_identifiers is undefined"
@@ -131,35 +131,35 @@
azure_rm_aduser_info:
attribute_name: proxyAddresses
tenant: "{{ tenant_id }}"
- register: missing attribute_value
- ignore_errors: yes
+ register: missing_attribute_value
+ ignore_errors: true
- name: Assert task failed
- assert:
+ ansible.builtin.assert:
that:
- - "attribute_value is undefined"
+ - "missing_attribute_value is undefined"
- name: Missing attribute_name Should Fail
azure_rm_aduser_info:
attribute_value: SMTP:user@contoso.com
tenant: "{{ tenant_id }}"
- register: missing attribute_name
- ignore_errors: yes
+ register: missing_attribute_name
+ ignore_errors: true
- name: Assert task failed
- assert:
+ ansible.builtin.assert:
that:
- - "attribute_name is undefined"
+ - "missing_attribute_name is undefined"
- name: Using all with principal name should fail
azure_rm_aduser_info:
- all: True
+ all: true
user_principal_name: "{{ user_id }}"
tenant: "{{ tenant_id }}"
- register: using_all_with_principal_name
- ignore_errors: yes
+ register: using_all_with_principal_name
+ ignore_errors: true
- name: Assert task failed
- assert:
+ ansible.builtin.assert:
that:
- "using_all_with_principal_name is undefined"
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_aks/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_aks/tasks/main.yml
index cf3f856ec..ff60ca681 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_aks/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_aks/tasks/main.yml
@@ -1,572 +1,578 @@
- - set_fact:
- rpfx: "{{ resource_group | hash('md5') | truncate(8, True, '') }}"
- noderpfx: "{{ resource_group | hash('md5') | truncate(4, True, '') }}"
-
- - include: minimal-cluster.yml
-
- - name: Find available k8s version
- azure_rm_aksversion_info:
- location: eastus
- register: versions
-
- - name: Create an AKS instance (check mode)
- azure_rm_aks:
- name: "aks{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- location: eastus
- dns_prefix: "aks{{ rpfx }}"
- kubernetes_version: "{{ versions.azure_aks_versions[0] }}"
- service_principal:
- client_id: "{{ azure_client_id }}"
- client_secret: "{{ azure_secret }}"
- linux_profile:
- admin_username: azureuser
- ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible
- agent_pool_profiles:
- - name: default
- count: 1
- vm_size: Standard_B2s
- type: VirtualMachineScaleSets
- mode: System
- node_labels: {"release":"stable"}
- max_pods: 42
- availability_zones:
- - 1
- - 2
- node_resource_group: "node{{ noderpfx }}"
- enable_rbac: yes
- network_profile:
- load_balancer_sku: standard
- check_mode: yes
-
- - name: Check there is no AKS created
- azure_rm_aks_info:
- name: "aks{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- register: fact
-
- - name: Check there is no AKS created
- assert:
- that:
- - "fact.aks | length == 0"
-
- - name: Create an AKS instance
- azure_rm_aks:
- name: "aks{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- location: eastus
- dns_prefix: "aks{{ rpfx }}"
- kubernetes_version: "{{ versions.azure_aks_versions[0] }}"
- service_principal:
- client_id: "{{ azure_client_id }}"
- client_secret: "{{ azure_secret }}"
- linux_profile:
- admin_username: azureuser
- ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible
- agent_pool_profiles:
- - name: default
- count: 1
- vm_size: Standard_B2s
- type: VirtualMachineScaleSets
- mode: System
- node_labels: {"release":"stable"}
- max_pods: 42
- availability_zones:
- - 1
- - 2
- node_resource_group: "node{{ noderpfx }}"
- enable_rbac: yes
- network_profile:
- load_balancer_sku: standard
- register: output
-
- - name: Assert the AKS instance is well created
- assert:
- that:
- - output.changed
- - output.provisioning_state == 'Succeeded'
-
- - name: Get AKS fact
- azure_rm_aks_info:
- name: "aks{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- register: fact
-
- - name: Assert fact returns the created one
- assert:
- that:
- - "fact.aks | length == 1"
- - fact.aks[0].id == output.id
- - fact.aks[0].properties.agentPoolProfiles[0].availabilityZones == ["1", "2"]
- - fact.aks[0].properties.agentPoolProfiles[0].mode == "System"
- - fact.aks[0].properties.agentPoolProfiles[0].nodeLabels | length == 1
-
- - name: Update an AKS instance node_labels
- azure_rm_aks:
- name: "aks{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- location: eastus
- dns_prefix: "aks{{ rpfx }}"
- kubernetes_version: "{{ versions.azure_aks_versions[0] }}"
- service_principal:
- client_id: "{{ azure_client_id }}"
- client_secret: "{{ azure_secret }}"
- linux_profile:
- admin_username: azureuser
- ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible
- agent_pool_profiles:
- - name: default
- count: 1
- vm_size: Standard_B2s
- type: VirtualMachineScaleSets
- mode: System
- node_labels: {"release":"stable", "environment":"dev"}
- max_pods: 42
- availability_zones:
- - 1
- - 2
- node_resource_group: "node{{ noderpfx }}"
- enable_rbac: yes
- network_profile:
- load_balancer_sku: standard
- register: output
-
- - name: Assert the AKS instance is well update
- assert:
- that:
- - output.changed
-
- - name: Get AKS fact
- azure_rm_aks_info:
- name: "aks{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- register: fact
-
- - name: Assert fact returns the created one
- assert:
- that:
- - "fact.aks | length == 1"
- - fact.aks[0].id == output.id
- - fact.aks[0].properties.agentPoolProfiles[0].nodeLabels | length == 2
-
- - name: Get AKS upgrade versions
- azure_rm_aksupgrade_info:
- name: "aks{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- register: upgrades
-
- - name: Assert available control-plane versions for upgrade
- assert:
- that:
- - "upgrades.azure_aks_upgrades.control_plane_profile.kubernetes_version == versions.azure_aks_versions[0]"
- - "upgrades.azure_aks_upgrades.control_plane_profile.upgrades | length > 0"
-
- - name: Create an AKS instance (idempotent)
- azure_rm_aks:
- name: "aks{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- location: eastus
- dns_prefix: "aks{{ rpfx }}"
- kubernetes_version: "{{ versions.azure_aks_versions[0] }}"
- service_principal:
- client_id: "{{ azure_client_id }}"
- linux_profile:
- admin_username: azureuser
- ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible
- agent_pool_profiles:
- - name: default
- count: 1
- vm_size: Standard_B2s
- type: VirtualMachineScaleSets
- mode: System
- max_pods: 42
- availability_zones:
- - 1
- - 2
- node_resource_group: "node{{ noderpfx }}"
- enable_rbac: yes
- network_profile:
- load_balancer_sku: standard
- register: output
-
- - name: Assert idempotent
- assert:
- that:
- - not output.changed
-
- - name: Get available version
- azure_rm_aksversion_info:
- location: eastus
- version: "{{ versions.azure_aks_versions[0] }}"
- register: version1
-
- - name: Upgrade the AKS instance with addon
- azure_rm_aks:
- name: "aks{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- location: eastus
- dns_prefix: "aks{{ rpfx }}"
- kubernetes_version: "{{ version1.azure_aks_versions[0] }}"
- service_principal:
- client_id: "{{ azure_client_id }}"
- linux_profile:
- admin_username: azureuser
- ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible
- agent_pool_profiles:
- - name: default
- count: 1
- vm_size: Standard_B2s
- type: VirtualMachineScaleSets
- mode: System
- max_pods: 42
- availability_zones:
- - 1
- - 2
- node_resource_group: "node{{ noderpfx }}"
- addon:
- http_application_routing: {}
- network_profile:
- network_plugin: kubenet
- load_balancer_sku: standard
- enable_rbac: yes
- register: output
-
- - name: Assert the AKS instance is upgraded
- assert:
- that:
- - output.changed
- - output.kubernetes_version == version1.azure_aks_versions[0]
- - output.addon.httpApplicationRouting.enabled == True
- - output.agent_pool_profiles[0].count == 1
- - output.network_profile.network_plugin == 'kubenet'
-
- - name: Upgrade the AKS instance with addon (idempontent)
- azure_rm_aks:
- name: "aks{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- location: eastus
- dns_prefix: "aks{{ rpfx }}"
- kubernetes_version: "{{ version1.azure_aks_versions[0] }}"
- service_principal:
- client_id: "{{ azure_client_id }}"
- linux_profile:
- admin_username: azureuser
- ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible
- agent_pool_profiles:
- - name: default
- count: 1
- vm_size: Standard_B2s
- type: VirtualMachineScaleSets
- mode: System
- max_pods: 42
- availability_zones:
- - 1
- - 2
- node_resource_group: "node{{ noderpfx }}"
- addon:
- http_application_routing: {}
- network_profile:
- network_plugin: kubenet
- load_balancer_sku: standard
- enable_rbac: yes
- register: output
-
- - assert:
- that:
- - not output.changed
-
- - name: Upgrade the AKS instance with agent pool profiles
- azure_rm_aks:
- name: "aks{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- location: eastus
- dns_prefix: "aks{{ rpfx }}"
- kubernetes_version: "{{ version1.azure_aks_versions[0] }}"
- service_principal:
- client_id: "{{ azure_client_id }}"
- client_secret: "{{ azure_secret }}"
- linux_profile:
- admin_username: azureuser
- ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible
- agent_pool_profiles:
- - name: default
- count: 1
- vm_size: Standard_B2s
- type: VirtualMachineScaleSets
- mode: System
- enable_auto_scaling: True
- max_count: 6
- min_count: 1
- max_pods: 42
- availability_zones:
- - 1
- - 2
- node_resource_group: "node{{ noderpfx }}"
- enable_rbac: yes
- network_profile:
- load_balancer_sku: standard
- register: output
- ignore_errors: yes
-
- - name: Assert the AKS instance is well created
- assert:
- that:
- - output.changed
- - output.provisioning_state == 'Succeeded'
- ignore_errors: yes
-
- - name: Upgrade the AKS instance with agent pool profiles (idempontent)
- azure_rm_aks:
- name: "aks{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- location: eastus
- dns_prefix: "aks{{ rpfx }}"
- kubernetes_version: "{{ version1.azure_aks_versions[0] }}"
- service_principal:
- client_id: "{{ azure_client_id }}"
- client_secret: "{{ azure_secret }}"
- linux_profile:
- admin_username: azureuser
- ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible
- agent_pool_profiles:
- - name: default
- count: 1
- vm_size: Standard_B2s
- type: VirtualMachineScaleSets
- mode: System
- enable_auto_scaling: True
- max_count: 6
- min_count: 1
- max_pods: 42
- availability_zones:
- - 1
- - 2
- node_resource_group: "node{{ noderpfx }}"
- enable_rbac: yes
- network_profile:
- load_balancer_sku: standard
- register: output
-
- - name: Assert the AKS instance is well created
- assert:
- that:
- - not output.changed
-
- - name: Upgrade the AKS instance with multiple agent pool profiles
- azure_rm_aks:
- name: "aks{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- location: eastus
- dns_prefix: "aks{{ rpfx }}"
- kubernetes_version: "{{ version1.azure_aks_versions[0] }}"
- service_principal:
- client_id: "{{ azure_client_id }}"
- client_secret: "{{ azure_secret }}"
- linux_profile:
- admin_username: azureuser
- ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible
- agent_pool_profiles:
- - name: default
- count: 1
- vm_size: Standard_B2s
- type: VirtualMachineScaleSets
- mode: System
- enable_auto_scaling: True
- max_count: 6
- min_count: 1
- max_pods: 42
- availability_zones:
- - 1
- - 2
- - name: default2
- count: 1
- vm_size: Standard_B2s
- type: VirtualMachineScaleSets
- mode: User
- node_resource_group: "node{{ noderpfx }}"
- enable_rbac: yes
- network_profile:
- load_balancer_sku: standard
- register: output
- ignore_errors: yes
-
- - name: Assert the AKS instance is well created
- assert:
- that:
- - output.changed
- - "output.agent_pool_profiles | length == 2"
- - output.provisioning_state == 'Succeeded'
- - output.agent_pool_profiles[1].mode == 'User'
- ignore_errors: yes
-
- - name: Upgrade the AKS instance with multiple agent pool profiles (idempontent)
- azure_rm_aks:
- name: "aks{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- location: eastus
- dns_prefix: "aks{{ rpfx }}"
- kubernetes_version: "{{ version1.azure_aks_versions[0] }}"
- service_principal:
- client_id: "{{ azure_client_id }}"
- client_secret: "{{ azure_secret }}"
- linux_profile:
- admin_username: azureuser
- ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible
- agent_pool_profiles:
- - name: default
- count: 1
- vm_size: Standard_B2s
- type: VirtualMachineScaleSets
- enable_auto_scaling: True
- max_count: 6
- min_count: 1
- max_pods: 42
- availability_zones:
- - 1
- - 2
- - name: default2
- count: 1
- vm_size: Standard_B2s
- type: VirtualMachineScaleSets
- mode: User
- node_resource_group: "node{{ noderpfx }}"
- enable_rbac: yes
- network_profile:
- load_balancer_sku: standard
- register: output
-
- - name: Assert the AKS instance is well created
- assert:
- that:
- - not output.changed
-
- - name: Update the default2 agent_pool mode from User to System
- azure_rm_aks:
- name: "aks{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- location: eastus
- dns_prefix: "aks{{ rpfx }}"
- kubernetes_version: "{{ version1.azure_aks_versions[0] }}"
- service_principal:
- client_id: "{{ azure_client_id }}"
- client_secret: "{{ azure_secret }}"
- linux_profile:
- admin_username: azureuser
- ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible
- agent_pool_profiles:
- - name: default
- count: 1
- vm_size: Standard_B2s
- type: VirtualMachineScaleSets
- mode: System
- enable_auto_scaling: True
- max_count: 6
- min_count: 1
- max_pods: 42
- availability_zones:
- - 1
- - 2
- - name: default2
- count: 1
- vm_size: Standard_B2s
- type: VirtualMachineScaleSets
- mode: System
- node_resource_group: "node{{ noderpfx }}"
- enable_rbac: yes
- network_profile:
- load_balancer_sku: standard
- ignore_errors: yes
- register: output
-
- - name: Assert the AKS instance is well created
- assert:
- that:
- - output.changed
- - "output.agent_pool_profiles | length == 2"
- - output.provisioning_state == 'Succeeded'
- - output.agent_pool_profiles[1].mode == 'System'
- ignore_errors: yes
-
- - name: Update the default2 agent_pool mode from User to System (idempontent)
- azure_rm_aks:
- name: "aks{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- location: eastus
- dns_prefix: "aks{{ rpfx }}"
- kubernetes_version: "{{ version1.azure_aks_versions[0] }}"
- service_principal:
- client_id: "{{ azure_client_id }}"
- client_secret: "{{ azure_secret }}"
- linux_profile:
- admin_username: azureuser
- ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible
- agent_pool_profiles:
- - name: default
- count: 1
- vm_size: Standard_B2s
- type: VirtualMachineScaleSets
- enable_auto_scaling: True
- max_count: 6
- min_count: 1
- max_pods: 42
- availability_zones:
- - 1
- - 2
- - name: default2
- count: 1
- vm_size: Standard_B2s
- type: VirtualMachineScaleSets
- mode: System
- node_resource_group: "node{{ noderpfx }}"
- enable_rbac: yes
- network_profile:
- load_balancer_sku: standard
- register: output
-
- - name: Get AKS fact
- azure_rm_aks_info:
- name: "aks{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- show_kubeconfig: user
- register: fact
-
- - name: Assert fact returns the created one
- assert:
- that:
- - "fact.aks | length == 1"
- - fact.aks[0].kube_config == output.kube_config
-
- - name: Delete the AKS instance
- azure_rm_aks:
- name: "aks{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- state: absent
- register: output
-
- - name: Assert the AKS instance is well deleted
- assert:
- that:
- - output.changed
-
- - name: Delete the AKS instance (idempotent)
- azure_rm_aks:
- name: "aks{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- state: absent
- register: output
-
- - name: Assert idempotent
- assert:
- that:
- - not output.changed
-
- - name: Get AKS fact
- azure_rm_aks_info:
- name: "aks{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- register: fact
-
- - name: Assert fact returns empty
- assert:
- that:
- - "fact.aks | length == 0"
+- name: Set varialbles
+ ansible.builtin.set_fact:
+ rpfx: "{{ resource_group | hash('md5') | truncate(8, True, '') }}"
+ noderpfx: "{{ resource_group | hash('md5') | truncate(4, True, '') }}"
+
+- name: Include aks tasks
+ ansible.builtin.include_tasks: minimal-cluster.yml
+
+- name: Find available k8s version
+ azure_rm_aksversion_info:
+ location: eastus
+ register: versions
+
+- name: Create an AKS instance (check mode)
+ azure_rm_aks:
+ name: "aks{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ location: eastus
+ dns_prefix: "aks{{ rpfx }}"
+ kubernetes_version: "{{ versions.azure_aks_versions[0] }}"
+ service_principal:
+ client_id: "{{ azure_client_id }}"
+ client_secret: "{{ azure_secret }}"
+ linux_profile:
+ admin_username: azureuser
+ ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible
+ agent_pool_profiles:
+ - name: default
+ count: 1
+ vm_size: Standard_B2s
+ type: VirtualMachineScaleSets
+ mode: System
+ node_labels: {"release":"stable"}
+ max_pods: 42
+ availability_zones:
+ - 1
+ - 2
+ node_resource_group: "node{{ noderpfx }}"
+ enable_rbac: true
+ network_profile:
+ load_balancer_sku: standard
+ check_mode: true
+
+- name: Check there is no AKS created
+ azure_rm_aks_info:
+ name: "aks{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ register: fact
+
+- name: Check there is no AKS created
+ ansible.builtin.assert:
+ that:
+ - "fact.aks | length == 0"
+
+- name: Create an AKS instance
+ azure_rm_aks:
+ name: "aks{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ location: eastus
+ dns_prefix: "aks{{ rpfx }}"
+ kubernetes_version: "{{ versions.azure_aks_versions[0] }}"
+ service_principal:
+ client_id: "{{ azure_client_id }}"
+ client_secret: "{{ azure_secret }}"
+ linux_profile:
+ admin_username: azureuser
+ ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible
+ agent_pool_profiles:
+ - name: default
+ count: 1
+ vm_size: Standard_B2s
+ type: VirtualMachineScaleSets
+ mode: System
+ node_labels: {"release":"stable"}
+ max_pods: 42
+ availability_zones:
+ - 1
+ - 2
+ node_resource_group: "node{{ noderpfx }}"
+ enable_rbac: true
+ network_profile:
+ load_balancer_sku: standard
+ register: output
+
+- name: Assert the AKS instance is well created
+ ansible.builtin.assert:
+ that:
+ - output.changed
+ - output.provisioning_state == 'Succeeded'
+
+- name: Get AKS fact
+ azure_rm_aks_info:
+ name: "aks{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ register: fact
+
+- name: Assert fact returns the created one
+ ansible.builtin.assert:
+ that:
+ - "fact.aks | length == 1"
+ - fact.aks[0].id == output.id
+ - fact.aks[0].agent_pool_profiles[0].availability_zones == ["1", "2"]
+ - fact.aks[0].agent_pool_profiles[0].mode == "System"
+ - fact.aks[0].agent_pool_profiles[0].node_labels | length == 1
+
+- name: Update an AKS instance node_labels
+ azure_rm_aks:
+ name: "aks{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ location: eastus
+ dns_prefix: "aks{{ rpfx }}"
+ kubernetes_version: "{{ versions.azure_aks_versions[0] }}"
+ service_principal:
+ client_id: "{{ azure_client_id }}"
+ client_secret: "{{ azure_secret }}"
+ linux_profile:
+ admin_username: azureuser
+ ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible
+ agent_pool_profiles:
+ - name: default
+ count: 1
+ vm_size: Standard_B2s
+ type: VirtualMachineScaleSets
+ mode: System
+ node_labels: {"release":"stable", "environment":"dev"}
+ max_pods: 42
+ availability_zones:
+ - 1
+ - 2
+ node_resource_group: "node{{ noderpfx }}"
+ enable_rbac: true
+ network_profile:
+ load_balancer_sku: standard
+ register: output
+
+- name: Assert the AKS instance is well update
+ ansible.builtin.assert:
+ that:
+ - output.changed
+
+- name: Get AKS fact
+ azure_rm_aks_info:
+ name: "aks{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ register: fact
+
+- name: Assert fact returns the created one
+ ansible.builtin.assert:
+ that:
+ - "fact.aks | length == 1"
+ - fact.aks[0].id == output.id
+ - fact.aks[0].agent_pool_profiles[0].node_labels | length == 2
+
+- name: Get AKS upgrade versions
+ azure_rm_aksupgrade_info:
+ name: "aks{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ register: upgrades
+
+- name: Assert available control-plane versions for upgrade
+ ansible.builtin.assert:
+ that:
+ - "upgrades.azure_aks_upgrades.control_plane_profile.kubernetes_version == versions.azure_aks_versions[0]"
+ - "upgrades.azure_aks_upgrades.control_plane_profile.upgrades | length > 0"
+
+- name: Create an AKS instance (idempotent)
+ azure_rm_aks:
+ name: "aks{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ location: eastus
+ dns_prefix: "aks{{ rpfx }}"
+ kubernetes_version: "{{ versions.azure_aks_versions[0] }}"
+ service_principal:
+ client_id: "{{ azure_client_id }}"
+ linux_profile:
+ admin_username: azureuser
+ ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible
+ agent_pool_profiles:
+ - name: default
+ count: 1
+ vm_size: Standard_B2s
+ type: VirtualMachineScaleSets
+ mode: System
+ max_pods: 42
+ availability_zones:
+ - 1
+ - 2
+ node_resource_group: "node{{ noderpfx }}"
+ enable_rbac: true
+ network_profile:
+ load_balancer_sku: standard
+ register: output
+
+- name: Assert idempotent
+ ansible.builtin.assert:
+ that:
+ - not output.changed
+
+- name: Get available version
+ azure_rm_aksversion_info:
+ location: eastus
+ version: "{{ versions.azure_aks_versions[0] }}"
+ register: version1
+
+- name: Upgrade the AKS instance with addon
+ azure_rm_aks:
+ name: "aks{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ location: eastus
+ dns_prefix: "aks{{ rpfx }}"
+ kubernetes_version: "{{ version1.azure_aks_versions[0] }}"
+ service_principal:
+ client_id: "{{ azure_client_id }}"
+ linux_profile:
+ admin_username: azureuser
+ ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible
+ agent_pool_profiles:
+ - name: default
+ count: 1
+ vm_size: Standard_B2s
+ type: VirtualMachineScaleSets
+ mode: System
+ max_pods: 42
+ availability_zones:
+ - 1
+ - 2
+ node_resource_group: "node{{ noderpfx }}"
+ addon:
+ http_application_routing: {}
+ network_profile:
+ network_plugin: kubenet
+ load_balancer_sku: standard
+ enable_rbac: true
+ register: output
+
+- name: Assert the AKS instance is upgraded
+ ansible.builtin.assert:
+ that:
+ - output.changed
+ - output.kubernetes_version == version1.azure_aks_versions[0]
+ - output.addon.httpApplicationRouting.enabled == True
+ - output.agent_pool_profiles[0].count == 1
+ - output.network_profile.network_plugin == 'kubenet'
+
+- name: Upgrade the AKS instance with addon (idempontent)
+ azure_rm_aks:
+ name: "aks{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ location: eastus
+ dns_prefix: "aks{{ rpfx }}"
+ kubernetes_version: "{{ version1.azure_aks_versions[0] }}"
+ service_principal:
+ client_id: "{{ azure_client_id }}"
+ linux_profile:
+ admin_username: azureuser
+ ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible
+ agent_pool_profiles:
+ - name: default
+ count: 1
+ vm_size: Standard_B2s
+ type: VirtualMachineScaleSets
+ mode: System
+ max_pods: 42
+ availability_zones:
+ - 1
+ - 2
+ node_resource_group: "node{{ noderpfx }}"
+ addon:
+ http_application_routing: {}
+ network_profile:
+ network_plugin: kubenet
+ load_balancer_sku: standard
+ enable_rbac: true
+ register: output
+
+- name: Assert the aks idempotent
+ ansible.builtin.assert:
+ that:
+ - not output.changed
+
+- name: Upgrade the AKS instance with agent pool profiles
+ azure_rm_aks:
+ name: "aks{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ location: eastus
+ dns_prefix: "aks{{ rpfx }}"
+ kubernetes_version: "{{ version1.azure_aks_versions[0] }}"
+ service_principal:
+ client_id: "{{ azure_client_id }}"
+ client_secret: "{{ azure_secret }}"
+ linux_profile:
+ admin_username: azureuser
+ ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible
+ agent_pool_profiles:
+ - name: default
+ count: 1
+ vm_size: Standard_B2s
+ type: VirtualMachineScaleSets
+ mode: System
+ enable_auto_scaling: true
+ max_count: 6
+ min_count: 1
+ max_pods: 42
+ availability_zones:
+ - 1
+ - 2
+ node_resource_group: "node{{ noderpfx }}"
+ enable_rbac: true
+ network_profile:
+ load_balancer_sku: standard
+ register: output
+ ignore_errors: true
+
+- name: Assert the AKS instance is well created
+ ansible.builtin.assert:
+ that:
+ - output.changed
+ - output.provisioning_state == 'Succeeded'
+ ignore_errors: true
+ register: ignore_errors_register
+
+- name: Upgrade the AKS instance with agent pool profiles (idempontent)
+ azure_rm_aks:
+ name: "aks{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ location: eastus
+ dns_prefix: "aks{{ rpfx }}"
+ kubernetes_version: "{{ version1.azure_aks_versions[0] }}"
+ service_principal:
+ client_id: "{{ azure_client_id }}"
+ client_secret: "{{ azure_secret }}"
+ linux_profile:
+ admin_username: azureuser
+ ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible
+ agent_pool_profiles:
+ - name: default
+ count: 1
+ vm_size: Standard_B2s
+ type: VirtualMachineScaleSets
+ mode: System
+ enable_auto_scaling: true
+ max_count: 6
+ min_count: 1
+ max_pods: 42
+ availability_zones:
+ - 1
+ - 2
+ node_resource_group: "node{{ noderpfx }}"
+ enable_rbac: true
+ network_profile:
+ load_balancer_sku: standard
+ register: output
+
+- name: Assert the AKS instance is well created
+ ansible.builtin.assert:
+ that:
+ - not output.changed
+
+- name: Upgrade the AKS instance with multiple agent pool profiles
+ azure_rm_aks:
+ name: "aks{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ location: eastus
+ dns_prefix: "aks{{ rpfx }}"
+ kubernetes_version: "{{ version1.azure_aks_versions[0] }}"
+ service_principal:
+ client_id: "{{ azure_client_id }}"
+ client_secret: "{{ azure_secret }}"
+ linux_profile:
+ admin_username: azureuser
+ ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible
+ agent_pool_profiles:
+ - name: default
+ count: 1
+ vm_size: Standard_B2s
+ type: VirtualMachineScaleSets
+ mode: System
+ enable_auto_scaling: true
+ max_count: 6
+ min_count: 1
+ max_pods: 42
+ availability_zones:
+ - 1
+ - 2
+ - name: default2
+ count: 1
+ vm_size: Standard_B2s
+ type: VirtualMachineScaleSets
+ mode: User
+ node_resource_group: "node{{ noderpfx }}"
+ enable_rbac: true
+ network_profile:
+ load_balancer_sku: standard
+ register: output
+ ignore_errors: true
+
+- name: Assert the AKS instance is well created
+ ansible.builtin.assert:
+ that:
+ - output.changed
+ - "output.agent_pool_profiles | length == 2"
+ - output.provisioning_state == 'Succeeded'
+ - output.agent_pool_profiles[1].mode == 'User'
+ ignore_errors: true
+ register: ignore_errors_register
+
+- name: Upgrade the AKS instance with multiple agent pool profiles (idempontent)
+ azure_rm_aks:
+ name: "aks{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ location: eastus
+ dns_prefix: "aks{{ rpfx }}"
+ kubernetes_version: "{{ version1.azure_aks_versions[0] }}"
+ service_principal:
+ client_id: "{{ azure_client_id }}"
+ client_secret: "{{ azure_secret }}"
+ linux_profile:
+ admin_username: azureuser
+ ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible
+ agent_pool_profiles:
+ - name: default
+ count: 1
+ vm_size: Standard_B2s
+ type: VirtualMachineScaleSets
+ enable_auto_scaling: true
+ max_count: 6
+ min_count: 1
+ max_pods: 42
+ availability_zones:
+ - 1
+ - 2
+ - name: default2
+ count: 1
+ vm_size: Standard_B2s
+ type: VirtualMachineScaleSets
+ mode: User
+ node_resource_group: "node{{ noderpfx }}"
+ enable_rbac: true
+ network_profile:
+ load_balancer_sku: standard
+ register: output
+
+- name: Assert the AKS instance is well created
+ ansible.builtin.assert:
+ that:
+ - not output.changed
+
+- name: Update the default2 agent_pool mode from User to System
+ azure_rm_aks:
+ name: "aks{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ location: eastus
+ dns_prefix: "aks{{ rpfx }}"
+ kubernetes_version: "{{ version1.azure_aks_versions[0] }}"
+ service_principal:
+ client_id: "{{ azure_client_id }}"
+ client_secret: "{{ azure_secret }}"
+ linux_profile:
+ admin_username: azureuser
+ ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible
+ agent_pool_profiles:
+ - name: default
+ count: 1
+ vm_size: Standard_B2s
+ type: VirtualMachineScaleSets
+ mode: System
+ enable_auto_scaling: true
+ max_count: 6
+ min_count: 1
+ max_pods: 42
+ availability_zones:
+ - 1
+ - 2
+ - name: default2
+ count: 1
+ vm_size: Standard_B2s
+ type: VirtualMachineScaleSets
+ mode: System
+ node_resource_group: "node{{ noderpfx }}"
+ enable_rbac: true
+ network_profile:
+ load_balancer_sku: standard
+ ignore_errors: true
+ register: output
+
+- name: Assert the AKS instance is well created
+ ansible.builtin.assert:
+ that:
+ - output.changed
+ - "output.agent_pool_profiles | length == 2"
+ - output.provisioning_state == 'Succeeded'
+ - output.agent_pool_profiles[1].mode == 'System'
+ ignore_errors: true
+ register: ignore_errors_register
+
+- name: Update the default2 agent_pool mode from User to System (idempontent)
+ azure_rm_aks:
+ name: "aks{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ location: eastus
+ dns_prefix: "aks{{ rpfx }}"
+ kubernetes_version: "{{ version1.azure_aks_versions[0] }}"
+ service_principal:
+ client_id: "{{ azure_client_id }}"
+ client_secret: "{{ azure_secret }}"
+ linux_profile:
+ admin_username: azureuser
+ ssh_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible
+ agent_pool_profiles:
+ - name: default
+ count: 1
+ vm_size: Standard_B2s
+ type: VirtualMachineScaleSets
+ enable_auto_scaling: true
+ max_count: 6
+ min_count: 1
+ max_pods: 42
+ availability_zones:
+ - 1
+ - 2
+ - name: default2
+ count: 1
+ vm_size: Standard_B2s
+ type: VirtualMachineScaleSets
+ mode: System
+ node_resource_group: "node{{ noderpfx }}"
+ enable_rbac: true
+ network_profile:
+ load_balancer_sku: standard
+ register: output
+
+- name: Get AKS fact
+ azure_rm_aks_info:
+ name: "aks{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ show_kubeconfig: user
+ register: fact
+
+- name: Assert fact returns the created one
+ ansible.builtin.assert:
+ that:
+ - "fact.aks | length == 1"
+ - fact.aks[0].kube_config == output.kube_config
+
+- name: Delete the AKS instance
+ azure_rm_aks:
+ name: "aks{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ state: absent
+ register: output
+
+- name: Assert the AKS instance is well deleted
+ ansible.builtin.assert:
+ that:
+ - output.changed
+
+- name: Delete the AKS instance (idempotent)
+ azure_rm_aks:
+ name: "aks{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ state: absent
+ register: output
+
+- name: Assert idempotent
+ ansible.builtin.assert:
+ that:
+ - not output.changed
+
+- name: Get AKS fact
+ azure_rm_aks_info:
+ name: "aks{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ register: fact
+
+- name: Assert fact returns empty
+ ansible.builtin.assert:
+ that:
+ - "fact.aks | length == 0"
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_aks/tasks/minimal-cluster.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_aks/tasks/minimal-cluster.yml
index bda3c06ec..79362b384 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_aks/tasks/minimal-cluster.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_aks/tasks/minimal-cluster.yml
@@ -1,4 +1,5 @@
-- set_fact:
+- name: Set varialbles
+ ansible.builtin.set_fact:
rpfx: "{{ resource_group | hash('md5') | truncate(8, True, '') }}"
- name: Find available k8s version
@@ -26,30 +27,30 @@
- "192.0.2.0"
- "198.51.100.0"
- "203.0.113.0"
- enable_private_cluster: no
+ enable_private_cluster: false
network_profile:
load_balancer_sku: standard
outbound_type: loadBalancer
register: output
- name: Assert the AKS instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.provisioning_state == 'Succeeded'
- name: Get AKS fact
azure_rm_aks_info:
- name: "minimal{{ rpfx }}"
- resource_group: "{{ resource_group }}"
+ name: "minimal{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
register: fact
- name: Assert fact returns the created one
- assert:
+ ansible.builtin.assert:
that:
- "fact.aks | length == 1"
- fact.aks[0].id == output.id
- - fact.aks[0].properties.aadProfile.managed == true
+ - fact.aks[0].aad_profile.managed == true
- name: Use minimal parameters and system-assigned identity (idempotent)
azure_rm_aks:
@@ -71,14 +72,14 @@
- "192.0.2.0"
- "198.51.100.0"
- "203.0.113.0"
- enable_private_cluster: no
+ enable_private_cluster: false
network_profile:
load_balancer_sku: standard
outbound_type: loadBalancer
register: output
- name: Assert idempotent
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
@@ -101,14 +102,14 @@
- "192.0.2.0"
- "198.51.100.0"
- "203.0.113.0"
- enable_private_cluster: no
+ enable_private_cluster: false
network_profile:
load_balancer_sku: standard
outbound_type: loadBalancer
register: output
- name: Assert idempotent
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -120,7 +121,7 @@
register: output
- name: Assert the AKS instance is well deleted
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -131,6 +132,6 @@
register: fact
- name: Assert fact returns empty
- assert:
+ ansible.builtin.assert:
that:
- "fact.aks | length == 0"
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_aksagentpool/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_aksagentpool/tasks/main.yml
index 1d098e7f1..26f71c211 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_aksagentpool/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_aksagentpool/tasks/main.yml
@@ -1,4 +1,5 @@
-- set_fact:
+- name: Set varialbes
+ ansible.builtin.set_fact:
rpfx: "{{ resource_group | hash('md5') | truncate(8, True, '') }}"
- name: Find available k8s version
@@ -26,7 +27,7 @@
- "192.0.2.0"
- "198.51.100.0"
- "203.0.113.0"
- enable_private_cluster: no
+ enable_private_cluster: false
network_profile:
load_balancer_sku: standard
outbound_type: loadBalancer
@@ -39,7 +40,7 @@
register: output
- name: Assert the cluster with one agent pool
- assert:
+ ansible.builtin.assert:
that:
- "output.aks_agent_pools | length == 1"
@@ -50,7 +51,7 @@
register: agentpool_version
- name: Assert the orchestrator version is not None
- assert:
+ ansible.builtin.assert:
that:
- "agentpool_version.azure_orchestrator_version | length >= 1"
@@ -65,7 +66,7 @@
mode: System
node_labels: {"release":"stable"}
max_pods: 42
- enable_auto_scaling: True
+ enable_auto_scaling: true
min_count: 1
max_count: 10
orchestrator_version: "{{ agentpool_version.azure_orchestrator_version[0] }}"
@@ -75,7 +76,7 @@
register: output
- name: Assert the node agent pool created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -90,7 +91,7 @@
mode: System
node_labels: {"release":"stable"}
max_pods: 42
- enable_auto_scaling: True
+ enable_auto_scaling: true
min_count: 1
max_count: 10
orchestrator_version: "{{ agentpool_version.azure_orchestrator_version[0] }}"
@@ -100,7 +101,7 @@
register: output
- name: Assert the node agent pool not changed
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
@@ -111,7 +112,7 @@
register: output
- name: Assert node agent pool
- assert:
+ ansible.builtin.assert:
that:
- "output.aks_agent_pools | length == 2"
@@ -126,7 +127,7 @@
mode: System
node_labels: {"release":"stable"}
max_pods: 42
- enable_auto_scaling: True
+ enable_auto_scaling: true
min_count: 2
max_count: 20
orchestrator_version: "{{ agentpool_version.azure_orchestrator_version[0] }}"
@@ -136,7 +137,7 @@
register: output
- name: Assert the node agent pool udpated
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -148,10 +149,9 @@
register: output
- name: Assert node agent configuration
- assert:
+ ansible.builtin.assert:
that:
- output.aks_agent_pools[0].availability_zones == [1, 2]
- - output.aks_agent_pools[0].count == 1
- output.aks_agent_pools[0].min_count == 2
- output.aks_agent_pools[0].max_count == 20
- output.aks_agent_pools[0].type_properties_type == "VirtualMachineScaleSets"
@@ -167,6 +167,6 @@
register: output
- name: Assert the node agent pool has deleted
- assert:
+ ansible.builtin.assert:
that:
- output.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_apimanagement/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_apimanagement/tasks/main.yml
index 72b5588c4..d7d9b5fc5 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_apimanagement/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_apimanagement/tasks/main.yml
@@ -1,11 +1,11 @@
- name: Fix resource prefix
- set_fact:
+ ansible.builtin.set_fact:
api_id: "myPolicy{{ resource_group | hash('md5') | truncate(23, True, '') }}"
service_name: "myService{{ resource_group | hash('md5') | truncate(22, True, '') }}"
display_name: test-api
path: myapipath
-- name: create API management service
+- name: Create API management service
azure_rm_apimanagementservice:
resource_group: "{{ resource_group }}"
name: "{{ service_name }}"
@@ -15,8 +15,9 @@
sku_capacity: 1
- name: Pause for 60 mimutes to create api mangement
- pause:
+ ansible.builtin.pause:
minutes: 60
+ changed_when: true
- name: Create a new API instance
azure_rm_apimanagement:
@@ -29,15 +30,15 @@
path: "{{ path }}"
protocols:
- https
- register: newApi
-
+ register: newapi
+
- name: Assert that output has changed
- assert:
+ ansible.builtin.assert:
that:
- - newApi.changed == True
- - newApi.failed == False
+ - newapi.changed == True
+ - newapi.failed == False
-- name: Create a new API instance(Idempotent)
+- name: Create a new API instance Idempotent
azure_rm_apimanagement:
resource_group: "{{ resource_group }}"
service_name: "{{ service_name }}"
@@ -48,15 +49,15 @@
path: "{{ path }}"
protocols:
- https
- register: newApi_idempotent
+ register: newapi_idempotent
- name: Assert that output has changed
- assert:
+ ansible.builtin.assert:
that:
- - newApi_idempotent.changed == False
- - newApi_idempotent.failed == False
+ - newapi_idempotent.changed == False
+ - newapi_idempotent.failed == False
-- name: Update API's protocols
+- name: Update protocols
azure_rm_apimanagement:
resource_group: "{{ resource_group }}"
service_name: "{{ service_name }}"
@@ -68,12 +69,12 @@
protocols:
- https
- http
- register: updateApi
+ register: updateapi
- name: Assert that output has changed
- assert:
+ ansible.builtin.assert:
that:
- - updateApi.changed == True
+ - updateapi.changed == True
- name: Create different format api
azure_rm_apimanagement:
@@ -85,13 +86,13 @@
display_name: "{{ display_name }}-secondary"
protocols:
- https
- register: newOpenApi
+ register: newopenapi
- name: Assert that output has changed
- assert:
+ ansible.builtin.assert:
that:
- - newOpenApi.changed == True
- - newOpenApi.failed == False
+ - newopenapi.changed == True
+ - newopenapi.failed == False
- name: Get api information
azure_rm_apimanagement_info:
@@ -101,7 +102,7 @@
register: output
- name: Assert that output has changed
- assert:
+ ansible.builtin.assert:
that:
- output.api.id != None
@@ -111,25 +112,25 @@
service_name: "{{ service_name }}"
api_id: "{{ api_id }}"
state: absent
- register: deleteApi
+ register: deleteapi
- name: Assert the changes
- assert:
+ ansible.builtin.assert:
that:
- - deleteApi.changed == True
+ - deleteapi.changed == True
-- name: Delete an api(Idempotent)
+- name: Delete an api Idempotent
azure_rm_apimanagement:
resource_group: "{{ resource_group }}"
service_name: "{{ service_name }}"
api_id: "{{ api_id }}"
state: absent
- register: deleteApi_idempotent
+ register: deleteapi_idempotent
- name: Assert the changes
- assert:
+ ansible.builtin.assert:
that:
- - deleteApi_idempotent.changed == False
+ - deleteapi_idempotent.changed == False
- name: Delete an api
azure_rm_apimanagement:
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_apimanagementservice/meta/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_apimanagementservice/meta/main.yml
index 48f5726d8..95e1952f9 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_apimanagementservice/meta/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_apimanagementservice/meta/main.yml
@@ -1,2 +1,2 @@
dependencies:
- - setup_azure \ No newline at end of file
+ - setup_azure
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_apimanagementservice/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_apimanagementservice/tasks/main.yml
index 0dab04af8..01b3d982c 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_apimanagementservice/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_apimanagementservice/tasks/main.yml
@@ -1,11 +1,11 @@
- name: Fix resource prefix
- set_fact:
- name: "myPolicy{{ resource_group | hash('md5') | truncate(22, True, '') }}"
+ ansible.builtin.set_fact:
+ name_rpfx: "myPolicy{{ resource_group | hash('md5') | truncate(22, True, '') }}"
-- name: To create API Management service
+- name: To create api management service
azure_rm_apimanagementservice:
resource_group: "{{ resource_group }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
publisher_email: user@example.com
publisher_name: Username
sku_name: Developer
@@ -13,15 +13,15 @@
register: output
- name: Assert that output has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed == True
- output.failed == False
-- name: Recreate API Management service( Idempotent test)
+- name: Recreate api management service idempotent test
azure_rm_apimanagementservice:
resource_group: "{{ resource_group }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
publisher_email: user@example.com
publisher_name: Username
sku_name: Developer
@@ -29,7 +29,7 @@
register: output
- name: Assert that output has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.failed == False
@@ -37,22 +37,22 @@
- name: Get api management service information
azure_rm_apimanagementservice_info:
resource_group: "{{ resource_group }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
register: output
- name: Assert that output has changed
- assert:
+ ansible.builtin.assert:
that:
- - output.api_management_service.name == "{{ name }}"
+ - output.api_management_service.name == "{{ name_rpfx }}"
- name: To delete an api management service
azure_rm_apimanagementservice:
resource_group: "{{ resource_group }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
state: absent
register: output
- name: Assert the changes
- assert:
+ ansible.builtin.assert:
that:
- output.changed == True
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_appgateway/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_appgateway/tasks/main.yml
index 1367300c7..b5584d2f5 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_appgateway/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_appgateway/tasks/main.yml
@@ -1,20 +1,20 @@
- name: Prepare random number
- set_fact:
+ ansible.builtin.set_fact:
rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
cert1_file: "cert1.txt"
cert2_file: "cert2.txt"
cert3b64_file: "cert3b64.txt"
- run_once: yes
+ run_once: true
- name: Set json query to only retrieve gateways from this test
- set_fact:
+ ansible.builtin.set_fact:
query: "[?ends_with(name, `{{ rpfx }}`)]"
- run_once: yes
+ run_once: true
- name: Load app gateways
azure_rm_appgateway_info:
register: appgw_output
- name: Assert there are no gateways
- assert:
+ ansible.builtin.assert:
that:
- appgw_output.gateways | community.general.json_query(query) | length == 0
@@ -23,11 +23,11 @@
name: vnet{{ rpfx }}
resource_group: "{{ resource_group }}"
address_prefixes_cidr:
- - 10.1.0.0/16
- - 172.100.0.0/16
+ - 10.1.0.0/16
+ - 172.100.0.0/16
dns_servers:
- - 127.0.0.1
- - 127.0.0.2
+ - 127.0.0.1
+ - 127.0.0.2
register: vnet_output
- name: Create a subnet
azure_rm_subnet:
@@ -73,13 +73,13 @@
- ip_address: 10.0.0.4
name: test_backend_address_pool
probes:
- - name: custom_probe
- protocol: http
- host: 10.0.0.4
- path: /healthz
- interval: 30
- timeout: 30
- unhealthy_threshold: 3
+ - name: custom_probe
+ protocol: http
+ host: 10.0.0.4
+ path: /healthz
+ interval: 30
+ timeout: 30
+ unhealthy_threshold: 3
backend_http_settings_collection:
- port: 80
protocol: http
@@ -97,29 +97,29 @@
protocol: http
name: http_listener
request_routing_rules:
- - rule_type: Basic
+ - rule_type: basic
backend_address_pool: test_backend_address_pool
backend_http_settings: sample_appgateway_http_settings
http_listener: sample_http_listener
name: rule1
- - rule_type: Basic
+ - rule_type: basic
http_listener: http_listener
redirect_configuration: redirect_site_to_https
name: http_redirect_rule
redirect_configurations:
- - redirect_type: permanent
- target_listener: sample_http_listener
- include_path: true
- include_query_string: true
- name: redirect_site_to_https
+ - redirect_type: permanent
+ target_listener: sample_http_listener
+ include_path: true
+ include_query_string: true
+ name: redirect_site_to_https
register: output
- check_mode: yes
+ check_mode: true
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
-- name: Create instance of Application Gateway
+- name: Create instance of application gateway
azure_rm_appgateway:
resource_group: "{{ resource_group }}"
name: "appgateway{{ rpfx }}"
@@ -155,13 +155,13 @@
- ip_address: 10.0.0.4
name: test_backend_address_pool
probes:
- - name: custom_probe
- protocol: http
- host: 10.0.0.4
- path: /healthz
- interval: 30
- timeout: 30
- unhealthy_threshold: 3
+ - name: custom_probe
+ protocol: http
+ host: 10.0.0.4
+ path: /healthz
+ interval: 30
+ timeout: 30
+ unhealthy_threshold: 3
backend_http_settings_collection:
- port: 80
protocol: http
@@ -179,24 +179,24 @@
protocol: http
name: http_listener
request_routing_rules:
- - rule_type: Basic
+ - rule_type: basic
backend_address_pool: test_backend_address_pool
backend_http_settings: sample_appgateway_http_settings
http_listener: sample_http_listener
name: rule1
- - rule_type: Basic
+ - rule_type: basic
http_listener: http_listener
redirect_configuration: redirect_site_to_https
name: http_redirect_rule
redirect_configurations:
- - redirect_type: permanent
- target_listener: sample_http_listener
- include_path: true
- include_query_string: true
- name: redirect_site_to_https
+ - redirect_type: permanent
+ target_listener: sample_http_listener
+ include_path: true
+ include_query_string: true
+ name: redirect_site_to_https
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -206,7 +206,7 @@
resource_group: "{{ resource_group }}"
register: output
- name: Assert properties
- assert:
+ ansible.builtin.assert:
that:
- output.gateways | length == 1
- output.gateways[0].name == 'appgateway{{ rpfx }}'
@@ -222,7 +222,7 @@
check_mode: true
register: output
- name: Assert the resource instance is stopped
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -233,7 +233,7 @@
gateway_state: stopped
register: output
- name: Assert the resource instance is stopped
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.operational_state == 'Stopped'
@@ -245,7 +245,7 @@
gateway_state: stopped
register: output
- name: Assert the resource instance did not change
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
- output.operational_state == 'Stopped'
@@ -258,7 +258,7 @@
check_mode: true
register: output
- name: Assert the resource instance is started
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -269,7 +269,7 @@
gateway_state: started
register: output
- name: Assert the resource instance is started
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.operational_state == 'Running'
@@ -281,7 +281,7 @@
gateway_state: started
register: output
- name: Assert the resource instance did not change
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
- output.operational_state == 'Running'
@@ -322,13 +322,13 @@
- ip_address: 10.0.0.4
name: test_backend_address_pool
probes:
- - name: custom_probe
- protocol: http
- host: 10.0.0.4
- path: /healthz
- interval: 30
- timeout: 30
- unhealthy_threshold: 3
+ - name: custom_probe
+ protocol: http
+ host: 10.0.0.4
+ path: /healthz
+ interval: 30
+ timeout: 30
+ unhealthy_threshold: 3
backend_http_settings_collection:
- port: 80
protocol: http
@@ -346,24 +346,24 @@
protocol: http
name: http_listener
request_routing_rules:
- - rule_type: Basic
+ - rule_type: basic
backend_address_pool: test_backend_address_pool
backend_http_settings: sample_appgateway_http_settings
http_listener: sample_http_listener
name: rule1
- - rule_type: Basic
+ - rule_type: basic
http_listener: http_listener
redirect_configuration: redirect_site_to_https
name: http_redirect_rule
redirect_configurations:
- - redirect_type: permanent
- target_listener: sample_http_listener
- include_path: true
- include_query_string: true
- name: redirect_site_to_https
+ - redirect_type: permanent
+ target_listener: sample_http_listener
+ include_path: true
+ include_query_string: true
+ name: redirect_site_to_https
register: output
- name: Assert the resource instance is not changed
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
@@ -403,13 +403,13 @@
- ip_address: 10.0.0.4
name: test_backend_address_pool
probes:
- - name: custom_probe
- protocol: http
- host: 10.0.0.4
- path: /healthz
- interval: 30
- timeout: 30
- unhealthy_threshold: 3
+ - name: custom_probe
+ protocol: http
+ host: 10.0.0.4
+ path: /healthz
+ interval: 30
+ timeout: 30
+ unhealthy_threshold: 3
backend_http_settings_collection:
- port: 81
protocol: http
@@ -427,24 +427,24 @@
protocol: http
name: http_listener
request_routing_rules:
- - rule_type: Basic
+ - rule_type: basic
backend_address_pool: test_backend_address_pool
backend_http_settings: sample_appgateway_http_settings
http_listener: sample_http_listener
name: rule1
- - rule_type: Basic
+ - rule_type: basic
http_listener: http_listener
redirect_configuration: redirect_site_to_https
name: http_redirect_rule
redirect_configurations:
- - redirect_type: permanent
- target_listener: sample_http_listener
- include_path: true
- include_query_string: true
- name: redirect_site_to_https
+ - redirect_type: permanent
+ target_listener: sample_http_listener
+ include_path: true
+ include_query_string: true
+ name: redirect_site_to_https
register: output
- name: Assert the resource instance is updated
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -488,13 +488,13 @@
- ip_address: 10.0.0.4
name: test_backend_address_pool
probes:
- - name: custom_probe
- protocol: http
- host: 10.0.0.4
- path: /healthz
- interval: 30
- timeout: 30
- unhealthy_threshold: 3
+ - name: custom_probe
+ protocol: http
+ host: 10.0.0.4
+ path: /healthz
+ interval: 30
+ timeout: 30
+ unhealthy_threshold: 3
backend_http_settings_collection:
- port: 81
protocol: http
@@ -512,24 +512,24 @@
protocol: http
name: http_listener
request_routing_rules:
- - rule_type: Basic
+ - rule_type: basic
backend_address_pool: test_backend_address_pool
backend_http_settings: sample_appgateway_http_settings
http_listener: sample_http_listener
name: rule1
- - rule_type: Basic
+ - rule_type: basic
http_listener: http_listener
redirect_configuration: redirect_site_to_https
name: http_redirect_rule
redirect_configurations:
- - redirect_type: permanent
- target_listener: sample_http_listener
- include_path: true
- include_query_string: true
- name: redirect_site_to_https
+ - redirect_type: permanent
+ target_listener: sample_http_listener
+ include_path: true
+ include_query_string: true
+ name: redirect_site_to_https
register: output
- name: Assert the resource instance is updated
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -539,7 +539,7 @@
resource_group: "{{ resource_group }}"
register: output
- name: Assert SSL config updated
- assert:
+ ansible.builtin.assert:
that:
- output.gateways[0].ssl_policy.policy_type == 'custom'
@@ -583,13 +583,13 @@
- ip_address: 10.0.0.4
name: test_backend_address_pool
probes:
- - name: custom_probe
- protocol: http
- host: 10.0.0.4
- path: /healthz
- interval: 30
- timeout: 30
- unhealthy_threshold: 3
+ - name: custom_probe
+ protocol: http
+ host: 10.0.0.4
+ path: /healthz
+ interval: 30
+ timeout: 30
+ unhealthy_threshold: 3
backend_http_settings_collection:
- port: 81
protocol: http
@@ -607,24 +607,24 @@
protocol: http
name: http_listener
request_routing_rules:
- - rule_type: Basic
+ - rule_type: basic
backend_address_pool: test_backend_address_pool
backend_http_settings: sample_appgateway_http_settings
http_listener: sample_http_listener
name: rule1
- - rule_type: Basic
+ - rule_type: basic
http_listener: http_listener
redirect_configuration: redirect_site_to_https
name: http_redirect_rule
redirect_configurations:
- - redirect_type: permanent
- target_listener: sample_http_listener
- include_path: true
- include_query_string: true
- name: redirect_site_to_https
+ - redirect_type: permanent
+ target_listener: sample_http_listener
+ include_path: true
+ include_query_string: true
+ name: redirect_site_to_https
register: output
- name: Assert the resource instance is not changed
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
@@ -666,13 +666,13 @@
- ip_address: 10.0.0.4
name: test_backend_address_pool
probes:
- - name: custom_probe
- protocol: http
- host: 10.0.0.4
- path: /healthz
- interval: 30
- timeout: 30
- unhealthy_threshold: 3
+ - name: custom_probe
+ protocol: http
+ host: 10.0.0.4
+ path: /healthz
+ interval: 30
+ timeout: 30
+ unhealthy_threshold: 3
backend_http_settings_collection:
- port: 80
protocol: http
@@ -690,24 +690,24 @@
protocol: http
name: http_listener
request_routing_rules:
- - rule_type: Basic
+ - rule_type: basic
backend_address_pool: test_backend_address_pool
backend_http_settings: sample_appgateway_http_settings
http_listener: sample_http_listener
name: rule1
- - rule_type: Basic
+ - rule_type: basic
http_listener: http_listener
redirect_configuration: redirect_site_to_https
name: http_redirect_rule
redirect_configurations:
- - redirect_type: permanent
- target_listener: sample_http_listener
- include_path: true
- include_query_string: true
- name: redirect_site_to_https
+ - redirect_type: permanent
+ target_listener: sample_http_listener
+ include_path: true
+ include_query_string: true
+ name: redirect_site_to_https
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -715,7 +715,7 @@
azure_rm_appgateway_info:
register: appgw_output
- name: Assert there are the correct number of gateways
- assert:
+ ansible.builtin.assert:
that:
- appgw_output.gateways | community.general.json_query(query) | length == 2
@@ -725,7 +725,7 @@
resource_group: "{{ resource_group }}"
register: appgw_output
- name: Assert there are the correct number of gateways
- assert:
+ ansible.builtin.assert:
that:
- appgw_output.gateways | community.general.json_query(query) | length == 1
- (appgw_output.gateways | community.general.json_query(query))[0].name == 'appgateway-subnet-lookup{{ rpfx }}'
@@ -769,13 +769,13 @@
- ip_address: 10.0.0.4
name: test_backend_address_pool
probes:
- - name: custom_probe
- protocol: http
- path: /healthz
- interval: 30
- timeout: 30
- unhealthy_threshold: 3
- pick_host_name_from_backend_http_settings: true
+ - name: custom_probe
+ protocol: http
+ path: /healthz
+ interval: 30
+ timeout: 30
+ unhealthy_threshold: 3
+ pick_host_name_from_backend_http_settings: true
backend_http_settings_collection:
- port: 80
protocol: http
@@ -794,24 +794,24 @@
protocol: http
name: http_listener
request_routing_rules:
- - rule_type: Basic
+ - rule_type: basic
backend_address_pool: test_backend_address_pool
backend_http_settings: sample_appgateway_http_settings
http_listener: sample_http_listener
name: rule1
- - rule_type: Basic
+ - rule_type: basic
http_listener: http_listener
redirect_configuration: redirect_site_to_https
name: http_redirect_rule
redirect_configurations:
- - redirect_type: permanent
- target_listener: sample_http_listener
- include_path: true
- include_query_string: true
- name: redirect_site_to_https
+ - redirect_type: permanent
+ target_listener: sample_http_listener
+ include_path: true
+ include_query_string: true
+ name: redirect_site_to_https
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -852,13 +852,13 @@
- ip_address: 10.0.0.4
name: test_backend_address_pool
probes:
- - name: custom_probe
- protocol: http
- path: /healthz
- interval: 30
- timeout: 30
- unhealthy_threshold: 3
- pick_host_name_from_backend_http_settings: true
+ - name: custom_probe
+ protocol: http
+ path: /healthz
+ interval: 30
+ timeout: 30
+ unhealthy_threshold: 3
+ pick_host_name_from_backend_http_settings: true
backend_http_settings_collection:
- port: 80
protocol: http
@@ -877,24 +877,24 @@
protocol: http
name: http_listener
request_routing_rules:
- - rule_type: Basic
+ - rule_type: basic
backend_address_pool: test_backend_address_pool
backend_http_settings: sample_appgateway_http_settings
http_listener: sample_http_listener
name: rule1
- - rule_type: Basic
+ - rule_type: basic
http_listener: http_listener
redirect_configuration: redirect_site_to_https
name: http_redirect_rule
redirect_configurations:
- - redirect_type: permanent
- target_listener: sample_http_listener
- include_path: true
- include_query_string: true
- name: redirect_site_to_https
+ - redirect_type: permanent
+ target_listener: sample_http_listener
+ include_path: true
+ include_query_string: true
+ name: redirect_site_to_https
register: output
- name: Assert the resource instance is not changed
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
@@ -903,7 +903,7 @@
resource_group: "{{ resource_group_secondary }}"
register: appgw_output
- name: Assert there are the correct number of gateways and they are the right ones
- assert:
+ ansible.builtin.assert:
that:
- appgw_output.gateways | community.general.json_query(query) | length == 1
- (appgw_output.gateways | community.general.json_query(query))[0].name == 'appgateway-probe-{{ rpfx }}'
@@ -914,7 +914,7 @@
resource_group: "{{ resource_group_secondary }}"
register: appgw_output
- name: Assert there are no results
- assert:
+ ansible.builtin.assert:
that:
- appgw_output.gateways | community.general.json_query(query) | length == 0
@@ -954,13 +954,13 @@
- ip_address: 10.0.0.4
name: test_backend_address_pool
probes:
- - name: custom_probe
- protocol: http
- host: 10.0.0.4
- path: /healthz
- interval: 30
- timeout: 30
- unhealthy_threshold: 3
+ - name: custom_probe
+ protocol: http
+ host: 10.0.0.4
+ path: /healthz
+ interval: 30
+ timeout: 30
+ unhealthy_threshold: 3
backend_http_settings_collection:
- port: 80
protocol: http
@@ -982,7 +982,7 @@
http_listener: sample_http_listener
name: rule1
url_path_map: path_mappings
- - rule_type: Basic
+ - rule_type: basic
http_listener: http_listener
redirect_configuration: redirect_site_to_https
name: http_redirect_rule
@@ -998,14 +998,14 @@
- "/abc"
- "/123/*"
redirect_configurations:
- - redirect_type: permanent
- target_listener: sample_http_listener
- include_path: true
- include_query_string: true
- name: redirect_site_to_https
+ - redirect_type: permanent
+ target_listener: sample_http_listener
+ include_path: true
+ include_query_string: true
+ name: redirect_site_to_https
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -1045,13 +1045,13 @@
- ip_address: 10.0.0.4
name: test_backend_address_pool
probes:
- - name: custom_probe
- protocol: http
- host: 10.0.0.4
- path: /healthz
- interval: 30
- timeout: 30
- unhealthy_threshold: 3
+ - name: custom_probe
+ protocol: http
+ host: 10.0.0.4
+ path: /healthz
+ interval: 30
+ timeout: 30
+ unhealthy_threshold: 3
backend_http_settings_collection:
- port: 80
protocol: http
@@ -1073,7 +1073,7 @@
http_listener: sample_http_listener
name: rule1
url_path_map: path_mappings
- - rule_type: Basic
+ - rule_type: basic
http_listener: http_listener
redirect_configuration: redirect_site_to_https
name: http_redirect_rule
@@ -1089,14 +1089,14 @@
- "/abc"
- "/123/*"
redirect_configurations:
- - redirect_type: permanent
- target_listener: sample_http_listener
- include_path: true
- include_query_string: true
- name: redirect_site_to_https
+ - redirect_type: permanent
+ target_listener: sample_http_listener
+ include_path: true
+ include_query_string: true
+ name: redirect_site_to_https
register: output
- name: Assert the resource instance is not changed
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
@@ -1192,20 +1192,20 @@
http_listener: "inbound-http"
redirect_configuration: "redirect-http"
probes:
- - name: "http-probe1"
- interval: 30
- path: "/abc"
- protocol: "https"
- pick_host_name_from_backend_http_settings: true
- timeout: 30
- unhealthy_threshold: 2
- - name: "http-probe2"
- interval: 30
- path: "/xyz"
- protocol: "http"
- pick_host_name_from_backend_http_settings: true
- timeout: 30
- unhealthy_threshold: 2
+ - name: "http-probe1"
+ interval: 30
+ path: "/abc"
+ protocol: "https"
+ pick_host_name_from_backend_http_settings: true
+ timeout: 30
+ unhealthy_threshold: 2
+ - name: "http-probe2"
+ interval: 30
+ path: "/xyz"
+ protocol: "http"
+ pick_host_name_from_backend_http_settings: true
+ timeout: 30
+ unhealthy_threshold: 2
redirect_configurations:
- name: "redirect-http"
redirect_type: "permanent"
@@ -1223,7 +1223,7 @@
- "path_mappings"
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -1319,20 +1319,20 @@
http_listener: "inbound-http"
redirect_configuration: "redirect-http"
probes:
- - name: "http-probe1"
- interval: 30
- path: "/abc"
- protocol: "https"
- pick_host_name_from_backend_http_settings: true
- timeout: 30
- unhealthy_threshold: 2
- - name: "http-probe2"
- interval: 30
- path: "/xyz"
- protocol: "http"
- pick_host_name_from_backend_http_settings: true
- timeout: 30
- unhealthy_threshold: 2
+ - name: "http-probe1"
+ interval: 30
+ path: "/abc"
+ protocol: "https"
+ pick_host_name_from_backend_http_settings: true
+ timeout: 30
+ unhealthy_threshold: 2
+ - name: "http-probe2"
+ interval: 30
+ path: "/xyz"
+ protocol: "http"
+ pick_host_name_from_backend_http_settings: true
+ timeout: 30
+ unhealthy_threshold: 2
redirect_configurations:
- name: "redirect-http"
redirect_type: "permanent"
@@ -1350,7 +1350,7 @@
- "path_mappings"
register: output
- name: Assert the resource instance is not changed
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
@@ -1481,20 +1481,20 @@
- header_name: "Foo"
header_value: "Bar"
probes:
- - name: "http-probe1"
- interval: 30
- path: "/abc"
- protocol: "https"
- pick_host_name_from_backend_http_settings: true
- timeout: 30
- unhealthy_threshold: 2
- - name: "http-probe2"
- interval: 30
- path: "/xyz"
- protocol: "http"
- pick_host_name_from_backend_http_settings: true
- timeout: 30
- unhealthy_threshold: 2
+ - name: "http-probe1"
+ interval: 30
+ path: "/abc"
+ protocol: "https"
+ pick_host_name_from_backend_http_settings: true
+ timeout: 30
+ unhealthy_threshold: 2
+ - name: "http-probe2"
+ interval: 30
+ path: "/xyz"
+ protocol: "http"
+ pick_host_name_from_backend_http_settings: true
+ timeout: 30
+ unhealthy_threshold: 2
redirect_configurations:
- name: "redirect-http"
redirect_type: "permanent"
@@ -1512,7 +1512,7 @@
- "path_mappings"
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -1636,20 +1636,20 @@
- header_name: "Foo"
header_value: "Bar"
probes:
- - name: "http-probe1"
- interval: 30
- path: "/abc"
- protocol: "https"
- pick_host_name_from_backend_http_settings: true
- timeout: 30
- unhealthy_threshold: 2
- - name: "http-probe2"
- interval: 30
- path: "/xyz"
- protocol: "http"
- pick_host_name_from_backend_http_settings: true
- timeout: 30
- unhealthy_threshold: 2
+ - name: "http-probe1"
+ interval: 30
+ path: "/abc"
+ protocol: "https"
+ pick_host_name_from_backend_http_settings: true
+ timeout: 30
+ unhealthy_threshold: 2
+ - name: "http-probe2"
+ interval: 30
+ path: "/xyz"
+ protocol: "http"
+ pick_host_name_from_backend_http_settings: true
+ timeout: 30
+ unhealthy_threshold: 2
redirect_configurations:
- name: "redirect-http"
redirect_type: "permanent"
@@ -1667,7 +1667,7 @@
- "path_mappings"
register: output
- name: Assert the resource instance is not updated
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
@@ -1794,20 +1794,20 @@
- header_name: "FooResponse"
header_value: "BarResponse"
probes:
- - name: "http-probe1"
- interval: 30
- path: "/abc"
- protocol: "https"
- pick_host_name_from_backend_http_settings: true
- timeout: 30
- unhealthy_threshold: 2
- - name: "http-probe2"
- interval: 30
- path: "/xyz"
- protocol: "http"
- pick_host_name_from_backend_http_settings: true
- timeout: 30
- unhealthy_threshold: 2
+ - name: "http-probe1"
+ interval: 30
+ path: "/abc"
+ protocol: "https"
+ pick_host_name_from_backend_http_settings: true
+ timeout: 30
+ unhealthy_threshold: 2
+ - name: "http-probe2"
+ interval: 30
+ path: "/xyz"
+ protocol: "http"
+ pick_host_name_from_backend_http_settings: true
+ timeout: 30
+ unhealthy_threshold: 2
redirect_configurations:
- name: "redirect-http"
redirect_type: "permanent"
@@ -1825,7 +1825,7 @@
- "path_mappings"
register: output
- name: Assert the resource instance is updated
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -1877,8 +1877,8 @@
probe: "http-probe1"
cookie_based_affinity: "Disabled"
connection_draining:
- drain_timeout_in_sec: 60
- enabled: true
+ drain_timeout_in_sec: 60
+ enabled: true
trusted_root_certificates:
- "rootCert3"
- name: "http-profile2"
@@ -1960,20 +1960,20 @@
- header_name: "Foo"
header_value: "Bar"
probes:
- - name: "http-probe1"
- interval: 30
- path: "/abc"
- protocol: "https"
- pick_host_name_from_backend_http_settings: true
- timeout: 30
- unhealthy_threshold: 2
- - name: "http-probe2"
- interval: 30
- path: "/xyz"
- protocol: "http"
- pick_host_name_from_backend_http_settings: true
- timeout: 30
- unhealthy_threshold: 2
+ - name: "http-probe1"
+ interval: 30
+ path: "/abc"
+ protocol: "https"
+ pick_host_name_from_backend_http_settings: true
+ timeout: 30
+ unhealthy_threshold: 2
+ - name: "http-probe2"
+ interval: 30
+ path: "/xyz"
+ protocol: "http"
+ pick_host_name_from_backend_http_settings: true
+ timeout: 30
+ unhealthy_threshold: 2
redirect_configurations:
- name: "redirect-http"
redirect_type: "permanent"
@@ -1992,7 +1992,7 @@
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -2160,7 +2160,7 @@
register: output
- name: Assert the resource instance is not updated
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
@@ -2321,17 +2321,17 @@
url_path_maps:
- "path_mappings"
web_application_firewall_configuration:
- enabled: true
- firewall_mode: "Detection"
- rule_set_type: "OWASP"
- rule_set_version: "3.0"
- request_body_check: true
- max_request_body_size_in_kb: 128
- file_upload_limit_in_mb: 100
+ enabled: true
+ firewall_mode: "Detection"
+ rule_set_type: "OWASP"
+ rule_set_version: "3.0"
+ request_body_check: true
+ max_request_body_size_in_kb: 128
+ file_upload_limit_in_mb: 100
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -2495,7 +2495,7 @@
register: output
- name: Assert the resource instance is not updated
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
@@ -2504,10 +2504,10 @@
resource_group: "{{ resource_group }}"
name: "appgateway{{ rpfx }}"
state: absent
- check_mode: yes
+ check_mode: true
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -2518,7 +2518,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -2529,7 +2529,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed == false
@@ -2540,7 +2540,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -2551,7 +2551,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -2562,7 +2562,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -2573,7 +2573,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -2584,7 +2584,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -2595,7 +2595,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -2606,7 +2606,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -2617,7 +2617,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_appserviceplan/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_appserviceplan/tasks/main.yml
index 3e0906bfc..3c65aa299 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_appserviceplan/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_appserviceplan/tasks/main.yml
@@ -1,29 +1,29 @@
- name: Prepare facts
- set_fact:
+ ansible.builtin.set_fact:
resource_prefix: "{{ resource_group_secondary | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
- run_once: yes
+ run_once: true
- name: Prepare facts
- set_fact:
+ ansible.builtin.set_fact:
linux_plan_resource_group: "{{ resource_group_secondary }}"
- win_plan_name: "{{ (resource_prefix | replace('-','x'))[-8:] }}winplan"
- linux_plan_name: "{{ (resource_prefix | replace('-','x'))[-8:] }}linplan"
- run_once: yes
+ win_plan_name: "{{ (resource_prefix | replace('-', 'x'))[-8:] }}winplan"
+ linux_plan_name: "{{ (resource_prefix | replace('-', 'x'))[-8:] }}linplan"
+ run_once: true
-- name: create a windows plan
+- name: Create a windows plan
azure_rm_appserviceplan:
name: "{{ win_plan_name }}1"
resource_group: "{{ resource_group }}"
sku: B1
register: output
-- name: assert app service was created
- assert:
+- name: Assert app service was created
+ ansible.builtin.assert:
that:
- output.changed
- output.id
-- name: create a linux plan
+- name: Create a linux plan
azure_rm_appserviceplan:
resource_group: "{{ linux_plan_resource_group }}"
name: "{{ linux_plan_name }}1"
@@ -32,25 +32,25 @@
number_of_workers: 1
register: output
-- name: assert app service was created
- assert:
+- name: Assert app service was created
+ ansible.builtin.assert:
that:
- output.changed
- output.id
-- name: get app service plan by name
+- name: Get app service plan by name
azure_rm_appserviceplan_info:
resource_group: "{{ linux_plan_resource_group }}"
name: "{{ linux_plan_name }}1"
register: output
-- name: assert is_linux is True
- assert:
+- name: Assert is_linux is True
+ ansible.builtin.assert:
that:
- output.appserviceplans | length == 1
- output.appserviceplans[0].is_linux == True
-- name: create linux app service plan idempotent
+- name: Create linux app service plan idempotent
azure_rm_appserviceplan:
resource_group: "{{ linux_plan_resource_group }}"
name: "{{ linux_plan_name }}1"
@@ -59,23 +59,23 @@
number_of_workers: 1
register: output
-- name: assert app service is not updated
- assert:
+- name: Assert app service is not updated
+ ansible.builtin.assert:
that: not output.changed
-- name: update a windows plan sku
+- name: Update a windows plan sku
azure_rm_appserviceplan:
name: "{{ win_plan_name }}1"
resource_group: "{{ resource_group }}"
sku: B2
register: output
-- name: assert app service was updated
- assert:
+- name: Assert app service was updated
+ ansible.builtin.assert:
that:
- output.changed
-- name: update a linux plan number of workers
+- name: Update a linux plan number of workers
azure_rm_appserviceplan:
resource_group: "{{ linux_plan_resource_group }}"
name: "{{ linux_plan_name }}1"
@@ -84,12 +84,12 @@
number_of_workers: 2
register: output
-- name: assert app service was updated
- assert:
+- name: Assert app service was updated
+ ansible.builtin.assert:
that:
- output.changed
-- name: create premium linux plan
+- name: Create premium linux plan
azure_rm_appserviceplan:
resource_group: "{{ linux_plan_resource_group }}"
name: "{{ linux_plan_name }}-premium"
@@ -97,13 +97,13 @@
is_linux: true
register: output
-- name: assert app service was created
- assert:
+- name: Assert app service was created
+ ansible.builtin.assert:
that:
- output.changed
- output.id
-- name: create premium linux plan idempotent
+- name: Create premium linux plan idempotent
azure_rm_appserviceplan:
resource_group: "{{ linux_plan_resource_group }}"
name: "{{ linux_plan_name }}-premium"
@@ -111,6 +111,6 @@
is_linux: true
register: output
-- name: assert app service is not updated
- assert:
+- name: Assert app service is not updated
+ ansible.builtin.assert:
that: not output.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_automationaccount/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_automationaccount/tasks/main.yml
index 1e00eb9ac..96e386733 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_automationaccount/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_automationaccount/tasks/main.yml
@@ -1,88 +1,95 @@
- name: Prepare random number
- set_fact:
+ ansible.builtin.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: yes
+ name_rpfx: "account{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
+ run_once: true
- name: Create automation account
azure_rm_automationaccount:
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
resource_group: "{{ resource_group }}"
- check_mode: yes
+ check_mode: true
register: output
-- assert:
+- name: Check the check mode return
+ ansible.builtin.assert:
that:
- - output.changed
+ - output.changed
- name: Create automation account
azure_rm_automationaccount:
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
resource_group: "{{ resource_group }}"
register: output
-- assert:
+- name: Assert the account created
+ ansible.builtin.assert:
that:
- - output.changed
- - output.id
+ - output.changed
+ - output.id
- name: Create automation account
azure_rm_automationaccount:
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
resource_group: "{{ resource_group }}"
register: output
-- assert:
+- name: Assert the account already created
+ ansible.builtin.assert:
that:
- - not output.changed
+ - not output.changed
- name: Get automation account
azure_rm_automationaccount_info:
- name: "{{ name }}"
- resource_group: "{{ resource_group }}"
- list_statistics: yes
- list_usages: yes
- list_keys: yes
+ name: "{{ name_rpfx }}"
+ resource_group: "{{ resource_group }}"
+ list_statistics: true
+ list_usages: true
+ list_keys: true
register: facts
-- assert:
+- name: Assert the account facts
+ ansible.builtin.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"
+ - 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
azure_rm_automationaccount:
- name: "{{ name }}"
- resource_group: "{{ resource_group }}"
- state: absent
- check_mode: yes
+ name: "{{ name_rpfx }}"
+ resource_group: "{{ resource_group }}"
+ state: absent
+ check_mode: true
register: output
-- assert:
- that:
- - output.changed
+- name: Assert the account deleted
+ ansible.builtin.assert:
+ that:
+ - output.changed
- name: Delete account
azure_rm_automationaccount:
- name: "{{ name }}"
- resource_group: "{{ resource_group }}"
- state: absent
+ name: "{{ name_rpfx }}"
+ resource_group: "{{ resource_group }}"
+ state: absent
register: output
-- assert:
- that:
- - output.changed
+- name: Assert the account deleted
+ ansible.builtin.assert:
+ that:
+ - output.changed
- name: Delete account
azure_rm_automationaccount:
- name: "{{ name }}"
- resource_group: "{{ resource_group }}"
- state: absent
+ name: "{{ name_rpfx }}"
+ resource_group: "{{ resource_group }}"
+ state: absent
register: output
-- assert:
- that:
- - not output.changed
+- name: Assert the account delete
+ ansible.builtin.assert:
+ that:
+ - not output.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_automationrunbook/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_automationrunbook/tasks/main.yml
index d6f7ba8a1..1901474c3 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_automationrunbook/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_automationrunbook/tasks/main.yml
@@ -1,23 +1,23 @@
- name: Prepare random number
- set_fact:
+ ansible.builtin.set_fact:
rpfx: "{{ resource_group | hash('md5') | truncate(10, True, '') }}"
- run_once: yes
+ run_once: true
- name: Create automation account
azure_rm_automationaccount:
name: "account-{{ rpfx }}"
resource_group: "{{ resource_group }}"
-- name: create automation runbook (check mode)
+- name: Create automation runbook (check mode)
azure_rm_automationrunbook:
resource_group: "{{ resource_group }}"
automation_account_name: "account-{{ rpfx }}"
name: "runbook-{{ rpfx }}"
runbook_type: "Script"
description: "Fred test"
- check_mode: yes
+ check_mode: true
-- name: create automation runbook with default parameters
+- name: Create automation runbook with default parameters
azure_rm_automationrunbook:
resource_group: "{{ resource_group }}"
automation_account_name: "account-{{ rpfx }}"
@@ -27,11 +27,11 @@
register: output
- name: Assert the automation runbook is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
-- name: create automation runbook with default parameters (idempotent)
+- name: Create automation runbook with default parameters (idempotent)
azure_rm_automationrunbook:
resource_group: "{{ resource_group }}"
automation_account_name: "account-{{ rpfx }}"
@@ -41,11 +41,11 @@
register: output
- name: Assert the automation runbook is well created
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
-- name: Create automation runbook with more paramters
+- name: Create automation runbook with more paramters
azure_rm_automationrunbook:
resource_group: "{{ resource_group }}"
automation_account_name: "account-{{ rpfx }}"
@@ -53,18 +53,18 @@
runbook_type: "Script"
description: "test"
log_activity_trace: 2
- log_progress: False
- log_verbose: True
- tags:
+ log_progress: false
+ log_verbose: true
+ tags:
key1: value1
register: output
- name: Assert the automation runbook is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
-- name: Update automation runbook with more paramters
+- name: Update automation runbook with more paramters
azure_rm_automationrunbook:
resource_group: "{{ resource_group }}"
automation_account_name: "account-{{ rpfx }}"
@@ -72,27 +72,27 @@
runbook_type: "Script"
description: "update"
log_activity_trace: 3
- log_progress: True
- log_verbose: False
- tags:
+ log_progress: true
+ log_verbose: false
+ tags:
key2: value2
register: output
- name: Assert the automation runbook is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
-- name: Publish automation runbook
+- name: Publish automation runbook
azure_rm_automationrunbook:
resource_group: "{{ resource_group }}"
automation_account_name: "account-{{ rpfx }}"
name: "runbook-{{ rpfx }}-secondary"
- publish: True
+ publish: true
register: output
- name: Assert the automation runbook is well published
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -104,7 +104,7 @@
register: output
- name: Assert the automation runbook is well created
- assert:
+ ansible.builtin.assert:
that:
- output.automation_runbook[0].description == 'update'
- output.automation_runbook[0].log_activity_trace == 3
@@ -120,18 +120,18 @@
register: output
- name: Assert the automation runbook is well created
- assert:
+ ansible.builtin.assert:
that:
- output.automation_runbook | length == 2
-- name: delete automation runbook
+- name: Delete automation runbook
azure_rm_automationrunbook:
resource_group: "{{ resource_group }}"
automation_account_name: "account-{{ rpfx }}"
name: "runbook-{{ rpfx }}"
state: absent
-- name: delete automation runbook
+- name: Delete automation runbook
azure_rm_automationrunbook:
resource_group: "{{ resource_group }}"
automation_account_name: "account-{{ rpfx }}"
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_autoscale/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_autoscale/tasks/main.yml
index 8c8f144dc..4a19ee340 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_autoscale/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_autoscale/tasks/main.yml
@@ -1,8 +1,8 @@
- name: Prepare random number
- set_fact:
+ ansible.builtin.set_fact:
rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
- name: "scale{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
- run_once: yes
+ name_rpfx: "scale{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
+ run_once: true
- name: Create virtual network
azure_rm_virtualnetwork:
@@ -35,9 +35,9 @@
managed_disk_type: Standard_LRS
os_disk_caching: ReadWrite
image:
- offer: UbuntuServer
+ offer: 0001-com-ubuntu-server-focal
publisher: Canonical
- sku: 18.04-LTS
+ sku: 20_04-lts
version: latest
data_disks:
- lun: 0
@@ -46,157 +46,164 @@
managed_disk_type: Standard_LRS
register: vmss
-- name: create auto scaling (check mode)
+- name: Create auto scaling (check mode)
azure_rm_autoscale:
resource_group: "{{ resource_group }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
target: "{{ vmss.ansible_facts.azure_vmss.id }}"
enabled: true
profiles:
- - count: '1'
- recurrence_days:
- - Monday
- name: Auto created scale condition
- recurrence_timezone: China Standard Time
- recurrence_mins:
- - '0'
- min_count: '1'
- max_count: '1'
- recurrence_frequency: Week
- recurrence_hours:
- - '18'
- check_mode: yes
+ - count: '1'
+ recurrence_days:
+ - Monday
+ name: Auto created scale condition
+ recurrence_timezone: China Standard Time
+ recurrence_mins:
+ - '0'
+ min_count: '1'
+ max_count: '1'
+ recurrence_frequency: Week
+ recurrence_hours:
+ - '18'
+ check_mode: true
register: output
-- assert:
+- name: Assert check mode facts
+ ansible.builtin.assert:
that:
- output.changed
-- name: create auto scaling
+- name: Create auto scaling
azure_rm_autoscale:
resource_group: "{{ resource_group }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
target:
name: "testVMSS{{ rpfx }}"
types: "virtualMachineScaleSets"
namespace: "Microsoft.Compute"
enabled: true
profiles:
- - count: '1'
- recurrence_days:
- - Monday
- name: Auto created scale condition
- recurrence_timezone: China Standard Time
- recurrence_mins:
- - '0'
- min_count: '1'
- max_count: '1'
- recurrence_frequency: Week
- recurrence_hours:
- - '18'
+ - count: '1'
+ recurrence_days:
+ - Monday
+ name: Auto created scale condition
+ recurrence_timezone: China Standard Time
+ recurrence_mins:
+ - '0'
+ min_count: '1'
+ max_count: '1'
+ recurrence_frequency: Week
+ recurrence_hours:
+ - '18'
register: output
-- assert:
+- name: Assert the auto scale created
+ ansible.builtin.assert:
that:
- output.changed
- output.id
-- name: create auto scaling (idemponent)
+- name: Create auto scaling (idemponent)
azure_rm_autoscale:
resource_group: "{{ resource_group }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
target: "{{ vmss.ansible_facts.azure_vmss.id }}"
enabled: true
profiles:
- - count: '1'
- recurrence_days:
- - Monday
- name: Auto created scale condition
- recurrence_timezone: China Standard Time
- recurrence_mins:
- - '0'
- min_count: '1'
- max_count: '1'
- recurrence_frequency: Week
- recurrence_hours:
- - '18'
+ - count: '1'
+ recurrence_days:
+ - Monday
+ name: Auto created scale condition
+ recurrence_timezone: China Standard Time
+ recurrence_mins:
+ - '0'
+ min_count: '1'
+ max_count: '1'
+ recurrence_frequency: Week
+ recurrence_hours:
+ - '18'
register: output
-- assert:
+- name: Assert the auto scale idempotent
+ ansible.builtin.assert:
that:
- not output.changed
- output.id
-- name: update auto scaling
+- name: Update auto scaling
azure_rm_autoscale:
resource_group: "{{ resource_group }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
target: "{{ vmss.ansible_facts.azure_vmss.id }}"
enabled: true
profiles:
- - count: '1'
- recurrence_days:
- - Monday
- name: Auto created scale condition 0
- rules:
- - time_aggregation: Average
- time_window: 10
- direction: Increase
- metric_name: Percentage CPU
- metric_resource_uri: "{{ vmss.ansible_facts.azure_vmss.id }}"
- value: '1'
- threshold: 70
- cooldown: 5
- time_grain: 1
- statistic: Average
- operator: GreaterThan
- type: ChangeCount
- max_count: '1'
- recurrence_mins:
- - '0'
- min_count: '1'
- recurrence_timezone: China Standard Time
- recurrence_frequency: Week
- recurrence_hours:
- - '6'
+ - count: '1'
+ recurrence_days:
+ - Monday
+ name: Auto created scale condition 0
+ rules:
+ - time_aggregation: Average
+ time_window: 10
+ direction: Increase
+ metric_name: Percentage CPU
+ metric_resource_uri: "{{ vmss.ansible_facts.azure_vmss.id }}"
+ value: '1'
+ threshold: 70
+ cooldown: 5
+ time_grain: 1
+ statistic: Average
+ operator: GreaterThan
+ type: ChangeCount
+ max_count: '1'
+ recurrence_mins:
+ - '0'
+ min_count: '1'
+ recurrence_timezone: China Standard Time
+ recurrence_frequency: Week
+ recurrence_hours:
+ - '6'
register: output
-- assert:
+- name: Assert the auto scale created
+ ansible.builtin.assert:
that:
- output.changed
- output.profiles[0].rules[0].metric_resource_uri == vmss.ansible_facts.azure_vmss.id
-- name: delete auto scaling (check mode)
+- name: Delete auto scaling (check mode)
azure_rm_autoscale:
resource_group: "{{ resource_group }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
state: absent
- check_mode: yes
+ check_mode: true
register: output
-- assert:
+- name: Assert the auto scaling deleted
+ ansible.builtin.assert:
that:
- output.changed
-- name: delete auto scaling
+- name: Delete auto scaling
azure_rm_autoscale:
resource_group: "{{ resource_group }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
state: absent
register: output
-- assert:
+- name: Assert the auto scaling deleted
+ ansible.builtin.assert:
that:
- output.changed
-- name: delete auto scaling (idemponetent)
+- name: Delete auto scaling (idemponetent)
azure_rm_autoscale:
resource_group: "{{ resource_group }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
state: absent
register: output
-- assert:
+- name: Assert the auto scaling deleted idempotent
+ ansible.builtin.assert:
that:
- not output.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_availabilityset/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_availabilityset/tasks/main.yml
index 7dc00bf26..c1e42e9bc 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_availabilityset/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_availabilityset/tasks/main.yml
@@ -5,9 +5,10 @@
tags:
tag1: testtag
register: results
- check_mode: yes
+ check_mode: true
-- assert:
+- name: Assert the availability created
+ ansible.builtin.assert:
that: results.changed
- name: Create an availability set with default options
@@ -18,11 +19,12 @@
tag1: testtag
register: results
-- assert:
+- name: Assert the availability created
+ ansible.builtin.assert:
that: results.changed
- name: Create proximity placement group name
- set_fact:
+ ansible.builtin.set_fact:
ppgroup_name: "ppg{{ resource_group | hash('md5') | truncate(22, True, '') }}"
- name: Create a proximity placement group
@@ -43,7 +45,8 @@
sku: Aligned
register: results
-- assert:
+- name: Assert the availability set created
+ ansible.builtin.assert:
that: results.changed
- name: Modify availabilty set immutable options - no changes, fail for immutable options
@@ -55,12 +58,13 @@
proximity_placement_group: "{{ ppgroup_name }}"
sku: Aligned
register: results
- ignore_errors: yes
+ ignore_errors: true
-- assert:
- that:
- - not results.changed
- - results.msg == 'You tried to change platform_update_domain_count but is was unsuccessful. An Availability Set is immutable, except tags'
+- name: Assert availabilty set modified
+ ansible.builtin.assert:
+ that:
+ - not results.changed
+ - results.msg == 'You tried to change platform_update_domain_count but is was unsuccessful. An Availability Set is immutable, except tags'
- name: Modify availabilty set immutable options and set tags - change tags and fail for immutable options
azure_rm_availabilityset:
@@ -73,12 +77,13 @@
tags:
test1: modified
register: results
- ignore_errors: yes
+ ignore_errors: true
-- assert:
- that:
- - not results.changed
- - results.msg == 'You tried to change platform_update_domain_count but is was unsuccessful. An Availability Set is immutable, except tags'
+- name: Assert the availabilty set idempotent
+ ansible.builtin.assert:
+ that:
+ - not results.changed
+ - results.msg == 'You tried to change platform_update_domain_count but is was unsuccessful. An Availability Set is immutable, except tags'
- name: Modify availabilty set options to update tags
azure_rm_availabilityset:
@@ -92,7 +97,8 @@
test2: modified
register: results
-- assert:
+- name: Assert availabilty set updated
+ ansible.builtin.assert:
that:
- results.state.tags.test2 == 'modified'
@@ -104,9 +110,10 @@
platform_fault_domain_count: 4
sku: Aligned
register: results
- ignore_errors: yes
+ ignore_errors: true
-- assert:
+- name: Assert the error return
+ ansible.builtin.assert:
{ that: "'The specified fault domain count 4 must fall in the range 1 to' in results['msg']" }
- name: Test check_mode
@@ -120,11 +127,12 @@
tags:
checktest1: modified1
checktest2: modified2
- check_mode: yes
+ check_mode: true
register: results
-- assert:
- that:
+- name: Assert the check mode test
+ ansible.builtin.assert:
+ that:
- results.changed
- results.state.tags.checktest1 == 'modified1'
@@ -137,23 +145,25 @@
resource_group: "{{ resource_group }}"
register: results
-- assert:
- that:
+- name: Assert the availabilty set facts
+ ansible.builtin.assert:
+ that:
- not results.changed
- not results.failed
- - results.ansible_info.azure_availabilitysets[0].properties.platformFaultDomainCount == 2
- - results.ansible_info.azure_availabilitysets[0].properties.platformUpdateDomainCount == 5
+ - results.ansible_info.azure_availabilitysets[0].platform_fault_domain_count == 2
+ - results.ansible_info.azure_availabilitysets[0].platform_update_domain_count == 5
- results.ansible_info.azure_availabilitysets[0].sku == 'Aligned'
- - results.ansible_info.azure_availabilitysets[0].properties.proximityPlacementGroup.id.split('/')[-1] == ppgroup_name
+ - results.ansible_info.azure_availabilitysets[0].proximity_placement_group.id.split('/')[-1] == ppgroup_name
- name: Delete an availability set - Check Mode
azure_rm_availabilityset:
name: myavailabilityset1
resource_group: "{{ resource_group }}"
state: absent
- check_mode: yes
+ check_mode: true
register: results
-- assert:
+- name: Assert the availabilty set deleted
+ ansible.builtin.assert:
that:
- results.changed
@@ -168,9 +178,10 @@
name: myavailabilityset1
resource_group: "{{ resource_group }}"
state: absent
- check_mode: yes
+ check_mode: true
register: results
-- assert:
+- name: Assert check mode return
+ ansible.builtin.assert:
that:
- not results.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_azurefirewall/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_azurefirewall/tasks/main.yml
index face59c2b..168e197bf 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_azurefirewall/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_azurefirewall/tasks/main.yml
@@ -1,5 +1,5 @@
- name: Fix resource prefix
- set_fact:
+ ansible.builtin.set_fact:
virtual_network_name: myVirtualNetwork
subnet_name: AzureFirewallSubnet
public_ipaddress_name: myPublicIpAddress
@@ -28,21 +28,22 @@
- name: Create public IP address
azure_rm_publicipaddress:
- resource_group: "{{ resource_group }}"
- allocation_method: Static
- name: "{{ public_ipaddress_name }}"
- sku: Standard
+ resource_group: "{{ resource_group }}"
+ allocation_method: Static
+ name: "{{ public_ipaddress_name }}"
+ sku: Standard
register: pip_output
-- debug:
+- name: Print the creating return
+ ansible.builtin.debug:
var: pip_output
- name: Create Azure Firewall
azure_rm_azurefirewall:
- resource_group: '{{resource_group}}'
- name: '{{azure_firewall_name}}'
- #tags:
- # key1: value1
+ resource_group: '{{ resource_group }}'
+ name: '{{ azure_firewall_name }}'
+ # tags:
+ # key1: value1
application_rule_collections:
- priority: 110
action: deny
@@ -101,18 +102,19 @@
name: azureFirewallIpConfiguration
register: output
-- debug:
+- name: Print the creating return
+ ansible.builtin.debug:
var: output
- name: Assert that output has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- name: Create Azure Firewall -- idempotent
azure_rm_azurefirewall:
- resource_group: '{{resource_group}}'
- name: '{{azure_firewall_name}}'
+ resource_group: '{{ resource_group }}'
+ name: '{{ azure_firewall_name }}'
application_rule_collections:
- priority: 110
action: deny
@@ -171,18 +173,19 @@
name: azureFirewallIpConfiguration
register: output
-- debug:
+- name: Print the return value
+ ansible.builtin.debug:
var: output
- name: Assert that output has not changed
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
- name: Create Azure Firewall -- change something
azure_rm_azurefirewall:
- resource_group: '{{resource_group}}'
- name: '{{azure_firewall_name}}'
+ resource_group: '{{ resource_group }}'
+ name: '{{ azure_firewall_name }}'
application_rule_collections:
- priority: 110
action: deny
@@ -239,22 +242,23 @@
public_ip_address:
name: "{{ public_ipaddress_name }}"
name: azureFirewallIpConfiguration
- check_mode: yes
+ check_mode: true
register: output
- name: Assert that output has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- name: Get info of the Azure Firewall
azure_rm_azurefirewall_info:
- resource_group: '{{resource_group}}'
- name: '{{azure_firewall_name}}'
+ resource_group: '{{ resource_group }}'
+ name: '{{ azure_firewall_name }}'
register: output
-- assert:
- that:
+- name: Assert the azure firewall facts
+ ansible.builtin.assert:
+ that:
- not output.changed
- output.firewalls['id'] != None
- output.firewalls['name'] != None
@@ -267,11 +271,12 @@
- name: Delete Azure Firewall
azure_rm_azurefirewall:
- resource_group: '{{resource_group}}'
- name: '{{azure_firewall_name}}'
+ resource_group: '{{ resource_group }}'
+ name: '{{ azure_firewall_name }}'
state: absent
register: output
-- assert:
- that:
+- name: Assert the azure firewall deleted
+ ansible.builtin.assert:
+ that:
- output.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_backupazurevm/meta/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_backupazurevm/meta/main.yml
index 48f5726d8..95e1952f9 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_backupazurevm/meta/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_backupazurevm/meta/main.yml
@@ -1,2 +1,2 @@
dependencies:
- - setup_azure \ No newline at end of file
+ - setup_azure
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_backupazurevm/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_backupazurevm/tasks/main.yml
index b8d0064f2..27ec031f2 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_backupazurevm/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_backupazurevm/tasks/main.yml
@@ -1,5 +1,5 @@
- name: Fix resource prefix
- set_fact:
+ ansible.builtin.set_fact:
resource_group: 'MyResourceGroup'
recovery_vault_name: 'MyRecoveryVault'
resource_id: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/MyVM"
@@ -15,7 +15,7 @@
register: output
- name: Assert that output has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -30,10 +30,10 @@
register: output
- name: Assert that output has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
-
+
- name: Stop protection but retain existing data
azure_rm_backupazurevm:
resource_group: "{{ resource_group }}"
@@ -44,7 +44,7 @@
register: output
- name: Assert that output has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -56,7 +56,7 @@
register: output
- name: Assert that output has changed
- assert:
+ ansible.builtin.assert:
that:
- output.response.id != None
- output.response.name != None
@@ -69,8 +69,8 @@
backup_policy_id: "{{ backup_policy_id }}"
state: "delete"
register: output
-
+
- name: Assert that output has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_backuppolicy/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_backuppolicy/tasks/main.yml
index f57eed4a8..c37a7fefd 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_backuppolicy/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_backuppolicy/tasks/main.yml
@@ -1,5 +1,5 @@
- name: Set Facts for Tests
- set_fact:
+ ansible.builtin.set_fact:
vault_name: "rsv{{ resource_group | hash('md5') | truncate(22, True, '') }}"
location: "eastus"
policy_name_daily: "bp-daily-policy-{{ resource_group | hash('md5') | truncate(22, True, '') }}"
@@ -34,13 +34,13 @@
register: backup_policy_exists
- name: Assert success on daily backup policy creation
- assert:
+ ansible.builtin.assert:
that:
- daily_policy_output.changed
- daily_policy_output.name == policy_name_daily
- name: Assert Policy Success Retrieving Info
- assert:
+ ansible.builtin.assert:
that:
- backup_policy_exists.id == daily_policy_output.id
- backup_policy_exists.location == daily_policy_output.location
@@ -62,7 +62,7 @@
register: daily_policy_output_update
- name: Assert success on update of daily policy
- assert:
+ ansible.builtin.assert:
that:
- daily_policy_output_update.changed
- daily_policy_output_update.name == policy_name_daily
@@ -86,7 +86,7 @@
register: weekly_policy_output
- name: Assert success on weekly backup policy creation
- assert:
+ ansible.builtin.assert:
that:
- weekly_policy_output.changed
- weekly_policy_output.name == policy_name_weekly
@@ -110,7 +110,7 @@
register: weekly_policy_output_update
- name: Assert success on update of weekly policy
- assert:
+ ansible.builtin.assert:
that:
- weekly_policy_output_update.changed
- weekly_policy_output_update.name == policy_name_weekly
@@ -124,7 +124,7 @@
register: daily_policy_output_delete
- name: Assert success on daily backup policy deletion
- assert:
+ ansible.builtin.assert:
that:
- daily_policy_output_delete.changed
@@ -137,7 +137,7 @@
register: weekly_policy_output_delete
- name: Assert success on weekly backup policy deletion
- assert:
+ ansible.builtin.assert:
that:
- weekly_policy_output_delete.changed
@@ -150,7 +150,7 @@
register: daily_policy_output_delete_idempotent
- name: Assert that there is no change after second deletion of daily backup policy
- assert:
+ ansible.builtin.assert:
that:
- not daily_policy_output_delete_idempotent.changed
@@ -163,6 +163,6 @@
register: weekly_policy_output_delete_idempotent
- name: Assert that there is no change after second deletion of weekly backup policy
- assert:
+ ansible.builtin.assert:
that:
- not weekly_policy_output_delete_idempotent.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_bastionhost/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_bastionhost/tasks/main.yml
index c9d9c23d7..e38f91eac 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_bastionhost/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_bastionhost/tasks/main.yml
@@ -1,8 +1,8 @@
- name: Set Bastion host name
- set_fact:
+ ansible.builtin.set_fact:
rpfx: "{{ resource_group | hash('md5') | truncate(8, True, '') }}"
-- name: create resource group
+- name: Create resource group
azure_rm_resourcegroup:
name: "{{ resource_group }}"
location: eastus
@@ -36,7 +36,7 @@
azure_rm_publicipaddress_info:
resource_group: "{{ resource_group }}"
name: "pip{{ rpfx }}"
- register: publicIP_output
+ register: publicip_output
- name: Create bastion host (checkmode test)
azure_rm_bastionhost:
@@ -44,22 +44,22 @@
name: "bh{{ rpfx }}"
ip_configurations:
- name: testip_configuration
- subnet:
+ subnet:
id: "{{ subnet_output.state.id }}"
- public_ip_address:
- id: "{{ publicIP_output.publicipaddresses[0].id }}"
+ public_ip_address:
+ id: "{{ publicip_output.publicipaddresses[0].id }}"
private_ip_allocation_method: Dynamic
sku:
name: Standard
- enable_tunneling: False
- enable_shareable_link: False
- enable_ip_connect: False
- enable_file_copy: False
+ enable_tunneling: false
+ enable_shareable_link: false
+ enable_ip_connect: false
+ enable_file_copy: false
scale_units: 6
- disable_copy_paste: False
+ disable_copy_paste: false
tags:
key3: value3
- check_mode: yes
+ check_mode: true
register: output
- name: Create bastion host
@@ -68,25 +68,25 @@
name: "bh{{ rpfx }}"
ip_configurations:
- name: testip_configuration
- subnet:
+ subnet:
id: "{{ subnet_output.state.id }}"
- public_ip_address:
- id: "{{ publicIP_output.publicipaddresses[0].id }}"
+ public_ip_address:
+ id: "{{ publicip_output.publicipaddresses[0].id }}"
private_ip_allocation_method: Dynamic
sku:
name: Standard
- enable_tunneling: False
- enable_shareable_link: False
- enable_ip_connect: False
- enable_file_copy: False
+ enable_tunneling: false
+ enable_shareable_link: false
+ enable_ip_connect: false
+ enable_file_copy: false
scale_units: 6
- disable_copy_paste: False
+ disable_copy_paste: false
tags:
key3: value3
register: output
- name: Assert the bastion host created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -96,30 +96,32 @@
name: "bh{{ rpfx }}"
ip_configurations:
- name: testip_configuration
- subnet:
+ subnet:
id: "{{ subnet_output.state.id }}"
- public_ip_address:
- id: "{{ publicIP_output.publicipaddresses[0].id }}"
+ public_ip_address:
+ id: "{{ publicip_output.publicipaddresses[0].id }}"
private_ip_allocation_method: Dynamic
sku:
name: Standard
- enable_tunneling: False
- enable_shareable_link: False
- enable_ip_connect: False
- enable_file_copy: False
+ enable_tunneling: false
+ enable_shareable_link: false
+ enable_ip_connect: false
+ enable_file_copy: false
scale_units: 6
- disable_copy_paste: False
+ disable_copy_paste: false
tags:
key3: value3
register: output
- name: Assert the bastion host no changed
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
- name: Pause for 20 mimutes to Bastion host updating
- shell: sleep 1200
+ ansible.builtin.command:
+ sleep 1200
+ changed_when: true
- name: Update bastion host
azure_rm_bastionhost:
@@ -127,25 +129,25 @@
name: "bh{{ rpfx }}"
ip_configurations:
- name: testip_configuration
- subnet:
+ subnet:
id: "{{ subnet_output.state.id }}"
- public_ip_address:
- id: "{{ publicIP_output.publicipaddresses[0].id }}"
+ public_ip_address:
+ id: "{{ publicip_output.publicipaddresses[0].id }}"
private_ip_allocation_method: Dynamic
sku:
name: Basic
- enable_tunneling: True
- enable_shareable_link: True
- enable_ip_connect: True
- enable_file_copy: True
+ enable_tunneling: true
+ enable_shareable_link: true
+ enable_ip_connect: true
+ enable_file_copy: true
scale_units: 8
- disable_copy_paste: True
+ disable_copy_paste: true
tags:
key2: value2
register: output
- name: Assert the bastion host updated
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -154,9 +156,9 @@
resource_group: "{{ resource_group }}"
name: "bh{{ rpfx }}"
register: output
-
+
- name: Assert the bastion host is well create
- assert:
+ ansible.builtin.assert:
that:
- output.bastion_host[0].disable_copy_paste == true
- output.bastion_host[0].enable_file_copy == true
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_batchaccount/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_batchaccount/tasks/main.yml
index e62cb67cf..e56a572a7 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_batchaccount/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_batchaccount/tasks/main.yml
@@ -11,66 +11,80 @@
#
# ----------------------------------------------------------------------------
- name: Prepare random number
- set_fact:
+ ansible.builtin.set_fact:
storage_account_name: "st{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
batch_account_name: "ba{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
- run_once: yes
+ run_once: true
- name: Create Storage Account
azure_rm_storageaccount:
- resource_group: "{{ resource_group }}"
- name: "{{ storage_account_name }}"
- location: eastus
- account_type: Standard_LRS
+ resource_group: "{{ resource_group }}"
+ name: "{{ storage_account_name }}"
+ location: eastus
+ account_type: Standard_LRS
- name: Create Batch Account
azure_rm_batchaccount:
- resource_group: "{{ resource_group }}"
- name: "{{ batch_account_name }}"
- location: eastus
- auto_storage_account:
- name: "{{ storage_account_name }}"
- pool_allocation_mode: batch_service
+ resource_group: "{{ resource_group }}"
+ name: "{{ batch_account_name }}"
+ location: eastus
+ auto_storage_account:
+ name: "{{ storage_account_name }}"
+ pool_allocation_mode: batch_service
+ tags:
+ key1: value1
+ key2: value2
register: output
- name: Assert the resource was created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- name: Create Batch Account -- idempotent
azure_rm_batchaccount:
- resource_group: "{{ resource_group }}"
- name: "{{ batch_account_name }}"
- location: eastus
- auto_storage_account:
- name: "{{ storage_account_name }}"
- pool_allocation_mode: batch_service
+ resource_group: "{{ resource_group }}"
+ name: "{{ batch_account_name }}"
+ location: eastus
+ auto_storage_account:
+ name: "{{ storage_account_name }}"
+ pool_allocation_mode: batch_service
+ tags:
+ key1: value1
+ key2: value2
register: output
- name: Assert the resource was created
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
+- name: Get Batch Account facts
+ azure_rm_batchaccount_info:
+ resource_group: "{{ resource_group }}"
+ name: "{{ batch_account_name }}"
+ register: output
+
+- name: Assert the facts
+ ansible.builtin.assert:
+ that:
+ - output.batch_account | length == 1
+ - output.batch_account[0].tags | length == 2
+
- name: Delete Batch Account
azure_rm_batchaccount:
- resource_group: "{{ resource_group }}"
- name: "{{ batch_account_name }}"
- location: eastus
- auto_storage_account:
- name: "{{ storage_account_name }}"
- pool_allocation_mode: batch_service
- state: absent
+ resource_group: "{{ resource_group }}"
+ name: "{{ batch_account_name }}"
+ state: absent
register: output
- name: Assert that state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- name: Clean up storage account
azure_rm_storageaccount:
- resource_group: "{{ resource_group }}"
- name: "{{ storage_account_name }}"
- state: absent
+ resource_group: "{{ resource_group }}"
+ name: "{{ storage_account_name }}"
+ state: absent
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_cdnprofile/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_cdnprofile/tasks/main.yml
index 657881a50..92012c6f5 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_cdnprofile/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_cdnprofile/tasks/main.yml
@@ -1,90 +1,91 @@
- name: Prepare random number
- set_fact:
+ ansible.builtin.set_fact:
cdnprofilename: "cdnprofile{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
endpointname: "endpoint{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
- run_once: yes
+ run_once: true
- name: Create a CDN profile(check mode)
azure_rm_cdnprofile:
- resource_group: "{{ resource_group }}"
- name: "{{ cdnprofilename }}"
- sku: standard_akamai
- tags:
- testing: testing
- delete: on-exit
- foo: bar
- check_mode: yes
+ resource_group: "{{ resource_group }}"
+ name: "{{ cdnprofilename }}"
+ sku: standard_verizon
+ tags:
+ testing: testing
+ delete: on-exit
+ foo: bar
+ check_mode: true
- name: Check there is no CDN profile created
azure_rm_cdnprofile_info:
- resource_group: "{{ resource_group }}"
- name: "{{ cdnprofilename }}"
+ resource_group: "{{ resource_group }}"
+ name: "{{ cdnprofilename }}"
register: fact
- name: Check there is no CDN profile created
- assert: { that: "{{ fact.cdnprofiles | length }} == 0" }
+ ansible.builtin.assert:
+ { that: "{{ fact.cdnprofiles | length }} == 0" }
- name: Create a CDN profile
azure_rm_cdnprofile:
- resource_group: "{{ resource_group }}"
- name: "{{ cdnprofilename }}"
- sku: standard_akamai
- tags:
- testing: testing
- delete: on-exit
- foo: bar
+ resource_group: "{{ resource_group }}"
+ name: "{{ cdnprofilename }}"
+ sku: standard_verizon
+ tags:
+ testing: testing
+ delete: on-exit
+ foo: bar
register: output
- name: Assert the CDN profile is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.id != ''
- name: Gather CDN profile facts
azure_rm_cdnprofile_info:
- resource_group: "{{ resource_group }}"
- name: "{{ cdnprofilename }}"
+ resource_group: "{{ resource_group }}"
+ name: "{{ cdnprofilename }}"
register: fact
- name: Assert fact returns the created one
- assert:
- that:
- - "fact.cdnprofiles | length == 1"
- - fact.cdnprofiles[0].sku == 'Standard_Akamai'
- - fact.cdnprofiles[0].tags.foo == 'bar'
+ ansible.builtin.assert:
+ that:
+ - "fact.cdnprofiles | length == 1"
+ - fact.cdnprofiles[0].sku == 'Standard_Verizon'
+ - fact.cdnprofiles[0].tags.foo == 'bar'
- name: Create a CDN profile (idempotent)
azure_rm_cdnprofile:
- resource_group: "{{ resource_group }}"
- name: "{{ cdnprofilename }}"
- sku: standard_akamai
- tags:
- testing: testing
- delete: on-exit
- foo: bar
+ resource_group: "{{ resource_group }}"
+ name: "{{ cdnprofilename }}"
+ sku: standard_verizon
+ tags:
+ testing: testing
+ delete: on-exit
+ foo: bar
register: output
- name: Assert idempotent
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
- name: Update the CDN profile
azure_rm_cdnprofile:
- resource_group: "{{ resource_group }}"
- name: "{{ cdnprofilename }}"
- sku: standard_akamai
- tags:
- testing: testing
- delete: on-exit
- foo: bar
- baz: qux
+ resource_group: "{{ resource_group }}"
+ name: "{{ cdnprofilename }}"
+ sku: standard_verizon
+ tags:
+ testing: testing
+ delete: on-exit
+ foo: bar
+ baz: qux
register: output
- name: Assert the CDN profile is updated
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -93,65 +94,65 @@
resource_group: "{{ resource_group }}"
name: "{{ cdnprofilename }}"
state: absent
- check_mode: yes
+ check_mode: true
- name: Gather CDN profile facts
azure_rm_cdnprofile_info:
- resource_group: "{{ resource_group }}"
- name: "{{ cdnprofilename }}"
+ resource_group: "{{ resource_group }}"
+ name: "{{ cdnprofilename }}"
register: fact
- name: Assert the CDN is still there
- assert:
- that:
- - "fact.cdnprofiles | length == 1"
- - fact.cdnprofiles[0].sku == 'Standard_Akamai'
- - fact.cdnprofiles[0].tags.foo == 'bar'
- - fact.cdnprofiles[0].tags.baz == 'qux'
+ ansible.builtin.assert:
+ that:
+ - "fact.cdnprofiles | length == 1"
+ - fact.cdnprofiles[0].sku == 'Standard_Verizon'
+ - fact.cdnprofiles[0].tags.foo == 'bar'
+ - fact.cdnprofiles[0].tags.baz == 'qux'
- name: Create a Azure CDN endpoint(check mode)
azure_rm_cdnendpoint:
- resource_group: "{{ resource_group }}"
- name: "{{ endpointname }}"
- profile_name: "{{ cdnprofilename }}"
- origins:
- - name: "org{{ endpointname }}"
- host_name: "www.google.com"
- tags:
- testing: testing
- delete: on-exit
- foo: bar
- check_mode: yes
+ resource_group: "{{ resource_group }}"
+ name: "{{ endpointname }}"
+ profile_name: "{{ cdnprofilename }}"
+ origins:
+ - name: "org{{ endpointname }}"
+ host_name: "www.google.com"
+ tags:
+ testing: testing
+ delete: on-exit
+ foo: bar
+ check_mode: true
- name: Create a Azure CDN endpoint
azure_rm_cdnendpoint:
- resource_group: "{{ resource_group }}"
- name: "{{ endpointname }}"
- profile_name: "{{ cdnprofilename }}"
- origins:
- - name: "org{{ endpointname }}"
- host_name: "www.google.com"
- tags:
- testing: testing
- delete: on-exit
- foo: bar
+ resource_group: "{{ resource_group }}"
+ name: "{{ endpointname }}"
+ profile_name: "{{ cdnprofilename }}"
+ origins:
+ - name: "org{{ endpointname }}"
+ host_name: "www.google.com"
+ tags:
+ testing: testing
+ delete: on-exit
+ foo: bar
register: output
- name: Assert the Azure CDN endpoint is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.id
- name: Get facts of a Azure CDN endpoint
azure_rm_cdnendpoint_info:
- resource_group: "{{ resource_group }}"
- name: "{{ endpointname }}"
- profile_name: "{{ cdnprofilename }}"
+ resource_group: "{{ resource_group }}"
+ name: "{{ endpointname }}"
+ profile_name: "{{ cdnprofilename }}"
register: facts
- name: Assert facts output
- assert:
+ ansible.builtin.assert:
that:
- facts['cdnendpoints'] | length == 1
- facts['cdnendpoints'][0]['id']
@@ -164,93 +165,93 @@
- name: Create a Azure CDN endpoint(idempotent)
azure_rm_cdnendpoint:
- resource_group: "{{ resource_group }}"
- name: "{{ endpointname }}"
- profile_name: "{{ cdnprofilename }}"
- origins:
- - name: "org{{ endpointname }}"
- host_name: "www.google.com"
- tags:
- testing: testing
- delete: on-exit
- foo: bar
+ resource_group: "{{ resource_group }}"
+ name: "{{ endpointname }}"
+ profile_name: "{{ cdnprofilename }}"
+ origins:
+ - name: "org{{ endpointname }}"
+ host_name: "www.google.com"
+ tags:
+ testing: testing
+ delete: on-exit
+ foo: bar
register: output
- name: Assert idempotent
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
- name: Stop a Azure CDN endpoint
azure_rm_cdnendpoint:
- resource_group: "{{ resource_group }}"
- name: "{{ endpointname }}"
- profile_name: "{{ cdnprofilename }}"
- started: False
+ resource_group: "{{ resource_group }}"
+ name: "{{ endpointname }}"
+ profile_name: "{{ cdnprofilename }}"
+ started: false
register: output
- name: Assert stopped
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- name: Stop a Azure CDN endpoint(idempotent)
azure_rm_cdnendpoint:
- resource_group: "{{ resource_group }}"
- name: "{{ endpointname }}"
- profile_name: "{{ cdnprofilename }}"
- started: False
+ resource_group: "{{ resource_group }}"
+ name: "{{ endpointname }}"
+ profile_name: "{{ cdnprofilename }}"
+ started: false
register: output
- name: Assert still stopped and not changed
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
- name: Start a Azure CDN endpoint
azure_rm_cdnendpoint:
- resource_group: "{{ resource_group }}"
- name: "{{ endpointname }}"
- profile_name: "{{ cdnprofilename }}"
- started: True
+ resource_group: "{{ resource_group }}"
+ name: "{{ endpointname }}"
+ profile_name: "{{ cdnprofilename }}"
+ started: true
register: output
- name: Assert started
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- name: Update the Azure CDN endpoint
azure_rm_cdnendpoint:
- resource_group: "{{ resource_group }}"
- name: "{{ endpointname }}"
- profile_name: "{{ cdnprofilename }}"
- origin_path: /test/
- tags:
- testing: testing
- delete: on-exit
- foo: baz
+ resource_group: "{{ resource_group }}"
+ name: "{{ endpointname }}"
+ profile_name: "{{ cdnprofilename }}"
+ origin_path: /test/
+ tags:
+ testing: testing
+ delete: on-exit
+ foo: baz
register: output
- name: Assert the Azure CDN endpoint is updated
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- name: Delete a Azure CDN endpoint(check mode)
azure_rm_cdnendpoint:
- resource_group: "{{ resource_group }}"
- name: "{{ endpointname }}"
- profile_name: "{{ cdnprofilename }}"
- state: absent
- check_mode: yes
+ resource_group: "{{ resource_group }}"
+ name: "{{ endpointname }}"
+ profile_name: "{{ cdnprofilename }}"
+ state: absent
+ check_mode: true
- name: Delete a Azure CDN endpoint
azure_rm_cdnendpoint:
- resource_group: "{{ resource_group }}"
- name: "{{ endpointname }}"
- profile_name: "{{ cdnprofilename }}"
- state: absent
+ resource_group: "{{ resource_group }}"
+ name: "{{ endpointname }}"
+ profile_name: "{{ cdnprofilename }}"
+ state: absent
- name: Delete the CDN profile
azure_rm_cdnprofile:
@@ -260,17 +261,17 @@
register: output
- name: Assert the CDN profile is well deleted
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- name: Get CDN profile fact
azure_rm_cdnprofile_info:
- resource_group: "{{ resource_group }}"
- name: "{{ cdnprofilename }}"
+ resource_group: "{{ resource_group }}"
+ name: "{{ cdnprofilename }}"
register: fact
- name: Assert fact returns empty
- assert:
+ ansible.builtin.assert:
that:
- "fact.cdnprofiles | length == 0"
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_cognitivesearch/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_cognitivesearch/tasks/main.yml
index fefad59a8..bcc19ced0 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_cognitivesearch/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_cognitivesearch/tasks/main.yml
@@ -1,5 +1,5 @@
- name: Create Azure Search name
- set_fact:
+ ansible.builtin.set_fact:
search_name: "search{{ resource_group | hash('md5') | truncate(16, True, '') }}"
search_name_secondary: "search{{ resource_group | hash('md5') | truncate(16, True, '') }}-secondary"
@@ -9,11 +9,11 @@
resource_group: "{{ resource_group }}"
hosting_mode: highDensity
register: invalid_hosting_name
- ignore_errors: yes
+ ignore_errors: true
- name: Assert task failed
- assert:
- that:
+ ansible.builtin.assert:
+ that:
- invalid_hosting_name.failed == True
- name: Create invalid Azure Search - Partition Count High Density
@@ -24,11 +24,11 @@
hosting_mode: highDensity
partition_count: 4
register: invalid_partition_count
- ignore_errors: yes
+ ignore_errors: true
- name: Assert task failed
- assert:
- that:
+ ansible.builtin.assert:
+ that:
- invalid_partition_count.failed == True
- name: Create invalid Azure Search - Partition Count
@@ -37,11 +37,11 @@
resource_group: "{{ resource_group }}"
partition_count: 7
register: invalid_partition_count
- ignore_errors: yes
+ ignore_errors: true
- name: Assert task failed
- assert:
- that:
+ ansible.builtin.assert:
+ that:
- invalid_partition_count.failed == True
- name: Create invalid Azure Search - Replica Count
@@ -51,11 +51,11 @@
sku: standard
replica_count: 13
register: invalid_replica_count
- ignore_errors: yes
+ ignore_errors: true
- name: Assert task failed
- assert:
- that:
+ ansible.builtin.assert:
+ that:
- invalid_replica_count.failed == True
- name: Create invalid Azure Search - Replica Count SKU basic
@@ -65,11 +65,11 @@
replica_count: 4
sku: basic
register: invalid_replica_count
- ignore_errors: yes
+ ignore_errors: true
- name: Assert task failed
- assert:
- that:
+ ansible.builtin.assert:
+ that:
- invalid_replica_count.failed == True
- name: Create basic Azure Search
@@ -79,7 +79,7 @@
register: search_info
- name: Assert status succeeded and results
- assert:
+ ansible.builtin.assert:
that:
- search_info.changed
- search_info.state.id is defined
@@ -101,7 +101,7 @@
register: search_info_module
- name: Assert status succeeded and results
- assert:
+ ansible.builtin.assert:
that:
- search_info_module.search.id is defined
- search_info_module.search.identity.type == "None"
@@ -122,7 +122,7 @@
register: search_info
- name: Assert that idempotence is ok
- assert:
+ ansible.builtin.assert:
that:
- not search_info.changed
@@ -132,7 +132,7 @@
resource_group: "{{ resource_group }}"
state: absent
-- name: Create Azure Search '{{ search_name }}' not default parameters
+- name: Create Azure Search not default parameters
azure_rm_cognitivesearch:
name: "{{ search_name_secondary }}"
resource_group: "{{ resource_group }}"
@@ -150,7 +150,7 @@
register: search_info
- name: Assert status succeeded and results
- assert:
+ ansible.builtin.assert:
that:
- search_info.changed
- search_info.state.id is defined
@@ -164,7 +164,7 @@
- search_info.state.provisioning_state == "succeeded"
- search_info.state.status == "running"
-- name: Update Azure Search '{{ search_name }}' not default parameters (Idempotence)
+- name: Update Azure Search not default parameters (Idempotence)
azure_rm_cognitivesearch:
name: "{{ search_name_secondary }}"
resource_group: "{{ resource_group }}"
@@ -182,7 +182,7 @@
register: search_info
- name: Assert that idempotence is ok
- assert:
+ ansible.builtin.assert:
that:
- not search_info.changed
@@ -191,4 +191,3 @@
name: "{{ search_name_secondary }}"
resource_group: "{{ resource_group }}"
state: absent
-
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_containerinstance/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_containerinstance/tasks/main.yml
index 44bb852a5..d8bd5f36e 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_containerinstance/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_containerinstance/tasks/main.yml
@@ -1,5 +1,5 @@
- name: Set Container Instance Names
- set_fact:
+ ansible.builtin.set_fact:
rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
- name: Create sample container instance
@@ -20,11 +20,12 @@
- 81
register: output
-- debug:
+- name: Print the created results
+ ansible.builtin.debug:
var: output
- name: Assert the container instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.provisioning_state == 'Succeeded'
@@ -48,7 +49,7 @@
register: output
- name: Assert the container instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
@@ -68,11 +69,11 @@
ports:
- 80
- 81
- force_update: yes
+ force_update: true
register: output
- name: Assert the container instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.provisioning_state == 'Succeeded'
@@ -142,7 +143,7 @@
register: output
- name: Assert the container instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -150,13 +151,14 @@
azure_rm_containerinstance_info:
resource_group: "{{ resource_group }}"
name: "aci{{ rpfx }}sec"
- register: output
+ register: output
-- debug:
+- name: Print the container instance facts
+ ansible.builtin.debug:
var: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.containerinstances[0]['resource_group'] != None
@@ -175,7 +177,7 @@
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.containerinstances[0]['resource_group'] != None
@@ -219,32 +221,37 @@
share_name: "{{ file_share_name }}"
storage_account_key: "{{ storage_account_key }}"
register: output
- ignore_errors: True
+ ignore_errors: true
-- debug:
+- name: Print failed return
+ ansible.builtin.debug:
var: output
- ignore_errors: True
+ ignore_errors: true
+ register: ignore_errors_register
- name: Assert the container instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.provisioning_state == 'Succeeded'
- ignore_errors: True
+ register: ignore_errors_register
+ ignore_errors: true
- name: Gather facts for Container Instance
azure_rm_containerinstance_info:
resource_group: "{{ resource_group }}"
name: "aci{{ rpfx }}thi"
register: output
- ignore_errors: True
+ ignore_errors: true
-- debug:
+- name: Assert the container instance facts
+ ansible.builtin.debug:
var: output
- ignore_errors: True
+ ignore_errors: true
+ register: ignore_errors_register
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.containerinstances[0]['resource_group'] != None
@@ -258,7 +265,8 @@
- output.containerinstances[0]['containers'][0]['volume_mounts'] | length == 1
- output.containerinstances[0]['containers'][0]['volume_mounts'][0]['name'] != None
- output.containerinstances[0]['containers'][0]['volume_mounts'][0]['mount_path'] != None
- ignore_errors: True
+ ignore_errors: true
+ register: ignore_errors_register
- name: Remove container instance
azure_rm_containerinstance:
@@ -287,7 +295,7 @@
storage_account_key: "{{ storage_account_key }}"
state: absent
register: output
- ignore_errors: True
+ ignore_errors: true
- name: Remove container instance
azure_rm_containerinstance:
@@ -309,7 +317,7 @@
register: output
- name: Assert the container instance is deleted
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -351,6 +359,6 @@
register: output
- name: Assert the changed is false
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_containerregistry/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_containerregistry/tasks/main.yml
index 7c83c5c5d..b474b0e1f 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_containerregistry/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_containerregistry/tasks/main.yml
@@ -1,116 +1,116 @@
- - name: Create an container registry
- azure_rm_containerregistry:
- name: "acr{{ resource_group | hash('md5') | truncate(7, True, '') }}"
- resource_group: "{{ resource_group }}"
- location: eastus2
- admin_user_enabled: true
- sku: Premium
- tags:
- Release: beta1
- Environment: Production
- register: output
+- name: Create an container registry
+ azure_rm_containerregistry:
+ name: "acr{{ resource_group | hash('md5') | truncate(7, True, '') }}"
+ resource_group: "{{ resource_group }}"
+ location: eastus2
+ admin_user_enabled: true
+ sku: Premium
+ tags:
+ Release: beta1
+ Environment: Production
+ register: output
- - name: Assert the container registry instance is well created
- assert:
- that:
- - output.changed
- - output.admin_user_enabled
- - output.location == 'eastus2'
- - output.sku == 'Premium'
- - output.tags['Environment'] == 'Production'
- - output.tags['Release'] == 'beta1'
- - output.provisioning_state == 'Succeeded'
- - output.credentials['password'] is defined
- - output.credentials['password2'] is defined
+- name: Assert the container registry instance is well created
+ ansible.builtin.assert:
+ that:
+ - output.changed
+ - output.admin_user_enabled
+ - output.location == 'eastus2'
+ - output.sku == 'Premium'
+ - output.tags['Environment'] == 'Production'
+ - output.tags['Release'] == 'beta1'
+ - output.provisioning_state == 'Succeeded'
+ - output.credentials['password'] is defined
+ - output.credentials['password2'] is defined
- - name: Update the ACR instance sku, tags and admin_user_enabled
- azure_rm_containerregistry:
- name: "acr{{ resource_group | hash('md5') | truncate(7, True, '') }}"
- resource_group: "{{ resource_group }}"
- location: eastus2
- admin_user_enabled: false
- sku: Standard
- tags:
- NewTag: newtag
- Release: beta1
- Environment: Production
- register: output
+- name: Update the ACR instance sku, tags and admin_user_enabled
+ azure_rm_containerregistry:
+ name: "acr{{ resource_group | hash('md5') | truncate(7, True, '') }}"
+ resource_group: "{{ resource_group }}"
+ location: eastus2
+ admin_user_enabled: false
+ sku: Standard
+ tags:
+ NewTag: newtag
+ Release: beta1
+ Environment: Production
+ register: output
- - name: Create second container registry (to test facts)
- azure_rm_containerregistry:
- name: "acr{{ resource_group | hash('md5') | truncate(7, True, '') }}sec"
- resource_group: "{{ resource_group }}"
- location: eastus2
- admin_user_enabled: false
- sku: Premium
- tags:
- Release: beta1
- Environment: Production
+- name: Create second container registry (to test facts)
+ azure_rm_containerregistry:
+ name: "acr{{ resource_group | hash('md5') | truncate(7, True, '') }}sec"
+ resource_group: "{{ resource_group }}"
+ location: eastus2
+ admin_user_enabled: false
+ sku: Premium
+ tags:
+ Release: beta1
+ Environment: Production
- - name: Assert the ACR instance is well updated
- assert:
- that:
- - output.changed == True
- - output.admin_user_enabled == False
- - output.sku == 'Standard'
- - output.tags['NewTag'] == 'newtag'
- - output.credentials | length == 0
- - output.credentials['password'] is not defined
- - output.credentials['password2'] is not defined
+- name: Assert the ACR instance is well updated
+ ansible.builtin.assert:
+ that:
+ - output.changed == True
+ - output.admin_user_enabled == False
+ - output.sku == 'Standard'
+ - output.tags['NewTag'] == 'newtag'
+ - output.credentials | length == 0
+ - output.credentials['password'] is not defined
+ - output.credentials['password2'] is not defined
- - name: Gather facts for single Container Registry
- azure_rm_containerregistry_info:
- resource_group: "{{ resource_group }}"
- name: "acr{{ resource_group | hash('md5') | truncate(7, True, '') }}"
- register: output
+- name: Gather facts for single Container Registry
+ azure_rm_containerregistry_info:
+ resource_group: "{{ resource_group }}"
+ name: "acr{{ resource_group | hash('md5') | truncate(7, True, '') }}"
+ register: output
- - name: Assert that facts are returned
- assert:
- that:
- - output.changed == False
- - output.registries[0]['name'] != None
- - output.registries[0]['location'] != None
- - output.registries[0]['admin_user_enabled'] != None
- - output.registries[0]['sku'] != None
- - output.registries[0]['provisioning_state'] != None
- - output.registries[0]['login_server'] != None
- - output.registries[0]['id'] != None
- - output.registries[0]['credentials'] != None
+- name: Assert that facts are returned
+ ansible.builtin.assert:
+ that:
+ - output.changed == False
+ - output.registries[0]['name'] != None
+ - output.registries[0]['location'] != None
+ - output.registries[0]['admin_user_enabled'] != None
+ - output.registries[0]['sku'] != None
+ - output.registries[0]['provisioning_state'] != None
+ - output.registries[0]['login_server'] != None
+ - output.registries[0]['id'] != None
+ - output.registries[0]['credentials'] != None
- - name: Gather facts for all Container Registries in the resource group
- azure_rm_containerregistry_info:
- resource_group: "{{ resource_group }}"
- register: output
+- name: Gather facts for all Container Registries in the resource group
+ azure_rm_containerregistry_info:
+ resource_group: "{{ resource_group }}"
+ register: output
- - name: Assert that facts are returned
- assert:
- that:
- - output.changed == False
- - output.registries[0]['name'] != None
- - output.registries[0]['location'] != None
- - output.registries[0]['admin_user_enabled'] != None
- - output.registries[0]['sku'] != None
- - output.registries[0]['provisioning_state'] != None
- - output.registries[0]['login_server'] != None
- - output.registries[0]['id'] != None
- - output.registries[0]['credentials'] != None
- - output.registries[1]['name'] != None
- - output.registries[1]['location'] != None
- - output.registries[1]['admin_user_enabled'] != None
- - output.registries[1]['sku'] != None
- - output.registries[1]['provisioning_state'] != None
- - output.registries[1]['login_server'] != None
- - output.registries[1]['id'] != None
- - output.registries[1]['credentials'] != None
+- name: Assert that facts are returned
+ ansible.builtin.assert:
+ that:
+ - output.changed == False
+ - output.registries[0]['name'] != None
+ - output.registries[0]['location'] != None
+ - output.registries[0]['admin_user_enabled'] != None
+ - output.registries[0]['sku'] != None
+ - output.registries[0]['provisioning_state'] != None
+ - output.registries[0]['login_server'] != None
+ - output.registries[0]['id'] != None
+ - output.registries[0]['credentials'] != None
+ - output.registries[1]['name'] != None
+ - output.registries[1]['location'] != None
+ - output.registries[1]['admin_user_enabled'] != None
+ - output.registries[1]['sku'] != None
+ - output.registries[1]['provisioning_state'] != None
+ - output.registries[1]['login_server'] != None
+ - output.registries[1]['id'] != None
+ - output.registries[1]['credentials'] != None
- - name: Delete first container registry
- azure_rm_containerregistry:
- name: "acr{{ resource_group | hash('md5') | truncate(7, True, '') }}"
- resource_group: "{{ resource_group }}"
- state: absent
+- name: Delete first container registry
+ azure_rm_containerregistry:
+ name: "acr{{ resource_group | hash('md5') | truncate(7, True, '') }}"
+ resource_group: "{{ resource_group }}"
+ state: absent
- - name: Delete second container registry
- azure_rm_containerregistry:
- name: "acr{{ resource_group | hash('md5') | truncate(7, True, '') }}sec"
- resource_group: "{{ resource_group }}"
- state: absent
+- name: Delete second container registry
+ azure_rm_containerregistry:
+ name: "acr{{ resource_group | hash('md5') | truncate(7, True, '') }}sec"
+ resource_group: "{{ resource_group }}"
+ state: absent
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_containerregistrytag/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_containerregistrytag/tasks/main.yml
index 6f90bcddf..eec64c3bb 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_containerregistrytag/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_containerregistrytag/tasks/main.yml
@@ -1,5 +1,5 @@
- name: Prepare random number
- set_fact:
+ ansible.builtin.set_fact:
rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
run_once: true
@@ -16,7 +16,7 @@
registry: "acr{{ rpfx }}"
register: output
- name: Verify no tags exist
- assert:
+ ansible.builtin.assert:
that: output.repositories | length == 0
- name: Load all tags for non-existant repository
@@ -25,7 +25,7 @@
repository_name: "does-not-exist"
register: output
- name: Verify no tags exist
- assert:
+ ansible.builtin.assert:
that: output.repositories | length == 0
- name: Import tag (check mode)
@@ -40,7 +40,7 @@
check_mode: true
register: output
- name: Assert output
- assert:
+ ansible.builtin.assert:
that: output.changed
- name: Import tag (actually import)
@@ -54,7 +54,7 @@
name: "latest"
register: output
- name: Assert output
- assert:
+ ansible.builtin.assert:
that: output.changed
- name: Import tag (test idempotency)
@@ -68,7 +68,7 @@
name: "latest"
register: output
- name: Assert output
- assert:
+ ansible.builtin.assert:
that: not output.changed
- name: Import additional tag
@@ -82,7 +82,7 @@
name: "latest"
register: output
- name: Assert output
- assert:
+ ansible.builtin.assert:
that: output.changed
- name: Import additional tag
@@ -96,7 +96,7 @@
name: "latest"
register: output
- name: Assert output
- assert:
+ ansible.builtin.assert:
that: output.changed
- name: Import additional tag
@@ -110,7 +110,7 @@
name: "latest"
register: output
- name: Assert output
- assert:
+ ansible.builtin.assert:
that: output.changed
- name: Load all tags
@@ -118,7 +118,7 @@
registry: "acr{{ rpfx }}"
register: output
- name: Assert tags exist
- assert:
+ ansible.builtin.assert:
that:
- output.repositories | length == 2
- output.repositories[0].name == 'app1'
@@ -136,7 +136,7 @@
repository_name: "app2"
register: output
- name: Assert tags exist
- assert:
+ ansible.builtin.assert:
that:
- output.repositories | length == 1
- output.repositories[0].name == 'app2'
@@ -152,7 +152,7 @@
name: "test-image"
register: output
- name: Assert tags exist
- assert:
+ ansible.builtin.assert:
that:
- output.repositories | length == 1
- output.repositories[0].name == 'app2'
@@ -165,7 +165,7 @@
name: "v1"
register: output
- name: Assert tags exist
- assert:
+ ansible.builtin.assert:
that:
- output.repositories | length == 2
- output.repositories[0].name == 'app1'
@@ -184,7 +184,7 @@
check_mode: true
register: output
- name: Assert output
- assert:
+ ansible.builtin.assert:
that: output.changed
- name: Delete tag by name (actually delete)
@@ -195,7 +195,7 @@
state: "absent"
register: output
- name: Assert output
- assert:
+ ansible.builtin.assert:
that: output.changed
- name: Delete tag by name (test idempotency)
@@ -206,7 +206,7 @@
state: "absent"
register: output
- name: Assert output
- assert:
+ ansible.builtin.assert:
that: not output.changed
- name: Load tags by repository
@@ -215,7 +215,7 @@
repository_name: "app2"
register: output
- name: Assert tags exist
- assert:
+ ansible.builtin.assert:
that:
- output.repositories | length == 1
- output.repositories[0].name == 'app2'
@@ -231,7 +231,7 @@
check_mode: true
register: output
- name: Assert output
- assert:
+ ansible.builtin.assert:
that: output.changed
- name: Delete repository (actually delete)
@@ -241,7 +241,7 @@
state: "absent"
register: output
- name: Assert output
- assert:
+ ansible.builtin.assert:
that: output.changed
- name: Delete repository (test idempotency)
@@ -251,7 +251,7 @@
state: "absent"
register: output
- name: Assert output
- assert:
+ ansible.builtin.assert:
that: not output.changed
- name: Load all tags
@@ -259,7 +259,7 @@
registry: "acr{{ rpfx }}"
register: output
- name: Assert tags exist
- assert:
+ ansible.builtin.assert:
that:
- output.repositories | length == 1
- output.repositories[0].name == 'app1'
@@ -275,7 +275,7 @@
name: "latest"
register: output
- name: Assert output
- assert:
+ ansible.builtin.assert:
that: output.changed
- name: Import tag with same name (test idempotency)
@@ -287,7 +287,7 @@
name: "latest"
register: output
- name: Assert output
- assert:
+ ansible.builtin.assert:
that: not output.changed
- name: Import tag with different repo, same name
@@ -300,7 +300,7 @@
name: "latest"
register: output
- name: Assert output
- assert:
+ ansible.builtin.assert:
that: output.changed
- name: Import tag with different repo, same name (test idempotency)
@@ -313,7 +313,7 @@
name: "latest"
register: output
- name: Assert output
- assert:
+ ansible.builtin.assert:
that: not output.changed
- name: Import tag with different name, same repo
@@ -326,7 +326,7 @@
name: "latest"
register: output
- name: Assert output
- assert:
+ ansible.builtin.assert:
that: output.changed
- name: Import tag with different name, same repo (test idempotency)
@@ -339,7 +339,7 @@
name: "latest"
register: output
- name: Assert output
- assert:
+ ansible.builtin.assert:
that: not output.changed
- name: Load all tags
@@ -347,7 +347,7 @@
registry: "acr{{ rpfx }}"
register: output
- name: Assert tags exist
- assert:
+ ansible.builtin.assert:
that:
- output.repositories | length == 2
- output.repositories[0].name == 'app1'
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_cosmosdbaccount/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_cosmosdbaccount/tasks/main.yml
index ca1cc8b90..5e1f3f4d8 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_cosmosdbaccount/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_cosmosdbaccount/tasks/main.yml
@@ -1,11 +1,11 @@
- name: Prepare random number
- set_fact:
+ ansible.builtin.set_fact:
dbname: "cosmos-{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
db2name: "cosmos2-{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
vnname: "vn{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
subnetname: "subnet{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
free_tier_supported: false # https://github.com/ansible-collections/azure/pull/675#discussion_r843584406
- run_once: yes
+ run_once: true
- name: Create virtual network
azure_rm_virtualnetwork:
@@ -34,10 +34,10 @@
- name: eastasia
failover_priority: 0
database_account_offer_type: Standard
- check_mode: yes
+ check_mode: true
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -53,16 +53,16 @@
- name: westus
failover_priority: 1
database_account_offer_type: Standard
- is_virtual_network_filter_enabled: yes
+ is_virtual_network_filter_enabled: true
virtual_network_rules:
- subnet:
resource_group: "{{ resource_group }}"
virtual_network_name: "{{ vnname }}"
subnet_name: "{{ subnetname }}"
- ignore_missing_v_net_service_endpoint: yes
+ ignore_missing_v_net_service_endpoint: true
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -78,16 +78,16 @@
- name: westus
failover_priority: 1
database_account_offer_type: Standard
- is_virtual_network_filter_enabled: yes
+ is_virtual_network_filter_enabled: true
virtual_network_rules:
- subnet:
resource_group: "{{ resource_group }}"
virtual_network_name: "{{ vnname }}"
subnet_name: "{{ subnetname }}"
- ignore_missing_v_net_service_endpoint: yes
+ ignore_missing_v_net_service_endpoint: true
register: output
- name: Assert the state has not changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed == false
@@ -103,17 +103,17 @@
- name: westus
failover_priority: 1
database_account_offer_type: Standard
- is_virtual_network_filter_enabled: yes
+ is_virtual_network_filter_enabled: true
virtual_network_rules:
- subnet:
resource_group: "{{ resource_group }}"
virtual_network_name: "{{ vnname }}"
subnet_name: "{{ subnetname }}"
- ignore_missing_v_net_service_endpoint: yes
- enable_automatic_failover: yes
+ ignore_missing_v_net_service_endpoint: true
+ enable_automatic_failover: true
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -129,16 +129,16 @@
- name: westus
failover_priority: 1
database_account_offer_type: Standard
- is_virtual_network_filter_enabled: yes
+ is_virtual_network_filter_enabled: true
virtual_network_rules:
- subnet:
resource_group: "{{ resource_group }}"
virtual_network_name: "{{ vnname }}"
subnet_name: "{{ subnetname }}"
- ignore_missing_v_net_service_endpoint: yes
+ ignore_missing_v_net_service_endpoint: true
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -148,7 +148,7 @@
name: "{{ dbname }}"
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.accounts | length == 1
@@ -184,7 +184,7 @@
retrieve_keys: all
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.accounts[0]['primary_master_key'] != None
@@ -197,10 +197,10 @@
resource_group: "{{ resource_group }}"
name: "{{ dbname }}"
retrieve_keys: readonly
- retrieve_connection_strings: yes
+ retrieve_connection_strings: true
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- "'primary_master_key' not in output.accounts[0]"
@@ -214,7 +214,7 @@
resource_group: "{{ resource_group }}"
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.accounts | length == 1
@@ -247,7 +247,7 @@
azure_rm_cosmosdbaccount_info:
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.accounts | length >= 2
@@ -272,17 +272,17 @@
- name: westus
failover_priority: 1
database_account_offer_type: Standard
- is_virtual_network_filter_enabled: yes
+ is_virtual_network_filter_enabled: true
virtual_network_rules:
- subnet:
resource_group: "{{ resource_group }}"
virtual_network_name: "{{ vnname }}"
subnet_name: "{{ subnetname }}"
- ignore_missing_v_net_service_endpoint: yes
- enable_automatic_failover: yes
+ ignore_missing_v_net_service_endpoint: true
+ enable_automatic_failover: true
register: output
- name: Assert resource created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -292,7 +292,7 @@
name: "{{ dbname }}-free4"
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.accounts[0]['mongo_version'] == '4.0'
- output.accounts[0]['enable_free_tier'] == free_tier_supported
@@ -307,10 +307,10 @@
resource_group: "{{ resource_group }}"
name: "{{ dbname }}"
state: absent
- check_mode: yes
+ check_mode: true
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -321,7 +321,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -332,7 +332,7 @@
state: absent
register: output
- name: Assert the state has not changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed == false
@@ -343,7 +343,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -354,7 +354,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_datafactory/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_datafactory/tasks/main.yml
index 25afbe8bb..5e6295247 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_datafactory/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_datafactory/tasks/main.yml
@@ -1,76 +1,79 @@
- name: Create data factory name
- set_fact:
- name: "df{{ resource_group | hash('md5') | truncate(21, True, '') }}"
+ ansible.builtin.set_fact:
+ name_rpfx: "df{{ resource_group | hash('md5') | truncate(21, True, '') }}"
- name: Create data factory (Checkmode)
azure_rm_datafactory:
resource_group: "{{ resource_group }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
public_network_access: Enabled
tags:
key1: value1
- check_mode: True
+ check_mode: true
-- name: Create data factory
+- name: Create data factory
azure_rm_datafactory:
resource_group: "{{ resource_group }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
public_network_access: Enabled
tags:
key1: value1
register: output
-- assert:
+- name: Assert the data factory created
+ ansible.builtin.assert:
that:
- output.changed
- name: Create data factory again (Idempotent test)
azure_rm_datafactory:
resource_group: "{{ resource_group }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
public_network_access: Enabled
tags:
key1: value1
register: output
-- assert:
+- name: Assert the idempotent success
+ ansible.builtin.assert:
that:
- not output.changed
- name: Update data factory
azure_rm_datafactory:
resource_group: "{{ resource_group }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
public_network_access: Disabled
tags:
key1: value1
key2: value2
register: output
-- assert:
+- name: Assert the data factory updated
+ ansible.builtin.assert:
that:
- output.changed
- name: Get data factory info
azure_rm_datafactory_info:
resource_group: "{{ resource_group }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
register: output
- name: Assert status succeed and result match expectations
- assert:
+ ansible.builtin.assert:
that:
- output.datafactory[0].tags | length == 2
- output.datafactory[0].public_network_access == 'Disabled'
-
- name: Delete data factory
azure_rm_datafactory:
resource_group: "{{ resource_group }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
state: absent
register: output
-- assert:
+- name: Assert the data factory deleted
+ ansible.builtin.assert:
that:
- output.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_datalakestore/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_datalakestore/tasks/main.yml
index 1b9e2409b..c72dfc2ce 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_datalakestore/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_datalakestore/tasks/main.yml
@@ -1,5 +1,5 @@
- name: Create data lake store name
- set_fact:
+ ansible.builtin.set_fact:
adl_name: "adl{{ resource_group_datalake | hash('md5') | truncate(21, True, '') }}"
vnet_name: "vnet{{ resource_group_datalake | hash('md5') | truncate(20, True, '') }}"
@@ -28,7 +28,7 @@
register: output
- name: Assert status succeeded and results
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.state.id is defined
@@ -52,7 +52,7 @@
register: output
- name: Assert that status has not changed
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
@@ -66,7 +66,7 @@
register: output
- name: Assert status succeeded and results include virtual_network_rules
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.state.virtual_network_rules | length == 1
@@ -79,13 +79,13 @@
name: "{{ adl_name }}"
encryption_state: Disabled
register: output
- ignore_errors: yes
+ ignore_errors: true
- name: Assert that encryption state cannot change
- assert:
- that:
- - not output.changed
- - output.msg == 'Encryption type cannot be updated.'
+ ansible.builtin.assert:
+ that:
+ - not output.changed
+ - output.msg == 'Encryption type cannot be updated.'
- name: Update data lake store to add new_tier
azure_rm_datalakestore:
@@ -95,7 +95,7 @@
register: output
- name: Assert status succeeded and results include virtual_network_rules
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.state.current_tier == "Consumption"
@@ -122,12 +122,10 @@
firewall_state: Enabled
firewall_allow_azure_ips: Enabled
firewall_rules:
- -
- name: test_rule_1
+ - name: test_rule_1
start_ip_address: 192.168.1.1
end_ip_address: 192.168.1.254
- -
- name: test_rule_2
+ - name: test_rule_2
start_ip_address: 10.0.0.1
end_ip_address: 10.1.0.1
virtual_network_rules:
@@ -135,8 +133,8 @@
subnet_id: "{{ subnet_output.state.id }}"
register: output
-- name: Assert status succeeded and results include an Id value
- assert:
+- name: Assert status succeeded and results include an Id value
+ ansible.builtin.assert:
that:
- output.changed
- output.state.id is defined
@@ -172,12 +170,10 @@
firewall_state: Enabled
firewall_allow_azure_ips: Enabled
firewall_rules:
- -
- name: test_rule_1
+ - name: test_rule_1
start_ip_address: 192.168.1.1
end_ip_address: 192.168.1.254
- -
- name: test_rule_2
+ - name: test_rule_2
start_ip_address: 10.0.0.1
end_ip_address: 10.1.0.1
virtual_network_rules:
@@ -186,7 +182,7 @@
register: output
- name: Assert that status has not changed
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_ddosprotectionplan/meta/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_ddosprotectionplan/meta/main.yml
index cf34ae763..50fd77acf 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_ddosprotectionplan/meta/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_ddosprotectionplan/meta/main.yml
@@ -1,2 +1,2 @@
dependencies:
- - setup_azure \ No newline at end of file
+ - setup_azure
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_ddosprotectionplan/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_ddosprotectionplan/tasks/main.yml
index a61003680..f51a7b91c 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_ddosprotectionplan/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_ddosprotectionplan/tasks/main.yml
@@ -1,16 +1,17 @@
- name: Create random ddos protection plan
- set_fact:
- ddosprotectionplan: "test{{ resource_group | hash('md5') | truncate(16, True, '') + (65535 | random | string) }}"
+ ansible.builtin.set_fact:
+ ddosprotectionplan: "test{{ resource_group | hash('md5') | truncate(16, True, '') + (65535 | random | string) }}"
- name: Create DDoS protection plan (check mode)
azure_rm_ddosprotectionplan:
location: eastus2
name: "{{ ddosprotectionplan }}"
resource_group: "{{ resource_group }}"
- check_mode: yes
+ check_mode: true
register: results
-- assert:
+- name: Assert the ddos protection check mode return
+ ansible.builtin.assert:
that: results.changed
- name: Create DDoS protection plan
@@ -20,7 +21,8 @@
resource_group: "{{ resource_group }}"
register: results
-- assert:
+- name: Assert the ddos protection created
+ ansible.builtin.assert:
that: results.changed
- name: Update DDoS protection plan
@@ -32,8 +34,9 @@
test: modified
register: results
-- assert:
- that:
+- name: Assert the ddos protection updated
+ ansible.builtin.assert:
+ that:
- results.changed
- results.state.tags.test == 'modified'
@@ -44,8 +47,8 @@
register: results
- name: Assert that facts module returned result
- assert:
- that:
+ ansible.builtin.assert:
+ that:
- results.ddosprotectionplan[0].tags.test == 'modified'
- name: Test idempotent
@@ -55,7 +58,8 @@
resource_group: "{{ resource_group }}"
register: results
-- assert:
+- name: Assert the ddos protection created
+ ansible.builtin.assert:
that:
- not results.changed
@@ -78,5 +82,6 @@
state: absent
register: results
-- assert:
+- name: Assert the ddos protection plan deleted
+ ansible.builtin.assert:
that: not results.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_deployment/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_deployment/tasks/main.yml
index 7e83a4c28..f2ed58b15 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_deployment/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_deployment/tasks/main.yml
@@ -1,5 +1,5 @@
- name: Create random dns label
- set_fact:
+ ansible.builtin.set_fact:
dns_label: "test{{ resource_group | hash('md5') | truncate(16, True, '') + (65535 | random | string) }}"
- name: Error Create Azure Deploy
@@ -18,7 +18,7 @@
ubuntuOSVersion:
value: "Never-LTS"
register: output
- ignore_errors: yes
+ ignore_errors: true
- name: Create Azure Deploy
azure_rm_deployment:
@@ -38,7 +38,7 @@
register: output
- name: Add new instance to host group
- add_host:
+ ansible.builtin.add_host:
hostname: "{{ item.vm_name }}"
ansible_host: "{{ item['ips'][0].public_ip }}"
ansible_user: chouseknecht
@@ -50,7 +50,8 @@
azure_rm_deployment_info:
resource_group: "{{ resource_group }}"
register: output
-- debug:
+- name: Print the deployment facts
+ ansible.builtin.debug:
var: output
- name: Get Deployment Facts for named deployment
@@ -58,11 +59,12 @@
resource_group: "{{ resource_group }}"
name: "{{ dns_label }}"
register: output
-- debug:
+- name: Print the deployment facts
+ ansible.builtin.debug:
var: output
- name: Assert that values are returned
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
- output.deployments[0]['provisioning_state'] != None
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_devtestlab/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_devtestlab/tasks/main.yml
index 87d63ad88..47d32dc70 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_devtestlab/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_devtestlab/tasks/main.yml
@@ -1,5 +1,5 @@
- name: Set devtest labe value
- set_fact:
+ ansible.builtin.set_fact:
rpfx: "{{ resource_group | hash('md5') | truncate(20, True, '') }}"
- name: Create a DevTest Lab (check mode)
@@ -10,7 +10,7 @@
premium_data_disks: true
tags:
key1: value1
- check_mode: yes
+ check_mode: true
- name: Create a DevTest Lab
azure_rm_devtestlab:
@@ -23,7 +23,7 @@
register: output
- name: Check the devtest lab changed
- assert:
+ ansible.builtin.assert:
that: output.changed
- name: Create a DevTest Lab (Idempotent test)
@@ -37,7 +37,7 @@
register: output
- name: Check the devtest lab not changed
- assert:
+ ansible.builtin.assert:
that: not output.changed
- name: Get devtest lab facts
@@ -45,9 +45,9 @@
resource_group: "{{ resource_group }}"
name: "dev-{{ rpfx }}"
register: output
-
+
- name: Assert the devtest lab create success
- assert:
+ ansible.builtin.assert:
that:
- output.labs | length == 1
- output.labs[0].provisioning_state == "Succeeded"
@@ -63,7 +63,7 @@
register: output
- name: Assert the devtest lab virtual network create successfully
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -75,7 +75,7 @@
register: output
- name: Assert the devtest lab virtual network facts
- assert:
+ ansible.builtin.assert:
that:
- output.virtualnetworks | length == 1
- output.virtualnetworks[0].description == "My Lab Virtual network"
@@ -95,17 +95,17 @@
name: "vnet-{{ rpfx }}Subnet"
virtual_network_name: "vnet-{{ rpfx }}"
image:
- offer: UbuntuServer
+ offer: 0001-com-ubuntu-server-focal
publisher: Canonical
- sku: 16.04-LTS
+ sku: 20_04-lts
os_type: Linux
version: latest
- allow_claim: no
+ allow_claim: false
expiration_date: "2025-10-22T01:49:12.117974Z"
register: output
- name: Assert the devtest lab virtual machine create successfully
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -117,13 +117,13 @@
register: output
- name: Assert the devtest lab virtualmachine facts
- assert:
+ ansible.builtin.assert:
that:
- output.virtualmachines | length == 1
- output.virtualmachines[0].provisioning_state == "Succeeded"
- output.virtualmachines[0].expiration_date == "2025-10-22T01:49:12.117974Z"
-- name: create a instance devtest lab image
+- name: Create a instance devtest lab image
azure_rm_devtestlabcustomimage:
resource_group: "{{ resource_group }}"
lab_name: "dev-{{ rpfx }}"
@@ -133,7 +133,7 @@
register: output
- name: Assert the devtest lab image create successufully
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -145,7 +145,7 @@
register: output
- name: Assert the devtest lab image facts
- assert:
+ ansible.builtin.assert:
that:
- output.custom_images | length == 1
- output.custom_images[0].lab_name
@@ -157,9 +157,9 @@
lab_name: "dev-{{ rpfx }}"
artifact_source_name: "public environment repo"
register: output
-
+
- name: Assert the devtest lab armtemplate is returned successfully
- assert:
+ ansible.builtin.assert:
that:
- output.armtemplates | length >= 1
@@ -174,7 +174,7 @@
register: output
- name: Assert the devtest lab policy creatre successfully
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -186,7 +186,7 @@
register: output
- name: Assert the devtest lab policy facts
- assert:
+ ansible.builtin.assert:
that:
- output.policies | length >= 1
@@ -200,7 +200,7 @@
register: output
- name: Assert the devtest lab schedule create sussessfully
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -212,7 +212,7 @@
register: output
- name: Assert the devtest lab schedule facts
- assert:
+ ansible.builtin.assert:
that:
- output.schedules | length >= 1
- output.schedules[0].name == "lab_vms_shutdown"
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_diskencryptionset/lookup_plugins/azure_service_principal_attribute.py b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_diskencryptionset/lookup_plugins/azure_service_principal_attribute.py
index 1b7d0318f..c6f488f13 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_diskencryptionset/lookup_plugins/azure_service_principal_attribute.py
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_diskencryptionset/lookup_plugins/azure_service_principal_attribute.py
@@ -45,15 +45,13 @@ _raw:
"""
from ansible.errors import AnsibleError
-from ansible.plugins import AnsiblePlugin
from ansible.plugins.lookup import LookupBase
from ansible.module_utils._text import to_native
try:
from azure.common.credentials import ServicePrincipalCredentials
from azure.graphrbac import GraphRbacManagementClient
- from msrestazure import azure_cloud
- from msrestazure.azure_exceptions import CloudError
+ from azure.cli.core import cloud as azure_cloud
except ImportError:
raise AnsibleError(
"The lookup azure_service_principal_attribute requires azure.graphrbac, msrest")
@@ -89,6 +87,6 @@ class LookupModule(LookupBase):
sp = response[0]
return sp.object_id.split(',')
- except CloudError as ex:
+ except Exception as ex:
raise AnsibleError("Failed to get service principal object id: %s" % to_native(ex))
return False
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_diskencryptionset/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_diskencryptionset/tasks/main.yml
index 79055e213..0d805598e 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_diskencryptionset/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_diskencryptionset/tasks/main.yml
@@ -1,23 +1,23 @@
- name: Prepare random number
- set_fact:
+ ansible.builtin.set_fact:
set_name: "des{{ resource_group | hash('md5') | truncate(22, True, '') }}"
rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
tenant_id: "{{ azure_tenant }}"
- run_once: yes
+ run_once: true
-- name: lookup service principal object id
- set_fact:
+- name: Lookup service principal object id
+ ansible.builtin.set_fact:
object_id: "{{ lookup('azure_service_principal_attribute',
azure_client_id=azure_client_id,
azure_secret=azure_secret,
azure_tenant=tenant_id) }}"
register: object_id_facts
-- name: create a key vault
+- name: Create a key vault
azure_rm_keyvault:
resource_group: "{{ resource_group }}"
vault_name: "myvault{{ rpfx }}"
- enabled_for_disk_encryption: yes
+ enabled_for_disk_encryption: true
vault_tenant: "{{ tenant_id }}"
sku:
name: standard
@@ -50,10 +50,11 @@
name: testkey
register: results
-- set_fact:
+- name: Assert the key vault facts
+ ansible.builtin.set_fact:
key_url: "{{ results['keys'][0]['kid'] }}"
-- name: create disk encryption set
+- name: Create disk encryption set
azure_rm_diskencryptionset:
resource_group: "{{ resource_group }}"
name: "{{ set_name }}"
@@ -63,10 +64,10 @@
register: results
- name: Assert that disk encryption set is created
- assert:
+ ansible.builtin.assert:
that: results.changed
-- name: create disk encryption set (Idempotent test)
+- name: Create disk encryption set (Idempotent test)
azure_rm_diskencryptionset:
resource_group: "{{ resource_group }}"
name: "{{ set_name }}"
@@ -76,7 +77,7 @@
register: results
- name: Assert that output is not changed
- assert:
+ ansible.builtin.assert:
that: not results.changed
- name: Update disk encryption set
@@ -91,7 +92,7 @@
register: results
- name: Assert that disk encryption set is updated
- assert:
+ ansible.builtin.assert:
that: results.changed
- name: Get disk encryption set facts
@@ -100,7 +101,8 @@
name: "{{ set_name }}"
register: results
-- assert:
+- name: Assert the disk encryption facts
+ ansible.builtin.assert:
that:
- not results.changed
- results.diskencryptionsets[0].id != None
@@ -117,7 +119,7 @@
register: results
- name: Assert that disk encryption set is deleted
- assert:
+ ansible.builtin.assert:
that: results.changed
- name: Delete disk encryption set (Idempotent test)
@@ -128,7 +130,7 @@
register: results
- name: Asset that output is not changed
- assert:
+ ansible.builtin.assert:
that: not results.changed
- name: Delete the Key Vault
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_dnsrecordset/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_dnsrecordset/tasks/main.yml
index 6b9acee8d..4481a596e 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_dnsrecordset/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_dnsrecordset/tasks/main.yml
@@ -1,5 +1,5 @@
- name: Create random domain name
- set_fact:
+ ansible.builtin.set_fact:
domain_name: "{{ resource_group | hash('md5') | truncate(16, True, '') + (65535 | random | string) }}"
- name: Create a DNS zone
@@ -10,10 +10,10 @@
register: results
- name: Assert that DNS zone was created
- assert:
+ ansible.builtin.assert:
that: results.changed
-- name: create "A" record set with multiple records
+- name: Create "A" record set with multiple records
azure_rm_dnsrecordset:
resource_group: "{{ resource_group }}"
relative_name: www
@@ -26,10 +26,10 @@
register: results
- name: Assert that A record set was created
- assert:
+ ansible.builtin.assert:
that: results.changed
-- name: re-run "A" record with same values
+- name: Re-run "A" record with same values
azure_rm_dnsrecordset:
resource_group: "{{ resource_group }}"
relative_name: www
@@ -42,7 +42,7 @@
register: results
- name: Assert that A record set was not changed
- assert:
+ ansible.builtin.assert:
that: not results.changed
- name: Update "A" record set with additional record
@@ -57,11 +57,11 @@
register: results
- name: Assert that new record was appended
- assert:
- that:
+ ansible.builtin.assert:
+ that:
- results.changed
-- name: re-update "A" record set with additional record
+- name: Re-update "A" record set with additional record
azure_rm_dnsrecordset:
resource_group: "{{ resource_group }}"
relative_name: www
@@ -73,7 +73,7 @@
register: results
- name: Assert that A record set was not changed
- assert:
+ ansible.builtin.assert:
that:
- not results.changed
@@ -90,7 +90,7 @@
register: results
- name: Assert that record was deleted
- assert:
+ ansible.builtin.assert:
that:
- results.changed
@@ -102,17 +102,17 @@
record_type: A
records:
- entry: 192.168.100.105
- check_mode: yes
+ check_mode: true
register: results
- name: Assert that check_mode returns new state
- assert:
- that:
+ ansible.builtin.assert:
+ that:
- results.changed
# FUTURE: add facts module calls to ensure that we really didn't touch anything
-- name: delete a record set
+- name: Delete a record set
azure_rm_dnsrecordset:
resource_group: "{{ resource_group }}"
relative_name: www
@@ -122,10 +122,10 @@
register: results
- name: Assert that record set deleted
- assert:
+ ansible.builtin.assert:
that: results.changed
-- name: (idempotence test) re-run record set absent
+- name: Re-run record set absent(idempotence test)
azure_rm_dnsrecordset:
resource_group: "{{ resource_group }}"
relative_name: www
@@ -134,11 +134,11 @@
state: absent
register: results
-- name:
- assert:
+- name: Assert the record set deleted
+ ansible.builtin.assert:
that: not results.changed
-- name: create SRV records in a new record set
+- name: Create SRV records in a new record set
azure_rm_dnsrecordset:
resource_group: "{{ resource_group }}"
relative_name: "_sip._tcp.{{ domain_name }}.com"
@@ -147,18 +147,18 @@
record_type: SRV
state: present
records:
- - entry: sip.{{ domain_name }}.com
- priority: 20
- weight: 10
- port: 5060
+ - entry: sip.{{ domain_name }}.com
+ priority: 20
+ weight: 10
+ port: 5060
register: results
- name: Assert that SRV record set was created
- assert:
- that:
+ ansible.builtin.assert:
+ that:
- results.changed
-- name: create TXT records in a new record set
+- name: Create TXT records in a new record set
azure_rm_dnsrecordset:
resource_group: "{{ resource_group }}"
relative_name: "_txt.{{ domain_name }}.com"
@@ -174,7 +174,7 @@
register: results
- name: Assert that TXT record set was created
- assert:
+ ansible.builtin.assert:
that:
- results.changed
@@ -196,7 +196,7 @@
register: results
- name: Assert that SOA record set was created
- assert:
+ ansible.builtin.assert:
that:
- results.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_dnszone/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_dnszone/tasks/main.yml
index 3f38ca554..849755798 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_dnszone/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_dnszone/tasks/main.yml
@@ -1,5 +1,5 @@
- name: Create random domain name
- set_fact:
+ ansible.builtin.set_fact:
domain_name: "{{ resource_group | hash('md5') | truncate(16, True, '') + (65535 | random | string) }}"
- name: Create a DNS zone (check mode)
@@ -7,9 +7,10 @@
resource_group: "{{ resource_group }}"
name: "{{ domain_name }}.com"
register: results
- check_mode: yes
+ check_mode: true
-- assert:
+- name: Assert the dns zone created
+ ansible.builtin.assert:
that: results.changed
- name: Create a DNS zone
@@ -18,7 +19,8 @@
name: "{{ domain_name }}.com"
register: results
-- assert:
+- name: Assert the dns zone created
+ ansible.builtin.assert:
that: results.changed
- name: Update DNS zone with tags
@@ -29,8 +31,9 @@
test: modified
register: results
-- assert:
- that:
+- name: Assert the dns zone updated
+ ansible.builtin.assert:
+ that:
- results.changed
- results.state.tags.test == 'modified'
@@ -41,8 +44,8 @@
register: zones
- name: Assert that facts module returned result
- assert:
- that:
+ ansible.builtin.assert:
+ that:
- zones.dnszones[0].tags.test == 'modified'
- zones.dnszones[0].type == 'public'
@@ -52,7 +55,8 @@
resource_group: "{{ resource_group }}"
register: results
-- assert:
+- name: Assert idempotent test result
+ ansible.builtin.assert:
that:
- not results.changed
@@ -60,7 +64,7 @@
# azure_rm_dnsrecordset test
#
-- name: create "A" record set with multiple records
+- name: Create "A" record set with multiple records
azure_rm_dnsrecordset:
resource_group: "{{ resource_group }}"
relative_name: www
@@ -73,12 +77,12 @@
register: results
- name: Assert that A record set was created
- assert:
+ ansible.builtin.assert:
that:
- - results.changed
- - 'results.state.a_records | length == 3'
+ - results.changed
+ - 'results.state.a_records | length == 3'
-- name: re-run "A" record with same values
+- name: Re-run "A" record with same values
azure_rm_dnsrecordset:
resource_group: "{{ resource_group }}"
relative_name: www
@@ -91,7 +95,7 @@
register: results
- name: Assert that A record set was not changed
- assert:
+ ansible.builtin.assert:
that: not results.changed
- name: Update "A" record set with additional record
@@ -106,12 +110,12 @@
register: results
- name: Assert that new record was appended
- assert:
- that:
+ ansible.builtin.assert:
+ that:
- results.changed
- 'results.state.a_records | length == 4'
-- name: re-update "A" record set with additional record
+- name: Re-update "A" record set with additional record
azure_rm_dnsrecordset:
resource_group: "{{ resource_group }}"
relative_name: www
@@ -123,7 +127,7 @@
register: results
- name: Assert that A record set was not changed
- assert:
+ ansible.builtin.assert:
that:
- not results.changed
@@ -140,10 +144,10 @@
register: results
- name: Assert that record was deleted
- assert:
+ ansible.builtin.assert:
that:
- results.changed
- - 'results.state.a_records | length == 3'
+ - 'results.state.a_records | length == 3'
- name: Check_mode test
azure_rm_dnsrecordset:
@@ -153,17 +157,17 @@
record_type: A
records:
- entry: 192.168.100.105
- check_mode: yes
+ check_mode: true
register: results
- name: Assert that check_mode returns new state
- assert:
- that:
+ ansible.builtin.assert:
+ that:
- results.changed
# FUTURE: add facts module calls to ensure that we really didn't touch anything
-- name: create SRV records in a new record set
+- name: Create SRV records in a new record set
azure_rm_dnsrecordset:
resource_group: "{{ resource_group }}"
relative_name: "_sip._tcp.{{ domain_name }}.com"
@@ -171,18 +175,18 @@
time_to_live: 7200
record_type: SRV
records:
- - entry: sip.{{ domain_name }}.com
- priority: 20
- weight: 10
- port: 5060
+ - entry: sip.{{ domain_name }}.com
+ priority: 20
+ weight: 10
+ port: 5060
register: results
- name: Assert that SRV record set was created
- assert:
- that:
+ ansible.builtin.assert:
+ that:
- results.changed
-- name: create TXT records in a new record set
+- name: Create TXT records in a new record set
azure_rm_dnsrecordset:
resource_group: "{{ resource_group }}"
relative_name: "_txt.{{ domain_name }}.com"
@@ -196,8 +200,8 @@
- "baz"
register: results
-- name: Assert that TXT record set was created
- assert:
+- name: Cssert that TXT record set was created
+ ansible.builtin.assert:
that:
- results.changed
@@ -214,8 +218,8 @@
register: results
- name: Assert that facts module returned result for single Record Set
- assert:
- that:
+ ansible.builtin.assert:
+ that:
- not results.changed
# - azure_dnsrecordset[0].name == 'www'
- results.dnsrecordsets[0].relative_name == 'www'
@@ -229,8 +233,8 @@
register: facts
- name: Assert that facts module returned result for all Record Sets
- assert:
- that:
+ ansible.builtin.assert:
+ that:
- not facts.changed
# - facts.ansible_facts.azure_dnsrecordset[0].name == '@'
# - facts.ansible_facts.azure_dnsrecordset[1].name == '@'
@@ -239,7 +243,7 @@
#
# azure_rm_dnsrecordset cleanup
#
-- name: delete all record sets except for @
+- name: Delete all record sets except for @
azure_rm_dnsrecordset:
resource_group: "{{ resource_group }}"
relative_name: "{{ item.relative_name }}"
@@ -252,7 +256,7 @@
register: results
- name: Assert that record set deleted
- assert:
+ ansible.builtin.assert:
that: results.changed
- name: Retrieve DNS Record Set Facts for all Record Sets
@@ -262,12 +266,12 @@
register: facts
- name: Assert all record set deleted
- assert:
+ ansible.builtin.assert:
that:
- - item.relative_name == '@'
+ - item.relative_name == '@'
with_items: "{{ facts.dnsrecordsets }}"
-- name: (idempotence test) re-run record set absent
+- name: Re-run record set absent(Idempotent test)
azure_rm_dnsrecordset:
resource_group: "{{ resource_group }}"
relative_name: www
@@ -276,8 +280,8 @@
state: absent
register: results
-- name:
- assert:
+- name: Assert the dns recored deleted
+ ansible.builtin.assert:
that: not results.changed
#
@@ -286,7 +290,7 @@
- name: Delete DNS zone
azure_rm_dnszone:
resource_group: "{{ resource_group }}"
- name: "{{ domain_name }}.com"
+ name: "{{ domain_name }}.com"
state: absent
- name: Delete DNS zone (idempotent)
@@ -296,5 +300,6 @@
state: absent
register: results
-- assert:
+- name: Assert the dns zone deleted
+ ansible.builtin.assert:
that: not results.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_eventhub/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_eventhub/tasks/main.yml
index 484f0146d..62e60e95b 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_eventhub/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_eventhub/tasks/main.yml
@@ -1,7 +1,7 @@
- name: Create random event hub and namespace
- set_fact:
- namespace_name: "test{{ resource_group | hash('md5') | truncate(16, True, '') + (65535 | random | string) }}"
- name: "test{{ resource_group | hash('md5') | truncate(16, True, '') + (65535 | random | string) }}"
+ ansible.builtin.set_fact:
+ namespace_name: "test{{ resource_group | hash('md5') | truncate(16, True, '') + (65535 | random | string) }}"
+ name_rpfx: "test{{ resource_group | hash('md5') | truncate(16, True, '') + (65535 | random | string) }}"
- name: Create Event Hub Namespace (check mode)
azure_rm_eventhub:
@@ -9,23 +9,25 @@
namespace_name: "{{ namespace_name }}"
resource_group: "{{ resource_group }}"
sku: "Basic"
- check_mode: yes
+ check_mode: true
register: results
-- assert:
+- name: Assert the check mode result
+ ansible.builtin.assert:
that: results.changed
-- name: Create Event Hub (check mode)
+- name: Create Event Hub (check mode)
azure_rm_eventhub:
location: eastus2
namespace_name: "{{ namespace_name }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
resource_group: "{{ resource_group }}"
sku: "Basic"
- check_mode: yes
+ check_mode: true
register: results
-- assert:
+- name: Assert the check mode result
+ ansible.builtin.assert:
that: results.changed
- name: Create Event Hub Namespace
@@ -36,18 +38,20 @@
sku: "Basic"
register: results
-- assert:
+- name: Assert the event hub namespace created
+ ansible.builtin.assert:
that: results.changed
- name: Create Event Hub
azure_rm_eventhub:
location: eastus2
namespace_name: "{{ namespace_name }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
resource_group: "{{ resource_group }}"
register: results
-- assert:
+- name: Assert the event hub created
+ ansible.builtin.assert:
that: results.changed
- name: Update Namespace
@@ -60,8 +64,9 @@
test: modified
register: results
-- assert:
- that:
+- name: Assert the namespace updated
+ ansible.builtin.assert:
+ that:
- results.changed
- results.state.tags.test == 'modified'
@@ -69,7 +74,7 @@
azure_rm_eventhub:
location: eastus2
namespace_name: "{{ namespace_name }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
resource_group: "{{ resource_group }}"
message_retention_in_days: 4
state: present
@@ -77,8 +82,9 @@
test: modified
register: results
-- assert:
- that:
+- name: Assert the event hub updated
+ ansible.builtin.assert:
+ that:
- results.changed
- name: Retrieve Namespace
@@ -97,16 +103,17 @@
test: modified
register: results
-- assert:
+- name: Assert idempotent success
+ ansible.builtin.assert:
that:
- not results.changed
-#cleanup
+# cleanup
- name: Delete Event Hub
azure_rm_eventhub:
location: eastus2
namespace_name: "{{ namespace_name }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
resource_group: "{{ resource_group }}"
state: absent
@@ -114,12 +121,13 @@
azure_rm_eventhub:
location: eastus2
namespace_name: "{{ namespace_name }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
resource_group: "{{ resource_group }}"
state: absent
register: results
-- assert:
+- name: Assert the event hub deleted
+ ansible.builtin.assert:
that: not results.changed
- name: Delete Namespace
@@ -130,8 +138,9 @@
state: absent
- name: Pause for 1 minutes to check namespace deleted
- pause:
+ ansible.builtin.pause:
minutes: 1
+ changed_when: true
- name: Delete Namespace (idempotent)
azure_rm_eventhub:
@@ -141,5 +150,6 @@
state: absent
register: results
-- assert:
+- name: Assert the namespace deleted
+ ansible.builtin.assert:
that: not results.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_expressroute/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_expressroute/tasks/main.yml
index d90dbfdf6..3d70ddd82 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_expressroute/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_expressroute/tasks/main.yml
@@ -1,5 +1,5 @@
- name: Create random express route
- set_fact:
+ ansible.builtin.set_fact:
express_route: "test{{ resource_group | hash('md5') | truncate(16, True, '') + (65535 | random | string) }}"
- name: Create Express route (check mode)
@@ -21,9 +21,10 @@
tier: premium
family: metereddata
register: results
- check_mode: yes
+ check_mode: true
-- assert:
+- name: Assert the excpress route check mode result
+ ansible.builtin.assert:
that: results.changed
@@ -34,7 +35,7 @@
resource_group: "{{ resource_group }}"
allow_classic_operations: true
global_reach_enabled: false
- tags:
+ tags:
a: b
authorizations:
- name: authorization_test
@@ -47,7 +48,8 @@
family: metereddata
register: results
-- assert:
+- name: Assert the express route created
+ ansible.builtin.assert:
that: results.changed
@@ -58,7 +60,7 @@
resource_group: "{{ resource_group }}"
allow_classic_operations: true
global_reach_enabled: false
- tags:
+ tags:
test: modified
authorizations:
- name: authorization_test
@@ -71,8 +73,9 @@
family: metereddata
register: results
-- assert:
- that:
+- name: Assert the express route updated
+ ansible.builtin.assert:
+ that:
- results.changed
- results.state.tags.test == 'modified'
@@ -84,8 +87,8 @@
register: results
- name: Assert that facts module returned result
- assert:
- that:
+ ansible.builtin.assert:
+ that:
- results.expressroute[0].tags.test == 'modified'
- results.expressroute[0].type == 'Microsoft.Network/expressRouteCircuits'
@@ -95,7 +98,8 @@
resource_group: "{{ resource_group }}"
register: results
-- assert:
+- name: Assert the idempotent
+ ansible.builtin.assert:
that:
- not results.changed
@@ -105,7 +109,7 @@
- name: Delete Express Route
azure_rm_expressroute:
resource_group: "{{ resource_group }}"
- name: "{{ express_route }}"
+ name: "{{ express_route }}"
state: absent
- name: Delete Express Route (idempotent)
@@ -115,5 +119,6 @@
state: absent
register: results
-- assert:
+- name: Assert the express route deleted
+ ansible.builtin.assert:
that: not results.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_firewallpolicy/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_firewallpolicy/tasks/main.yml
index 4bbba792e..f81ab9708 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_firewallpolicy/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_firewallpolicy/tasks/main.yml
@@ -1,5 +1,5 @@
- name: Create firewall policy name
- set_fact:
+ ansible.builtin.set_fact:
policy_name: "fp{{ resource_group | hash('md5') | truncate(22, True, '') }}"
- name: Create firewall policy
@@ -18,7 +18,7 @@
register: results
- name: Assert that firewall policy is created
- assert:
+ ansible.builtin.assert:
that: results.changed
- name: Create a firewall policy again (Idempotent test)
@@ -37,7 +37,7 @@
register: results
- name: Assert that output is not changed
- assert:
+ ansible.builtin.assert:
that: not results.changed
- name: Update a firewall policy
@@ -58,7 +58,7 @@
register: results
- name: Assert that firewall policy is updated
- assert:
+ ansible.builtin.assert:
that: results.changed
- name: Get firewall policy facts
@@ -67,7 +67,8 @@
name: "{{ policy_name }}"
register: results
-- assert:
+- name: Assert the firewall policy facts
+ ansible.builtin.assert:
that:
- not results.changed
- results.firewallpolicies[0].id != None
@@ -85,7 +86,7 @@
register: results
- name: Assert that firewall policy is deleted
- assert:
+ ansible.builtin.assert:
that: results.changed
- name: Delete firewall policy again (Idempotent test)
@@ -96,5 +97,5 @@
register: results
- name: Asset that output is not changed
- assert:
+ ansible.builtin.assert:
that: not results.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_functionapp/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_functionapp/tasks/main.yml
index e618e7038..5c5d5e3fe 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_functionapp/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_functionapp/tasks/main.yml
@@ -1,56 +1,56 @@
- name: Fix resource prefix
- set_fact:
+ ansible.builtin.set_fact:
fixed_resource_prefix: "fa{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
- name: Fix resource prefix
- set_fact:
+ ansible.builtin.set_fact:
funcapp_name_basic: "fa{{ fixed_resource_prefix }}basic"
funcapp_name_container: "fa{{ fixed_resource_prefix }}container"
funcapp_name_params: "fa{{ fixed_resource_prefix }}params"
storage_account_name: "sa{{ fixed_resource_prefix }}"
plan_name: "ap{{ fixed_resource_prefix }}"
-- name: create storage account for function apps
+- name: Create storage account for function apps
azure_rm_storageaccount:
resource_group: '{{ resource_group }}'
name: "{{ storage_account_name }}"
account_type: Standard_LRS
-- name: create basic function app
+- name: Create basic function app
azure_rm_functionapp:
resource_group: "{{ resource_group }}"
name: "{{ funcapp_name_basic }}"
storage_account: "{{ storage_account_name }}"
register: output
-- name: assert the function was created
- assert:
+- name: Assert the function was created
+ ansible.builtin.assert:
that: output.changed
-- name: list facts for function
+- name: List facts for function
azure_rm_functionapp_info:
resource_group: '{{ resource_group }}'
name: "{{ funcapp_name_basic }}"
register: results
-- name: assert the facts were retrieved
- assert:
+- name: Assert the facts were retrieved
+ ansible.builtin.assert:
that:
- - results.ansible_info.azure_functionapps|length == 1
- - results.ansible_info.azure_functionapps[0].name == "{{ funcapp_name_basic }}"
+ - results.ansible_info.azure_functionapps|length == 1
+ - results.ansible_info.azure_functionapps[0].name == "{{ funcapp_name_basic }}"
-- name: delete basic function app
+- name: Delete basic function app
azure_rm_functionapp:
resource_group: '{{ resource_group }}'
name: "{{ funcapp_name_basic }}"
state: absent
register: output
-- name: assert the function was deleted
- assert:
+- name: Assert the function was deleted
+ ansible.builtin.assert:
that: output.changed
-- name: create a function with app settings
+- name: Create a function with app settings
azure_rm_functionapp:
resource_group: '{{ resource_group }}'
name: "{{ funcapp_name_params }}"
@@ -61,11 +61,11 @@
FUNCTIONS_EXTENSION_VERSION: "~2"
register: output
-- name: assert the function with app settings was created
- assert:
+- name: Assert the function with app settings was created
+ ansible.builtin.assert:
that: output.changed
-- name: change app settings
+- name: Change app settings
azure_rm_functionapp:
resource_group: '{{ resource_group }}'
name: "{{ funcapp_name_params }}"
@@ -77,19 +77,19 @@
another: one
register: output
-- name: assert the function was changed
- assert:
+- name: Assert the function was changed
+ ansible.builtin.assert:
that: output.changed
-- name: delete the function app
+- name: Delete the function app
azure_rm_functionapp:
resource_group: '{{ resource_group }}'
name: "{{ funcapp_name_params }}"
state: absent
register: output
-- name: assert the function was deleted
- assert:
+- name: Assert the function was deleted
+ ansible.builtin.assert:
that: output.changed
- name: Create a linux app service plan
@@ -106,25 +106,25 @@
name: "{{ funcapp_name_container }}"
storage_account: "{{ storage_account_name }}"
plan:
- resource_group: "{{ resource_group }}"
- name: "{{ plan_name }}"
+ resource_group: "{{ resource_group }}"
+ name: "{{ plan_name }}"
container_settings:
- name: httpd
+ name: httpd
app_settings:
- FUNCTIONS_EXTENSION_VERSION: "~2"
+ FUNCTIONS_EXTENSION_VERSION: "~2"
register: output
-- name: assert the function was changed
- assert:
+- name: Assert the function was changed
+ ansible.builtin.assert:
that: output.changed
-- name: delete the function app
+- name: Delete the function app
azure_rm_functionapp:
resource_group: '{{ resource_group }}'
name: "{{ funcapp_name_container }}"
state: absent
-- name: delete storage account
+- name: Delete storage account
azure_rm_storageaccount:
resource_group: '{{ resource_group }}'
name: "{{ storage_account_name }}"
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_gallery/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_gallery/tasks/main.yml
index f67fa218f..b9705dc34 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_gallery/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_gallery/tasks/main.yml
@@ -1,7 +1,7 @@
- name: Prepare random number
- set_fact:
+ ansible.builtin.set_fact:
rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
- run_once: yes
+ run_once: true
- name: Create virtual network
azure_rm_virtualnetwork:
@@ -42,9 +42,9 @@
vm_size: Standard_B1ms
network_interfaces: "vmforimage{{ rpfx }}nic"
image:
- offer: UbuntuServer
+ offer: 0001-com-ubuntu-server-focal
publisher: Canonical
- sku: 16.04-LTS
+ sku: 20_04-lts
version: latest
- name: Get VM facts
@@ -54,7 +54,9 @@
register: output
- name: Pause for 10 mimutes to VM updating
- shell: sleep 600
+ ansible.builtin.command:
+ sleep 600
+ changed_when: true
- name: Create a snapshot by importing an unmanaged blob from the same subscription.
azure_rm_snapshot:
@@ -66,8 +68,9 @@
source_uri: 'https://{{ output.vms[0].storage_account_name }}.blob.core.windows.net/{{ output.vms[0].storage_container_name }}/{{ output.vms[0].storage_blob_name }}'
register: output
-- assert:
- that:
+- name: Assert the snapshot created
+ ansible.builtin.assert:
+ that:
- output.changed
- name: Create a managed disk
@@ -82,13 +85,14 @@
resource_group: "{{ resource_group }}"
name: "mySnapshot-{{ rpfx }}02"
location: eastus
- incremental: True
+ incremental: true
creation_data:
create_option: Copy
source_id: "{{ disk_output.state.id }}"
register: output
-- assert:
+- name: Assert the snapshot idempotent result
+ ansible.builtin.assert:
that:
- output.changed
@@ -96,7 +100,7 @@
azure_rm_virtualmachine:
resource_group: "{{ resource_group }}"
name: "vmforimage{{ rpfx }}"
- generalized: yes
+ generalized: true
- name: Create custom image
azure_rm_image:
resource_group: "{{ resource_group }}"
@@ -110,8 +114,9 @@
description: This is the gallery description.
register: output
-- assert:
- that:
+- name: Assert the gallery created
+ ansible.builtin.assert:
+ that:
- output.changed
- name: Create or update a simple gallery - idempotent
@@ -122,8 +127,9 @@
description: This is the gallery description.
register: output
-- assert:
- that:
+- name: Assert the gallery created
+ ansible.builtin.assert:
+ that:
- not output.changed
- name: Create or update a simple gallery - change description
@@ -134,8 +140,9 @@
description: This is the gallery description - xxx.
register: output
-- assert:
- that:
+- name: Assert the gallery updated
+ ansible.builtin.assert:
+ that:
- output.changed
- name: Get a gallery info.
@@ -144,8 +151,9 @@
name: myGallery{{ rpfx }}
register: output
-- assert:
- that:
+- name: Assedrt the gallery facts
+ ansible.builtin.assert:
+ that:
- not output.changed
- output.galleries['id'] != None
- output.galleries['name'] != None
@@ -168,8 +176,9 @@
description: Image Description
register: output
-- assert:
- that:
+- name: Assert the gallery image created
+ ansible.builtin.assert:
+ that:
- output.changed
- name: Create or update gallery image - idempotent
@@ -187,8 +196,9 @@
description: Image Description
register: output
-- assert:
- that:
+- name: Assert the gallery image idempotent result
+ ansible.builtin.assert:
+ that:
- not output.changed
- name: Create or update gallery image - change description
@@ -206,8 +216,9 @@
description: Image Description XXXs
register: output
-- assert:
- that:
+- name: Assert the gallery image updated
+ ansible.builtin.assert:
+ that:
- output.changed
- name: Get a gallery image info.
@@ -217,8 +228,9 @@
name: myImage
register: output
-- assert:
- that:
+- name: Assert the gallery image facts
+ ansible.builtin.assert:
+ that:
- not output.changed
- output.images['id'] != None
- output.images['name'] != None
@@ -236,7 +248,7 @@
location: eastus
publishing_profile:
end_of_life_date: "2050-10-01t00:00:00+00:00"
- exclude_from_latest: yes
+ exclude_from_latest: true
replica_count: 3
storage_account_type: Standard_LRS
target_regions:
@@ -250,8 +262,9 @@
resource_group: "{{ resource_group }}"
register: output
-- assert:
- that:
+- name: Assert the gallery image version created
+ ansible.builtin.assert:
+ that:
- output.changed
- name: Create or update a simple gallery Image Version - idempotent
@@ -263,7 +276,7 @@
location: eastus
publishing_profile:
end_of_life_date: "2050-10-01t00:00:00+00:00"
- exclude_from_latest: yes
+ exclude_from_latest: true
replica_count: 3
storage_account_type: Standard_LRS
target_regions:
@@ -277,8 +290,9 @@
resource_group: "{{ resource_group }}"
register: output
-- assert:
- that:
+- name: Assert the gallery image version result
+ ansible.builtin.assert:
+ that:
- not output.changed
- name: Create or update a simple gallery Image Version - change end of life
@@ -290,7 +304,7 @@
location: eastus
publishing_profile:
end_of_life_date: "2051-10-01t00:00:00+00:00"
- exclude_from_latest: yes
+ exclude_from_latest: true
replica_count: 3
storage_account_type: Standard_LRS
target_regions:
@@ -304,8 +318,9 @@
resource_group: "{{ resource_group }}"
register: output
-- assert:
- that:
+- name: Assert the gallery image version updated
+ ansible.builtin.assert:
+ that:
- output.changed
- name: Get a simple gallery Image Version info.
@@ -316,8 +331,9 @@
name: 10.1.3
register: output
-- assert:
- that:
+- name: Assert the gallery image version facts
+ ansible.builtin.assert:
+ that:
- not output.changed
- output.versions['id'] != None
- output.versions['name'] != None
@@ -334,13 +350,15 @@
state: absent
register: output
-- assert:
- that:
+- name: Assert the gallery image version deleted
+ ansible.builtin.assert:
+ that:
- output.changed
-- name: pasue 2 minutes, wait for deletion complete
- pause:
+- name: Pasue 2 minutes, wait for deletion complete
+ ansible.builtin.pause:
minutes: 2
+ changed_when: true
- name: Delete gallery image
azure_rm_galleryimage:
@@ -350,13 +368,15 @@
state: absent
register: output
-- assert:
- that:
+- name: Assert the gallery image deleted
+ ansible.builtin.assert:
+ that:
- output.changed
-- name: pasue 2 minutes, wait for deletion complete
- pause:
+- name: Pasue 2 minutes, wait for deletion complete
+ ansible.builtin.pause:
minutes: 2
+ changed_when: true
- name: Delete gallery
azure_rm_gallery:
@@ -365,6 +385,7 @@
state: absent
register: output
-- assert:
- that:
+- name: Assert the gallery deleted
+ ansible.builtin.assert:
+ that:
- output.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_hdinsightcluster/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_hdinsightcluster/tasks/main.yml
index edb99c4c1..23b80aa4e 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_hdinsightcluster/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_hdinsightcluster/tasks/main.yml
@@ -1,14 +1,14 @@
- name: Prepare random number
- set_fact:
+ ansible.builtin.set_fact:
rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
- run_once: yes
+ run_once: true
- name: Create storage account
azure_rm_storageaccount:
- resource_group: "{{ resource_group }}"
- name: "storage{{ rpfx }}"
- account_type: Standard_LRS
- location: eastus2
+ resource_group: "{{ resource_group }}"
+ name: "storage{{ rpfx }}"
+ account_type: Standard_LRS
+ location: eastus2
- name: Sample for Azure REST API - StorageAccounts_ListKeys
azure_rm_resource:
@@ -22,7 +22,8 @@
- type: listkeys
register: storage_output
-- debug:
+- name: Print the storage account keys
+ ansible.builtin.debug:
var: storage_output
- name: Create instance of Cluster -- check mode
@@ -38,8 +39,8 @@
gateway_rest_username: http-user
gateway_rest_password: Password123!
storage_accounts:
- - name: storage{{ rpfx }}.blob.core.windows.net
- is_default: yes
+ - name: storage{{ rpfx }}.blob.core.windows.net
+ is_default: true
container: "cluster{{ rpfx }}"
key: "{{ storage_output['response']['keys'][0]['value'] }}"
compute_profile_roles:
@@ -61,10 +62,10 @@
linux_profile:
username: sshuser
password: Password123!
- check_mode: yes
+ check_mode: true
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -81,8 +82,8 @@
gateway_rest_username: http-user
gateway_rest_password: Password123!
storage_accounts:
- - name: storage{{ rpfx }}.blob.core.windows.net
- is_default: yes
+ - name: storage{{ rpfx }}.blob.core.windows.net
+ is_default: true
container: "cluster{{ rpfx }}"
key: "{{ storage_output['response']['keys'][0]['value'] }}"
compute_profile_roles:
@@ -107,7 +108,7 @@
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -124,8 +125,8 @@
gateway_rest_username: http-user
gateway_rest_password: Password123!
storage_accounts:
- - name: storage{{ rpfx }}.blob.core.windows.net
- is_default: yes
+ - name: storage{{ rpfx }}.blob.core.windows.net
+ is_default: true
container: "cluster{{ rpfx }}"
key: "{{ storage_output['response']['keys'][0]['value'] }}"
compute_profile_roles:
@@ -149,7 +150,7 @@
password: Password123!
register: output
- name: Assert the state has not changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed == false
@@ -166,8 +167,8 @@
gateway_rest_username: http-user
gateway_rest_password: Password123!
storage_accounts:
- - name: storage{{ rpfx }}.blob.core.windows.net
- is_default: yes
+ - name: storage{{ rpfx }}.blob.core.windows.net
+ is_default: true
container: "cluster{{ rpfx }}"
key: "{{ storage_output['response']['keys'][0]['value'] }}"
compute_profile_roles:
@@ -192,10 +193,11 @@
tags:
aaa: bbb
register: output
-- debug:
+- name: Print the cluster creating result
+ ansible.builtin.debug:
var: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -206,7 +208,7 @@
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.clusters[0]['id'] != None
@@ -225,10 +227,10 @@
resource_group: "{{ resource_group }}"
name: "cluster{{ rpfx }}"
state: absent
- check_mode: yes
+ check_mode: true
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -239,6 +241,6 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_hostgroup/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_hostgroup/tasks/main.yml
index 8b2d408eb..04808a62a 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_hostgroup/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_hostgroup/tasks/main.yml
@@ -1,5 +1,5 @@
- name: Create host group name
- set_fact:
+ ansible.builtin.set_fact:
group_name: "hostgroup{{ resource_group | hash('md5') | truncate(22, True, '') }}"
- name: Create a host group
@@ -14,7 +14,7 @@
register: results
- name: Assert that host group is created
- assert:
+ ansible.builtin.assert:
that: results.changed
- name: Create a host group again (Idempotent test)
@@ -29,7 +29,7 @@
register: results
- name: Assert that output is not changed
- assert:
+ ansible.builtin.assert:
that: not results.changed
- name: Update a host group
@@ -46,7 +46,7 @@
register: results
- name: Assert that host group is updated
- assert:
+ ansible.builtin.assert:
that: results.changed
- name: Get host group facts
@@ -55,7 +55,8 @@
name: "{{ group_name }}"
register: results
-- assert:
+- name: Assert the host group facts
+ ansible.builtin.assert:
that:
- not results.changed
- results.hostgroups[0].name == "{{ group_name }}"
@@ -72,7 +73,7 @@
register: results
- name: Assert that host group is deleted
- assert:
+ ansible.builtin.assert:
that: results.changed
- name: Delete host group again (Idempotent test)
@@ -83,5 +84,5 @@
register: results
- name: Asset that output is not changed
- assert:
+ ansible.builtin.assert:
that: not results.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_image/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_image/tasks/main.yml
index cbe9baa31..2fc543091 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_image/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_image/tasks/main.yml
@@ -1,115 +1,118 @@
- name: Create storage account name
- set_fact:
- vm_name: "vm{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}x"
- public_ip_name: "pip{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
- security_group_name: "sg{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
- empty_disk_name: "emptydisk{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
+ ansible.builtin.set_fact:
+ vm_name: "vm{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}x"
+ public_ip_name: "pip{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
+ security_group_name: "sg{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
+ empty_disk_name: "emptydisk{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
- name: Create virtual network
azure_rm_virtualnetwork:
- resource_group: "{{ resource_group }}"
- name: "{{ vm_name }}"
- address_prefixes: "10.10.0.0/16"
+ resource_group: "{{ resource_group }}"
+ name: "{{ vm_name }}"
+ address_prefixes: "10.10.0.0/16"
- name: Add subnet
azure_rm_subnet:
- resource_group: "{{ resource_group }}"
- name: "{{ vm_name }}"
- address_prefix: "10.10.0.0/24"
- virtual_network: "{{ vm_name }}"
+ resource_group: "{{ resource_group }}"
+ name: "{{ vm_name }}"
+ address_prefix: "10.10.0.0/24"
+ virtual_network: "{{ vm_name }}"
- name: Create public ip
azure_rm_publicipaddress:
- resource_group: "{{ resource_group }}"
- allocation_method: Static
- name: "{{ public_ip_name }}"
+ resource_group: "{{ resource_group }}"
+ allocation_method: Static
+ name: "{{ public_ip_name }}"
- name: Create security group
azure_rm_securitygroup:
- resource_group: "{{ resource_group }}"
- name: "{{ security_group_name }}"
+ resource_group: "{{ resource_group }}"
+ name: "{{ security_group_name }}"
- name: Create NIC
azure_rm_networkinterface:
- resource_group: "{{ resource_group }}"
- name: "{{ vm_name }}"
- virtual_network: "{{ vm_name }}"
- subnet: "{{ vm_name }}"
- public_ip_name: "{{ public_ip_name }}"
- security_group: "{{ security_group_name }}"
+ resource_group: "{{ resource_group }}"
+ name: "{{ vm_name }}"
+ virtual_network: "{{ vm_name }}"
+ subnet: "{{ vm_name }}"
+ public_ip_name: "{{ public_ip_name }}"
+ security_group: "{{ security_group_name }}"
- name: Create virtual machine
azure_rm_virtualmachine:
- resource_group: "{{ resource_group }}"
- name: "{{ vm_name }}"
- vm_size: Standard_B1ms
- managed_disk_type: Standard_LRS
- admin_username: adminuser
- ssh_password_enabled: false
- ssh_public_keys:
- - path: /home/adminuser/.ssh/authorized_keys
- key_data: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDfoYlIV4lTPZTv7hXaVwQQuqBgGs4yeNRX0SPo2+HQt9u4X7IGwrtXc0nEUm6LfaCikMH58bOL8f20NTGz285kxdFHZRcBXtqmnMz2rXwhK9gwq5h1khc+GzHtdcJXsGA4y0xuaNcidcg04jxAlN/06fwb/VYwwWTVbypNC0gpGEpWckCNm8vlDlA55sU5et0SZ+J0RKVvEaweUOeNbFZqckGPA384imfeYlADppK/7eAxqfBVadVvZG8IJk4yvATgaIENIFj2cXxqu2mQ/Bp5Wr45uApvJsFXmi+v/nkiOEV1QpLOnEwAZo6EfFS4CCQtsymxJCl1PxdJ5LD4ZOtP xiuxi.sun@qq.com"
- os_type: Linux
- network_interfaces: "{{ vm_name }}"
- image:
- offer: UbuntuServer
- publisher: Canonical
- sku: 16.04-LTS
- version: latest
+ resource_group: "{{ resource_group }}"
+ name: "{{ vm_name }}"
+ vm_size: Standard_B1ms
+ managed_disk_type: Standard_LRS
+ admin_username: adminuser
+ ssh_password_enabled: false
+ ssh_public_keys:
+ - path: /home/adminuser/.ssh/authorized_keys
+ key_data: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDfoYlIV4lTPZTv7hXaVwQQuqBgGs4yeNRX0SPo2+HQt9u4X7IGwrtXc0nEUm6LfaCikMH58bOL8f20NTGz285kxdFHZRcBXtqmnMz2rXwhK9gwq5h1khc+GzHtdcJXsGA4y0xuaNcidcg04jxAlN/06fwb/VYwwWTVbypNC0gpGEpWckCNm8vlDlA55sU5et0SZ+J0RKVvEaweUOeNbFZqckGPA384imfeYlADppK/7eAxqfBVadVvZG8IJk4yvATgaIENIFj2cXxqu2mQ/Bp5Wr45uApvJsFXmi+v/nkiOEV1QpLOnEwAZo6EfFS4CCQtsymxJCl1PxdJ5LD4ZOtP xiuxi.sun@qq.com"
+ os_type: Linux
+ network_interfaces: "{{ vm_name }}"
+ image:
+ offer: 0001-com-ubuntu-server-focal
+ publisher: Canonical
+ sku: 20_04-lts
+ version: latest
register: vm
- name: Create new empty managed disk
azure_rm_manageddisk:
- resource_group: "{{ resource_group }}"
- name: "{{ empty_disk_name }}"
- storage_account_type: "Standard_LRS"
- disk_size_gb: 1
+ resource_group: "{{ resource_group }}"
+ name: "{{ empty_disk_name }}"
+ storage_account_type: "Standard_LRS"
+ disk_size_gb: 1
register: emptydisk
- name: Create an image from VM (check mode)
azure_rm_image:
- resource_group: "{{ resource_group }}"
- source: "{{ vm.ansible_facts.azure_vm.properties.storageProfile.osDisk.managedDisk.id }}"
- name: testimage001
- os_type: Linux
- hyper_v_generation: V1
- data_disk_sources:
- - "{{ empty_disk_name }}"
- check_mode: yes
+ resource_group: "{{ resource_group }}"
+ source: "{{ vm.ansible_facts.azure_vm.storage_profile.os_disk.managed_disk.id }}"
+ name: testimage001
+ os_type: Linux
+ hyper_v_generation: V1
+ data_disk_sources:
+ - "{{ empty_disk_name }}"
+ check_mode: true
register: output
-- assert:
- that: output.changed
+- name: Assert the image check mode
+ ansible.builtin.assert:
+ that: output.changed
- name: Create an image from VM
azure_rm_image:
- resource_group: "{{ resource_group }}"
- source:
- name: "{{ vm_name }}"
- type: disks
- name: testimage001
- hyper_v_generation: V1
- os_type: Linux
+ resource_group: "{{ resource_group }}"
+ source:
+ name: "{{ vm_name }}"
+ type: disks
+ name: testimage001
+ hyper_v_generation: V1
+ os_type: Linux
register: output
-- assert:
- that:
- - output.changed
- - output.id
+- name: Assert the image created
+ ansible.builtin.assert:
+ that:
+ - output.changed
+ - output.id
- name: Create an image from VM (idempotent)
azure_rm_image:
- resource_group: "{{ resource_group }}"
- source: "{{ vm.ansible_facts.azure_vm.properties.storageProfile.osDisk.managedDisk.id }}"
- name: testimage001
- hyper_v_generation: V1
- os_type: Linux
+ resource_group: "{{ resource_group }}"
+ source: "{{ vm.ansible_facts.azure_vm.storage_profile.os_disk.managed_disk.id }}"
+ name: testimage001
+ hyper_v_generation: V1
+ os_type: Linux
register: output
-- assert:
- that:
- - not output.changed
- - output.id
+- name: Assert the image created
+ ansible.builtin.assert:
+ that:
+ - not output.changed
+ - output.id
- name: Gather information about image created
azure_rm_image_info:
@@ -117,62 +120,66 @@
name: testimage001
register: output
-- assert:
- that:
- - output.images != []
- - output.images[0].hyper_v_generation == 'V1'
+- name: Assert the image facts
+ ansible.builtin.assert:
+ that:
+ - output.images != []
+ - output.images[0].hyper_v_generation == 'V1'
- name: Delete image (check mode)
azure_rm_image:
- resource_group: "{{ resource_group }}"
- name: testimage001
- state: absent
+ resource_group: "{{ resource_group }}"
+ name: testimage001
+ state: absent
register: output
- check_mode: yes
+ check_mode: true
-- assert:
+- name: Assert the image check mode
+ ansible.builtin.assert:
that:
- output.changed
- name: Delete image
azure_rm_image:
- resource_group: "{{ resource_group }}"
- name: testimage001
- state: absent
+ resource_group: "{{ resource_group }}"
+ name: testimage001
+ state: absent
register: output
-- assert:
+- name: Assert the imaged deleted
+ ansible.builtin.assert:
that:
- output.changed
- name: Delete image (idempotent)
azure_rm_image:
- resource_group: "{{ resource_group }}"
- name: testimage001
- state: absent
+ resource_group: "{{ resource_group }}"
+ name: testimage001
+ state: absent
register: output
-- assert:
+- name: Assert the image has deleted
+ ansible.builtin.assert:
that:
- not output.changed
- name: Delete empty disk
azure_rm_manageddisk:
- resource_group: "{{ resource_group }}"
- name: "{{ empty_disk_name }}"
- state: absent
+ resource_group: "{{ resource_group }}"
+ name: "{{ empty_disk_name }}"
+ state: absent
- name: Delete VM
azure_rm_virtualmachine:
- resource_group: "{{ resource_group }}"
- name: "{{ vm_name }}"
- state: absent
- vm_size: Standard_A0
+ resource_group: "{{ resource_group }}"
+ name: "{{ vm_name }}"
+ state: absent
+ vm_size: Standard_A0
register: output
- name: Delete public ip
azure_rm_publicipaddress:
- resource_group: "{{ resource_group }}"
- allocation_method: Static
- name: "{{ public_ip_name }}"
- state: absent
+ resource_group: "{{ resource_group }}"
+ allocation_method: Static
+ name: "{{ public_ip_name }}"
+ state: absent
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_iothub/aliases b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_iothub/aliases
index aa77c071a..cbb31e489 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_iothub/aliases
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_iothub/aliases
@@ -1,3 +1,4 @@
cloud/azure
shippable/azure/group2
destructive
+disabled
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_iothub/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_iothub/tasks/main.yml
index 6cb319050..2b2e33695 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_iothub/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_iothub/tasks/main.yml
@@ -1,178 +1,182 @@
-- set_fact:
+- name: Set variables
+ ansible.builtin.set_fact:
rpfx: "{{ resource_group | hash('md5') | truncate(8, True, '') }}"
- name: Create IoT Hub (check mode)
azure_rm_iothub:
- name: "hub{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- ip_filters:
- - name: filter1
- action: reject
- ip_mask: 40.60.80.10
- check_mode: yes
+ name: "hub{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ ip_filters:
+ - name: filter1
+ action: reject
+ ip_mask: 40.60.80.10
+ check_mode: true
register: iothub
-- assert:
+- name: Assert the check mode result
+ ansible.builtin.assert:
that:
- - iothub.changed
+ - iothub.changed
- name: Query IoT Hub
azure_rm_iothub_info:
- name: "hub{{ rpfx }}"
- resource_group: "{{ resource_group }}"
+ name: "hub{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
register: iothub
- ignore_errors: yes
+ ignore_errors: true
- name: Create IoT Hub
azure_rm_iothub:
- name: "hub{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- ip_filters:
- - name: filter1
- action: reject
- ip_mask: 40.60.80.10
+ name: "hub{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ ip_filters:
+ - name: filter1
+ action: reject
+ ip_mask: 40.60.80.10
register: iothub
-- assert:
+- name: Assert tht iot hub created
+ ansible.builtin.assert:
that:
- - iothub.changed
+ - iothub.changed
- name: Create IoT Hub (idempontent)
azure_rm_iothub:
- name: "hub{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- ip_filters:
- - name: filter1
- action: reject
- ip_mask: 40.60.80.10
+ name: "hub{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ ip_filters:
+ - name: filter1
+ action: reject
+ ip_mask: 40.60.80.10
register: iothub
-- assert:
+- name: Assert the iot hub created
+ ansible.builtin.assert:
that:
- - not iothub.changed
+ - not iothub.changed
- name: Query IoT Hub
azure_rm_iothub_info:
- name: "hub{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- list_keys: yes
+ name: "hub{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ list_keys: true
register: iothub
-- assert:
+- name: Assert the iot hub facts
+ ansible.builtin.assert:
that:
- - iothub.iothubs | length == 1
+ - iothub.iothubs | length == 1
-- set_fact:
+- name: Set variables
+ ansible.builtin.set_fact:
registry_write_name: "{{ item.key_name }}"
registry_write_key: "{{ item.primary_key }}"
+ secondary_key: "{{ item.secondary_key }}"
with_items: "{{ iothub.iothubs[0]['keys'] }}"
when: item.rights == 'RegistryWrite, ServiceConnect, DeviceConnect'
- name: Create devices
azure_rm_iotdevice:
- hub: "hub{{ rpfx }}"
- hub_policy_name: "{{ registry_write_name }}"
- hub_policy_key: "{{ registry_write_key }}"
- name: "mydevice{{ item }}"
- twin_tags:
- location:
- country: US
- city: Redmond
- sensor: humidity
+ hub: "hub{{ rpfx }}"
+ hub_policy_name: "{{ registry_write_name }}"
+ hub_policy_key: "{{ registry_write_key }}"
+ name: "mydevice{{ item }}"
+ primary_key: "{{ registry_write_key }}"
+ secondary_key: "{{ secondary_key }}"
+ twin_tags:
+ location:
+ country: US
+ city: Redmond
+ sensor: humidity
with_items:
- 1
- 2
- name: Query devices
azure_rm_iotdevice_info:
- hub: "hub{{ rpfx }}"
- hub_policy_name: "{{ registry_write_name }}"
- hub_policy_key: "{{ registry_write_key }}"
+ hub: "hub{{ rpfx }}"
+ hub_policy_name: "{{ registry_write_name }}"
+ hub_policy_key: "{{ registry_write_key }}"
register: devices
-- assert:
- that:
- - devices.iot_devices | length == 2
+- name: Assert the iot devices facts
+ ansible.builtin.assert:
+ that:
+ - devices.iot_devices | length == 2
-- name: Query devices
+- name: Query devices by name
azure_rm_iotdevice_info:
- hub: "hub{{ rpfx }}"
- name: "mydevice1"
- hub_policy_name: "{{ registry_write_name }}"
- hub_policy_key: "{{ registry_write_key }}"
+ hub: "hub{{ rpfx }}"
+ name: "mydevice1"
+ hub_policy_name: "{{ registry_write_name }}"
+ hub_policy_key: "{{ registry_write_key }}"
register: devices
-- assert:
- that:
- - devices.iot_devices | length == 1
- - devices.iot_devices[0].deviceId == 'mydevice1'
+- name: Assert the iot device facts
+ ansible.builtin.assert:
+ that:
+ - devices.iot_devices | length == 1
+ - devices.iot_devices[0].deviceId == 'mydevice1'
- name: Pause for 5 mimutes
- shell: sleep 300
-
-- name: Query devices twin
- azure_rm_iotdevice_info:
- hub: "hub{{ rpfx }}"
- query: "SELECT * FROM devices WHERE tags.location.country = 'US'"
- hub_policy_name: "{{ registry_write_name }}"
- hub_policy_key: "{{ registry_write_key }}"
- register: devices
-
-- assert:
- that:
- - devices.iot_devices | length == 2
+ ansible.builtin.command: sleep 300
+ changed_when: true
- name: Update devices
azure_rm_iotdevice:
- hub: "hub{{ rpfx }}"
- hub_policy_name: "{{ registry_write_name }}"
- hub_policy_key: "{{ registry_write_key }}"
- name: "mydevice{{ item }}"
- edge_enabled: yes
- twin_tags:
- location:
- country: China
- city: Shanghai
- sensor: humidity
+ hub: "hub{{ rpfx }}"
+ hub_policy_name: "{{ registry_write_name }}"
+ hub_policy_key: "{{ registry_write_key }}"
+ name: "mydevice{{ item }}"
+ edge_enabled: true
+ primary_key: "{{ registry_write_key }}"
+ secondary_key: "{{ secondary_key }}"
+ twin_tags:
+ location:
+ country: China
+ city: Shanghai
+ sensor: humidity
with_items:
- 1
- - 3
+ - 2
- name: Pause for 5 mimutes
- shell: sleep 300
+ changed_when: true
+ ansible.builtin.command: sleep 300
- name: Query devices twin
azure_rm_iotdevice_info:
- hub: "hub{{ rpfx }}"
- query: "SELECT * FROM devices WHERE tags.location.country = 'US'"
- hub_policy_name: "{{ registry_write_name }}"
- hub_policy_key: "{{ registry_write_key }}"
+ hub: "hub{{ rpfx }}"
+ hub_policy_name: "{{ registry_write_name }}"
+ hub_policy_key: "{{ registry_write_key }}"
register: devices
-- assert:
- that:
- - devices.iot_devices | length == 1
- - devices.iot_devices[0].deviceId == 'mydevice2'
+- name: Assert the iot devices facts
+ ansible.builtin.assert:
+ that:
+ - devices.iot_devices | length == 2
- name: Delete IoT Hub (check mode)
azure_rm_iothub:
- name: "hub{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- state: absent
- check_mode: yes
+ name: "hub{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ state: absent
+ check_mode: true
register: iothub
-- assert:
+- name: Assert iot hub check mode result
+ ansible.builtin.assert:
that:
- - iothub.changed
+ - iothub.changed
- name: Delete IoT Hub
azure_rm_iothub:
- name: "hub{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- state: absent
+ name: "hub{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ state: absent
register: iothub
-- assert:
+- name: Assert the iot hub deleted
+ ansible.builtin.assert:
that:
- - iothub.changed
+ - iothub.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_ipgroup/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_ipgroup/tasks/main.yml
index 8656c7110..604ecce32 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_ipgroup/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_ipgroup/tasks/main.yml
@@ -1,5 +1,5 @@
- name: Create IP group name
- set_fact:
+ ansible.builtin.set_fact:
group_name: "ipgroup{{ resource_group | hash('md5') | truncate(22, True, '') }}"
- name: Create IP group (check mode)
@@ -14,7 +14,7 @@
tags:
key1: "value1"
state: present
- check_mode: yes
+ check_mode: true
- name: Create IP group
azure_rm_ipgroup:
@@ -31,7 +31,7 @@
register: results
- name: Assert that IP group is created
- assert:
+ ansible.builtin.assert:
that: results.changed
- name: Create same IP group again (Idempotent test)
@@ -49,7 +49,7 @@
register: results
- name: Assert that output is not changed
- assert:
+ ansible.builtin.assert:
that: not results.changed
- name: Update IP group
@@ -64,7 +64,7 @@
register: results
- name: Assert that IP group is updated
- assert:
+ ansible.builtin.assert:
that: results.changed
- name: Get IP group facts
@@ -73,7 +73,8 @@
name: "{{ group_name }}"
register: results
-- assert:
+- name: Assert the ip group facts
+ ansible.builtin.assert:
that:
- not results.changed
- results.ipgroups[0].id != None
@@ -91,7 +92,7 @@
register: results
- name: Assert that IP group is deleted
- assert:
+ ansible.builtin.assert:
that: results.changed
- name: Delete IP group again (Idempotent test)
@@ -102,5 +103,5 @@
register: results
- name: Asset that output is not changed
- assert:
+ ansible.builtin.assert:
that: not results.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_keyvault/lookup_plugins/azure_service_principal_attribute.py b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_keyvault/lookup_plugins/azure_service_principal_attribute.py
index 1b7d0318f..c6f488f13 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_keyvault/lookup_plugins/azure_service_principal_attribute.py
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_keyvault/lookup_plugins/azure_service_principal_attribute.py
@@ -45,15 +45,13 @@ _raw:
"""
from ansible.errors import AnsibleError
-from ansible.plugins import AnsiblePlugin
from ansible.plugins.lookup import LookupBase
from ansible.module_utils._text import to_native
try:
from azure.common.credentials import ServicePrincipalCredentials
from azure.graphrbac import GraphRbacManagementClient
- from msrestazure import azure_cloud
- from msrestazure.azure_exceptions import CloudError
+ from azure.cli.core import cloud as azure_cloud
except ImportError:
raise AnsibleError(
"The lookup azure_service_principal_attribute requires azure.graphrbac, msrest")
@@ -89,6 +87,6 @@ class LookupModule(LookupBase):
sp = response[0]
return sp.object_id.split(',')
- except CloudError as ex:
+ except Exception as ex:
raise AnsibleError("Failed to get service principal object id: %s" % to_native(ex))
return False
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_keyvault/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_keyvault/tasks/main.yml
index 2cd690fbc..07f324d22 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_keyvault/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_keyvault/tasks/main.yml
@@ -1,11 +1,11 @@
- name: Prepare random number
- set_fact:
+ ansible.builtin.set_fact:
rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
tenant_id: "{{ azure_tenant }}"
- run_once: yes
+ run_once: true
-- name: lookup service principal object id
- set_fact:
+- name: Lookup service principal object id
+ ansible.builtin.set_fact:
object_id: "{{ lookup('azure_service_principal_attribute',
azure_client_id=azure_client_id,
azure_secret=azure_secret,
@@ -16,7 +16,7 @@
azure_rm_keyvault:
resource_group: "{{ resource_group }}"
vault_name: "vault{{ rpfx }}"
- enabled_for_deployment: yes
+ enabled_for_deployment: true
vault_tenant: "{{ tenant_id }}"
soft_delete_retention_in_days: 7
sku:
@@ -43,10 +43,10 @@
- recover
- backup
- restore
- check_mode: yes
+ check_mode: true
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -54,7 +54,7 @@
azure_rm_keyvault:
resource_group: "{{ resource_group }}"
vault_name: "vault{{ rpfx }}"
- enabled_for_deployment: yes
+ enabled_for_deployment: true
vault_tenant: "{{ tenant_id }}"
soft_delete_retention_in_days: 7
sku:
@@ -74,7 +74,7 @@
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -82,7 +82,7 @@
azure_rm_keyvault:
resource_group: "{{ resource_group }}"
vault_name: "vault{{ rpfx }}"
- enabled_for_deployment: yes
+ enabled_for_deployment: true
vault_tenant: "{{ tenant_id }}"
soft_delete_retention_in_days: 7
sku:
@@ -101,7 +101,7 @@
- restore
register: output
- name: Assert the state has not changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed == false
@@ -109,7 +109,7 @@
azure_rm_keyvault:
resource_group: "{{ resource_group }}"
vault_name: "vault{{ rpfx }}"
- enabled_for_deployment: yes
+ enabled_for_deployment: true
vault_tenant: "{{ tenant_id }}"
soft_delete_retention_in_days: 7
sku:
@@ -140,7 +140,7 @@
aaa: bbb
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed == true
@@ -151,7 +151,7 @@
register: facts
- name: Assert the facts are properly set
- assert:
+ ansible.builtin.assert:
that:
- facts['keyvaults'] | length == 1
- facts['keyvaults'][0]['vault_uri'] != None
@@ -165,19 +165,22 @@
# azure_rm_keyvaultkey tests
#
-- name: create a keyvault key
+- name: Create a keyvault key
block:
- - azure_rm_keyvaultkey:
+ - name: Create a keyvault key
+ azure_rm_keyvaultkey:
keyvault_uri: https://vault{{ rpfx }}.vault.azure.net
key_name: testkey
tags:
testing: test
delete: on-exit
register: output
- - assert:
+ - name: Assert the keyvault key created
+ ansible.builtin.assert:
that: output.changed
rescue:
- - azure_rm_keyvaultkey:
+ - name: Delete the keyvault key
+ azure_rm_keyvaultkey:
keyvault_uri: https://vault{{ rpfx }}.vault.azure.net
state: absent
key_name: testkey
@@ -189,7 +192,7 @@
register: facts
- name: Assert key facts
- assert:
+ ansible.builtin.assert:
that:
- facts['keys'] | length == 1
- facts['keys'][0]['kid']
@@ -197,22 +200,24 @@
- facts['keys'][0]['type']
- facts['keys'][0]['version']
-- name: delete a kevyault key
+- name: Delete a kevyault key
azure_rm_keyvaultkey:
keyvault_uri: https://vault{{ rpfx }}.vault.azure.net
state: absent
key_name: testkey
register: output
-- assert:
+- name: Assert the keyvault deleted
+ ansible.builtin.assert:
that: output.changed
#
# azure_rm_keyvaultsecret tests
#
-- name: create a keyvault secret
+- name: Create a keyvault secret
block:
- - azure_rm_keyvaultsecret:
+ - name: Create a keyvault secret
+ azure_rm_keyvaultsecret:
keyvault_uri: https://vault{{ rpfx }}.vault.azure.net
secret_name: testsecret
secret_value: 'mysecret'
@@ -220,22 +225,25 @@
testing: test
delete: on-exit
register: output
- - assert:
+ - name: Assert the keyvault secret created
+ ansible.builtin.assert:
that: output.changed
rescue:
- - azure_rm_keyvaultsecret:
+ - name: Delete the keyvault secret
+ azure_rm_keyvaultsecret:
keyvault_uri: https://vault{{ rpfx }}.vault.azure.net
state: absent
secret_name: testsecret
-- name: delete a keyvault secret
+- name: Delete a keyvault secret
azure_rm_keyvaultsecret:
keyvault_uri: https://vault{{ rpfx }}.vault.azure.net
state: absent
secret_name: testsecret
register: output
-- assert:
+- name: Assert the keyvault secret deleted
+ ansible.builtin.assert:
that: output.changed
#
@@ -247,10 +255,10 @@
resource_group: "{{ resource_group }}"
vault_name: "vault{{ rpfx }}"
state: absent
- check_mode: yes
+ check_mode: true
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -261,7 +269,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -272,6 +280,6 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed == false
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_keyvaultkey/lookup_plugins/azure_service_principal_attribute.py b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_keyvaultkey/lookup_plugins/azure_service_principal_attribute.py
index 1b7d0318f..c6f488f13 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_keyvaultkey/lookup_plugins/azure_service_principal_attribute.py
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_keyvaultkey/lookup_plugins/azure_service_principal_attribute.py
@@ -45,15 +45,13 @@ _raw:
"""
from ansible.errors import AnsibleError
-from ansible.plugins import AnsiblePlugin
from ansible.plugins.lookup import LookupBase
from ansible.module_utils._text import to_native
try:
from azure.common.credentials import ServicePrincipalCredentials
from azure.graphrbac import GraphRbacManagementClient
- from msrestazure import azure_cloud
- from msrestazure.azure_exceptions import CloudError
+ from azure.cli.core import cloud as azure_cloud
except ImportError:
raise AnsibleError(
"The lookup azure_service_principal_attribute requires azure.graphrbac, msrest")
@@ -89,6 +87,6 @@ class LookupModule(LookupBase):
sp = response[0]
return sp.object_id.split(',')
- except CloudError as ex:
+ except Exception as ex:
raise AnsibleError("Failed to get service principal object id: %s" % to_native(ex))
return False
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_keyvaultkey/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_keyvaultkey/tasks/main.yml
index 1d09f9e6d..869cb7257 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_keyvaultkey/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_keyvaultkey/tasks/main.yml
@@ -1,11 +1,11 @@
- name: Prepare random number
- set_fact:
+ ansible.builtin.set_fact:
rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
tenant_id: "{{ azure_tenant }}"
- run_once: yes
+ run_once: true
-- name: lookup service principal object id
- set_fact:
+- name: Lookup service principal object id
+ ansible.builtin.set_fact:
object_id: "{{ lookup('azure_service_principal_attribute',
azure_client_id=azure_client_id,
azure_secret=azure_secret,
@@ -16,7 +16,7 @@
azure_rm_keyvault:
resource_group: "{{ resource_group }}"
vault_name: "vault{{ rpfx }}"
- enabled_for_deployment: yes
+ enabled_for_deployment: true
vault_tenant: "{{ tenant_id }}"
sku:
name: standard
@@ -50,33 +50,37 @@
- restore
register: output
-- name: create a kevyault key
+- name: Create a kevyault key
block:
- - azure_rm_keyvaultkey:
+ - name: Create a keyvault key
+ azure_rm_keyvaultkey:
keyvault_uri: https://vault{{ rpfx }}.vault.azure.net
key_name: testkey
tags:
testing: test
delete: on-exit
register: output
- - assert:
+ - name: Assert the keyvault key created
+ ansible.builtin.assert:
that: output.changed
rescue:
- - azure_rm_keyvaultkey:
+ - name: Delete the keyvault key
+ azure_rm_keyvaultkey:
keyvault_uri: https://vault{{ rpfx }}.vault.azure.net
state: absent
key_name: testkey
-- name: delete a kevyault key
+- name: Delete a kevyault key
azure_rm_keyvaultkey:
keyvault_uri: https://vault{{ rpfx }}.vault.azure.net
state: absent
key_name: testkey
register: output
-- name: create a kevyault key of type EC
+- name: Create a kevyault key of type EC
block:
- - azure_rm_keyvaultkey:
+ - name: Create a keyvault key of type EC
+ azure_rm_keyvaultkey:
keyvault_uri: https://vault{{ rpfx }}.vault.azure.net
key_name: testkeyEC
key_type: EC
@@ -84,24 +88,27 @@
testing: test
delete: on-exit
register: output
- - assert:
+ - name: Assert the keyvault key created
+ ansible.builtin.assert:
that: output.changed
rescue:
- - azure_rm_keyvaultkey:
+ - name: Delete the keyvault key
+ azure_rm_keyvaultkey:
keyvault_uri: https://vault{{ rpfx }}.vault.azure.net
state: absent
key_name: testkeyEC
-- name: delete a kevyault key of type EC
+- name: Delete a kevyault key of type EC
azure_rm_keyvaultkey:
keyvault_uri: https://vault{{ rpfx }}.vault.azure.net
state: absent
key_name: testkeyEC
register: output
-- name: create a kevyault key of size 4096
+- name: Create a kevyault key of size 4096
block:
- - azure_rm_keyvaultkey:
+ - name: Create a keyvault key of size 4096
+ azure_rm_keyvaultkey:
keyvault_uri: https://vault{{ rpfx }}.vault.azure.net
key_name: testkey4096
key_size: 4096
@@ -109,24 +116,27 @@
testing: test
delete: on-exit
register: output
- - assert:
+ - name: Assert the keyvault key created
+ ansible.builtin.assert:
that: output.changed
rescue:
- - azure_rm_keyvaultkey:
+ - name: Delete the keyvault key
+ azure_rm_keyvaultkey:
keyvault_uri: https://vault{{ rpfx }}.vault.azure.net
state: absent
key_name: testkey4096
-- name: delete a kevyault key of size 4096
+- name: Delete a kevyault key of size 4096
azure_rm_keyvaultkey:
keyvault_uri: https://vault{{ rpfx }}.vault.azure.net
state: absent
key_name: testkey4096
register: output
-- name: create a kevyault key with P-521 curve
+- name: Create a kevyault key with P-521 curve
block:
- - azure_rm_keyvaultkey:
+ - name: Create a keyvault key with P-521
+ azure_rm_keyvaultkey:
keyvault_uri: https://vault{{ rpfx }}.vault.azure.net
key_name: testkeycurve
curve: P-521
@@ -134,24 +144,27 @@
testing: test
delete: on-exit
register: output
- - assert:
+ - name: Assert the keyvault key created
+ ansible.builtin.assert:
that: output.changed
rescue:
- - azure_rm_keyvaultkey:
+ - name: Delete the keyvault key
+ azure_rm_keyvaultkey:
keyvault_uri: https://vault{{ rpfx }}.vault.azure.net
state: absent
key_name: testkeycurve
-- name: delete a kevyault key with P-521 curve
+- name: Delete a kevyault key with P-521 curve
azure_rm_keyvaultkey:
keyvault_uri: https://vault{{ rpfx }}.vault.azure.net
state: absent
key_name: testkeycurve
register: output
-- name: create a kevyault key with attributes
+- name: Create a kevyault key with attributes
block:
- - azure_rm_keyvaultkey:
+ - name: Create a keyvault key with attributes
+ azure_rm_keyvaultkey:
keyvault_uri: https://vault{{ rpfx }}.vault.azure.net
key_name: testkeyattribute
key_attributes:
@@ -161,22 +174,25 @@
testing: test
delete: on-exit
register: output
- - assert:
+ - name: Assert the keyvault key created
+ ansible.builtin.assert:
that: output.changed
rescue:
- - azure_rm_keyvaultkey:
+ - name: Delete the keyvault ke
+ azure_rm_keyvaultkey:
keyvault_uri: https://vault{{ rpfx }}.vault.azure.net
state: absent
key_name: testkeyattributes
-- name: delete a kevyault key with attributes
+- name: Delete a kevyault key with attributes
azure_rm_keyvaultkey:
keyvault_uri: https://vault{{ rpfx }}.vault.azure.net
state: absent
key_name: testkeyattribute
register: output
-- assert:
+- name: Assert the keyvault key deleted
+ ansible.builtin.assert:
that: output.changed
- name: Delete instance of Key Vault
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_keyvaultsecret/lookup_plugins/azure_service_principal_attribute.py b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_keyvaultsecret/lookup_plugins/azure_service_principal_attribute.py
index 1b7d0318f..c6f488f13 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_keyvaultsecret/lookup_plugins/azure_service_principal_attribute.py
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_keyvaultsecret/lookup_plugins/azure_service_principal_attribute.py
@@ -45,15 +45,13 @@ _raw:
"""
from ansible.errors import AnsibleError
-from ansible.plugins import AnsiblePlugin
from ansible.plugins.lookup import LookupBase
from ansible.module_utils._text import to_native
try:
from azure.common.credentials import ServicePrincipalCredentials
from azure.graphrbac import GraphRbacManagementClient
- from msrestazure import azure_cloud
- from msrestazure.azure_exceptions import CloudError
+ from azure.cli.core import cloud as azure_cloud
except ImportError:
raise AnsibleError(
"The lookup azure_service_principal_attribute requires azure.graphrbac, msrest")
@@ -89,6 +87,6 @@ class LookupModule(LookupBase):
sp = response[0]
return sp.object_id.split(',')
- except CloudError as ex:
+ except Exception as ex:
raise AnsibleError("Failed to get service principal object id: %s" % to_native(ex))
return False
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_keyvaultsecret/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_keyvaultsecret/tasks/main.yml
index 0a4226a0e..d91641d80 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_keyvaultsecret/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_keyvaultsecret/tasks/main.yml
@@ -1,11 +1,11 @@
- name: Prepare random number
- set_fact:
+ ansible.builtin.set_fact:
rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
tenant_id: "{{ azure_tenant }}"
- run_once: yes
+ run_once: true
-- name: lookup service principal object id
- set_fact:
+- name: Lookup service principal object id
+ ansible.builtin.set_fact:
object_id: "{{ lookup('azure_service_principal_attribute',
azure_client_id=azure_client_id,
azure_secret=azure_secret,
@@ -16,7 +16,7 @@
azure_rm_keyvault:
resource_group: "{{ resource_group }}"
vault_name: "vault{{ rpfx }}"
- enabled_for_deployment: yes
+ enabled_for_deployment: true
vault_tenant: "{{ tenant_id }}"
sku:
name: standard
@@ -44,23 +44,26 @@
- restore
register: output
-- name: create a kevyault secret
+- name: Create a kevyault secret
block:
- - azure_rm_keyvaultsecret:
+ - name: Create a kevyault secret
+ azure_rm_keyvaultsecret:
keyvault_uri: https://vault{{ rpfx }}.vault.azure.net
secret_name: testsecret
secret_value: 'mysecret'
content_type: 'Content Type Secret'
- secret_valid_from: 2000-01-02T010203Z
- secret_expiry: 2030-03-04T040506Z
+ secret_valid_from: 2000-01-02T010203Z
+ secret_expiry: 2030-03-04T040506Z
tags:
testing: test
delete: on-exit
register: output
- - assert:
+ - name: Assert the keyvault secret created
+ ansible.builtin.assert:
that: output.changed
rescue:
- - azure_rm_keyvaultsecret:
+ - name: Delete the keyvault secret
+ azure_rm_keyvaultsecret:
keyvault_uri: https://vault{{ rpfx }}.vault.azure.net
state: absent
secret_name: testsecret
@@ -72,7 +75,7 @@
register: facts
- name: Assert secret facts
- assert:
+ ansible.builtin.assert:
that:
- facts['secrets'] | length == 1
- facts['secrets'][0]['sid']
@@ -85,12 +88,13 @@
- facts['secrets'][0]['attributes']['expires'] == "2030-03-04T04:05:06+00:00"
- facts['secrets'][0]['attributes']['not_before'] == "2000-01-02T01:02:03+00:00"
-- name: delete a kevyault secret
+- name: Delete a kevyault secret
azure_rm_keyvaultsecret:
keyvault_uri: https://vault{{ rpfx }}.vault.azure.net
state: absent
secret_name: testsecret
register: output
-- assert:
+- name: Assert the keyvault secret deleted
+ ansible.builtin.assert:
that: output.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_loadbalancer/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_loadbalancer/tasks/main.yml
index 2c1eb736e..913e618d0 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_loadbalancer/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_loadbalancer/tasks/main.yml
@@ -1,5 +1,5 @@
- name: Prepare random number
- set_fact:
+ ansible.builtin.set_fact:
pipaname: "pipa{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
pipbname: "pipb{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
lbvnname: "lbvn{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
@@ -8,84 +8,84 @@
lbname_c1: "lbc1-{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
lbname_c2: "lbc2-{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
lbname_d: "lbd{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
- run_once: yes
+ run_once: true
-- name: create public ip
+- name: Create public ip
azure_rm_publicipaddress:
name: "{{ pipbname }}"
sku: Standard
allocation_method: Static
resource_group: '{{ resource_group }}'
-- name: create public ip
+- name: Create public ip
azure_rm_publicipaddress:
name: "{{ pipaname }}"
resource_group: '{{ resource_group }}'
-- name: clear load balancer
+- name: Clear load balancer
azure_rm_loadbalancer:
resource_group: '{{ resource_group }}'
name: "{{ lbname_a }}"
state: absent
-- name: create load balancer -- check mode
+- name: Create load balancer -- check mode
azure_rm_loadbalancer:
resource_group: '{{ resource_group }}'
name: "{{ lbname_a }}"
public_ip: "{{ pipaname }}"
- check_mode: yes
+ check_mode: true
register: output
-- name: assert load balancer created
- assert:
+- name: Assert load balancer created
+ ansible.builtin.assert:
that: output.changed
-- name: create load balancer
+- name: Create load balancer
azure_rm_loadbalancer:
resource_group: '{{ resource_group }}'
name: "{{ lbname_a }}"
public_ip: "{{ pipaname }}"
register: output
-- name: assert load balancer created
- assert:
+- name: Assert load balancer created
+ ansible.builtin.assert:
that: output.changed
-- name: create load balancer -- idempotent
+- name: Create load balancer -- idempotent
azure_rm_loadbalancer:
resource_group: '{{ resource_group }}'
name: "{{ lbname_a }}"
public_ip: "{{ pipaname }}"
register: output
-- name: assert no change
- assert:
+- name: Assert no change
+ ansible.builtin.assert:
that:
- not output.changed
-- name: delete load balancer
+- name: Delete load balancer
azure_rm_loadbalancer:
resource_group: '{{ resource_group }}'
name: "{{ lbname_a }}"
state: absent
register: output
-- name: assert load balancer deleted
- assert:
+- name: Assert load balancer deleted
+ ansible.builtin.assert:
that: output.changed
-- name: delete load balancer (idempotent)
+- name: Delete load balancer (idempotent)
azure_rm_loadbalancer:
resource_group: '{{ resource_group }}'
name: "{{ lbname_a }}"
state: absent
register: output
-- name: assert load balancer deleted (idempotent)
- assert:
+- name: Assert load balancer deleted (idempotent)
+ ansible.builtin.assert:
that: not output.changed
-- name: create another load balancer with more options
+- name: Create another load balancer with more options
azure_rm_loadbalancer:
resource_group: '{{ resource_group }}'
name: "{{ lbname_b }}"
@@ -106,13 +106,13 @@
natpool_protocol: Tcp
register: output
-- name: assert complex load balancer created
- assert:
+- name: Assert complex load balancer created
+ ansible.builtin.assert:
that:
- - output.changed
- - output.state.sku.name == 'Standard'
+ - output.changed
+ - output.state.sku.name == 'Standard'
-- name: create load balancer again to check idempotency
+- name: Create load balancer again to check idempotency
azure_rm_loadbalancer:
resource_group: '{{ resource_group }}'
name: "{{ lbname_b }}"
@@ -133,12 +133,12 @@
natpool_protocol: Tcp
register: output
-- name: assert that output has not changed
- assert:
+- name: Assert that output has not changed
+ ansible.builtin.assert:
that:
- - not output.changed
+ - not output.changed
-- name: create load balancer again to check idempotency - change something
+- name: Create load balancer again to check idempotency - change something
azure_rm_loadbalancer:
resource_group: '{{ resource_group }}'
name: "{{ lbname_b }}"
@@ -159,18 +159,18 @@
natpool_protocol: Tcp
register: output
-- name: assert that output has changed
- assert:
+- name: Assert that output has changed
+ ansible.builtin.assert:
that:
- - output.changed
+ - output.changed
-- name: delete load balancer
+- name: Delete load balancer
azure_rm_loadbalancer:
resource_group: '{{ resource_group }}'
name: "{{ lbname_b }}"
state: absent
-- name: create load balancer with multiple parameters
+- name: Create load balancer with multiple parameters
azure_rm_loadbalancer:
resource_group: '{{ resource_group }}'
name: "{{ lbname_c1 }}"
@@ -196,21 +196,21 @@
frontend_port: 80
backend_port: 80
probe: prob0
- disable_outbound_snat: True
+ disable_outbound_snat: true
register: output
-- name: assert complex load balancer created
- assert:
+- name: Assert complex load balancer created
+ ansible.builtin.assert:
that:
- output.changed
-- name: delete load balancer
+- name: Delete load balancer
azure_rm_loadbalancer:
resource_group: '{{ resource_group }}'
name: "{{ lbname_c1 }}"
state: absent
-- name: create load balancer with multiple parameters
+- name: Create load balancer with multiple parameters
azure_rm_loadbalancer:
resource_group: '{{ resource_group }}'
name: "{{ lbname_c2 }}"
@@ -229,7 +229,7 @@
frontend_port: 80
backend_port: 80
probe: prob0
- disable_outbound_snat: True
+ disable_outbound_snat: true
inbound_nat_rules:
- name: inboundnatrule0
backend_port: 8080
@@ -238,11 +238,11 @@
frontend_ip_configuration: frontendipconf0
register: output
-- name: assert complex load balancer created
- assert:
+- name: Assert complex load balancer created
+ ansible.builtin.assert:
that: output.changed
-- name: delete load balancer
+- name: Delete load balancer
azure_rm_loadbalancer:
resource_group: '{{ resource_group }}'
name: "{{ lbname_c2 }}"
@@ -250,19 +250,19 @@
- name: Create virtual network
azure_rm_virtualnetwork:
- resource_group: "{{ resource_group }}"
- name: "{{ lbvnname }}"
- address_prefixes: "10.10.0.0/16"
+ resource_group: "{{ resource_group }}"
+ name: "{{ lbvnname }}"
+ address_prefixes: "10.10.0.0/16"
- name: Add subnet
azure_rm_subnet:
- resource_group: "{{ resource_group }}"
- name: "lb{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}sb"
- address_prefix: "10.10.0.0/24"
- virtual_network: "{{ lbvnname }}"
+ resource_group: "{{ resource_group }}"
+ name: "lb{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}sb"
+ address_prefix: "10.10.0.0/24"
+ virtual_network: "{{ lbvnname }}"
register: subnet
-- name: create internal loadbalancer
+- name: Create internal loadbalancer
azure_rm_loadbalancer:
resource_group: '{{ resource_group }}'
name: "{{ lbname_d }}"
@@ -295,39 +295,39 @@
frontend_port: 80
backend_port: 80
probe: prob0
- disable_outbound_snat: False
+ disable_outbound_snat: false
register: output
-- name: assert complex load balancer created
- assert:
+- name: Assert complex load balancer created
+ ansible.builtin.assert:
that:
- output.changed
- output.state.frontend_ip_configurations[0].zones | length == 3
-- name: delete load balancer
+- name: Delete load balancer
azure_rm_loadbalancer:
resource_group: '{{ resource_group }}'
name: "{{ lbname_d }}"
state: absent
-- name: cleanup public ip
+- name: Cleanup public ip
azure_rm_publicipaddress:
name: "{{ item }}"
resource_group: '{{ resource_group }}'
state: absent
with_items:
- - "{{ pipaname }}"
- - "{{ pipbname }}"
+ - "{{ pipaname }}"
+ - "{{ pipbname }}"
-- name: cleanup subnet
+- name: Cleanup subnet
azure_rm_subnet:
- resource_group: "{{ resource_group }}"
- name: "lb{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}sb"
- virtual_network: "{{ lbvnname }}"
- state: absent
+ resource_group: "{{ resource_group }}"
+ name: "lb{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}sb"
+ virtual_network: "{{ lbvnname }}"
+ state: absent
-- name: cleanup virtual network
+- name: Cleanup virtual network
azure_rm_virtualnetwork:
- resource_group: "{{ resource_group }}"
- name: "{{ lbvnname }}"
- state: absent
+ resource_group: "{{ resource_group }}"
+ name: "{{ lbvnname }}"
+ state: absent
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_loganalyticsworkspace/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_loganalyticsworkspace/tasks/main.yml
index 3c9e1d493..be5e45572 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_loganalyticsworkspace/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_loganalyticsworkspace/tasks/main.yml
@@ -1,26 +1,27 @@
- name: Prepare random number
- set_fact:
- name: "loganalytics{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
+ ansible.builtin.set_fact:
+ name_rpfx: "loganalytics{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
retention_days: 60
- name: Create Log Analytics Workspace (Check Mode On)
azure_rm_loganalyticsworkspace:
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
intelligence_packs:
Backup: true
Containers: true
retention_in_days: "{{ retention_days }}"
resource_group: "{{ resource_group }}"
- check_mode: yes
+ check_mode: true
register: output
-- assert:
+- name: Assert there is no log analytics workspace
+ ansible.builtin.assert:
that:
- output.changed
- name: Get Log Analytics workspace information
azure_rm_loganalyticsworkspace_info:
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
resource_group: "{{ resource_group }}"
show_intelligence_packs: true
show_management_groups: true
@@ -28,13 +29,14 @@
show_usages: true
register: facts
-- assert:
+- name: Assert the log analytics workspace facts
+ ansible.builtin.assert:
that:
- facts.workspaces | length == 0
- name: Create Log Analytics Workspace
azure_rm_loganalyticsworkspace:
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
intelligence_packs:
Backup: true
Containers: true
@@ -44,7 +46,8 @@
key1: value1
register: output
-- assert:
+- name: Assert the log analytics workspace created
+ ansible.builtin.assert:
that:
- output.changed
- output.retention_in_days == 30
@@ -55,7 +58,7 @@
- name: Update Log Analytics Workspace
azure_rm_loganalyticsworkspace:
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
intelligence_packs:
Backup: true
Containers: true
@@ -66,7 +69,8 @@
key2: value2
register: output
-- assert:
+- name: Assert the log analytics workspace updated
+ ansible.builtin.assert:
that:
- output.changed
- output.retention_in_days == retention_days
@@ -74,7 +78,7 @@
- name: Get Log Analytics workspace information (Show full information)
azure_rm_loganalyticsworkspace_info:
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
resource_group: "{{ resource_group }}"
show_intelligence_packs: true
show_management_groups: true
@@ -82,7 +86,8 @@
show_usages: true
register: facts
-- assert:
+- name: Assert the log analytics workspace facts
+ ansible.builtin.assert:
that:
- not facts.changed
- facts.workspaces | length > 0
@@ -100,11 +105,12 @@
- name: Get Log Analytics workspace information (Show default information)
azure_rm_loganalyticsworkspace_info:
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
resource_group: "{{ resource_group }}"
register: facts
-- assert:
+- name: Assert the log analytics workspace facts
+ ansible.builtin.assert:
that:
- not facts.changed
- facts.workspaces | length > 0
@@ -117,67 +123,73 @@
- name: Create Log Analytics workspace (Test Idempotence)
azure_rm_loganalyticsworkspace:
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
resource_group: "{{ resource_group }}"
retention_in_days: "{{ retention_days }}"
register: output
-- assert:
+- name: Assert the log anaytics workspace already created
+ ansible.builtin.assert:
that:
- not output.changed
- name: Remove Log Analytics workspace (Check Mode On)
azure_rm_loganalyticsworkspace:
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
resource_group: "{{ resource_group }}"
state: absent
- check_mode: yes
+ check_mode: true
register: output
-- assert:
+- name: Assert there is no log anaytics workspace
+ ansible.builtin.assert:
that:
- output.changed
- name: Get Log Analytics workspace information(Check still exists after remove Check Mode On)
azure_rm_loganalyticsworkspace_info:
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
resource_group: "{{ resource_group }}"
register: facts
-- assert:
+- name: Assert the log analytics workspace facts
+ ansible.builtin.assert:
that:
- facts.workspaces | length == 1
- name: Remove Log Analytics workspace
azure_rm_loganalyticsworkspace:
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
resource_group: "{{ resource_group }}"
state: absent
force: true
register: output
-- assert:
+- name: Assert the log analytics workspace deleted
+ ansible.builtin.assert:
that:
- output.changed
- name: Get Log Analytics workspace information
azure_rm_loganalyticsworkspace_info:
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
resource_group: "{{ resource_group }}"
register: facts
-- assert:
+- name: Assert the log analytics workspace facts
+ ansible.builtin.assert:
that:
- facts.workspaces | length == 0
- name: Remove Log Analytics workspace (Test Idempotence)
azure_rm_loganalyticsworkspace:
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
resource_group: "{{ resource_group }}"
state: absent
force: true
register: output
-- assert:
+- name: Assert the log analytics workspace deleted
+ ansible.builtin.assert:
that:
- not output.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_manageddisk/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_manageddisk/tasks/main.yml
index ce6b4e6b6..1ccae8fc0 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_manageddisk/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_manageddisk/tasks/main.yml
@@ -1,260 +1,268 @@
- - name: Prepare random number
- set_fact:
- rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
- parameter: {}
- run_once: yes
-
- - name: Clearing (if) previous disks were created
- azure_rm_manageddisk:
- resource_group: "{{ resource_group }}"
- name: "md{{ rpfx }}{{ item }}"
- managed_by: ''
- state: absent
- with_items:
- - 1
- - 2
- - 3
-
- - name: Test invalid account name (should give error)
- azure_rm_manageddisk:
- resource_group: "{{ resource_group }}"
- name: "invalid_char$"
- disk_size_gb: 1
- register: output
- ignore_errors: yes
- check_mode: no
-
- - name: Assert task failed
- assert: { that: "output['failed'] == True" }
-
- - name: Create managed disk (Check Mode)
- azure_rm_manageddisk:
- resource_group: "{{ resource_group }}"
- name: "md{{ rpfx }}1"
- storage_account_type: "Standard_LRS"
- disk_size_gb: 1
- tags:
- testing: testing
- delete: never
- register: output
- check_mode: yes
-
- - name: Assert status succeeded (Check Mode)
- assert:
- that:
- - output.changed
- - output.state
-
- - name: Create new managed disk succesfully
- azure_rm_manageddisk:
- resource_group: "{{ resource_group }}"
- name: "md{{ rpfx }}1"
- storage_account_type: "Standard_LRS"
- disk_size_gb: 1
- tags:
- testing: testing
- delete: never
- register: output
-
- - name: Assert status succeeded and results include an Id value
- assert:
- that:
- - output.changed
- - output.state.disk_size_gb == 1
- - output.state.id is defined
- - output.state.os_type == None
- - output.state.storage_account_type == "Standard_LRS"
-
- - name: Copy disk to a new managed disk
- azure_rm_manageddisk:
- resource_group: "{{ resource_group }}"
- name: "md{{ rpfx }}2"
- create_option: "copy"
- source_uri: "{{ output.state.id }}"
- disk_size_gb: 1
- register: disk2
-
- - name: Assert status succeeded and results include an Id value
- assert:
- that:
- - disk2.changed
- - disk2.state.id is defined
-
- - name: Create disk to a new managed disk with zone and os type
- azure_rm_manageddisk:
- resource_group: "{{ resource_group }}"
- name: "md{{ rpfx }}3"
- source_uri: "{{ output.state.id }}"
- disk_size_gb: 1
- zone: "1"
- os_type: windows
- register: disk3
-
- - name: Assert status succeeded and results include an Id value
- assert:
- that:
- - disk3.changed
- - disk3.state.id is defined
- - disk3.state.zone == "1"
- - disk3.state.os_type == "windows"
-
- - name: Change storage account type to an invalid type
- azure_rm_manageddisk:
- resource_group: "{{ resource_group }}"
- name: "md{{ rpfx }}1"
- storage_account_type: "PremiumL"
- disk_size_gb: 1
- register: output
- ignore_errors: yes
-
- - name: Assert storage account type change failed
- assert: { that: "output['failed'] == True" }
-
- - name: Update disk options (os_type, account_type, size, tags)
- azure_rm_manageddisk:
- resource_group: "{{ resource_group }}"
- name: "md{{ rpfx }}1"
- disk_size_gb: 2
- os_type: linux
- storage_account_type: "StandardSSD_LRS"
- tags:
- galaxy: "no"
- delete: never
- register: output
-
- - assert:
- that:
- - output.changed
- - output.state.storage_account_type == "StandardSSD_LRS"
- - output.state.disk_size_gb == 2
- - "output.state.tags | length == 2"
- - "output.state.tags.galaxy == 'no'"
- - output.state.os_type == 'linux'
-
- - name: Gather facts to one specific disk
- azure_rm_manageddisk_info:
- resource_group: "{{ resource_group }}"
- name: "md{{ rpfx }}1"
- register: output
-
- - assert:
- that:
- - "output.ansible_info.azure_managed_disk | length == 1"
- - output.ansible_info.azure_managed_disk[0].storage_account_type == "StandardSSD_LRS"
- - output.ansible_info.azure_managed_disk[0].disk_size_gb == 2
- - "output.ansible_info.azure_managed_disk[0].os_type == 'linux'"
-
- - set_fact:
- parameter: "{{parameter |combine({item.key: item.value})}}"
- when: "{{item.key not in ['id', 'changed'] and item.value != None}}"
- with_dict: "{{ output.ansible_info.azure_managed_disk[0] }}"
-
- - name: Create disk with facts return value
- azure_rm_manageddisk:
- resource_group: "{{ resource_group }}"
- location: "{{ parameter.location }}"
- name: "{{ parameter.name }}"
- storage_account_type: "{{ parameter.storage_account_type }}"
- disk_size_gb: "{{ parameter.disk_size_gb }}"
- create_option: "{{ parameter.create_option }}"
- tags: "{{ parameter.tags }}"
- register: output
-
- - assert:
- that:
- - not output.changed
-
- - name: Create new managed disk with I(account_type=StandardSSD_ZRS)
- azure_rm_manageddisk:
- resource_group: "{{ resource_group }}"
- name: "md{{ rpfx }}4"
- storage_account_type: "StandardSSD_ZRS"
- disk_size_gb: 2
- location: westus2
- register: output
-
- - assert:
- that:
- - output.changed
- - output.state.storage_account_type == "StandardSSD_ZRS"
- - output.state.disk_size_gb == 2
-
- - name: Gather facts to one specific disk
- azure_rm_manageddisk_info:
- resource_group: "{{ resource_group }}"
- name: "md{{ rpfx }}4"
- register: output
-
- - assert:
- that:
- - "output.ansible_info.azure_managed_disk | length == 1"
- - output.ansible_info.azure_managed_disk[0].storage_account_type == "StandardSSD_ZRS"
- - output.ansible_info.azure_managed_disk[0].disk_size_gb == 2
-
- - name: Create new managed disk with I(account_type=Premium_ZRS)
- azure_rm_manageddisk:
- resource_group: "{{ resource_group }}"
- name: "md{{ rpfx }}5"
- storage_account_type: "Premium_ZRS"
- disk_size_gb: 2
- location: westus2
- register: output
-
- - assert:
- that:
- - output.changed
- - output.state.storage_account_type == "Premium_ZRS"
- - output.state.disk_size_gb == 2
-
- - name: Gather facts to one specific disk
- azure_rm_manageddisk_info:
- resource_group: "{{ resource_group }}"
- name: "md{{ rpfx }}5"
- register: output
-
- - assert:
- that:
- - "output.ansible_info.azure_managed_disk | length == 1"
- - output.ansible_info.azure_managed_disk[0].storage_account_type == "Premium_ZRS"
- - output.ansible_info.azure_managed_disk[0].disk_size_gb == 2
-
- - name: Delete managed disk (Check Mode)
- azure_rm_manageddisk:
- resource_group: "{{ resource_group }}"
- name: "md{{ rpfx }}1"
- state: absent
- register: output
- check_mode: yes
-
- - name: Assert status succeeded
- assert:
- that:
- - output.changed
- - output.state
-
- - name: Delete all managed disk
- azure_rm_manageddisk:
- resource_group: "{{ resource_group }}"
- name: "md{{ rpfx }}{{ item }}"
- managed_by: ''
- state: absent
- with_items:
- - 1
- - 2
- - 3
- - 4
- - 5
-
- - name: Delete virtual machine
- azure_rm_virtualmachine:
- resource_group: "{{ resource_group }}"
- name: "tr{{ rpfx }}"
- state: absent
- vm_size: Standard_DS1_v2
-
- - name: Delete public ip
- azure_rm_publicipaddress:
- resource_group: "{{ resource_group }}"
- allocation_method: Static
- name: "tr{{ rpfx }}"
- state: absent
+- name: Prepare random number
+ ansible.builtin.set_fact:
+ rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
+ parameter: {}
+ run_once: true
+
+- name: Clearing (if) previous disks were created
+ azure_rm_manageddisk:
+ resource_group: "{{ resource_group }}"
+ name: "md{{ rpfx }}{{ item }}"
+ managed_by: ''
+ state: absent
+ with_items:
+ - 1
+ - 2
+ - 3
+
+- name: Test invalid account name (should give error)
+ azure_rm_manageddisk:
+ resource_group: "{{ resource_group }}"
+ name: "invalid_char$"
+ disk_size_gb: 1
+ register: output
+ ignore_errors: true
+ check_mode: false
+
+- name: Assert task failed
+ ansible.builtin.assert: { that: "output['failed'] == True" }
+
+- name: Create managed disk (Check Mode)
+ azure_rm_manageddisk:
+ resource_group: "{{ resource_group }}"
+ name: "md{{ rpfx }}1"
+ storage_account_type: "Standard_LRS"
+ disk_size_gb: 1
+ tags:
+ testing: testing
+ delete: never
+ register: output
+ check_mode: true
+
+- name: Assert status succeeded (Check Mode)
+ ansible.builtin.assert:
+ that:
+ - output.changed
+ - output.state
+
+- name: Create new managed disk succesfully
+ azure_rm_manageddisk:
+ resource_group: "{{ resource_group }}"
+ name: "md{{ rpfx }}1"
+ storage_account_type: "Standard_LRS"
+ disk_size_gb: 1
+ tags:
+ testing: testing
+ delete: never
+ register: output
+
+- name: Assert status succeeded and results include an Id value
+ ansible.builtin.assert:
+ that:
+ - output.changed
+ - output.state.disk_size_gb == 1
+ - output.state.id is defined
+ - output.state.os_type == None
+ - output.state.storage_account_type == "Standard_LRS"
+
+- name: Copy disk to a new managed disk
+ azure_rm_manageddisk:
+ resource_group: "{{ resource_group }}"
+ name: "md{{ rpfx }}2"
+ create_option: "copy"
+ source_uri: "{{ output.state.id }}"
+ disk_size_gb: 1
+ register: disk2
+
+- name: Assert status succeeded and results include an Id value
+ ansible.builtin.assert:
+ that:
+ - disk2.changed
+ - disk2.state.id is defined
+
+- name: Create disk to a new managed disk with zone and os type
+ azure_rm_manageddisk:
+ resource_group: "{{ resource_group }}"
+ name: "md{{ rpfx }}3"
+ source_uri: "{{ output.state.id }}"
+ disk_size_gb: 1
+ zone: "1"
+ os_type: windows
+ register: disk3
+
+- name: Assert status succeeded and results include an Id value
+ ansible.builtin.assert:
+ that:
+ - disk3.changed
+ - disk3.state.id is defined
+ - disk3.state.zone == "1"
+ - disk3.state.os_type == "windows"
+
+- name: Change storage account type to an invalid type
+ azure_rm_manageddisk:
+ resource_group: "{{ resource_group }}"
+ name: "md{{ rpfx }}1"
+ storage_account_type: "PremiumL"
+ disk_size_gb: 1
+ register: output
+ ignore_errors: true
+
+- name: Assert storage account type change failed
+ ansible.builtin.assert: { that: "output['failed'] == True" }
+
+- name: Update disk options (os_type, account_type, size, tags)
+ azure_rm_manageddisk:
+ resource_group: "{{ resource_group }}"
+ name: "md{{ rpfx }}1"
+ disk_size_gb: 2
+ os_type: linux
+ storage_account_type: "StandardSSD_LRS"
+ tags:
+ galaxy: "no"
+ delete: never
+ register: output
+
+- name: Assert the disk updated
+ ansible.builtin.assert:
+ that:
+ - output.changed
+ - output.state.storage_account_type == "StandardSSD_LRS"
+ - output.state.disk_size_gb == 2
+ - "output.state.tags | length == 2"
+ - "output.state.tags.galaxy == 'no'"
+ - output.state.os_type == 'linux'
+
+- name: Gather facts to one specific disk
+ azure_rm_manageddisk_info:
+ resource_group: "{{ resource_group }}"
+ name: "md{{ rpfx }}1"
+ register: output
+
+- name: Assert the disk facts
+ ansible.builtin.assert:
+ that:
+ - "output.ansible_info.azure_managed_disk | length == 1"
+ - output.ansible_info.azure_managed_disk[0].storage_account_type == "StandardSSD_LRS"
+ - output.ansible_info.azure_managed_disk[0].disk_size_gb == 2
+ - "output.ansible_info.azure_managed_disk[0].os_type == 'linux'"
+
+- name: Set variables
+ ansible.builtin.set_fact:
+ parameter: "{{ parameter | combine({item.key: item.value}) }}"
+ when: item.key not in ['id', 'changed'] and item.value != None
+ with_dict: "{{ output.ansible_info.azure_managed_disk[0] }}"
+
+- name: Create disk with facts return value
+ azure_rm_manageddisk:
+ resource_group: "{{ resource_group }}"
+ location: "{{ parameter.location }}"
+ name: "{{ parameter.name }}"
+ storage_account_type: "{{ parameter.storage_account_type }}"
+ disk_size_gb: "{{ parameter.disk_size_gb }}"
+ create_option: "{{ parameter.create_option }}"
+ tags: "{{ parameter.tags }}"
+ register: output
+
+- name: Assert the disk created
+ ansible.builtin.assert:
+ that:
+ - not output.changed
+
+- name: Create new managed disk with I(account_type=StandardSSD_ZRS)
+ azure_rm_manageddisk:
+ resource_group: "{{ resource_group }}"
+ name: "md{{ rpfx }}4"
+ storage_account_type: "StandardSSD_ZRS"
+ disk_size_gb: 2
+ location: westus2
+ register: output
+
+- name: Assert the managed disk update
+ ansible.builtin.assert:
+ that:
+ - output.changed
+ - output.state.storage_account_type == "StandardSSD_ZRS"
+ - output.state.disk_size_gb == 2
+
+- name: Gather facts to one specific disk
+ azure_rm_manageddisk_info:
+ resource_group: "{{ resource_group }}"
+ name: "md{{ rpfx }}4"
+ register: output
+
+- name: Assert the managed disk facts
+ ansible.builtin.assert:
+ that:
+ - "output.ansible_info.azure_managed_disk | length == 1"
+ - output.ansible_info.azure_managed_disk[0].storage_account_type == "StandardSSD_ZRS"
+ - output.ansible_info.azure_managed_disk[0].disk_size_gb == 2
+
+- name: Create new managed disk with I(account_type=Premium_ZRS)
+ azure_rm_manageddisk:
+ resource_group: "{{ resource_group }}"
+ name: "md{{ rpfx }}5"
+ storage_account_type: "Premium_ZRS"
+ disk_size_gb: 2
+ location: westus2
+ register: output
+
+- name: Assert the managed disk created
+ ansible.builtin.assert:
+ that:
+ - output.changed
+ - output.state.storage_account_type == "Premium_ZRS"
+ - output.state.disk_size_gb == 2
+
+- name: Gather facts to one specific disk
+ azure_rm_manageddisk_info:
+ resource_group: "{{ resource_group }}"
+ name: "md{{ rpfx }}5"
+ register: output
+
+- name: Assert the managed disk facts
+ ansible.builtin.assert:
+ that:
+ - "output.ansible_info.azure_managed_disk | length == 1"
+ - output.ansible_info.azure_managed_disk[0].storage_account_type == "Premium_ZRS"
+ - output.ansible_info.azure_managed_disk[0].disk_size_gb == 2
+
+- name: Delete managed disk (Check Mode)
+ azure_rm_manageddisk:
+ resource_group: "{{ resource_group }}"
+ name: "md{{ rpfx }}1"
+ state: absent
+ register: output
+ check_mode: true
+
+- name: Assert status succeeded
+ ansible.builtin.assert:
+ that:
+ - output.changed
+ - output.state
+
+- name: Delete all managed disk
+ azure_rm_manageddisk:
+ resource_group: "{{ resource_group }}"
+ name: "md{{ rpfx }}{{ item }}"
+ managed_by: ''
+ state: absent
+ with_items:
+ - 1
+ - 2
+ - 3
+ - 4
+ - 5
+
+- name: Delete virtual machine
+ azure_rm_virtualmachine:
+ resource_group: "{{ resource_group }}"
+ name: "tr{{ rpfx }}"
+ state: absent
+ vm_size: Standard_DS1_v2
+
+- name: Delete public ip
+ azure_rm_publicipaddress:
+ resource_group: "{{ resource_group }}"
+ allocation_method: Static
+ name: "tr{{ rpfx }}"
+ state: absent
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_managementgroup/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_managementgroup/tasks/main.yml
index 3a6c03649..1f4e94634 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_managementgroup/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_managementgroup/tasks/main.yml
@@ -5,31 +5,31 @@
- name: Get a managementgroup by id
azure_rm_managementgroup_info:
id: "{{ az_all_managementgroups.management_groups[0].id }}"
- recurse: True
- flatten: True
- children: True
+ recurse: true
+ flatten: true
+ children: true
register: az_recursive_managementgroups
- name: Get a managementgroup by name
azure_rm_managementgroup_info:
name: "{{ az_all_managementgroups.management_groups[0].name }}"
- recurse: True
- flatten: True
+ recurse: true
+ flatten: true
- name: Test invalid name id combo
azure_rm_managementgroup_info:
name: "{{ az_all_managementgroups.management_groups[0].name }}"
id: "{{ az_all_managementgroups.management_groups[0].id }}"
register: invalid_name
- ignore_errors: yes
+ ignore_errors: true
- name: Validate expected states
- assert:
+ ansible.builtin.assert:
that:
- invalid_name['failed']
- name: Validate expected attributes
- assert:
+ ansible.builtin.assert:
that:
- "{{ item.id is defined }}"
loop: "{{ az_recursive_managementgroups.management_groups + az_recursive_managementgroups.subscriptions }}"
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_mariadbserver/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_mariadbserver/tasks/main.yml
index 14d101a9a..4fd89fb26 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_mariadbserver/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_mariadbserver/tasks/main.yml
@@ -1,7 +1,7 @@
- name: Prepare random number
- set_fact:
+ ansible.builtin.set_fact:
rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
- run_once: yes
+ run_once: true
- name: Create instance of MariaDB Server -- check mode
azure_rm_mariadbserver:
@@ -13,13 +13,13 @@
location: westus2
storage_mb: 51200
version: 10.2
- enforce_ssl: True
+ enforce_ssl: true
admin_username: zimxyz
admin_password: Password123!
- check_mode: yes
+ check_mode: true
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -33,12 +33,12 @@
location: westus2
storage_mb: 51200
version: 10.2
- enforce_ssl: True
+ enforce_ssl: true
admin_username: zimxyz
admin_password: Password123!
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.state == 'Ready'
@@ -53,12 +53,12 @@
location: westus2
storage_mb: 51200
version: 10.2
- enforce_ssl: True
+ enforce_ssl: true
admin_username: zimxyz
admin_password: Password123!
register: output
- name: Assert the state has not changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed == false
- output.state == 'Ready'
@@ -73,16 +73,17 @@
location: westus2
storage_mb: 128000
version: 10.2
- enforce_ssl: True
+ enforce_ssl: true
admin_username: zimxyz
admin_password: Password123!
register: output
- name: Assert the state has not changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.state == 'Ready'
-- debug:
+- name: Print the state of the mariadb server
+ ansible.builtin.debug:
var: output
- name: Gather facts MariaDB Server
@@ -91,7 +92,7 @@
name: mariadbsrv{{ rpfx }}
register: output
- name: Assert that storage size is correct
- assert:
+ ansible.builtin.assert:
that:
- output.servers[0]['storage_mb'] == 128000
@@ -105,7 +106,7 @@
location: westus2
storage_mb: 51200
version: 10.3
- enforce_ssl: True
+ enforce_ssl: true
admin_username: zimxyz
admin_password: Password123!
tags:
@@ -121,7 +122,7 @@
location: westus2
storage_mb: 51200
version: 10.3
- enforce_ssl: True
+ enforce_ssl: true
admin_username: zimxyz
admin_password: Password123!
tags:
@@ -131,10 +132,10 @@
azure_rm_mariadbserver_info:
resource_group: "{{ resource_group }}"
name: mariadbsrv{{ rpfx }}second
- register: output
+ register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.servers[0]['id'] != None
@@ -154,7 +155,7 @@
resource_group: "{{ resource_group }}"
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.servers[0]['id'] != None
@@ -184,10 +185,10 @@
resource_group: "{{ resource_group }}"
server_name: mariadbsrv{{ rpfx }}
name: testdatabase
- check_mode: yes
+ check_mode: true
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -200,7 +201,7 @@
charset: latin1
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.name == 'testdatabase'
@@ -214,7 +215,7 @@
charset: latin1
register: output
- name: Assert the state has not changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed == false
- output.name == 'testdatabase'
@@ -226,10 +227,10 @@
name: testdatabase
collation: utf8_general_ci
charset: utf8
- ignore_errors: yes
+ ignore_errors: true
register: output
- name: Assert that nothing has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
@@ -240,10 +241,10 @@
name: testdatabase
collation: utf8_general_ci
charset: utf8
- force_update: yes
+ force_update: true
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.name == 'testdatabase'
@@ -259,10 +260,10 @@
resource_group: "{{ resource_group }}"
server_name: mariadbsrv{{ rpfx }}
name: testdatabase
- register: output
+ register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.databases[0]['server_name'] != None
@@ -276,7 +277,7 @@
server_name: mariadbsrv{{ rpfx }}
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.databases[0]['server_name'] != None
@@ -294,10 +295,10 @@
server_name: mariadbsrv{{ rpfx }}
name: testdatabase
state: absent
- check_mode: yes
+ check_mode: true
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -309,7 +310,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -321,7 +322,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed == false
@@ -335,10 +336,10 @@
name: firewallrule{{ rpfx }}
start_ip_address: 172.28.10.136
end_ip_address: 172.28.10.138
- check_mode: yes
+ check_mode: true
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -351,7 +352,7 @@
end_ip_address: 172.28.10.138
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -364,7 +365,7 @@
end_ip_address: 172.28.10.138
register: output
- name: Assert the state has not changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed == false
@@ -374,10 +375,10 @@
server_name: mariadbsrv{{ rpfx }}
name: firewallrule{{ rpfx }}
state: absent
- check_mode: yes
+ check_mode: true
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -390,7 +391,7 @@
end_ip_address: 172.28.10.138
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -401,7 +402,7 @@
name: firewallrule{{ rpfx }}
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.rules[0].id != None
@@ -417,7 +418,7 @@
server_name: mariadbsrv{{ rpfx }}
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.rules[0].id != None
@@ -439,7 +440,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -451,7 +452,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed == false
@@ -469,7 +470,7 @@
name: firewallrule{{ rpfx }}
register: output
- name: Assert that empty list was returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- "output.rules | length == 0"
@@ -483,10 +484,10 @@
server_name: mariadbsrv{{ rpfx }}
name: event_scheduler
value: "ON"
- check_mode: yes
+ check_mode: true
register: output
- name: Assert that change was registered
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -497,7 +498,7 @@
name: event_scheduler
register: output
- name: Get facts of event_scheduler
- debug:
+ ansible.builtin.debug:
var: output
- name: Try to delete default configuraion
@@ -508,7 +509,7 @@
state: absent
register: output
- name: Assert that change was registered
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
@@ -520,7 +521,7 @@
value: "ON"
register: output
- name: Assert that change was registered
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -532,7 +533,7 @@
value: "ON"
register: output
- name: Assert that change was registered
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
@@ -544,7 +545,7 @@
state: absent
register: output
- name: Assert that change was registered
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -556,7 +557,7 @@
state: absent
register: output
- name: Assert that change was registered
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
@@ -567,7 +568,7 @@
name: event_scheduler
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.settings[0].id != None
@@ -583,7 +584,7 @@
server_name: mariadbsrv{{ rpfx }}
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.settings[0].id != None
@@ -602,10 +603,10 @@
resource_group: "{{ resource_group }}"
name: mariadbsrv{{ rpfx }}
state: absent
- check_mode: yes
+ check_mode: true
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -616,7 +617,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -627,7 +628,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed == false
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_monitordiagnosticsetting/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_monitordiagnosticsetting/tasks/main.yml
index a725a0b33..46ef90a8d 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_monitordiagnosticsetting/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_monitordiagnosticsetting/tasks/main.yml
@@ -1,18 +1,18 @@
- name: Prepare random number
- set_fact:
+ ansible.builtin.set_fact:
rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
- run_once: yes
+ run_once: true
# ------ setup ------
-- name: create virtual network
+- name: Create virtual network
azure_rm_virtualnetwork:
name: "vnet-{{ rpfx }}"
resource_group: "{{ resource_group }}"
address_prefixes: "10.0.0.0/16"
register: vnet_output
-- name: create web app
+- name: Create web app
azure_rm_webapp:
name: "webapp-{{ rpfx }}"
resource_group: "{{ resource_group }}"
@@ -23,7 +23,7 @@
sku: S1
register: webapp_output
-- name: create storage account
+- name: Create storage account
azure_rm_storageaccount:
name: "storage{{ rpfx }}"
resource_group: "{{ resource_group }}"
@@ -31,7 +31,7 @@
kind: StorageV2
register: storage_output
-- name: create second storage account
+- name: Create second storage account
azure_rm_storageaccount:
name: "storagesecond{{ rpfx }}"
resource_group: "{{ resource_group_secondary }}"
@@ -39,13 +39,13 @@
kind: StorageV2
register: storage2_output
-- name: create event hub namespace
+- name: Create event hub namespace
azure_rm_eventhub:
namespace_name: "hub-{{ rpfx }}"
resource_group: "{{ resource_group }}"
sku: "Basic"
-- name: create log analytics workspace
+- name: Create log analytics workspace
azure_rm_loganalyticsworkspace:
name: "analytics-{{ rpfx }}"
resource_group: "{{ resource_group_secondary }}"
@@ -54,23 +54,23 @@
# ------ tests ------
-- name: get diagnostic settings for non-existant resource
+- name: Get diagnostic settings for non-existant resource
azure_rm_monitordiagnosticsetting_info:
resource: "123abc"
register: output
failed_when: '"failed" not in output.msg | lower'
-- name: get diagnostic settings for virtual network
+- name: Get diagnostic settings for virtual network
azure_rm_monitordiagnosticsetting_info:
resource: "{{ vnet_output.state.id }}"
register: output
-- name: assert no settings
- assert:
+- name: Assert no settings
+ ansible.builtin.assert:
that:
- not output.changed
- output.settings | length == 0
-- name: create storage-based diagnostic setting for vnet (check mode)
+- name: Create storage-based diagnostic setting for vnet (check mode)
azure_rm_monitordiagnosticsetting:
name: "logs-storage"
resource: "{{ vnet_output.state.id }}"
@@ -81,12 +81,12 @@
- category: "AllMetrics"
check_mode: true
register: output
-- name: assert resource created
- assert:
+- name: Assert resource created
+ ansible.builtin.assert:
that:
- output.changed
-- name: create storage-based diagnostic setting for vnet (actually create)
+- name: Create storage-based diagnostic setting for vnet (actually create)
azure_rm_monitordiagnosticsetting:
name: "logs-storage"
resource: "{{ vnet_output.state.id }}"
@@ -96,8 +96,8 @@
metrics:
- category: "AllMetrics"
register: output
-- name: assert resource created
- assert:
+- name: Assert resource created
+ ansible.builtin.assert:
that:
- output.changed
- output.state.name == 'logs-storage'
@@ -111,7 +111,7 @@
- not output.state.event_hub
- not output.state.log_analytics
-- name: create storage-based diagnostic setting for vnet (idempotent)
+- name: Create storage-based diagnostic setting for vnet (idempotent)
azure_rm_monitordiagnosticsetting:
name: "logs-storage"
resource: "{{ vnet_output.state.id }}"
@@ -122,12 +122,12 @@
- category: "AllMetrics"
check_mode: true
register: output
-- name: assert resource not changed
- assert:
+- name: Assert resource not changed
+ ansible.builtin.assert:
that:
- not output.changed
-- name: create storage-based diagnostic setting for vnet by resource dict (idempotent)
+- name: Create storage-based diagnostic setting for vnet by resource dict (idempotent)
azure_rm_monitordiagnosticsetting:
name: "logs-storage"
resource:
@@ -140,12 +140,12 @@
metrics:
- category: "AllMetrics"
register: output
-- name: assert resource not changed
- assert:
+- name: Assert resource not changed
+ ansible.builtin.assert:
that:
- not output.changed
-- name: update storage-based diagnostic setting for vnet
+- name: Update storage-based diagnostic setting for vnet
azure_rm_monitordiagnosticsetting:
name: "logs-storage"
resource: "{{ vnet_output.state.id }}"
@@ -153,8 +153,8 @@
logs:
- category_group: "allLogs"
register: output
-- name: assert resource updated
- assert:
+- name: Assert resource updated
+ ansible.builtin.assert:
that:
- output.changed
- output.state.name == 'logs-storage'
@@ -166,7 +166,7 @@
- not output.state.event_hub
- not output.state.log_analytics
-- name: create second storage-based diagnostic setting for vnet
+- name: Create second storage-based diagnostic setting for vnet
azure_rm_monitordiagnosticsetting:
name: "logs-storage2"
resource: "{{ vnet_output.state.id }}"
@@ -178,8 +178,8 @@
retention_policy:
days: 15
register: output
-- name: assert resource created
- assert:
+- name: Assert resource created
+ ansible.builtin.assert:
that:
- output.changed
- output.state.name == 'logs-storage2'
@@ -193,7 +193,7 @@
- not output.state.event_hub
- not output.state.log_analytics
-- name: update second storage-based diagnostic setting for vnet
+- name: Update second storage-based diagnostic setting for vnet
azure_rm_monitordiagnosticsetting:
name: "logs-storage2"
resource: "{{ vnet_output.state.id }}"
@@ -205,13 +205,13 @@
retention_policy:
days: 30
register: output
-- name: assert resource created
- assert:
+- name: Assert resource created
+ ansible.builtin.assert:
that:
- output.changed
- output.state.logs[0].retention_policy.days == 30
-- name: update second storage-based diagnostic setting for vnet (idempotent)
+- name: Update second storage-based diagnostic setting for vnet (idempotent)
azure_rm_monitordiagnosticsetting:
name: "logs-storage2"
resource: "{{ vnet_output.state.id }}"
@@ -223,17 +223,17 @@
retention_policy:
days: 30
register: output
-- name: assert resource not changed
- assert:
+- name: Assert resource not changed
+ ansible.builtin.assert:
that:
- not output.changed
-- name: get diagnostic settings for virtual network
+- name: Get diagnostic settings for virtual network
azure_rm_monitordiagnosticsetting_info:
resource: "{{ vnet_output.state.id }}"
register: output
-- name: assert output maches expectations
- assert:
+- name: Assert output maches expectations
+ ansible.builtin.assert:
that:
- output.settings | length == 2
- output.settings[0].name == 'logs-storage'
@@ -255,13 +255,13 @@
- not output.settings[1].event_hub
- not output.settings[1].log_analytics
-- name: get specific diagnostic settings for virtual network
+- name: Get specific diagnostic settings for virtual network
azure_rm_monitordiagnosticsetting_info:
name: "logs-storage2"
resource: "{{ vnet_output.state.id }}"
register: output
-- name: assert output maches expectations
- assert:
+- name: Assert output maches expectations
+ ansible.builtin.assert:
that:
- output.settings | length == 1
- output.settings[0].name == 'logs-storage2'
@@ -275,17 +275,17 @@
- not output.settings[0].event_hub
- not output.settings[0].log_analytics
-- name: get non-existant diagnostic setting for virtual network
+- name: Get non-existant diagnostic setting for virtual network
azure_rm_monitordiagnosticsetting_info:
name: "does-not-exist"
resource: "{{ vnet_output.state.id }}"
register: output
-- name: assert no settings
- assert:
+- name: Assert no settings
+ ansible.builtin.assert:
that:
- output.settings | length == 0
-- name: create diagnostic setting for webapp with log analytics, event hub, and storage
+- name: Create diagnostic setting for webapp with log analytics, event hub, and storage
azure_rm_monitordiagnosticsetting:
name: "logs"
resource:
@@ -308,8 +308,8 @@
- category: "AppServiceIPSecAuditLogs"
- category: "AppServicePlatformLogs"
register: output
-- name: assert resource created
- assert:
+- name: Assert resource created
+ ansible.builtin.assert:
that:
- output.changed
- output.state.name == 'logs'
@@ -326,7 +326,7 @@
- output.state.logs[5].category == 'AppServicePlatformLogs'
- output.state.metrics | length == 0
-- name: create diagnostic setting for webapp with log analytics, event hub, and storage (idempotent)
+- name: Create diagnostic setting for webapp with log analytics, event hub, and storage (idempotent)
azure_rm_monitordiagnosticsetting:
name: "logs"
resource:
@@ -349,12 +349,12 @@
- category: "AppServiceIPSecAuditLogs"
- category: "AppServicePlatformLogs"
register: output
-- name: assert resource created
- assert:
+- name: Assert resource created
+ ansible.builtin.assert:
that:
- not output.changed
-- name: update diagnostic setting to remove storage and log category
+- name: Update diagnostic setting to remove storage and log category
azure_rm_monitordiagnosticsetting:
name: "logs"
resource:
@@ -374,8 +374,8 @@
- category: "AppServiceIPSecAuditLogs"
- category: "AppServicePlatformLogs"
register: output
-- name: assert resource updated
- assert:
+- name: Assert resource updated
+ ansible.builtin.assert:
that:
- output.changed
- not output.state.storage_account
@@ -386,7 +386,7 @@
- output.state.logs[3].category == 'AppServiceIPSecAuditLogs'
- output.state.logs[4].category == 'AppServicePlatformLogs'
-- name: delete diagnostic setting via resource dict
+- name: Delete diagnostic setting via resource dict
azure_rm_monitordiagnosticsetting:
name: "logs"
resource:
@@ -395,12 +395,12 @@
resource_group: "{{ resource_group }}"
state: "absent"
register: output
-- name: assert resource delete
- assert:
+- name: Assert resource delete
+ ansible.builtin.assert:
that:
- output.changed
-- name: delete diagnostic setting via resource dict (idempotent)
+- name: Delete diagnostic setting via resource dict (idempotent)
azure_rm_monitordiagnosticsetting:
name: "logs"
resource:
@@ -409,95 +409,95 @@
resource_group: "{{ resource_group }}"
state: "absent"
register: output
-- name: assert resource delete
- assert:
+- name: Assert resource delete
+ ansible.builtin.assert:
that:
- not output.changed
-- name: delete diagnostic setting (check mode)
+- name: Delete diagnostic setting (check mode)
azure_rm_monitordiagnosticsetting:
name: "logs-storage"
resource: "{{ vnet_output.state.id }}"
state: "absent"
check_mode: true
register: output
-- name: assert resource deleted
- assert:
+- name: Assert resource deleted
+ ansible.builtin.assert:
that:
- output.changed
-- name: delete diagnostic setting (actually delete)
+- name: Delete diagnostic setting (actually delete)
azure_rm_monitordiagnosticsetting:
name: "logs-storage"
resource: "{{ vnet_output.state.id }}"
state: "absent"
register: output
-- name: assert resource deleted
- assert:
+- name: Assert resource deleted
+ ansible.builtin.assert:
that:
- output.changed
-- name: delete diagnostic setting (idempotent)
+- name: Delete diagnostic setting (idempotent)
azure_rm_monitordiagnosticsetting:
name: "logs-storage"
resource: "{{ vnet_output.state.id }}"
state: "absent"
register: output
-- name: assert resource already deleted
- assert:
+- name: Assert resource already deleted
+ ansible.builtin.assert:
that:
- not output.changed
-- name: delete second diagnostic setting
+- name: Delete second diagnostic setting
azure_rm_monitordiagnosticsetting:
name: "logs-storage2"
resource: "{{ vnet_output.state.id }}"
state: "absent"
register: output
-- name: assert resource deleted
- assert:
+- name: Assert resource deleted
+ ansible.builtin.assert:
that:
- output.changed
# ------ teardown ------
-- name: delete log analytics workspace
+- name: Delete log analytics workspace
azure_rm_loganalyticsworkspace:
name: "analytics-{{ rpfx }}"
resource_group: "{{ resource_group_secondary }}"
state: "absent"
-- name: delete event hub namespace
+- name: Delete event hub namespace
azure_rm_eventhub:
namespace_name: "hub-{{ rpfx }}"
resource_group: "{{ resource_group }}"
state: "absent"
-- name: delete second storage account
+- name: Delete second storage account
azure_rm_storageaccount:
name: "storagesecond{{ rpfx }}"
resource_group: "{{ resource_group_secondary }}"
state: "absent"
-- name: delete storage account
+- name: Delete storage account
azure_rm_storageaccount:
name: "storage{{ rpfx }}"
resource_group: "{{ resource_group }}"
state: "absent"
-- name: delete web app
+- name: Delete web app
azure_rm_webapp:
name: "webapp-{{ rpfx }}"
resource_group: "{{ resource_group }}"
state: "absent"
-- name: delete web app plan
+- name: Delete web app plan
azure_rm_appserviceplan:
name: "webapp-{{ rpfx }}-plan"
resource_group: "{{ resource_group }}"
state: "absent"
-- name: delete virtual network
+- name: Delete virtual network
azure_rm_virtualnetwork:
name: "vnet-{{ rpfx }}"
resource_group: "{{ resource_group }}"
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_monitorlogprofile/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_monitorlogprofile/tasks/main.yml
index dc30caf98..0a41203ad 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_monitorlogprofile/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_monitorlogprofile/tasks/main.yml
@@ -1,17 +1,17 @@
- name: Prepare random number
- set_fact:
+ ansible.builtin.set_fact:
storage_name: "storage{{ resource_group | hash('md5') | truncate(5, True, '') }}{{ 1000 | random }}"
profile_name: "profile{{ resource_group | hash('md5') | truncate(5, True, '') }}{{ 1000 | random }}"
location: eastus
- run_once: yes
+ run_once: true
-- name: create Azure storage account
+- name: Create Azure storage account
azure_rm_storageaccount:
name: '{{ storage_name }}'
resource_group: "{{ resource_group }}"
account_type: Standard_LRS
-- name: create log profile (check mode)
+- name: Create log profile (check mode)
azure_rm_monitorlogprofile:
name: "{{ profile_name }}"
location: "{{ location }}"
@@ -22,20 +22,20 @@
- Write
- Action
retention_policy:
- enabled: False
+ enabled: false
days: 1
storage_account:
resource_group: "{{ resource_group }}"
name: "{{ storage_name }}"
- check_mode: yes
+ check_mode: true
register: output
-- name: assert create check mode
- assert:
+- name: Assert create check mode
+ ansible.builtin.assert:
that:
- output.changed
-- name: create log profile
+- name: Create log profile
azure_rm_monitorlogprofile:
name: "{{ profile_name }}"
location: "{{ location }}"
@@ -46,19 +46,19 @@
- Write
- Action
retention_policy:
- enabled: False
+ enabled: false
days: 1
storage_account:
resource_group: "{{ resource_group }}"
name: "{{ storage_name }}"
register: output
-- name: assert create
- assert:
+- name: Assert create
+ ansible.builtin.assert:
that:
- output.changed
- output.id
-- name: update log profile (idempotence)
+- name: Update log profile (idempotence)
azure_rm_monitorlogprofile:
name: "{{ profile_name }}"
location: "{{ location }}"
@@ -69,18 +69,18 @@
- Write
- Action
retention_policy:
- enabled: False
+ enabled: false
days: 1
storage_account:
resource_group: "{{ resource_group }}"
name: "{{ storage_name }}"
register: output
-- name: assert update idempotence
- assert:
+- name: Assert update idempotence
+ ansible.builtin.assert:
that:
- not output.changed
-- name: update log profile
+- name: Update log profile
azure_rm_monitorlogprofile:
name: "{{ profile_name }}"
location: "{{ location }}"
@@ -90,44 +90,44 @@
- Write
- Action
retention_policy:
- enabled: False
+ enabled: false
days: 2
storage_account:
resource_group: "{{ resource_group }}"
name: "{{ storage_name }}"
register: output
-- name: assert update
- assert:
+- name: Assert update
+ ansible.builtin.assert:
that:
- output.changed
-- name: delete log profile (check mode)
+- name: Delete log profile (check mode)
azure_rm_monitorlogprofile:
name: "{{ profile_name }}"
state: absent
register: output
check_mode: true
-- name: assert delete
- assert:
+- name: Assert delete
+ ansible.builtin.assert:
that:
- output.changed
-- name: delete log profile
+- name: Delete log profile
azure_rm_monitorlogprofile:
name: "{{ profile_name }}"
state: absent
register: output
-- name: assert delete
- assert:
+- name: Assert delete
+ ansible.builtin.assert:
that:
- output.changed
-- name: delete log profile (idempotence)
+- name: Delete log profile (idempotence)
azure_rm_monitorlogprofile:
name: "{{ profile_name }}"
state: absent
register: output
-- name: assert delete
- assert:
+- name: Assert delete
+ ansible.builtin.assert:
that:
- not output.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_multiplemanageddisks/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_multiplemanageddisks/tasks/main.yml
index 78b712653..b25349009 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_multiplemanageddisks/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_multiplemanageddisks/tasks/main.yml
@@ -1,2 +1,4 @@
-- include_tasks: tasks/test_shared.yml
-- include_tasks: tasks/test_async.yml
+- name: Excute test_shared.yml
+ ansible.builtin.include_tasks: tasks/test_shared.yml
+- name: Excute test_async.yml
+ ansible.builtin.include_tasks: tasks/test_async.yml
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_multiplemanageddisks/tasks/test_async.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_multiplemanageddisks/tasks/test_async.yml
index 448a54dde..25398bf7e 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_multiplemanageddisks/tasks/test_async.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_multiplemanageddisks/tasks/test_async.yml
@@ -16,28 +16,28 @@
- name: Create virtual machines
azure_rm_virtualmachine:
- resource_group: "{{ resource_group_secondary }}"
- name: "{{ async_virtual_machine_prefix }}-{{ item }}"
- vm_size: Standard_E2_v3
- managed_disk_type: Standard_LRS
- virtual_network: "{{ async_virtual_network }}-{{ item }}"
- admin_username: adminuser
- admin_password: "!test123@"
- os_type: Linux
- image:
- offer: UbuntuServer
- publisher: Canonical
- sku: 16.04-LTS
- version: latest
- tags:
- key: value
+ resource_group: "{{ resource_group_secondary }}"
+ name: "{{ async_virtual_machine_prefix }}-{{ item }}"
+ vm_size: Standard_E2_v3
+ managed_disk_type: Standard_LRS
+ virtual_network: "{{ async_virtual_network }}-{{ item }}"
+ admin_username: adminuser
+ admin_password: "!test123@"
+ os_type: Linux
+ image:
+ offer: 0001-com-ubuntu-server-focal
+ publisher: Canonical
+ sku: 20_04-lts
+ version: latest
+ tags:
+ key: value
with_sequence: start=1 end="{{ async_number_virtual_machine }}"
register: create_vms
async: 1000
poll: 0
- name: Wait for Virtual machine to be created
- async_status:
+ ansible.builtin.async_status:
jid: "{{ item.ansible_job_id }}"
register: wait_create_vm
until: wait_create_vm.finished
@@ -52,7 +52,8 @@
- key
register: _vms
-- set_fact:
+- name: Set varialbes
+ ansible.builtin.set_fact:
attach_disk_config: "{{ lookup('template', 'disk_config.j2') | from_yaml }}"
vars:
virtual_machines: "{{ _vms.vms }}"
@@ -68,7 +69,7 @@
with_items: "{{ attach_disk_config }}"
- name: Wait for disks to be created and attached
- async_status:
+ ansible.builtin.async_status:
jid: "{{ item.ansible_job_id }}"
register: attach_disk
until: attach_disk.finished
@@ -84,7 +85,7 @@
with_items: "{{ attach_disk_config | map(attribute='disks') | flatten | list }}"
- name: Validate that disks are attached to VMs
- assert:
+ ansible.builtin.assert:
that:
- result.ansible_info.azure_managed_disk[0].managed_by
with_items: "{{ disks_info.results }}"
@@ -103,7 +104,7 @@
with_items: "{{ attach_disk_config }}"
- name: Wait for disks to be created and attached
- async_status:
+ ansible.builtin.async_status:
jid: "{{ item.ansible_job_id }}"
register: attach_disk
until: attach_disk.finished
@@ -119,7 +120,7 @@
with_items: "{{ attach_disk_config | map(attribute='disks') | flatten | list }}"
- name: Validate that disks are attached to VMs
- assert:
+ ansible.builtin.assert:
that:
- not result.ansible_info.azure_managed_disk[0].managed_by
with_items: "{{ disks_info.results }}"
@@ -136,7 +137,7 @@
with_items: "{{ attach_disk_config }}"
- name: Wait for disks to be created and attached
- async_status:
+ ansible.builtin.async_status:
jid: "{{ item.ansible_job_id }}"
register: attach_disk
until: attach_disk.finished
@@ -152,7 +153,7 @@
with_items: "{{ attach_disk_config | map(attribute='disks') | flatten | list }}"
- name: Validate that disks are attached to VMs
- assert:
+ ansible.builtin.assert:
that:
- result.ansible_info.azure_managed_disk == []
with_items: "{{ disks_info.results }}"
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_multiplemanageddisks/tasks/test_shared.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_multiplemanageddisks/tasks/test_shared.yml
index 853ef8ed4..4b6e5f638 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_multiplemanageddisks/tasks/test_shared.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_multiplemanageddisks/tasks/test_shared.yml
@@ -18,7 +18,7 @@
ignore_errors: true
- name: Validate that disk creation failed
- assert:
+ ansible.builtin.assert:
that:
- result is failed
- 'result.msg == "Some required options are missing from managed disks configuration."'
@@ -33,7 +33,7 @@
register: azure_disks
- name: Ensure result is changed
- assert:
+ ansible.builtin.assert:
that:
- azure_disks is changed
- azure_disks.state | length == 2
@@ -51,12 +51,12 @@
register: create_idempotency
- name: Ensure result is not changed
- assert:
+ ansible.builtin.assert:
that:
- create_idempotency is not changed
- name: Validate that disks have been created
- assert:
+ ansible.builtin.assert:
that:
- item.name in disk_names
with_items: "{{ shared_disks }}"
@@ -81,26 +81,26 @@
- name: Create virtual machines
azure_rm_virtualmachine:
- resource_group: "{{ item.resource_group }}"
- name: "{{ item.name }}"
- vm_size: Standard_E2_v3
- virtual_network: "vnet-{{ item.name }}"
- managed_disk_type: Standard_LRS
- admin_username: adminuser
- admin_password: "!test123@"
- os_type: Linux
- image:
- offer: UbuntuServer
- publisher: Canonical
- sku: 16.04-LTS
- version: latest
+ resource_group: "{{ item.resource_group }}"
+ name: "{{ item.name }}"
+ vm_size: Standard_E2_v3
+ virtual_network: "vnet-{{ item.name }}"
+ managed_disk_type: Standard_LRS
+ admin_username: adminuser
+ admin_password: "!test123@"
+ os_type: Linux
+ image:
+ offer: 0001-com-ubuntu-server-focal
+ publisher: Canonical
+ sku: 20_04-lts
+ version: latest
with_items: "{{ shared_virtual_machines }}"
register: create_vms
async: 1000
poll: 0
- name: Wait for Virtual machine to be created
- async_status:
+ ansible.builtin.async_status:
jid: "{{ item.ansible_job_id }}"
register: wait_create_vm
until: wait_create_vm.finished
@@ -115,7 +115,8 @@
register: vm_result
with_items: "{{ shared_virtual_machines }}"
-- set_fact:
+- name: Assert the virtualmachine facts
+ ansible.builtin.set_fact:
vm_ids: "{{ vm_result.results | map(attribute='vms') | flatten | map(attribute='id') | list }}"
# Test attach disk on VMs
@@ -128,7 +129,7 @@
with_items: "{{ shared_virtual_machines }}"
- name: Ensure result is changed
- assert:
+ ansible.builtin.assert:
that:
- attach_disks is changed
- attach_disks.results | length == 2
@@ -141,7 +142,7 @@
with_items: "{{ shared_disks }}"
- name: Validate disks are attached to the VMs
- assert:
+ ansible.builtin.assert:
that:
- azure_managed_disks | length == 2
- azure_managed_disks.0.managed_by_extended | length == 2
@@ -160,7 +161,7 @@
register: attach_idempotency
- name: Ensure result is not changed
- assert:
+ ansible.builtin.assert:
that:
- attach_idempotency is not changed
@@ -169,13 +170,13 @@
azure.azcollection.azure_rm_multiplemanageddisks:
managed_disks:
- "{{ shared_disks[0] }}"
- managed_by_extended:
+ managed_by_extended:
- "{{ shared_virtual_machines[0] }}"
state: absent
register: detach_disks
- name: Ensure result is changed
- assert:
+ ansible.builtin.assert:
that:
- detach_disks is changed
@@ -187,7 +188,7 @@
with_items: "{{ shared_disks }}"
- name: Ensure disk 1 is attached to VM 1 only and disk 2 is attached to VM 1 and VM 2
- assert:
+ ansible.builtin.assert:
that:
- azure_managed_disks | length == 2
- azure_managed_disks.0.managed_by_extended | length == 1
@@ -204,20 +205,20 @@
azure.azcollection.azure_rm_multiplemanageddisks:
managed_disks:
- "{{ shared_disks[0] }}"
- managed_by_extended:
+ managed_by_extended:
- "{{ shared_virtual_machines[0] }}"
state: absent
register: detach_idempotency
- name: Ensure result is not changed
- assert:
+ ansible.builtin.assert:
that:
- detach_idempotency is not changed
# Test Detach disks from all VMs
- name: Detach disk 2 from all VMs
azure.azcollection.azure_rm_multiplemanageddisks:
- managed_disks:
+ managed_disks:
- "{{ shared_disks[1] }}"
managed_by_extended: []
state: present
@@ -230,7 +231,7 @@
register: azure_disks
- name: Ensure disk is not attached to any VM
- assert:
+ ansible.builtin.assert:
that:
- detach_from_vms is changed
- azure_disks.ansible_info.azure_managed_disk | length == 1
@@ -239,14 +240,14 @@
- name: Detach disk 2 from all VMs once again (idempotency)
azure.azcollection.azure_rm_multiplemanageddisks:
- managed_disks:
+ managed_disks:
- "{{ shared_disks[1] }}"
managed_by_extended: []
state: present
register: detach_from_vms
- name: Ensure nothing changed
- assert:
+ ansible.builtin.assert:
that:
- detach_from_vms is not changed
@@ -258,14 +259,14 @@
register: azure_disks
- name: Ensure disk is attached to at least one VM
- assert:
+ ansible.builtin.assert:
that:
- azure_disks.ansible_info.azure_managed_disk.0.managed_by
- azure_disks.ansible_info.azure_managed_disk.0.managed_by_extended | length > 0
- name: Delete managed disk attached to VM
azure.azcollection.azure_rm_multiplemanageddisks:
- managed_disks:
+ managed_disks:
- "{{ shared_disks[0] }}"
state: absent
register: delete_attached_disk
@@ -277,41 +278,41 @@
register: azure_disks
- name: Ensure disk was deleted
- assert:
+ ansible.builtin.assert:
that:
- delete_attached_disk is changed
- azure_disks.ansible_info.azure_managed_disk | length == 0
- name: Delete managed disk once again (idempotency)
azure.azcollection.azure_rm_multiplemanageddisks:
- managed_disks:
+ managed_disks:
- "{{ shared_disks[0] }}"
state: absent
register: delete_attached_disk
- name: Ensure delete idempotency
- assert:
+ ansible.builtin.assert:
that:
- delete_attached_disk is not changed
# Test managed disks deletion with managed_by_extended set to []
- name: Trying to delete managed disks with managed_by_extended set to []
azure.azcollection.azure_rm_multiplemanageddisks:
- managed_disks:
+ managed_disks:
- "{{ shared_disks[1] }}"
managed_by_extended: []
state: absent
register: delete_with_wrong_parameter
- name: Ensure disks were not deleted
- assert:
+ ansible.builtin.assert:
that:
- delete_with_wrong_parameter is not changed
# Test managed disks deletion
- name: Delete managed disks
azure.azcollection.azure_rm_multiplemanageddisks:
- managed_disks:
+ managed_disks:
- "{{ shared_disks[1] }}"
state: absent
register: delete_disk
@@ -323,19 +324,19 @@
register: azure_disks
- name: Ensure disk was deleted
- assert:
+ ansible.builtin.assert:
that:
- delete_disk is changed
- azure_disks.ansible_info.azure_managed_disk | length == 0
- name: Delete managed disks once again (idempotency)
azure.azcollection.azure_rm_multiplemanageddisks:
- managed_disks:
+ managed_disks:
- "{{ shared_disks[1] }}"
state: absent
register: delete_idempotency
- name: Ensure nothing changed
- assert:
+ ansible.builtin.assert:
that:
- delete_idempotency is not changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_mysqlserver/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_mysqlserver/tasks/main.yml
index 75475bc3b..819ebd9f7 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_mysqlserver/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_mysqlserver/tasks/main.yml
@@ -1,7 +1,7 @@
- name: Prepare random number
- set_fact:
+ ansible.builtin.set_fact:
rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
- run_once: yes
+ run_once: true
- name: Create instance of MySQL Server -- check mode
azure_rm_mysqlserver:
@@ -17,13 +17,13 @@
geo_redundant_backup: Disabled
storage_autogrow: Disabled
version: 5.7
- enforce_ssl: True
+ enforce_ssl: true
admin_username: zimxyz
admin_password: Password123!
- check_mode: yes
+ check_mode: true
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -41,12 +41,12 @@
geo_redundant_backup: Disabled
storage_autogrow: Disabled
version: 5.7
- enforce_ssl: True
+ enforce_ssl: true
admin_username: zimxyz
admin_password: Password123!
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.state == 'Ready'
@@ -65,12 +65,12 @@
geo_redundant_backup: Disabled
storage_autogrow: Disabled
version: 5.7
- enforce_ssl: True
+ enforce_ssl: true
admin_username: zimxyz
admin_password: Password123!
register: output
- name: Assert the state has not changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed == false
- output.state == 'Ready'
@@ -89,16 +89,17 @@
geo_redundant_backup: Disabled
storage_autogrow: Disabled
version: 5.7
- enforce_ssl: True
+ enforce_ssl: true
admin_username: zimxyz
admin_password: Password123!
register: output
- name: Assert the state has not changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.state == 'Ready'
-- debug:
+- name: Print the state of the mysql server
+ ansible.builtin.debug:
var: output
- name: Gather facts MySQL Server
@@ -107,7 +108,7 @@
name: mysqlsrv{{ rpfx }}
register: output
- name: Assert that storage size is correct
- assert:
+ ansible.builtin.assert:
that:
- output.servers[0]['storage_profile']['storage_mb'] == 128000
@@ -115,10 +116,10 @@
azure_rm_mysqlserver:
resource_group: "{{ resource_group }}"
name: mysqlsrv{{ rpfx }}
- restarted: True
+ restarted: true
register: output
- name: Assert the state has not changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -136,7 +137,7 @@
geo_redundant_backup: Disabled
storage_autogrow: Disabled
version: 5.7
- enforce_ssl: True
+ enforce_ssl: true
admin_username: zimxyz
admin_password: Password123!
tags:
@@ -156,7 +157,7 @@
geo_redundant_backup: Disabled
storage_autogrow: Disabled
version: 5.7
- enforce_ssl: True
+ enforce_ssl: true
admin_username: zimxyz
admin_password: Password123!
tags:
@@ -166,10 +167,10 @@
azure_rm_mysqlserver_info:
resource_group: "{{ resource_group }}"
name: mysqlsrv{{ rpfx }}second
- register: output
+ register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.servers[0]['id'] != None
@@ -189,7 +190,7 @@
resource_group: "{{ resource_group }}"
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.servers[0]['id'] != None
@@ -219,10 +220,10 @@
resource_group: "{{ resource_group }}"
server_name: mysqlsrv{{ rpfx }}
name: testdatabase
- check_mode: yes
+ check_mode: true
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -235,7 +236,7 @@
charset: latin1
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.name == 'testdatabase'
@@ -249,7 +250,7 @@
charset: latin1
register: output
- name: Assert the state has not changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed == false
- output.name == 'testdatabase'
@@ -261,10 +262,10 @@
name: testdatabase
collation: utf8_general_ci
charset: utf8
- ignore_errors: yes
+ ignore_errors: true
register: output
- name: Assert that nothing has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
@@ -275,10 +276,10 @@
name: testdatabase
collation: utf8_general_ci
charset: utf8
- force_update: yes
+ force_update: true
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.name == 'testdatabase'
@@ -294,10 +295,10 @@
resource_group: "{{ resource_group }}"
server_name: mysqlsrv{{ rpfx }}
name: testdatabase
- register: output
+ register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.databases[0]['server_name'] != None
@@ -311,7 +312,7 @@
server_name: mysqlsrv{{ rpfx }}
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.databases[0]['server_name'] != None
@@ -329,10 +330,10 @@
server_name: mysqlsrv{{ rpfx }}
name: testdatabase
state: absent
- check_mode: yes
+ check_mode: true
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -344,7 +345,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -356,7 +357,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed == false
@@ -370,10 +371,10 @@
name: firewallrule{{ rpfx }}
start_ip_address: 172.28.10.136
end_ip_address: 172.28.10.138
- check_mode: yes
+ check_mode: true
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -386,7 +387,7 @@
end_ip_address: 172.28.10.138
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -399,7 +400,7 @@
end_ip_address: 172.28.10.138
register: output
- name: Assert the state has not changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed == false
@@ -409,10 +410,10 @@
server_name: mysqlsrv{{ rpfx }}
name: firewallrule{{ rpfx }}
state: absent
- check_mode: yes
+ check_mode: true
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -425,7 +426,7 @@
end_ip_address: 172.28.10.138
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -436,7 +437,7 @@
name: firewallrule{{ rpfx }}
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.rules[0].id != None
@@ -452,7 +453,7 @@
server_name: mysqlsrv{{ rpfx }}
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.rules[0].id != None
@@ -474,7 +475,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -486,7 +487,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed == false
@@ -504,7 +505,7 @@
name: firewallrule{{ rpfx }}
register: output
- name: Assert that empty list was returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- "output.rules | length == 0"
@@ -518,10 +519,10 @@
server_name: mysqlsrv{{ rpfx }}
name: event_scheduler
value: "ON"
- check_mode: yes
+ check_mode: true
register: output
- name: Assert that change was registered
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -532,7 +533,7 @@
name: event_scheduler
register: output
- name: Get facts of event_scheduler
- debug:
+ ansible.builtin.debug:
var: output
- name: Try to delete default configuraion
@@ -543,7 +544,7 @@
state: absent
register: output
- name: Assert that change was registered
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
@@ -555,7 +556,7 @@
value: "ON"
register: output
- name: Assert that change was registered
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -567,7 +568,7 @@
value: "ON"
register: output
- name: Assert that change was registered
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
@@ -579,7 +580,7 @@
state: absent
register: output
- name: Assert that change was registered
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -591,7 +592,7 @@
state: absent
register: output
- name: Assert that change was registered
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
@@ -602,7 +603,7 @@
name: event_scheduler
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.settings[0].id != None
@@ -618,7 +619,7 @@
server_name: mysqlsrv{{ rpfx }}
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.settings[0].id != None
@@ -637,10 +638,10 @@
resource_group: "{{ resource_group }}"
name: mysqlsrv{{ rpfx }}
state: absent
- check_mode: yes
+ check_mode: true
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -651,7 +652,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -662,7 +663,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed == false
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_natgateway/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_natgateway/tasks/main.yml
index b411d2422..d950304eb 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_natgateway/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_natgateway/tasks/main.yml
@@ -1,9 +1,9 @@
- name: Prepare random number
- set_fact:
+ ansible.builtin.set_fact:
rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
run_once: true
- name: Set json query to only retrieve gateways from this test
- set_fact:
+ ansible.builtin.set_fact:
query: "[?ends_with(name, `{{ rpfx }}`)]"
run_once: true
@@ -12,7 +12,7 @@
name: "{{ resource_group }}"
register: rg_output
- name: Store rg location
- set_fact:
+ ansible.builtin.set_fact:
rg_location: "{{ rg_output.resourcegroups[0].location }}"
run_once: true
@@ -21,7 +21,7 @@
resource_group: "{{ resource_group }}"
register: natgw_output
- name: Assert there are no gateways
- assert:
+ ansible.builtin.assert:
that:
- natgw_output.gateways | community.general.json_query(query) | length == 0
@@ -30,9 +30,9 @@
resource_group: "{{ resource_group }}"
name: nat-gateway{{ rpfx }}1
register: output
- check_mode: yes
+ check_mode: true
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -41,7 +41,7 @@
resource_group: "{{ resource_group }}"
register: natgw_output
- name: Assert there are still no gateways
- assert:
+ ansible.builtin.assert:
that:
- natgw_output.gateways | community.general.json_query(query) | length == 0
@@ -51,7 +51,7 @@
name: nat-gateway{{ rpfx }}1
register: natgw_output
- name: Assert that gateway is well created
- assert:
+ ansible.builtin.assert:
that:
- natgw_output.changed
- natgw_output.resource_group == "{{ resource_group }}"
@@ -63,7 +63,7 @@
resource_group: "{{ resource_group }}"
register: natgw_output
- name: Assert that gateway has the right default parameters
- assert:
+ ansible.builtin.assert:
that:
- natgw_output.gateways[0].idle_timeout_in_minutes == 4
@@ -73,7 +73,7 @@
name: nat-gateway{{ rpfx }}1
register: output
- name: Assert the resource instance is not changed
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
@@ -84,7 +84,7 @@
idle_timeout_in_minutes: 10
register: natgw_output
- name: Assert the resource instance is changed
- assert:
+ ansible.builtin.assert:
that:
- natgw_output.changed
- natgw_output.location == "{{ rg_location }}"
@@ -94,7 +94,7 @@
resource_group: "{{ resource_group }}"
register: natgw_output
- name: Assert that gateway has the right parameters
- assert:
+ ansible.builtin.assert:
that:
- natgw_output.gateways[0].idle_timeout_in_minutes == 10
@@ -107,7 +107,7 @@
idle_timeout_in_minutes: 10
register: output
- name: Assert the resource instance is not changed
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
@@ -142,7 +142,7 @@
- "nat-gateway{{ rpfx }}-pip2"
register: natgw_output
- name: Assert the resource instance is changed
- assert:
+ ansible.builtin.assert:
that:
- natgw_output.changed
- name: Get NAT gateways
@@ -151,7 +151,7 @@
resource_group: "{{ resource_group }}"
register: natgw_output
- name: Assert that gateway has the right parameters
- assert:
+ ansible.builtin.assert:
that:
- natgw_output.gateways[0].public_ip_addresses | length == 2
@@ -166,7 +166,7 @@
- "nat-gateway{{ rpfx }}-pip2"
register: natgw_output
- name: Assert the resource instance is changed
- assert:
+ ansible.builtin.assert:
that:
- natgw_output.changed
- name: Get NAT gateways
@@ -175,7 +175,7 @@
resource_group: "{{ resource_group }}"
register: natgw_output
- name: Assert that gateway has the right parameters
- assert:
+ ansible.builtin.assert:
that:
- natgw_output.gateways[0].public_ip_addresses | length == 1
@@ -189,7 +189,7 @@
name: standard
register: natgw_output
- name: Assert the resource instance is changed
- assert:
+ ansible.builtin.assert:
that:
- natgw_output.changed
- name: Get NAT gateways
@@ -198,7 +198,7 @@
resource_group: "{{ resource_group }}"
register: natgw_output
- name: Assert that gateway has the right parameters
- assert:
+ ansible.builtin.assert:
that:
- natgw_output.gateways[0].public_ip_addresses == None
@@ -231,7 +231,7 @@
resource_group: "{{ resource_group }}"
register: output
- name: Assert the NAT Gateway is associated
- assert:
+ ansible.builtin.assert:
that:
- output.subnets[0].nat_gateway == "{{ natgw_output.gateways[0].id }}"
@@ -254,7 +254,7 @@
resource_group: "{{ resource_group }}"
register: output
- name: Assert the NAT Gateway is not associated
- assert:
+ ansible.builtin.assert:
that:
- output.subnets[0].nat_gateway == "{{ natgw_output3.id }}"
@@ -271,7 +271,7 @@
resource_group: "{{ resource_group }}"
register: output
- name: Assert the NAT Gateway is not associated
- assert:
+ ansible.builtin.assert:
that:
- output.subnets[0].nat_gateway == None
@@ -282,12 +282,12 @@
name: nat-gateway{{ rpfx }}2
idle_timeout_in_minutes: 10
location: eastus
- zones: [ 1 ]
+ zones: [1]
sku:
name: standard
register: natgw_output
- name: Assert the resource instance is changed
- assert:
+ ansible.builtin.assert:
that:
- natgw_output.changed
- natgw_output.location == "eastus"
@@ -297,7 +297,7 @@
resource_group: "{{ resource_group }}"
register: natgw_output
- name: Assert that gateway has the right parameters
- assert:
+ ansible.builtin.assert:
that:
- natgw_output.gateways[0].idle_timeout_in_minutes == 10
- natgw_output.gateways[0].zones[0] == "1"
@@ -310,9 +310,9 @@
state: absent
register: output
with_items:
- - 1
- - 2
- - 3
+ - 1
+ - 2
+ - 3
- name: Remove subnet
azure_rm_subnet:
@@ -332,15 +332,15 @@
resource_group: "{{ resource_group }}"
register: natgw_output
- name: Assert there are no gateways left
- assert:
+ ansible.builtin.assert:
that:
- natgw_output.gateways | community.general.json_query(query) | length == 0
- name: Delete public IPs for NAT Gateway
azure_rm_publicipaddress:
- resource_group: "{{ resource_group }}"
- name: "nat-gateway{{ rpfx }}-pip{{ item }}"
- state: absent
+ resource_group: "{{ resource_group }}"
+ name: "nat-gateway{{ rpfx }}-pip{{ item }}"
+ state: absent
with_items:
- - 1
- - 2
+ - 1
+ - 2
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_networkinterface/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_networkinterface/tasks/main.yml
index 7e38fc7ee..e47906d72 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_networkinterface/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_networkinterface/tasks/main.yml
@@ -1,24 +1,24 @@
- name: Prepare random number
- set_fact:
+ ansible.builtin.set_fact:
rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
applicationsecuritygroup_name1: "asg{{ resource_group | hash('md5') | truncate(5, True, '') }}{{ 1000 | random }}"
applicationsecuritygroup_name2: "asg{{ resource_group | hash('md5') | truncate(5, True, '') }}{{ 1000 | random }}"
nic_name1: "nic1{{ resource_group | hash('md5') | truncate(5, True, '') }}{{ 1000 | random }}"
- run_once: yes
+ run_once: true
- name: Create virtual network
azure_rm_virtualnetwork:
- resource_group: "{{ resource_group_secondary }}"
- name: "tn{{ rpfx }}"
- address_prefixes: ["10.10.0.0/16", "fdae:f296:2787::/48"]
+ resource_group: "{{ resource_group_secondary }}"
+ name: "tn{{ rpfx }}"
+ address_prefixes: ["10.10.0.0/16", "fdae:f296:2787::/48"]
register: vn
- name: Add subnet
azure_rm_subnet:
- resource_group: "{{ resource_group_secondary }}"
- name: "tn{{ rpfx }}"
- address_prefixes_cidr: ["10.10.0.0/24", "fdae:f296:2787::/64"]
- virtual_network: "tn{{ rpfx }}"
+ resource_group: "{{ resource_group_secondary }}"
+ name: "tn{{ rpfx }}"
+ address_prefixes_cidr: ["10.10.0.0/24", "fdae:f296:2787::/64"]
+ virtual_network: "tn{{ rpfx }}"
- name: Create public IP addresses
azure_rm_publicipaddress:
@@ -37,7 +37,7 @@
- name: 'tn{{ rpfx }}v6'
version: 'ipv6'
-- name: create load balancer with multiple parameters
+- name: Create load balancer with multiple parameters
azure_rm_loadbalancer:
resource_group: '{{ resource_group }}'
name: "lb{{ rpfx }}"
@@ -84,32 +84,34 @@
- name: Create most simple NIC with virtual_network id (check mode)
azure_rm_networkinterface:
- resource_group: "{{ resource_group }}"
- name: "tn{{ rpfx }}"
- virtual_network: "{{ vn.state.id }}"
- subnet: "tn{{ rpfx }}"
- public_ip: False
- create_with_security_group: False
+ resource_group: "{{ resource_group }}"
+ name: "tn{{ rpfx }}"
+ virtual_network: "{{ vn.state.id }}"
+ subnet: "tn{{ rpfx }}"
+ public_ip: false
+ create_with_security_group: false
register: output
- check_mode: yes
+ check_mode: true
-- assert:
+- name: Assert the check mode facts
+ ansible.builtin.assert:
that:
- output.changed
- name: Create most simple NIC with virtual_network resource_group
azure_rm_networkinterface:
- resource_group: "{{ resource_group }}"
+ resource_group: "{{ resource_group }}"
+ name: "tn{{ rpfx }}"
+ virtual_network:
name: "tn{{ rpfx }}"
- virtual_network:
- name: "tn{{ rpfx }}"
- resource_group: "{{ resource_group_secondary }}"
- subnet: "tn{{ rpfx }}"
- public_ip: False
- create_with_security_group: False
+ resource_group: "{{ resource_group_secondary }}"
+ subnet: "tn{{ rpfx }}"
+ public_ip: false
+ create_with_security_group: false
register: output
-- assert:
+- name: Assert the NIC created
+ ansible.builtin.assert:
that:
- output.changed
- output.state.id
@@ -121,7 +123,8 @@
name: "tn{{ rpfx }}"
register: facts
-- assert:
+- name: Assert the NIC facts
+ ansible.builtin.assert:
that:
- "facts.networkinterfaces | length == 1"
- facts.networkinterfaces[0].id == output.state.id
@@ -134,149 +137,157 @@
- name: Create most simple NIC with ip configurations (idempotent)
azure_rm_networkinterface:
- resource_group: "{{ facts.networkinterfaces[0].resource_group }}"
- name: "{{ facts.networkinterfaces[0].name }}"
- virtual_network: "{{ facts.networkinterfaces[0].virtual_network }}"
- create_with_security_group: False
- ip_configurations:
- - name: "{{ facts.networkinterfaces[0].ip_configurations[0].name }}"
- private_ip_address: "{{ facts.networkinterfaces[0].ip_configurations[0].private_ip_address }}"
- private_ip_allocation_method: "{{ facts.networkinterfaces[0].ip_configurations[0].private_ip_allocation_method }}"
- primary: "{{ facts.networkinterfaces[0].ip_configurations[0].primary }}"
- subnet: "{{ facts.networkinterfaces[0].subnet }}"
+ resource_group: "{{ facts.networkinterfaces[0].resource_group }}"
+ name: "{{ facts.networkinterfaces[0].name }}"
+ virtual_network: "{{ facts.networkinterfaces[0].virtual_network }}"
+ create_with_security_group: false
+ ip_configurations:
+ - name: "{{ facts.networkinterfaces[0].ip_configurations[0].name }}"
+ private_ip_address: "{{ facts.networkinterfaces[0].ip_configurations[0].private_ip_address }}"
+ private_ip_allocation_method: "{{ facts.networkinterfaces[0].ip_configurations[0].private_ip_allocation_method }}"
+ primary: "{{ facts.networkinterfaces[0].ip_configurations[0].primary }}"
+ subnet: "{{ facts.networkinterfaces[0].subnet }}"
register: output
-- assert:
+- name: Assert the NIC created
+ ansible.builtin.assert:
that:
- not output.changed
- name: Create most simple NIC (idempotent)
azure_rm_networkinterface:
- resource_group: "{{ resource_group }}"
- name: "tn{{ rpfx }}"
- virtual_network: "{{ vn.state.id }}"
- subnet: "tn{{ rpfx }}"
- create_with_security_group: False
- public_ip: False
+ resource_group: "{{ resource_group }}"
+ name: "tn{{ rpfx }}"
+ virtual_network: "{{ vn.state.id }}"
+ subnet: "tn{{ rpfx }}"
+ create_with_security_group: false
+ public_ip: false
register: output
-- assert:
+- name: Assert NIC created
+ ansible.builtin.assert:
that:
- not output.changed
- name: Update security group (check mode)
azure_rm_networkinterface:
- resource_group: "{{ resource_group }}"
- name: "tn{{ rpfx }}"
- virtual_network: "{{ vn.state.id }}"
- subnet: "tn{{ rpfx }}"
- public_ip: False
- security_group: "tn{{ rpfx }}sg"
+ resource_group: "{{ resource_group }}"
+ name: "tn{{ rpfx }}"
+ virtual_network: "{{ vn.state.id }}"
+ subnet: "tn{{ rpfx }}"
+ public_ip: false
+ security_group: "tn{{ rpfx }}sg"
register: output
- check_mode: yes
+ check_mode: true
-- assert:
+- name: Assert the security group check mode
+ ansible.builtin.assert:
that:
- output.changed
- name: Update public ip address (check mode)
azure_rm_networkinterface:
- resource_group: "{{ resource_group }}"
- name: "tn{{ rpfx }}"
- virtual_network: "{{ vn.state.id }}"
- subnet: "tn{{ rpfx }}"
- public_ip_address_name: "tn{{ rpfx }}"
- create_with_security_group: False
+ resource_group: "{{ resource_group }}"
+ name: "tn{{ rpfx }}"
+ virtual_network: "{{ vn.state.id }}"
+ subnet: "tn{{ rpfx }}"
+ public_ip_address_name: "tn{{ rpfx }}"
+ create_with_security_group: false
register: output
- check_mode: yes
+ check_mode: true
-- assert:
+- name: Assert the public ip check mode
+ ansible.builtin.assert:
that:
- output.changed
- name: Update accelerated networking (check mode)
azure_rm_networkinterface:
- resource_group: "{{ resource_group }}"
- name: "tn{{ rpfx }}"
- virtual_network: "{{ vn.state.id }}"
- subnet: "tn{{ rpfx }}"
- enable_accelerated_networking: True
- create_with_security_group: False
- public_ip: False
+ resource_group: "{{ resource_group }}"
+ name: "tn{{ rpfx }}"
+ virtual_network: "{{ vn.state.id }}"
+ subnet: "tn{{ rpfx }}"
+ enable_accelerated_networking: true
+ create_with_security_group: false
+ public_ip: false
register: output
- check_mode: yes
+ check_mode: true
-- assert:
+- name: Assert the network check mode facts
+ ansible.builtin.assert:
that:
- output.changed
- name: Update IP forwarding networking (check mode)
azure_rm_networkinterface:
- resource_group: "{{ resource_group }}"
- name: "tn{{ rpfx }}"
- virtual_network: "{{ vn.state.id }}"
- subnet: "tn{{ rpfx }}"
- create_with_security_group: False
- enable_ip_forwarding: True
- public_ip: False
+ resource_group: "{{ resource_group }}"
+ name: "tn{{ rpfx }}"
+ virtual_network: "{{ vn.state.id }}"
+ subnet: "tn{{ rpfx }}"
+ create_with_security_group: false
+ enable_ip_forwarding: true
+ public_ip: false
register: output
- check_mode: yes
+ check_mode: true
-- assert:
+- name: Assert the NIC check mode facts
+ ansible.builtin.assert:
that:
- output.changed
- name: Update dns server (check mode)
azure_rm_networkinterface:
- resource_group: "{{ resource_group }}"
- name: "tn{{ rpfx }}"
- virtual_network: "{{ vn.state.id }}"
- subnet: "tn{{ rpfx }}"
- create_with_security_group: False
- public_ip: False
- dns_servers:
- - 8.9.10.11
- - 7.8.9.10
+ resource_group: "{{ resource_group }}"
+ name: "tn{{ rpfx }}"
+ virtual_network: "{{ vn.state.id }}"
+ subnet: "tn{{ rpfx }}"
+ create_with_security_group: false
+ public_ip: false
+ dns_servers:
+ - 8.9.10.11
+ - 7.8.9.10
register: output
- check_mode: yes
+ check_mode: true
-- assert:
+- name: Assert the NIC check mode facts
+ ansible.builtin.assert:
that:
- output.changed
- name: Update NIC
azure_rm_networkinterface:
- resource_group: "{{ resource_group }}"
- name: "tn{{ rpfx }}"
- virtual_network: "{{ vn.state.id }}"
- subnet: "tn{{ rpfx }}"
- enable_accelerated_networking: True
- enable_ip_forwarding: True
- security_group: "tn{{ rpfx }}sg"
- dns_servers:
- - 8.9.10.11
- - 7.8.9.10
- ip_configurations:
- - name: "{{ facts.networkinterfaces[0].ip_configurations[0].name }}"
- private_ip_address: "{{ facts.networkinterfaces[0].ip_configurations[0].private_ip_address }}"
- private_ip_allocation_method: "{{ facts.networkinterfaces[0].ip_configurations[0].private_ip_allocation_method }}"
- primary: "{{ facts.networkinterfaces[0].ip_configurations[0].primary }}"
- - name: ipconfig1
- public_ip_name: "tn{{ rpfx }}"
- load_balancer_backend_address_pools:
- - "{{ lb.state.backend_address_pools[0].id }}"
- - name: backendaddrpool1
- load_balancer: "lb{{ rpfx }}"
- - name: ipconfig2
- public_ip_name: "tn{{ rpfx }}v6"
- private_ip_address_version: 'IPv6'
- load_balancer_backend_address_pools:
- - "{{ lb.state.backend_address_pools[2].id }}"
- - name: backendaddrpool2
- load_balancer: "lb{{ rpfx }}"
- register: output
-
-- assert:
+ resource_group: "{{ resource_group }}"
+ name: "tn{{ rpfx }}"
+ virtual_network: "{{ vn.state.id }}"
+ subnet: "tn{{ rpfx }}"
+ enable_accelerated_networking: true
+ enable_ip_forwarding: true
+ security_group: "tn{{ rpfx }}sg"
+ dns_servers:
+ - 8.9.10.11
+ - 7.8.9.10
+ ip_configurations:
+ - name: "{{ facts.networkinterfaces[0].ip_configurations[0].name }}"
+ private_ip_address: "{{ facts.networkinterfaces[0].ip_configurations[0].private_ip_address }}"
+ private_ip_allocation_method: "{{ facts.networkinterfaces[0].ip_configurations[0].private_ip_allocation_method }}"
+ primary: "{{ facts.networkinterfaces[0].ip_configurations[0].primary }}"
+ - name: ipconfig1
+ public_ip_name: "tn{{ rpfx }}"
+ load_balancer_backend_address_pools:
+ - "{{ lb.state.backend_address_pools[0].id }}"
+ - name: backendaddrpool1
+ load_balancer: "lb{{ rpfx }}"
+ - name: ipconfig2
+ public_ip_name: "tn{{ rpfx }}v6"
+ private_ip_address_version: 'IPv6'
+ load_balancer_backend_address_pools:
+ - "{{ lb.state.backend_address_pools[2].id }}"
+ - name: backendaddrpool2
+ load_balancer: "lb{{ rpfx }}"
+ register: output
+
+- name: Assert NIC update facts
+ ansible.builtin.assert:
that:
- output.changed
- output.state.dns_settings.dns_servers == ['8.9.10.11', '7.8.9.10']
@@ -286,37 +297,38 @@
- name: Complicated NIC (idempontent)
azure_rm_networkinterface:
- resource_group: "{{ resource_group }}"
- name: "tn{{ rpfx }}"
- virtual_network: "{{ vn.state.id }}"
- subnet: "tn{{ rpfx }}"
- enable_accelerated_networking: True
- security_group: "tn{{ rpfx }}sg"
- enable_ip_forwarding: True
- dns_servers:
- - 8.9.10.11
- - 7.8.9.10
- ip_configurations:
- - name: "{{ facts.networkinterfaces[0].ip_configurations[0].name }}"
- private_ip_address: "{{ facts.networkinterfaces[0].ip_configurations[0].private_ip_address }}"
- private_ip_allocation_method: "{{ facts.networkinterfaces[0].ip_configurations[0].private_ip_allocation_method }}"
- primary: "{{ facts.networkinterfaces[0].ip_configurations[0].primary }}"
- - name: ipconfig1
- public_ip_name: "tn{{ rpfx }}"
- load_balancer_backend_address_pools:
- - "{{ lb.state.backend_address_pools[0].id }}"
- - name: backendaddrpool1
- load_balancer: "lb{{ rpfx }}"
- - name: ipconfig2
- public_ip_name: "tn{{ rpfx }}v6"
- private_ip_address_version: 'IPv6'
- load_balancer_backend_address_pools:
- - "{{ lb.state.backend_address_pools[2].id }}"
- - name: backendaddrpool2
- load_balancer: "lb{{ rpfx }}"
- register: output
-
-- assert:
+ resource_group: "{{ resource_group }}"
+ name: "tn{{ rpfx }}"
+ virtual_network: "{{ vn.state.id }}"
+ subnet: "tn{{ rpfx }}"
+ enable_accelerated_networking: true
+ security_group: "tn{{ rpfx }}sg"
+ enable_ip_forwarding: true
+ dns_servers:
+ - 8.9.10.11
+ - 7.8.9.10
+ ip_configurations:
+ - name: "{{ facts.networkinterfaces[0].ip_configurations[0].name }}"
+ private_ip_address: "{{ facts.networkinterfaces[0].ip_configurations[0].private_ip_address }}"
+ private_ip_allocation_method: "{{ facts.networkinterfaces[0].ip_configurations[0].private_ip_allocation_method }}"
+ primary: "{{ facts.networkinterfaces[0].ip_configurations[0].primary }}"
+ - name: ipconfig1
+ public_ip_name: "tn{{ rpfx }}"
+ load_balancer_backend_address_pools:
+ - "{{ lb.state.backend_address_pools[0].id }}"
+ - name: backendaddrpool1
+ load_balancer: "lb{{ rpfx }}"
+ - name: ipconfig2
+ public_ip_name: "tn{{ rpfx }}v6"
+ private_ip_address_version: 'IPv6'
+ load_balancer_backend_address_pools:
+ - "{{ lb.state.backend_address_pools[2].id }}"
+ - name: backendaddrpool2
+ load_balancer: "lb{{ rpfx }}"
+ register: output
+
+- name: Assert the NIC no change
+ ansible.builtin.assert:
that:
- not output.changed
@@ -324,9 +336,10 @@
azure_rm_networkinterface_info:
resource_group: "{{ resource_group }}"
name: "tn{{ rpfx }}"
- register: facts
+ register: facts
-- assert:
+- name: Assert the NIC facts
+ ansible.builtin.assert:
that:
- "facts.networkinterfaces | length == 1"
- facts.networkinterfaces[0].id == output.state.id
@@ -339,26 +352,27 @@
- name: Remove one dns server and ip configuration
azure_rm_networkinterface:
- resource_group: "{{ resource_group }}"
- name: "tn{{ rpfx }}"
- virtual_network: "{{ vn.state.id }}"
- subnet: "tn{{ rpfx }}"
- security_group: "tn{{ rpfx }}sg"
- enable_accelerated_networking: True
- enable_ip_forwarding: True
- dns_servers:
- - 8.9.10.11
- ip_configurations:
- - name: ipconfig1
- public_ip_name: "tn{{ rpfx }}"
- primary: True
- load_balancer_backend_address_pools:
- - "{{ lb.state.backend_address_pools[0].id }}"
- - name: backendaddrpool1
- load_balancer: "lb{{ rpfx }}"
- register: output
-
-- assert:
+ resource_group: "{{ resource_group }}"
+ name: "tn{{ rpfx }}"
+ virtual_network: "{{ vn.state.id }}"
+ subnet: "tn{{ rpfx }}"
+ security_group: "tn{{ rpfx }}sg"
+ enable_accelerated_networking: true
+ enable_ip_forwarding: true
+ dns_servers:
+ - 8.9.10.11
+ ip_configurations:
+ - name: ipconfig1
+ public_ip_name: "tn{{ rpfx }}"
+ primary: true
+ load_balancer_backend_address_pools:
+ - "{{ lb.state.backend_address_pools[0].id }}"
+ - name: backendaddrpool1
+ load_balancer: "lb{{ rpfx }}"
+ register: output
+
+- name: Assert the NIC changed
+ ansible.builtin.assert:
that:
- output.changed
- output.state.dns_settings.dns_servers == ['8.9.10.11']
@@ -370,15 +384,15 @@
- name: Create application security group(check mode)
azure_rm_applicationsecuritygroup:
- resource_group: "{{ resource_group }}"
- name: "{{ applicationsecuritygroup_name1 }}"
- tags:
- testing: testing
- check_mode: yes
+ resource_group: "{{ resource_group }}"
+ name: "{{ applicationsecuritygroup_name1 }}"
+ tags:
+ testing: testing
+ check_mode: true
register: output
- name: Assert check mode creation
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -387,11 +401,11 @@
resource_group: "{{ resource_group }}"
name: "{{ applicationsecuritygroup_name1 }}"
tags:
- testing: testing
+ testing: testing
register: output
- name: Assert application security group creation
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.id != ''
@@ -403,7 +417,7 @@
register: facts
- name: Assert facts
- assert:
+ ansible.builtin.assert:
that:
- facts['applicationsecuritygroups'] | length == 1
- facts['applicationsecuritygroups'][0]['name'] != None
@@ -412,28 +426,28 @@
- name: Create application security group (idempotent)
azure_rm_applicationsecuritygroup:
- resource_group: "{{ resource_group }}"
- name: "{{ applicationsecuritygroup_name1 }}"
- tags:
- testing: testing
+ resource_group: "{{ resource_group }}"
+ name: "{{ applicationsecuritygroup_name1 }}"
+ tags:
+ testing: testing
register: output
- name: Assert idempotent
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
- name: Update application security group
azure_rm_applicationsecuritygroup:
- resource_group: "{{ resource_group }}"
- name: "{{ applicationsecuritygroup_name1 }}"
- tags:
- testing: testing
- foo: bar
+ resource_group: "{{ resource_group }}"
+ name: "{{ applicationsecuritygroup_name1 }}"
+ tags:
+ testing: testing
+ foo: bar
register: output
- name: Assert update
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -449,18 +463,18 @@
name: "{{ nic_name1 }}"
virtual_network: "{{ vn.state.id }}"
subnet: "tn{{ rpfx }}"
- create_with_security_group: True
- public_ip: False
+ create_with_security_group: true
+ public_ip: false
ip_configurations:
- name: ipconfig1
application_security_groups:
- "{{ applicationsecuritygroup_name1 }}"
- "{{ asg.id }}"
- primary: True
+ primary: true
register: output
-- name: assert creation succeeded
- assert:
+- name: Assert creation succeeded
+ ansible.builtin.assert:
that:
- output.changed
@@ -470,18 +484,18 @@
name: "{{ nic_name1 }}"
virtual_network: "{{ vn.state.id }}"
subnet: "tn{{ rpfx }}"
- create_with_security_group: True
- public_ip: False
+ create_with_security_group: true
+ public_ip: false
ip_configurations:
- name: ipconfig1
application_security_groups:
- "{{ asg.id }}"
- "{{ applicationsecuritygroup_name1 }}"
- primary: True
+ primary: true
register: output
-- name: assert idempotent
- assert:
+- name: Assert idempotent
+ ansible.builtin.assert:
that:
- not output.changed
@@ -491,17 +505,17 @@
name: "{{ nic_name1 }}"
virtual_network: "{{ vn.state.id }}"
subnet: "tn{{ rpfx }}"
- create_with_security_group: True
- public_ip: False
+ create_with_security_group: true
+ public_ip: false
ip_configurations:
- name: ipconfig1
application_security_groups:
- "{{ applicationsecuritygroup_name1 }}"
- primary: True
+ primary: true
register: output
-- name: assert update succeeded
- assert:
+- name: Assert update succeeded
+ ansible.builtin.assert:
that:
- output.changed
@@ -511,7 +525,8 @@
name: "{{ nic_name1 }}"
register: facts
-- assert:
+- name: Assert the NIC created
+ ansible.builtin.assert:
that:
- "facts.networkinterfaces[0].ip_configurations[0].application_security_groups | length == 1"
@@ -523,22 +538,29 @@
address_prefix_cidr: 10.10.1.0/24
register: appgw_subnet_output
+- name: Create public IP addresses
+ azure_rm_publicipaddress:
+ name: my-appgw-pip
+ resource_group: "{{ resource_group_secondary }}"
+ sku: 'standard'
+ allocation_method: 'static'
+ version: 'ipv4'
+
- name: Create application gateway to connect NIC to
azure_rm_appgateway:
resource_group: "{{ resource_group_secondary }}"
name: "appgateway{{ rpfx }}"
sku:
- name: standard_small
- tier: standard
+ name: standard_v2
+ tier: standard_v2
capacity: 2
gateway_ip_configurations:
- subnet:
id: "{{ appgw_subnet_output.state.id }}"
name: app_gateway_ip_config
frontend_ip_configurations:
- - subnet:
- id: "{{ appgw_subnet_output.state.id }}"
- name: sample_gateway_frontend_ip_config
+ - name: sample_gateway_frontend_ip_config
+ public_ip_address: my-appgw-pip
frontend_ports:
- port: 80
name: http_frontend_port
@@ -555,7 +577,7 @@
protocol: http
name: http_listener
request_routing_rules:
- - rule_type: Basic
+ - rule_type: basic
backend_address_pool: test_backend_address_pool
backend_http_settings: sample_appgateway_http_settings
http_listener: http_listener
@@ -584,7 +606,8 @@
- name: "test_backend_address_pool"
application_gateway: "appgateway{{ rpfx }}"
register: output
-- assert:
+- name: Assert the NIC created
+ ansible.builtin.assert:
that:
- output.changed
- output.state.ip_configurations | length == 1
@@ -606,7 +629,8 @@
- name: "test_backend_address_pool"
application_gateway: "appgateway{{ rpfx }}"
register: output
-- assert:
+- name: Assert the NIC idempotent
+ ansible.builtin.assert:
that:
- not output.changed
@@ -615,7 +639,8 @@
name: "appgw-nic{{ rpfx }}"
resource_group: "{{ resource_group_secondary }}"
register: facts
-- assert:
+- name: Assert the NIC facts
+ ansible.builtin.assert:
that:
- facts.networkinterfaces | length == 1
- facts.networkinterfaces[0].id == output.state.id
@@ -629,7 +654,8 @@
resource_group: "{{ resource_group_secondary }}"
state: absent
register: output
-- assert:
+- name: Assert the NIC deleted
+ ansible.builtin.assert:
that:
- output.changed
@@ -639,51 +665,55 @@
resource_group: "{{ resource_group_secondary }}"
state: absent
register: output
-- assert:
+- name: Assert the application gateway deleted
+ ansible.builtin.assert:
that:
- output.changed
- name: Delete the NIC (check mode)
azure_rm_networkinterface:
- resource_group: "{{ resource_group }}"
- name: "tn{{ rpfx }}"
- state: absent
- check_mode: yes
+ resource_group: "{{ resource_group }}"
+ name: "tn{{ rpfx }}"
+ state: absent
+ check_mode: true
register: output
-- assert:
+- name: Assert the NIC check mode
+ ansible.builtin.assert:
that:
- output.changed
- name: Delete the NIC
azure_rm_networkinterface:
- resource_group: "{{ resource_group }}"
- name: "tn{{ rpfx }}"
- state: absent
+ resource_group: "{{ resource_group }}"
+ name: "tn{{ rpfx }}"
+ state: absent
register: output
-- assert:
+- name: Assert the NIC deleted
+ ansible.builtin.assert:
that:
- output.changed
- name: Delete the NIC (idempotent)
azure_rm_networkinterface:
- resource_group: "{{ resource_group }}"
- name: "tn{{ rpfx }}"
- state: absent
+ resource_group: "{{ resource_group }}"
+ name: "tn{{ rpfx }}"
+ state: absent
register: output
-- assert:
+- name: Assert the NIC idempotent
+ ansible.builtin.assert:
that:
- not output.changed
-- name: delete load balancer
+- name: Delete load balancer
azure_rm_loadbalancer:
resource_group: '{{ resource_group }}'
name: "lb{{ rpfx }}"
state: absent
-- name: delete public ip addresses
+- name: Delete public ip addresses
azure_rm_publicipaddress:
name: "{{ item }}"
resource_group: '{{ resource_group }}'
@@ -695,47 +725,48 @@
- 'tn{{ rpfx }}'
- 'tn{{ rpfx }}v6'
-- assert:
+- name: Assert the NIC deleted
+ ansible.builtin.assert:
that:
- output.changed
- output.results | length == 4
- name: Delete the NIC
azure_rm_networkinterface:
- resource_group: "{{ resource_group }}"
- name: "{{ nic_name1 }}"
- state: absent
+ resource_group: "{{ resource_group }}"
+ name: "{{ nic_name1 }}"
+ state: absent
- name: Delete the application security group (check mode)
azure_rm_applicationsecuritygroup:
- resource_group: "{{ resource_group }}"
- name: "{{ applicationsecuritygroup_name1 }}"
- state: absent
- check_mode: yes
+ resource_group: "{{ resource_group }}"
+ name: "{{ applicationsecuritygroup_name1 }}"
+ state: absent
+ check_mode: true
register: output
- name: Assert delete check mode
- assert:
- that:
- - output.changed
+ ansible.builtin.assert:
+ that:
+ - output.changed
- name: Delete the application security group
azure_rm_applicationsecuritygroup:
- resource_group: "{{ resource_group }}"
- name: "{{ applicationsecuritygroup_name1 }}"
- state: absent
+ resource_group: "{{ resource_group }}"
+ name: "{{ applicationsecuritygroup_name1 }}"
+ state: absent
register: output
- name: Assert the deletion
- assert:
- that:
- - output.changed
+ ansible.builtin.assert:
+ that:
+ - output.changed
- name: Delete second application security group
azure_rm_applicationsecuritygroup:
- resource_group: "{{ resource_group_secondary }}"
- name: "{{ applicationsecuritygroup_name2 }}"
- state: absent
+ resource_group: "{{ resource_group_secondary }}"
+ name: "{{ applicationsecuritygroup_name2 }}"
+ state: absent
register: output
- name: Delete network security groups
@@ -748,7 +779,8 @@
- '{{ nic_name1 }}'
- 'tn{{ rpfx }}sg'
-- assert:
+- name: Assert the security group deleted
+ ansible.builtin.assert:
that:
- output.changed
- output.results | length == 2
@@ -760,6 +792,7 @@
state: 'absent'
register: output
-- assert:
+- name: Assert the virtual network deleted
+ ansible.builtin.assert:
that:
- output.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_notificationhub/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_notificationhub/tasks/main.yml
index ed79aff83..7d734b077 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_notificationhub/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_notificationhub/tasks/main.yml
@@ -1,7 +1,7 @@
- name: Create random notification hub and namespace
- set_fact:
- namespace_name: "test{{ resource_group | hash('md5') | truncate(16, True, '') + (65535 | random | string) }}"
- name: "test{{ resource_group | hash('md5') | truncate(16, True, '') + (65535 | random | string) }}"
+ ansible.builtin.set_fact:
+ namespace_name: "test{{ resource_group | hash('md5') | truncate(16, True, '') + (65535 | random | string) }}"
+ name_rpfx: "test{{ resource_group | hash('md5') | truncate(16, True, '') + (65535 | random | string) }}"
- name: Create Notification Hub Namespace (check mode)
azure_rm_notificationhub:
@@ -9,23 +9,25 @@
namespace_name: "{{ namespace_name }}"
resource_group: "{{ resource_group }}"
sku: "free"
- check_mode: yes
+ check_mode: true
register: results
-- assert:
+- name: Assert the notification hub check mode
+ ansible.builtin.assert:
that: results.changed
- name: Create Notification Hub (check mode)
azure_rm_notificationhub:
location: eastus2
namespace_name: "{{ namespace_name }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
resource_group: "{{ resource_group }}"
sku: "free"
- check_mode: yes
+ check_mode: true
register: results
-- assert:
+- name: Assert the notfication hub check mode
+ ansible.builtin.assert:
that: results.changed
- name: Create Namespace Hub
@@ -36,19 +38,21 @@
sku: "free"
register: results
-- assert:
+- name: Assert the notification hub created
+ ansible.builtin.assert:
that: results.changed
- name: Create Notification Hub
azure_rm_notificationhub:
location: eastus2
namespace_name: "{{ namespace_name }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
resource_group: "{{ resource_group }}"
sku: "free"
register: results
-- assert:
+- name: Assert the notification hub created
+ ansible.builtin.assert:
that: results.changed
- name: Update Namespace
@@ -60,24 +64,25 @@
test: modified
register: results
-- assert:
- that:
+- name: Assert the namespace updated
+ ansible.builtin.assert:
+ that:
- results.changed
- results.state.tags.test == 'modified'
-
- name: Update Notification Hub
azure_rm_notificationhub:
location: eastus2
namespace_name: "{{ namespace_name }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
resource_group: "{{ resource_group }}"
tags:
test: modified
register: results
-- assert:
- that:
+- name: Assert the notification hub updated
+ ansible.builtin.assert:
+ that:
- results.changed
- results.state.tags.test == 'modified'
@@ -88,8 +93,8 @@
register: results
- name: Assert that facts module returned result
- assert:
- that:
+ ansible.builtin.assert:
+ that:
- results.namespace[0].tags.test == 'modified'
- name: Test idempotent
@@ -98,7 +103,8 @@
resource_group: "{{ resource_group }}"
register: results
-- assert:
+- name: Assert the notification hub check mode
+ ansible.builtin.assert:
that:
- not results.changed
@@ -114,8 +120,9 @@
state: absent
- name: Pause for 3 minutes to make sure delete successfully
- pause:
+ ansible.builtin.pause:
minutes: 3
+ changed_when: true
- name: Delete Namespace (idempotent)
azure_rm_notificationhub:
@@ -125,29 +132,32 @@
state: absent
register: results
-- assert:
+- name: Assert the namespace deleted
+ ansible.builtin.assert:
that: not results.changed
- name: Delete Notification Hub
azure_rm_notificationhub:
location: eastus2
namespace_name: "{{ namespace_name }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
resource_group: "{{ resource_group }}"
state: absent
- name: Pause for 3 minutes to make sure delete successfully
- pause:
+ ansible.builtin.pause:
minutes: 3
+ changed_when: true
- name: Delete Notification Hub (idempotent)
azure_rm_notificationhub:
location: eastus2
namespace_name: "{{ namespace_name }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
resource_group: "{{ resource_group }}"
state: absent
register: results
-- assert:
+- name: Assert the notificationhub deleted
+ ansible.builtin.assert:
that: not results.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_openshiftmanagedcluster/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_openshiftmanagedcluster/tasks/main.yml
index a173bf929..969347b8d 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_openshiftmanagedcluster/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_openshiftmanagedcluster/tasks/main.yml
@@ -1,7 +1,8 @@
-- set_fact:
+- name: Set variables
+ ansible.builtin.set_fact:
cluster_name: "{{ resource_group | hash('md5') | truncate(8, True, '') }}"
-- name: get resource group info
+- name: Get resource group info
azure_rm_resourcegroup_info:
name: "{{ resource_group_secondary }}"
register: rg_output
@@ -11,8 +12,9 @@
resource_group: "{{ resource_group_secondary }}"
register: output
-- assert:
- that: output['clusters'] | length == 0
+- name: Assert the cluster facts
+ ansible.builtin.assert:
+ that: output['clusters'] | length == 0
- name: Get specific cluster information for a specific cluster
azure_rm_openshiftmanagedcluster_info:
@@ -20,15 +22,17 @@
name: "{{ cluster_name }}"
register: output
-- assert:
- that: output['clusters'].keys() | length == 0
+- name: Assert the cluster facts
+ ansible.builtin.assert:
+ that: output['clusters'].keys() | length == 0
- name: Get all clusters
azure_rm_openshiftmanagedcluster_info:
register: output
-- assert:
- that: output['clusters']['value'] | length == 0
+- name: Assert all clusters facts
+ ansible.builtin.assert:
+ that: output['clusters']['value'] | length == 0
- name: Create virtual network
azure_rm_virtualnetwork:
@@ -38,7 +42,7 @@
- 10.151.0.0/16
- 10.152.0.0/16
-- name: create master subnet
+- name: Create master subnet
azure_rm_subnet:
name: master_foobar
virtual_network_name: testVnet
@@ -46,7 +50,7 @@
address_prefix_cidr: 10.151.0.0/24
register: master_sub_output
-- name: create work subnet
+- name: Create work subnet
azure_rm_subnet:
name: worker_foobar
virtual_network_name: testVnet
@@ -78,8 +82,9 @@
subnet_id: "{{ master_sub_output.state.id }}"
register: output
-- assert:
- that: output.changed
+- name: Assert the cluster created
+ ansible.builtin.assert:
+ that: output.changed
- name: Get available clusters for a specific resource_group
@@ -87,8 +92,9 @@
resource_group: "{{ resource_group }}"
register: output
-- assert:
- that: output['clusters'] | length == 1
+- name: Assert the cluster facts
+ ansible.builtin.assert:
+ that: output['clusters'] | length == 1
- name: Get specific cluster information for a specific cluster
azure_rm_openshiftmanagedcluster_info:
@@ -96,15 +102,17 @@
name: "{{ cluster_name }}"
register: output
-- assert:
- that: output['clusters']['name'] == "{{ cluster_name }}"
+- name: Assert the cluster facts
+ ansible.builtin.assert:
+ that: output['clusters']['name'] == "{{ cluster_name }}"
- name: Get all clusters
azure_rm_openshiftmanagedcluster_info:
register: output
-- assert:
- that: output['clusters'] | length >= 1
+- name: Assert all cluster
+ ansible.builtin.assert:
+ that: output['clusters'] | length >= 1
- name: Delete openshift cluster
azure_rm_openshiftmanagedcluster:
@@ -114,5 +122,6 @@
state: absent
register: output
-- assert:
- that: output.changed
+- name: Assert the cluster deleted
+ ansible.builtin.assert:
+ that: output.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_postgresqlserver/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_postgresqlserver/tasks/main.yml
index b4022b27b..e9602517a 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_postgresqlserver/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_postgresqlserver/tasks/main.yml
@@ -1,7 +1,7 @@
- name: Prepare random number
- set_fact:
+ ansible.builtin.set_fact:
rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
- run_once: yes
+ run_once: true
- name: Create instance of PostgreSQL Server -- check mode
azure_rm_postgresqlserver:
@@ -12,13 +12,13 @@
tier: Basic
location: westus2
storage_mb: 51200
- enforce_ssl: True
+ enforce_ssl: true
admin_username: zimxyz
admin_password: Password123!
- check_mode: yes
+ check_mode: true
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -31,12 +31,12 @@
tier: Basic
location: westus2
storage_mb: 51200
- enforce_ssl: True
+ enforce_ssl: true
admin_username: zimxyz
admin_password: Password123!
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.state == 'Ready'
@@ -50,12 +50,12 @@
tier: Basic
location: westus2
storage_mb: 51200
- enforce_ssl: True
+ enforce_ssl: true
admin_username: zimxyz
admin_password: Password123!
register: output
- name: Assert the state has not changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed == false
- output.state == 'Ready'
@@ -69,16 +69,17 @@
tier: Basic
location: westus2
storage_mb: 128000
- enforce_ssl: True
+ enforce_ssl: true
admin_username: zimxyz
admin_password: Password123!
register: output
- name: Assert the state has not changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.state == 'Ready'
-- debug:
+- name: Print the postgresql server states
+ ansible.builtin.debug:
var: output
- name: Gather facts postgresql Server
@@ -87,7 +88,7 @@
name: postgresqlsrv{{ rpfx }}
register: output
- name: Assert that storage size is correct
- assert:
+ ansible.builtin.assert:
that:
- output.servers[0]['storage_mb'] == 128000
@@ -100,8 +101,8 @@
tier: Basic
location: westus2
storage_mb: 51200
- enforce_ssl: True
- storage_autogrow: True
+ enforce_ssl: true
+ storage_autogrow: true
backup_retention_days: 7
admin_username: zimxyz
admin_password: Password123!
@@ -117,8 +118,8 @@
tier: Basic
location: westus2
storage_mb: 51200
- enforce_ssl: True
- storage_autogrow: True
+ enforce_ssl: true
+ storage_autogrow: true
backup_retention_days: 7
admin_username: zimxyz
admin_password: Password123!
@@ -132,7 +133,7 @@
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.servers[0]['id'] != None
@@ -153,7 +154,7 @@
resource_group: "{{ resource_group }}"
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.servers[0]['id'] != None
@@ -185,10 +186,10 @@
name: testdatabase
charset: UTF8
collation: English_United States.1252
- check_mode: yes
+ check_mode: true
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -201,7 +202,7 @@
collation: English_United States.1252
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.name == 'testdatabase'
@@ -215,7 +216,7 @@
collation: English_United States.1252
register: output
- name: Assert the state has not changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed == false
- output.name == 'testdatabase'
@@ -227,10 +228,10 @@
name: testdatabase
charset: utf8
collation: en_US.utf8
- ignore_errors: yes
+ ignore_errors: true
register: output
- name: Assert that nothing has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
@@ -241,10 +242,10 @@
name: testdatabase
charset: utf8
collation: en_US.utf8
- force_update: yes
+ force_update: true
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.name == 'testdatabase'
@@ -263,7 +264,7 @@
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.databases[0]['server_name'] != None
@@ -277,7 +278,7 @@
server_name: postgresqlsrv{{ rpfx }}
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.databases[0]['server_name'] != None
@@ -295,10 +296,10 @@
server_name: postgresqlsrv{{ rpfx }}
name: testdatabase
state: absent
- check_mode: yes
+ check_mode: true
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -310,7 +311,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -322,7 +323,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed == false
@@ -337,10 +338,10 @@
name: firewallrule{{ rpfx }}
start_ip_address: 172.28.10.136
end_ip_address: 172.28.10.138
- check_mode: yes
+ check_mode: true
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -353,7 +354,7 @@
end_ip_address: 172.28.10.138
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -366,7 +367,7 @@
end_ip_address: 172.28.10.138
register: output
- name: Assert the state has not changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed == false
@@ -385,7 +386,7 @@
name: firewallrule{{ rpfx }}
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.rules[0].id != None
@@ -401,7 +402,7 @@
server_name: postgresqlsrv{{ rpfx }}
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.rules[0].id != None
@@ -421,10 +422,10 @@
server_name: postgresqlsrv{{ rpfx }}
name: firewallrule{{ rpfx }}
state: absent
- check_mode: yes
+ check_mode: true
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -436,7 +437,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -448,7 +449,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed == false
@@ -466,7 +467,7 @@
name: firewallrule{{ rpfx }}
register: output
- name: Assert that empty list was returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- "output.rules | length == 0"
@@ -480,10 +481,10 @@
server_name: postgresqlsrv{{ rpfx }}
name: deadlock_timeout
value: 2000
- check_mode: yes
+ check_mode: true
register: output
- name: Assert that change was registered
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -495,7 +496,7 @@
value: 2000
register: output
- name: Assert that change was registered
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -507,7 +508,7 @@
value: 2000
register: output
- name: Assert that change was not registered
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
@@ -519,7 +520,7 @@
state: absent
register: output
- name: Assert that change was registered
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -531,7 +532,7 @@
state: absent
register: output
- name: Assert that change was registered
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
@@ -542,7 +543,7 @@
name: deadlock_timeout
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.settings[0].id != None
@@ -558,7 +559,7 @@
server_name: postgresqlsrv{{ rpfx }}
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.settings[0].id != None
@@ -577,10 +578,10 @@
resource_group: "{{ resource_group }}"
name: postgresqlsrv{{ rpfx }}
state: absent
- check_mode: yes
+ check_mode: true
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -591,7 +592,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -602,7 +603,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed == false
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_privatednsrecordset/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_privatednsrecordset/tasks/main.yml
index 645851a04..3de80ce43 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_privatednsrecordset/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_privatednsrecordset/tasks/main.yml
@@ -1,5 +1,5 @@
- name: Create random domain name
- set_fact:
+ ansible.builtin.set_fact:
domain_name: "{{ resource_group | hash('md5') | truncate(16, True, '') + (65535 | random | string) }}"
- name: Create a Private DNS zone
@@ -10,10 +10,10 @@
register: results
- name: Assert that Private DNS zone was created
- assert:
+ ansible.builtin.assert:
that: results.changed
-- name: create "A" record set with multiple records
+- name: Create "A" record set with multiple records
azure_rm_privatednsrecordset:
resource_group: "{{ resource_group }}"
relative_name: www
@@ -26,10 +26,10 @@
register: results
- name: Assert that A record set was created
- assert:
+ ansible.builtin.assert:
that: results.changed
-- name: re-run "A" record with same values
+- name: Re-run "A" record with same values
azure_rm_privatednsrecordset:
resource_group: "{{ resource_group }}"
relative_name: www
@@ -42,7 +42,7 @@
register: results
- name: Assert that A record set was not changed
- assert:
+ ansible.builtin.assert:
that: not results.changed
- name: Update "A" record set with additional record
@@ -57,11 +57,11 @@
register: results
- name: Assert that new record was appended
- assert:
+ ansible.builtin.assert:
that:
- results.changed
-- name: re-update "A" record set with additional record
+- name: Re-update "A" record set with additional record
azure_rm_privatednsrecordset:
resource_group: "{{ resource_group }}"
relative_name: www
@@ -73,7 +73,7 @@
register: results
- name: Assert that A record set was not changed
- assert:
+ ansible.builtin.assert:
that:
- not results.changed
@@ -90,7 +90,7 @@
register: results
- name: Assert that record was deleted
- assert:
+ ansible.builtin.assert:
that:
- results.changed
@@ -102,11 +102,11 @@
record_type: A
records:
- entry: 192.168.100.105
- check_mode: yes
+ check_mode: true
register: results
- name: Assert that check_mode returns new state
- assert:
+ ansible.builtin.assert:
that:
- results.changed
@@ -118,7 +118,8 @@
record_type: A
register: results
-- assert:
+- name: Assert the DNS recoredset facts
+ ansible.builtin.assert:
that:
- not results.changed
- results.dnsrecordsets[0].id != None
@@ -128,7 +129,7 @@
- results.dnsrecordsets[0].relative_name == 'www'
- results.dnsrecordsets[0].records | length > 0
-- name: delete a record set
+- name: Delete a record set
azure_rm_privatednsrecordset:
resource_group: "{{ resource_group }}"
relative_name: www
@@ -138,10 +139,10 @@
register: results
- name: Assert that record set deleted
- assert:
+ ansible.builtin.assert:
that: results.changed
-- name: (idempotence test) re-run record set absent
+- name: Re-run record set absent (idempotence test)
azure_rm_privatednsrecordset:
resource_group: "{{ resource_group }}"
relative_name: www
@@ -150,11 +151,11 @@
state: absent
register: results
-- name:
- assert:
+- name: Assert recored set deleted
+ ansible.builtin.assert:
that: not results.changed
-- name: create SRV records in a new record set
+- name: Create SRV records in a new record set
azure_rm_privatednsrecordset:
resource_group: "{{ resource_group }}"
relative_name: "_sip._tcp.{{ domain_name }}.com"
@@ -163,14 +164,14 @@
record_type: SRV
state: present
records:
- - entry: sip.{{ domain_name }}.com
- priority: 20
- weight: 10
- port: 5060
+ - entry: sip.{{ domain_name }}.com
+ priority: 20
+ weight: 10
+ port: 5060
register: results
- name: Assert that SRV record set was created
- assert:
+ ansible.builtin.assert:
that:
- results.changed
@@ -182,7 +183,8 @@
record_type: SRV
register: results
-- assert:
+- name: Assert the DNS recordset facts
+ ansible.builtin.assert:
that:
- not results.changed
- results.dnsrecordsets[0].id != None
@@ -192,7 +194,7 @@
- results.dnsrecordsets[0].relative_name == "_sip._tcp.{{ domain_name }}.com"
- results.dnsrecordsets[0].records | length > 0
-- name: create TXT records in a new record set
+- name: Create TXT records in a new record set
azure_rm_privatednsrecordset:
resource_group: "{{ resource_group }}"
relative_name: "_txt.{{ domain_name }}.com"
@@ -208,7 +210,7 @@
register: results
- name: Assert that TXT record set was created
- assert:
+ ansible.builtin.assert:
that:
- results.changed
@@ -220,7 +222,8 @@
record_type: TXT
register: results
-- assert:
+- name: Assert the DNS recordset facts
+ ansible.builtin.assert:
that:
- not results.changed
- results.dnsrecordsets[0].id != None
@@ -248,7 +251,7 @@
register: results
- name: Assert that SOA record set was created
- assert:
+ ansible.builtin.assert:
that:
- results.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_privatednszone/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_privatednszone/tasks/main.yml
index eba80899d..92b91344f 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_privatednszone/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_privatednszone/tasks/main.yml
@@ -1,5 +1,5 @@
- name: Create random domain name
- set_fact:
+ ansible.builtin.set_fact:
domain_name: "{{ resource_group | hash('md5') | truncate(16, True, '') + (65535 | random | string) }}"
- name: Create a private DNS zone (check mode)
@@ -9,7 +9,8 @@
register: results
check_mode: true
-- assert:
+- name: Assert there is no private dns zone resource
+ ansible.builtin.assert:
that: results.changed
- name: Create a private DNS zone
@@ -18,7 +19,8 @@
name: "{{ domain_name }}.com"
register: results
-- assert:
+- name: Assert the private dns zone created
+ ansible.builtin.assert:
that: results.changed
- name: Update private DNS zone with tags
@@ -29,7 +31,8 @@
test: modified
register: results
-- assert:
+- name: Assert the private dns zone updated
+ ansible.builtin.assert:
that:
- results.changed
- results.state.tags.test == 'modified'
@@ -40,7 +43,8 @@
resource_group: "{{ resource_group }}"
register: results
-- assert:
+- name: Assert idempotent
+ ansible.builtin.assert:
that:
- not results.changed
@@ -51,7 +55,7 @@
register: zones
- name: Assert that facts module returned result
- assert:
+ ansible.builtin.assert:
that:
- zones.privatednszones[0].tags.test == 'modified'
- zones.privatednszones[0].number_of_record_sets == 1
@@ -63,7 +67,7 @@
- name: Delete private DNS zone
azure_rm_privatednszone:
resource_group: "{{ resource_group }}"
- name: "{{ domain_name }}.com"
+ name: "{{ domain_name }}.com"
state: absent
- name: Delete private DNS zone (idempotent)
@@ -73,5 +77,6 @@
state: absent
register: results
-- assert:
+- name: Assert the private dns zone deleted
+ ansible.builtin.assert:
that: not results.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_privatednszonelink/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_privatednszonelink/tasks/main.yml
index 6125abaa3..febd845bb 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_privatednszonelink/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_privatednszonelink/tasks/main.yml
@@ -1,14 +1,14 @@
- name: Create virtual network link name
- set_fact:
+ ansible.builtin.set_fact:
link_name: "link{{ resource_group | hash('md5') | truncate(22, True, '') }}"
- name: Create random number
- set_fact:
+ ansible.builtin.set_fact:
rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
- run_once: yes
+ run_once: true
- name: Create random domain name
- set_fact:
+ ansible.builtin.set_fact:
domain_name: "{{ resource_group | hash('md5') | truncate(16, True, '') + (65535 | random | string) }}"
- name: Create a Private DNS zone
@@ -22,11 +22,11 @@
name: "vnet{{ rpfx }}"
resource_group: "{{ resource_group }}"
address_prefixes_cidr:
- - 10.1.0.0/16
- - 172.100.0.0/16
+ - 10.1.0.0/16
+ - 172.100.0.0/16
dns_servers:
- - 127.0.0.1
- - 127.0.0.2
+ - 127.0.0.1
+ - 127.0.0.2
- name: Create a subnet
azure_rm_subnet:
@@ -45,7 +45,7 @@
register: results
- name: Assert that virtual network link is created
- assert:
+ ansible.builtin.assert:
that: results.changed
- name: Create a virtual network link (Idempotent test)
@@ -58,7 +58,7 @@
register: results
- name: Assert that output is not changed
- assert:
+ ansible.builtin.assert:
that: not results.changed
- name: Update a virtual network link
@@ -72,7 +72,7 @@
register: results
- name: Assert that virtual network link is updated
- assert:
+ ansible.builtin.assert:
that: results.changed
- name: Get virtual network link
@@ -82,7 +82,8 @@
zone_name: "{{ domain_name }}.com"
register: results
-- assert:
+- name: Assert the virtual network link facts
+ ansible.builtin.assert:
that:
- not results.changed
- results.virtualnetworklinks[0].name == "{{ link_name }}"
@@ -98,7 +99,7 @@
register: results
- name: Assert that virtual network link is deleted
- assert:
+ ansible.builtin.assert:
that: results.changed
- name: Delete virtual network link (Idempotent test)
@@ -110,7 +111,7 @@
register: results
- name: Asset that output is not changed
- assert:
+ ansible.builtin.assert:
that: not results.changed
- name: Delete virtual network
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_privateendpoint/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_privateendpoint/tasks/main.yml
index 306c1cc0a..589c27843 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_privateendpoint/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_privateendpoint/tasks/main.yml
@@ -1,5 +1,5 @@
- name: Set Private Endpoint Name
- set_fact:
+ ansible.builtin.set_fact:
rpfx: "private{{ resource_group | hash('md5') | truncate(18, True, '') }}"
- name: Create virtual network
@@ -42,7 +42,7 @@
tier: GeneralPurpose
location: eastus
storage_mb: 51200
- enforce_ssl: True
+ enforce_ssl: true
admin_username: zimxyz
admin_password: Password123!
register: post_output
@@ -70,7 +70,7 @@
register: output
- name: Assert status succeeded and results match expectations
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.state.id is defined
@@ -88,15 +88,16 @@
- postgresqlServer
subnet:
id: "{{ subnet_output.state.id }}"
- tags:
+ tags:
key1: value1
register: output
- name: Assert status succeeded and results match expectations
- assert:
- that:
+ ansible.builtin.assert:
+ that:
- not output.changed
- ignore_errors: yes
+ ignore_errors: true
+ register: ignore_errors_register
- name: Update private endpoint with tags
azure_rm_privateendpoint:
@@ -109,13 +110,13 @@
- postgresqlServer
subnet:
id: "{{ subnet_output.state.id }}"
- tags:
+ tags:
key1: value1
key2: value2
register: output
- name: Assert status succeeded and results match expectations
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.state.tags | length == 2
@@ -127,7 +128,7 @@
register: output
- name: Assert private endpoint info
- assert:
+ ansible.builtin.assert:
that:
- output.privateendpoints[0].provisioning_state == "Succeeded"
- output.privateendpoints[0].tags | length == 2
@@ -140,7 +141,7 @@
register: output
- name: Assert status succeeded and results match expectations
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -152,6 +153,6 @@
register: output
- name: Assert status succeeded and results match expectations
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_privateendpointdnszonegroup/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_privateendpointdnszonegroup/tasks/main.yml
index e58a3ba22..b5fc3e1f1 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_privateendpointdnszonegroup/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_privateendpointdnszonegroup/tasks/main.yml
@@ -1,5 +1,5 @@
- name: Prepare random number
- set_fact:
+ ansible.builtin.set_fact:
rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
run_once: true
@@ -42,7 +42,7 @@
ignore_errors: true
register: output
- name: Assert results match expectations
- assert:
+ ansible.builtin.assert:
that:
- output.msg is match("Could not load the private endpoint", ignorecase=True)
@@ -76,7 +76,7 @@
resource_group: "{{ resource_group }}"
register: output
- name: Assert results match expectations
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
- output.groups | length == 0
@@ -92,7 +92,7 @@
register: output
check_mode: true
- name: Assert results match expectations
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -106,7 +106,7 @@
private_dns_zone: "privatelink.postgres.database.azure.com"
register: output
- name: Assert results match expectations
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.state.id
@@ -134,7 +134,7 @@
private_dns_zone: "privatelink.postgres.database.azure.com"
register: output
- name: Assert results match expectations
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
@@ -145,7 +145,7 @@
resource_group: "{{ resource_group }}"
register: output
- name: Assert results match expectations
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
- output.groups | length == 1
@@ -170,7 +170,7 @@
resource_group: "{{ resource_group }}"
register: output
- name: Assert results match expectations
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
- output.groups | length == 1
@@ -199,7 +199,7 @@
private_dns_zone: "privatelink.postgres.database.azure.com"
register: output
- name: Assert results match expectations
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.state.id
@@ -226,7 +226,7 @@
register: output
check_mode: true
- name: Assert results match expectations
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -238,7 +238,7 @@
state: "absent"
register: output
- name: Assert results match expectations
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -250,6 +250,6 @@
state: "absent"
register: output
- name: Assert results match expectations
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_privatelinkservice/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_privatelinkservice/tasks/main.yml
index bc0363c56..a3743b074 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_privatelinkservice/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_privatelinkservice/tasks/main.yml
@@ -1,5 +1,5 @@
- name: Set Private Link Service Names
- set_fact:
+ ansible.builtin.set_fact:
rpfx: "{{ resource_group | hash('md5') | truncate(20, True, '') }}"
azure_subscription_id: f64d4ee8-be94-457d-ba26-3fa6b6506cef
@@ -27,14 +27,14 @@
private_endpoint_network_policies: Disabled
register: subnet_output
-- name: create public ip
+- name: Create public ip
azure_rm_publicipaddress:
resource_group: '{{ resource_group }}'
name: "pip{{ rpfx }}"
sku: Standard
allocation_method: Static
-- name: create load balancer with frontend_ip_configurations
+- name: Create load balancer with frontend_ip_configurations
azure_rm_loadbalancer:
resource_group: '{{ resource_group }}'
name: "lb{{ rpfx }}"
@@ -66,54 +66,55 @@
azure_rm_privatelinkservice:
name: "lsp{{ rpfx }}"
resource_group: "{{ resource_group }}"
- enable_proxy_protocol: True
+ enable_proxy_protocol: true
fqdns:
- 'dns01.com'
- 'dns02.com'
visibility:
- subscriptions:
- - "{{ azure_subscription_id }}"
+ subscriptions:
+ - "{{ azure_subscription_id }}"
auto_approval:
- subscriptions:
- - "{{ azure_subscription_id }}"
+ subscriptions:
+ - "{{ azure_subscription_id }}"
load_balancer_frontend_ip_configurations:
- id: "{{ lb_output.state.frontend_ip_configurations[0].id }}"
ip_configurations:
- name: ip_configuration01
properties:
- primary: True
+ primary: true
private_ip_allocation_method: 'Dynamic'
private_ip_address_version: 'IPv4'
subnet:
id: "{{ subnet_output.state.id }}"
tags:
key1: value1
- check_mode: True
+ check_mode: true
register: output
-- assert:
+- name: Assert there is no private link service
+ ansible.builtin.assert:
that: output.changed
- name: Create private link service
azure_rm_privatelinkservice:
name: "lsp{{ rpfx }}"
resource_group: "{{ resource_group }}"
- enable_proxy_protocol: True
+ enable_proxy_protocol: true
fqdns:
- 'dns01.com'
- 'dns02.com'
visibility:
- subscriptions:
- - "{{ azure_subscription_id }}"
+ subscriptions:
+ - "{{ azure_subscription_id }}"
auto_approval:
- subscriptions:
- - "{{ azure_subscription_id }}"
+ subscriptions:
+ - "{{ azure_subscription_id }}"
load_balancer_frontend_ip_configurations:
- id: "{{ lb_output.state.frontend_ip_configurations[0].id }}"
ip_configurations:
- name: ip_configuration01
properties:
- primary: True
+ primary: true
private_ip_allocation_method: 'Dynamic'
private_ip_address_version: 'IPv4'
subnet:
@@ -122,29 +123,30 @@
key1: value1
register: output
-- assert:
+- name: Assert the private link service created
+ ansible.builtin.assert:
that: output.changed
- name: Create private link service (Idempotent test)
azure_rm_privatelinkservice:
name: "lsp{{ rpfx }}"
resource_group: "{{ resource_group }}"
- enable_proxy_protocol: True
+ enable_proxy_protocol: true
fqdns:
- 'dns01.com'
- 'dns02.com'
visibility:
- subscriptions:
- - "{{ azure_subscription_id }}"
+ subscriptions:
+ - "{{ azure_subscription_id }}"
auto_approval:
- subscriptions:
- - "{{ azure_subscription_id }}"
+ subscriptions:
+ - "{{ azure_subscription_id }}"
load_balancer_frontend_ip_configurations:
- id: "{{ lb_output.state.frontend_ip_configurations[0].id }}"
ip_configurations:
- name: ip_configuration01
properties:
- primary: True
+ primary: true
private_ip_allocation_method: 'Dynamic'
private_ip_address_version: 'IPv4'
subnet:
@@ -153,29 +155,30 @@
key1: value1
register: output
-- assert:
+- name: Assert idempotent
+ ansible.builtin.assert:
that: not output.changed
- name: Update private link service
azure_rm_privatelinkservice:
name: "lsp{{ rpfx }}"
resource_group: "{{ resource_group }}"
- enable_proxy_protocol: False
+ enable_proxy_protocol: false
fqdns:
- 'dns03.com'
- 'dns04.com'
visibility:
- subscriptions:
- - "{{ azure_subscription_id }}"
+ subscriptions:
+ - "{{ azure_subscription_id }}"
auto_approval:
- subscriptions:
- - "{{ azure_subscription_id }}"
+ subscriptions:
+ - "{{ azure_subscription_id }}"
load_balancer_frontend_ip_configurations:
- id: "{{ lb_output.state.frontend_ip_configurations[0].id }}"
ip_configurations:
- name: ip_configuration01
properties:
- primary: True
+ primary: true
private_ip_allocation_method: 'Dynamic'
private_ip_address_version: 'IPv4'
subnet:
@@ -185,7 +188,8 @@
key3: value3
register: output
-- assert:
+- name: Assert the private link service update
+ ansible.builtin.assert:
that: output.changed
- name: Get private link service info by name
@@ -194,7 +198,8 @@
resource_group: "{{ resource_group }}"
register: output
-- assert:
+- name: Assert the private link service facts
+ ansible.builtin.assert:
that:
- output.link_service[0].tags | length == 3
- output.link_service[0].fqdns | length == 4
@@ -217,7 +222,8 @@
resource_group: "{{ resource_group }}"
register: output
-- assert:
+- name: Assert the private endpoint connection facts
+ ansible.builtin.assert:
that:
- output.endpoint_connection[0].private_link_service_connection_state.actions_required == "None"
- output.endpoint_connection[0].private_link_service_connection_state.description == "Approved"
@@ -234,7 +240,8 @@
actions_required: "actions required"
register: output
-- assert:
+- name: Assert the private endpoint connection updated
+ ansible.builtin.assert:
that: output.changed
- name: Get private endpoint connection info by name
@@ -244,7 +251,8 @@
resource_group: "{{ resource_group }}"
register: output
-- assert:
+- name: Assert the private endpoint connection facts
+ ansible.builtin.assert:
that:
- output.endpoint_connection[0].private_link_service_connection_state.actions_required == "actions required"
- output.endpoint_connection[0].private_link_service_connection_state.description == "Rejected"
@@ -258,7 +266,8 @@
state: absent
register: output
-- assert:
+- name: Assert the private endpoint connection deleted
+ ansible.builtin.assert:
that: output.changed
- name: Delete private endpoint
@@ -267,11 +276,13 @@
resource_group: "{{ resource_group }}"
state: absent
-- assert:
+- name: Assert the private endpoint deleted
+ ansible.builtin.assert:
that: output.changed
- name: Pause for 5 mimutes to waiting
- shell: sleep 300
+ ansible.builtin.command: sleep 300
+ changed_when: true
- name: Delete private link service
azure_rm_privatelinkservice:
@@ -280,5 +291,6 @@
state: absent
register: output
-- assert:
+- name: Assert the private link service deleted
+ ansible.builtin.assert:
that: output.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_proximityplacementgroup/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_proximityplacementgroup/tasks/main.yml
index bf7dbfd0b..c418d06d5 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_proximityplacementgroup/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_proximityplacementgroup/tasks/main.yml
@@ -1,5 +1,5 @@
- name: Create proximity placement group name
- set_fact:
+ ansible.builtin.set_fact:
group_name: "ppg{{ resource_group | hash('md5') | truncate(22, True, '') }}"
- name: Create a proximity placement group
@@ -11,7 +11,7 @@
register: results
- name: Assert that placement group is created
- assert:
+ ansible.builtin.assert:
that: results.changed
- name: Create a proximity placement group again (Idempotent test)
@@ -23,7 +23,7 @@
register: results
- name: Assert that output is not changed
- assert:
+ ansible.builtin.assert:
that: not results.changed
- name: Update a proximity placement group
@@ -37,7 +37,7 @@
register: results
- name: Assert that placement group is updated
- assert:
+ ansible.builtin.assert:
that: results.changed
- name: Get proximity placement group facts
@@ -46,7 +46,8 @@
name: "{{ group_name }}"
register: results
-- assert:
+- name: Assert the proximity placement facts
+ ansible.builtin.assert:
that:
- not results.changed
- results.proximityplacementgroups[0].name == "{{ group_name }}"
@@ -61,7 +62,7 @@
register: results
- name: Assert that placement group is deleted
- assert:
+ ansible.builtin.assert:
that: results.changed
- name: Delete proximity placement group again (Idempotent test)
@@ -72,5 +73,5 @@
register: results
- name: Asset that output is not changed
- assert:
+ ansible.builtin.assert:
that: not results.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_publicipaddress/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_publicipaddress/tasks/main.yml
index 119747b26..07b60f46b 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_publicipaddress/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_publicipaddress/tasks/main.yml
@@ -1,109 +1,116 @@
- 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 }}"
+ ansible.builtin.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_rm_publicipaddress:
- resource_group: "{{ resource_group }}"
- name: "pip{{ rpfx }}"
- state: absent
+ resource_group: "{{ resource_group }}"
+ name: "pip{{ rpfx }}"
+ state: absent
- name: Create public ip
azure_rm_publicipaddress:
- resource_group: "{{ resource_group }}"
- name: "pip{{ rpfx }}"
- allocation_method: Static
- domain_name: "{{ domain_name }}"
- tags:
- testing: testing
- delete: on-exit
+ resource_group: "{{ resource_group }}"
+ name: "pip{{ rpfx }}"
+ allocation_method: Static
+ domain_name: "{{ domain_name }}"
+ tags:
+ testing: testing
+ delete: on-exit
register: output
-- 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: Assert the public ip created
+ ansible.builtin.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: Create public ip with IPV6
azure_rm_publicipaddress:
- resource_group: "{{ resource_group }}"
- name: "pip{{ rpfx }}-02"
- allocation_method: Static
- domain_name: "{{ domain_name }}-02"
- version: 'ipv6'
- sku: 'Standard'
- zones:
- - 1
+ resource_group: "{{ resource_group }}"
+ name: "pip{{ rpfx }}-02"
+ allocation_method: Static
+ domain_name: "{{ domain_name }}-02"
+ version: 'ipv6'
+ sku: 'Standard'
+ zones:
+ - 1
register: output
-- assert:
- that:
- - output.state.public_ip_address_version == 'ipv6'
- - output.state.zones == ['1']
+- name: Assert the public ip created
+ ansible.builtin.assert:
+ that:
+ - output.state.public_ip_address_version == 'ipv6'
+ - output.state.zones == ['1']
- name: Should be idempotent
azure_rm_publicipaddress:
- resource_group: "{{ resource_group }}"
- name: "pip{{ rpfx }}"
- allocation_method: static
- domain_name: "{{ domain_name }}"
+ resource_group: "{{ resource_group }}"
+ name: "pip{{ rpfx }}"
+ allocation_method: static
+ domain_name: "{{ domain_name }}"
register: output
-- assert:
- that: not output.changed
+- name: Assert idempotent
+ ansible.builtin.assert:
+ that: not output.changed
- name: Update tags
azure_rm_publicipaddress:
- resource_group: "{{ resource_group }}"
- name: "pip{{ rpfx }}"
- allocation_method: static
- domain_name: "{{ domain_name }}"
- append_tags: yes
- tags:
- delete: never
- foo: bar
+ resource_group: "{{ resource_group }}"
+ name: "pip{{ rpfx }}"
+ allocation_method: static
+ domain_name: "{{ domain_name }}"
+ append_tags: true
+ tags:
+ delete: never
+ foo: bar
register: output
-- assert:
- that:
- - output.state.tags | length == 3
- - output.state.tags.delete == 'never'
+- name: Assert the public ip address updated
+ ansible.builtin.assert:
+ that:
+ - output.state.tags | length == 3
+ - output.state.tags.delete == 'never'
- name: Gather facts, filtering by tag
azure_rm_publicipaddress_info:
- resource_group: "{{ resource_group }}"
- tags:
- - testing
- - foo:bar
+ resource_group: "{{ resource_group }}"
+ tags:
+ - testing
+ - foo:bar
register: infos
-- assert:
- that: infos.publicipaddresses | length == 1
+- name: Assert the public ip address facts
+ ansible.builtin.assert:
+ that: infos.publicipaddresses | length == 1
- name: Purge all tags
azure_rm_publicipaddress:
- resource_group: "{{ resource_group }}"
- name: "pip{{ rpfx }}"
- allocation_method: static
- domain_name: "{{ domain_name }}"
- append_tags: no
+ resource_group: "{{ resource_group }}"
+ name: "pip{{ rpfx }}"
+ allocation_method: static
+ domain_name: "{{ domain_name }}"
+ append_tags: false
register: output
-- assert:
- that:
- - output.state.tags | length == 0
+- name: Assert purge all tags
+ ansible.builtin.assert:
+ that:
+ - output.state.tags | length == 0
- name: Gather facts for a public ip
azure_rm_publicipaddress_info:
- resource_group: "{{ resource_group }}"
- name: "pip{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ name: "pip{{ rpfx }}"
register: pip
-- assert:
- that:
+- name: Assert the public ip address facts
+ ansible.builtin.assert:
+ that:
- "pip.publicipaddresses | length == 1"
- pip.publicipaddresses[0].name == "pip{{ rpfx }}"
- pip.publicipaddresses[0].allocation_method == 'static'
@@ -111,29 +118,31 @@
- name: Gather facts for all public ips
azure_rm_publicipaddress_info:
- resource_group: "{{ resource_group }}"
+ resource_group: "{{ resource_group }}"
register: infos
-- assert:
- that: infos.publicipaddresses | length > 0
+- name: Assert all public ips
+ ansible.builtin.assert:
+ that: infos.publicipaddresses | length > 0
- name: Remove IPV6 public ip
azure_rm_publicipaddress:
- resource_group: "{{ resource_group }}"
- name: "pip{{ rpfx }}-02"
- state: absent
+ resource_group: "{{ resource_group }}"
+ name: "pip{{ rpfx }}-02"
+ state: absent
- name: Remove public ip
azure_rm_publicipaddress:
- resource_group: "{{ resource_group }}"
- name: "pip{{ rpfx }}"
- state: absent
+ resource_group: "{{ resource_group }}"
+ name: "pip{{ rpfx }}"
+ state: absent
- name: Gather facts for a public ip
azure_rm_publicipaddress_info:
- resource_group: "{{ resource_group }}"
- name: "pip{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ name: "pip{{ rpfx }}"
register: infos
-- assert:
- that: infos.publicipaddresses | length == 0
+- name: Assert public ip address facts
+ ansible.builtin.assert:
+ that: infos.publicipaddresses | length == 0
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_recoveryservicesvault/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_recoveryservicesvault/tasks/main.yml
index fc92da931..6918632cd 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_recoveryservicesvault/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_recoveryservicesvault/tasks/main.yml
@@ -1,42 +1,42 @@
- name: Fix resource prefix
- set_fact:
- name: "revault{{ resource_group | hash('md5') | truncate(22, True, '') }}"
+ ansible.builtin.set_fact:
+ name_rpfx: "revault{{ resource_group | hash('md5') | truncate(22, True, '') }}"
location: "eastus"
- name: Create Azure Recovery Service vault
azure_rm_recoveryservicesvault:
resource_group: "{{ resource_group }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
location: "{{ location }}"
state: "present"
register: output
- name: Assert that output has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
-
+
- name: Create Azure Recovery Service vault (idempotent)
azure_rm_recoveryservicesvault:
resource_group: "{{ resource_group }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
location: "{{ location }}"
state: "present"
register: output
- name: Assert that output has no changed
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
- name: Get Azure Recovery Service Vault Details
azure_rm_recoveryservicesvault_info:
resource_group: "{{ resource_group }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
register: output
- name: Assert that output has changed
- assert:
+ ansible.builtin.assert:
that:
- output.response.id != None
- output.response.name != None
@@ -44,12 +44,12 @@
- name: Delete Azure Recovery Service vault
azure_rm_recoveryservicesvault:
resource_group: "{{ resource_group }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
location: "{{ location }}"
state: "absent"
register: output
- name: Assert that output has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_rediscache/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_rediscache/tasks/main.yml
index 18e71e56e..4d134b0e9 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_rediscache/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_rediscache/tasks/main.yml
@@ -1,10 +1,10 @@
- name: Fix resource prefix
- set_fact:
+ ansible.builtin.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: yes
+ run_once: true
- name: Create a redis cache (Check Mode)
azure_rm_rediscache:
@@ -13,12 +13,12 @@
sku:
name: basic
size: C1
- wait_for_provisioning: False
- check_mode: yes
+ wait_for_provisioning: false
+ check_mode: true
register: output
- name: Assert creating redis cache check mode
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -29,11 +29,11 @@
sku:
name: basic
size: C1
- wait_for_provisioning: False
+ wait_for_provisioning: false
register: output
- name: Assert creating redis cache
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.id
@@ -45,7 +45,7 @@
register: facts
- name: Assert facts
- assert:
+ ansible.builtin.assert:
that:
- facts.rediscaches | length == 1
- facts.rediscaches[0].id != None
@@ -61,119 +61,121 @@
sku:
name: basic
size: C1
- wait_for_provisioning: False
+ wait_for_provisioning: false
register: output
-- name: assert output not changed
- assert:
+- name: Assert output not changed
+ ansible.builtin.assert:
that:
- not output.changed
-- name: long-running rediscache tests [run with `--tags long_run,untagged` to enable]
+- name: Long-running rediscache tests [run with `--tags long_run,untagged` to enable]
# creating redis Cache costs about 20 mins async operation,
# need to poll status from Creating to Running, then able to perform updating/deleting operation,
# otherwise, will met error:
# "The resource '<resource_id>' is busy processing a previous update request or is undergoing system maintenance.
# As such, it is currently unable to accept the update request. Please try again later."
block:
- - name: Wait for Redis provisioning to complete
- azure_rm_rediscache_info:
+ - name: Wait for Redis provisioning to complete
+ azure_rm_rediscache_info:
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
- 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
- register: output
-
- - name: assert output changed
- assert:
- that:
- - output.changed
-
- - name: Update redis cache configuration
- 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
- register: output
-
- - name: assert output changed
- assert:
- that:
- - output.changed
-
- - name: Scale up the redis cache
- azure_rm_rediscache:
- resource_group: "{{ resource_group }}"
- name: "{{ redis_name }}"
- sku:
- name: standard
- size: C1
- tags:
- testing: foo
- wait_for_provisioning: True
- register: output
-
- - assert:
- that:
- - output.changed
-
- - name: Force reboot redis cache
- azure_rm_rediscache:
- resource_group: "{{ resource_group }}"
- name: "{{ redis_name }}"
- reboot:
- reboot_type: all
- register: output
-
- - name: assert redis rebooted
- assert:
- that:
- - output.changed
-
- - name: Delete the redis cache (Check Mode)
- azure_rm_rediscache:
- resource_group: "{{ resource_group }}"
- name: "{{ redis_name }}"
- state: absent
- check_mode: yes
- register: output
-
- - name: assert deleting redis cache check mode
- assert:
- that: output.changed
-
- - name: Delete the redis cache
- azure_rm_rediscache:
- resource_group: "{{ resource_group }}"
- name: "{{ redis_name }}"
- state: absent
- register: output
-
- - assert:
- that:
- - output.changed
- tags: [long_run, never]
+ register: facts
+ until: facts.rediscaches[0]['provisioning_state'] == 'Succeeded'
+ retries: 30
+ delay: 60
+
+ - name: (Actually) update redis cache
+ 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
+ register: output
+
+ - name: Assert output changed
+ ansible.builtin.assert:
+ that:
+ - output.changed
+
+ - name: Update redis cache configuration
+ 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
+ register: output
+
+ - name: Assert output changed
+ ansible.builtin.assert:
+ that:
+ - output.changed
+
+ - name: Scale up the redis cache
+ azure_rm_rediscache:
+ resource_group: "{{ resource_group }}"
+ name: "{{ redis_name }}"
+ sku:
+ name: standard
+ size: C1
+ tags:
+ testing: foo
+ wait_for_provisioning: true
+ register: output
+
+ - name: Assert the redis cache
+ ansible.builtin.assert:
+ that:
+ - output.changed
+
+ - name: Force reboot redis cache
+ azure_rm_rediscache:
+ resource_group: "{{ resource_group }}"
+ name: "{{ redis_name }}"
+ reboot:
+ reboot_type: all
+ register: output
+
+ - name: Assert redis rebooted
+ ansible.builtin.assert:
+ that:
+ - output.changed
+
+ - name: Delete the redis cache (Check Mode)
+ azure_rm_rediscache:
+ resource_group: "{{ resource_group }}"
+ name: "{{ redis_name }}"
+ state: absent
+ check_mode: true
+ register: output
+
+ - name: Assert deleting redis cache check mode
+ ansible.builtin.assert:
+ that: output.changed
+
+ - name: Delete the redis cache
+ azure_rm_rediscache:
+ resource_group: "{{ resource_group }}"
+ name: "{{ redis_name }}"
+ state: absent
+ register: output
+
+ - name: Assert the redis cache deleted
+ ansible.builtin.assert:
+ that:
+ - output.changed
+ tags: [long_run, never]
- name: Create a redis cache with enhanced configuration options
@@ -189,7 +191,7 @@
wait_for_provisioning: false
register: output
- name: Assert creating redis cache
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -199,7 +201,7 @@
name: "{{ redis_name }}-enhanced"
register: facts
- name: Assert enhanced cache facts
- assert:
+ ansible.builtin.assert:
that:
- facts.rediscaches | length == 1
- facts.rediscaches[0].id != None
@@ -212,122 +214,123 @@
- facts.rediscaches[0].public_network_access == 'Disabled'
-- name: long-running enhanced rediscache tests [run with `--tags long_run,untagged` to enable]
+- name: Long-running enhanced rediscache tests [run with `--tags long_run,untagged` to enable]
# creating redis Cache costs about 20 mins async operation,
# need to poll status from Creating to Running, then able to perform updating/deleting operation,
# otherwise, will met error:
# "The resource '<resource_id>' is busy processing a previous update request or is undergoing system maintenance.
# As such, it is currently unable to accept the update request. Please try again later."
block:
- - name: Wait for Redis provisioning to complete
- azure_rm_rediscache_info:
+ - name: Wait for Redis provisioning to complete
+ azure_rm_rediscache_info:
resource_group: "{{ resource_group }}"
name: "{{ redis_name }}-enhanced"
- register: facts
- until: facts.rediscaches[0]['provisioning_state'] == 'Succeeded'
- retries: 30
- delay: 60
-
- - name: update redis (idempotent)
- azure_rm_rediscache:
- resource_group: "{{ resource_group }}"
- name: "{{ redis_name }}-enhanced"
- sku:
- name: basic
- size: C1
- redis_version: "6"
- minimum_tls_version: "1.2"
- public_network_access: "Disabled"
- wait_for_provisioning: true
- register: output
- - name: assert output not changed
- assert:
- that:
- - not output.changed
-
- - name: update redis cache TLS
- azure_rm_rediscache:
- resource_group: "{{ resource_group }}"
- name: "{{ redis_name }}-enhanced"
- sku:
- name: basic
- size: C1
- redis_version: "6"
- minimum_tls_version: "1.1"
- public_network_access: "Disabled"
- wait_for_provisioning: true
- register: output
- - name: assert output changed
- assert:
- that:
- - output.changed
-
- - name: update redis cache public network access
- azure_rm_rediscache:
- resource_group: "{{ resource_group }}"
- name: "{{ redis_name }}-enhanced"
- sku:
- name: basic
- size: C1
- redis_version: "6"
- minimum_tls_version: "1.1"
- public_network_access: "Enabled"
- wait_for_provisioning: true
- register: output
- - name: assert output changed
- assert:
- that:
- - output.changed
-
- - name: Get facts for enhanced cache
- azure_rm_rediscache_info:
- resource_group: "{{ resource_group }}"
- name: "{{ redis_name }}-enhanced"
- register: facts
- - name: Assert enhanced cache facts
- assert:
- that:
- - facts.rediscaches[0].minimum_tls_version == '1.1'
- - facts.rediscaches[0].public_network_access == 'Enabled'
-
- - name: update redis cache version
- azure_rm_rediscache:
- resource_group: "{{ resource_group }}"
- name: "{{ redis_name }}-enhanced"
- sku:
- name: basic
- size: C1
- redis_version: "6"
- minimum_tls_version: "1.1"
- public_network_access: "Enabled"
- wait_for_provisioning: true
- register: output
- failed_when: "output.changed or 'not supported' not in output.msg"
-
- - name: Delete the redis cache
- azure_rm_rediscache:
- resource_group: "{{ resource_group }}"
- name: "{{ redis_name }}-enhanced"
- state: absent
- register: output
- - assert:
- that:
- - output.changed
- tags: [long_run, never]
+ register: facts
+ until: facts.rediscaches[0]['provisioning_state'] == 'Succeeded'
+ retries: 30
+ delay: 60
+
+ - name: Update redis (idempotent)
+ azure_rm_rediscache:
+ resource_group: "{{ resource_group }}"
+ name: "{{ redis_name }}-enhanced"
+ sku:
+ name: basic
+ size: C1
+ redis_version: "6"
+ minimum_tls_version: "1.2"
+ public_network_access: "Disabled"
+ wait_for_provisioning: true
+ register: output
+ - name: Assert output not changed
+ ansible.builtin.assert:
+ that:
+ - not output.changed
+
+ - name: Update redis cache TLS
+ azure_rm_rediscache:
+ resource_group: "{{ resource_group }}"
+ name: "{{ redis_name }}-enhanced"
+ sku:
+ name: basic
+ size: C1
+ redis_version: "6"
+ minimum_tls_version: "1.1"
+ public_network_access: "Disabled"
+ wait_for_provisioning: true
+ register: output
+ - name: Assert output changed
+ ansible.builtin.assert:
+ that:
+ - output.changed
+
+ - name: Update redis cache public network access
+ azure_rm_rediscache:
+ resource_group: "{{ resource_group }}"
+ name: "{{ redis_name }}-enhanced"
+ sku:
+ name: basic
+ size: C1
+ redis_version: "6"
+ minimum_tls_version: "1.1"
+ public_network_access: "Enabled"
+ wait_for_provisioning: true
+ register: output
+ - name: Assert output changed
+ ansible.builtin.assert:
+ that:
+ - output.changed
+
+ - name: Get facts for enhanced cache
+ azure_rm_rediscache_info:
+ resource_group: "{{ resource_group }}"
+ name: "{{ redis_name }}-enhanced"
+ register: facts
+ - name: Assert enhanced cache facts
+ ansible.builtin.assert:
+ that:
+ - facts.rediscaches[0].minimum_tls_version == '1.1'
+ - facts.rediscaches[0].public_network_access == 'Enabled'
+
+ - name: Update redis cache version
+ azure_rm_rediscache:
+ resource_group: "{{ resource_group }}"
+ name: "{{ redis_name }}-enhanced"
+ sku:
+ name: basic
+ size: C1
+ redis_version: "6"
+ minimum_tls_version: "1.1"
+ public_network_access: "Enabled"
+ wait_for_provisioning: true
+ register: output
+ failed_when: "output.changed or 'not supported' not in output.msg"
+
+ - name: Delete the redis cache
+ azure_rm_rediscache:
+ resource_group: "{{ resource_group }}"
+ name: "{{ redis_name }}-enhanced"
+ state: absent
+ register: output
+ - name: Assert the redis cache deleted
+ ansible.builtin.assert:
+ that:
+ - output.changed
+ tags: [long_run, never]
- name: Create virtual network
azure_rm_virtualnetwork:
- resource_group: "{{ resource_group }}"
- name: "{{ vnet_name }}"
- address_prefixes: "10.10.0.0/16"
+ resource_group: "{{ resource_group }}"
+ name: "{{ vnet_name }}"
+ address_prefixes: "10.10.0.0/16"
- name: Add subnet
azure_rm_subnet:
- resource_group: "{{ resource_group }}"
- name: "{{ subnet_name }}"
- address_prefix: "10.10.0.0/24"
- virtual_network: "{{ vnet_name }}"
+ resource_group: "{{ resource_group }}"
+ name: "{{ subnet_name }}"
+ address_prefix: "10.10.0.0/24"
+ virtual_network: "{{ vnet_name }}"
- name: Create redis with subnet
azure_rm_rediscache:
@@ -339,11 +342,11 @@
subnet:
name: "{{ subnet_name }}"
virtual_network_name: "{{ vnet_name }}"
- wait_for_provisioning: False
+ wait_for_provisioning: false
register: output
- name: Assert creating redis cache
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.id
@@ -352,11 +355,11 @@
azure_rm_rediscache_info:
resource_group: "{{ resource_group }}"
name: "{{ redis_name }}2"
- return_access_keys: True
+ return_access_keys: true
register: facts
- name: Assert facts
- assert:
+ ansible.builtin.assert:
that:
- facts.rediscaches | length == 1
- facts.rediscaches[0].subnet != None
@@ -369,16 +372,15 @@
name: "{{ rule_name }}"
start_ip_address: 192.168.1.1
end_ip_address: 192.168.1.4
- check_mode: yes
+ check_mode: true
register: output
- name: Assert check mode creation
- assert:
+ ansible.builtin.assert:
that:
- output.changed
-
-- name: long-running key/firewallrule tests [run with `--tags long_run,untagged` to enable]
+- name: Long-running key/firewallrule tests [run with `--tags long_run,untagged` to enable]
# Creating firewall rule need Redis status is running, while creating redis Cache costs about 20 mins async operation,
# need to poll status from Creating to Running, then able to perform firewall rule creating,
# otherwise, will met error:
@@ -386,107 +388,107 @@
# '/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myResourceGroup/providers/Microsoft.Cache/Redis/myRedis' is busy processing
# a previous update request or is undergoing system maintenance. As such, it is currently unable to accept the update request. Please try again later."
block:
- - name: Wait for Redis provisioning to complete
- azure_rm_rediscache_info:
+ - name: Wait for Redis provisioning to complete
+ azure_rm_rediscache_info:
+ 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
+ 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
+ register: output
+
+ - name: Assert creation
+ ansible.builtin.assert:
+ that:
+ - output.changed
+ - output.id
+
+ - name: Update firewall rule idempotence
+ 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
+ register: output
+
+ - name: Assert idempotence
+ ansible.builtin.assert:
+ that:
+ - output.changed == false
+
+ - name: Update firewall rule
+ azure_rm_rediscachefirewallrule:
+ resource_group: "{{ resource_group }}"
+ cache_name: "{{ redis_name }}2"
+ name: "{{ rule_name }}"
+ end_ip_address: 192.168.1.5
+ register: output
+
+ - name: Assert updating
+ ansible.builtin.assert:
+ that:
+ - output.changed
+
+ - name: Get key facts
+ azure_rm_rediscache_info:
+ resource_group: "{{ resource_group }}"
+ name: "{{ redis_name }}2"
+ return_access_keys: true
+ register: key_facts
+
+ - name: Regenerate primary redis key
+ azure_rm_rediscache:
+ resource_group: "{{ resource_group }}"
+ name: "{{ redis_name }}2"
+ regenerate_key:
+ key_type: "primary"
+ register: output
+
+ - name: Assert output
+ ansible.builtin.assert:
+ that:
+ - output.changed
+
+ - name: Get facts after key regeneration
+ azure_rm_rediscache_info:
+ resource_group: "{{ resource_group }}"
+ name: "{{ redis_name }}2"
+ return_access_keys: true
+ register: key_facts2
+
+ - name: Assert key change
+ ansible.builtin.assert:
+ that:
+ - key_facts.rediscaches[0].access_keys.primary != key_facts2.rediscaches[0].access_keys.primary
+ - key_facts.rediscaches[0].access_keys.secondary == key_facts2.rediscaches[0].access_keys.secondary
+
+ - name: Delete firewall rule
+ azure_rm_rediscachefirewallrule:
+ resource_group: "{{ resource_group }}"
+ cache_name: "{{ redis_name }}2"
+ name: "{{ rule_name }}"
+ state: absent
+ register: output
+
+ - name: Assert deletion
+ ansible.builtin.assert:
+ that:
+ - output.changed
+
+ - name: Delete the redis cache
+ azure_rm_rediscache:
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
- 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
- register: output
-
- - name: Assert creation
- assert:
- that:
- - output.changed
- - output.id
-
- - name: Update firewall rule idempotence
- 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
- register: output
-
- - name: Assert idempotence
- assert:
- that:
- - output.changed == False
-
- - name: Update firewall rule
- azure_rm_rediscachefirewallrule:
- resource_group: "{{ resource_group }}"
- cache_name: "{{ redis_name }}2"
- name: "{{ rule_name }}"
- end_ip_address: 192.168.1.5
- register: output
-
- - name: Assert updating
- assert:
- that:
- - output.changed
-
- - name: Get key facts
- azure_rm_rediscache_info:
- resource_group: "{{ resource_group }}"
- name: "{{ redis_name }}2"
- return_access_keys: True
- register: key_facts
-
- - name: regenerate primary redis key
- azure_rm_rediscache:
- resource_group: "{{ resource_group }}"
- name: "{{ redis_name }}2"
- regenerate_key:
- key_type: "primary"
- register: output
-
- - name: Assert output
- assert:
- that:
- - output.changed
-
- - name: Get facts after key regeneration
- azure_rm_rediscache_info:
- resource_group: "{{ resource_group }}"
- name: "{{ redis_name }}2"
- return_access_keys: true
- register: key_facts2
-
- - name: Assert key change
- assert:
- that:
- - key_facts.rediscaches[0].access_keys.primary != key_facts2.rediscaches[0].access_keys.primary
- - key_facts.rediscaches[0].access_keys.secondary == key_facts2.rediscaches[0].access_keys.secondary
-
- - name: Delete firewall rule
- azure_rm_rediscachefirewallrule:
- resource_group: "{{ resource_group }}"
- cache_name: "{{ redis_name }}2"
- name: "{{ rule_name }}"
- state: absent
- register: output
-
- - name: Assert deletion
- assert:
- that:
- - output.changed
-
- - name: Delete the redis cache
- azure_rm_rediscache:
- resource_group: "{{ resource_group }}"
- name: "{{ redis_name }}2"
- state: absent
- register: output
- tags: [long_run, never]
+ state: absent
+ register: output
+ tags: [long_run, never]
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_registrationassignment/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_registrationassignment/tasks/main.yml
index 055524705..05cc5d552 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_registrationassignment/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_registrationassignment/tasks/main.yml
@@ -1,10 +1,10 @@
-- name: set facts
- set_fact:
+- name: Set facts
+ ansible.builtin.set_fact:
subscription_id: "{{ azure_subscription_id }}"
managed_by_tenant_id: "{{ azure_managed_by_tenant_id }}"
principal_id: "{{ azure_principal_id }}"
role_definition_id: "{{ azure_role_definition_id }}"
- run_once: yes
+ run_once: true
- name: Create a RegistrationDefinition
azure_rm_registrationdefinition:
@@ -23,42 +23,46 @@
properties:
registration_definition_id: "{{ output1.state.id }}"
register: output
- check_mode: yes
+ check_mode: true
-- assert:
+- name: Assert the registration assignment check mode
+ ansible.builtin.assert:
that:
- - output.changed
+ - output.changed
-- name: Create a RegistrationAssignment
+- name: Create a RegistrationAssignment
azure_rm_registrationassignment:
scope: subscriptions/{{ subscription_id }}
properties:
registration_definition_id: "{{ output1.state.id }}"
register: output2
-- assert:
+- name: Assert the registration assignment created
+ ansible.builtin.assert:
that:
- output2.changed
- name: Create a RegistrationAssignment -- idempotent
azure_rm_registrationassignment:
scope: subscriptions/{{ subscription_id }}
- registration_assignment_id: "{{ output2.state.name }}"
+ registration_assignment_id: "{{ output2.state.name }}"
properties:
registration_definition_id: "{{ output1.state.id }}"
register: output
-- assert:
+- name: Assert idempotent
+ ansible.builtin.assert:
that:
- not output.changed
- name: Get a RegistrationAssignment
azure_rm_registrationassignment_info:
scope: subscriptions/{{ subscription_id }}
- registration_assignment_id: "{{ output2.state.name }}"
+ registration_assignment_id: "{{ output2.state.name }}"
register: output
-- assert:
+- name: Assert the registration assignment facts
+ ansible.builtin.assert:
that:
- output.registration_assignments[0].properties.registration_definition_id == "{{ output1.state.id }}"
@@ -67,12 +71,13 @@
scope: subscriptions/{{ subscription_id }}
register: output
-- assert:
+- name: Assert all registration assignment facts
+ ansible.builtin.assert:
that:
- output.registration_assignments | length >= 1
- name: Delete the RegistrationAssignment
azure_rm_registrationassignment:
scope: subscriptions/{{ subscription_id }}
- registration_assignment_id: "{{ output2.state.name }}"
+ registration_assignment_id: "{{ output2.state.name }}"
state: absent
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_registrationdefinition/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_registrationdefinition/tasks/main.yml
index 0395db002..3a5d58143 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_registrationdefinition/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_registrationdefinition/tasks/main.yml
@@ -1,12 +1,12 @@
-- name: set facts
- set_fact:
- subscription_id: "{{ azure_subscription_id }}"
- subscription_sec_id: "{{ azure_subscription_sec_id }}"
- managed_by_tenant_id: "{{ azure_managed_by_tenant_id }}"
- principal_id: "{{ azure_principal_id }}"
- role_definition_id: "{{ azure_role_definition_id }}"
- reg_def_name: test_name
- run_once: yes
+- name: Set facts
+ ansible.builtin.set_fact:
+ subscription_id: "{{ azure_subscription_id }}"
+ subscription_sec_id: "{{ azure_subscription_sec_id }}"
+ managed_by_tenant_id: "{{ azure_managed_by_tenant_id }}"
+ principal_id: "{{ azure_principal_id }}"
+ role_definition_id: "{{ azure_role_definition_id }}"
+ reg_def_name: test_name
+ run_once: true
- name: Create a RegistrationDefinition -- check mode
azure_rm_registrationdefinition:
@@ -17,11 +17,11 @@
role_definition_id: "{{ role_definition_id }}"
managed_by_tenant_id: "{{ managed_by_tenant_id }}"
registration_definition_name: "{{ reg_def_name }}"
- check_mode: yes
+ check_mode: true
register: output
- name: Assert creating registration definition check mode
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -38,7 +38,7 @@
register: output2
- name: Assert creating registration definition
- assert:
+ ansible.builtin.assert:
that:
- output2.changed
@@ -54,7 +54,7 @@
register: output1
- name: Assert creating registration definition
- assert:
+ ansible.builtin.assert:
that:
- output1.changed
@@ -71,7 +71,7 @@
register: output
- name: Assert creating registration definition
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
@@ -88,17 +88,17 @@
register: output
- name: Assert creating registration definition
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- name: Get the Registration Definition info
azure_rm_registrationdefinition_info:
- registration_definition_id: "{{ output1.state.name }}"
+ registration_definition_id: "{{ output1.state.name }}"
register: output
- name: Assert the registration definition info
- assert:
+ ansible.builtin.assert:
that:
- output.registration_definitions[0].name == "{{ output1.state.name }}"
- output.registration_definitions[0].properties.authorizations[0].principal_id == "{{ principal_id }}"
@@ -109,11 +109,11 @@
- name: Get All Registration Definition info in the subscription
azure_rm_registrationdefinition_info:
- scope: "{{ subscription_id }}"
+ scope: "{{ subscription_id }}"
register: output
- name: Assert all the registration definition info
- assert:
+ ansible.builtin.assert:
that:
- output.registration_definitions | length >=1
@@ -124,7 +124,7 @@
register: output
- name: Assert delete registration definition success
- assert:
+ ansible.builtin.assert:
that:
- output.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_resource/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_resource/tasks/main.yml
index 6ec87237d..0f9834165 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_resource/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_resource/tasks/main.yml
@@ -1,9 +1,9 @@
- name: Prepare random number
- set_fact:
+ ansible.builtin.set_fact:
nsgname: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
storageaccountname: "stacc{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
dbname: "mdb{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
- run_once: yes
+ run_once: true
- name: Call REST API
azure_rm_resource:
@@ -14,11 +14,11 @@
resource_name: "{{ nsgname }}"
body:
location: eastus
- idempotency: yes
+ idempotency: true
register: output
- name: Assert that something has changed
- assert:
+ ansible.builtin.assert:
that: output.changed
- name: Call REST API
@@ -30,11 +30,11 @@
resource_name: "{{ nsgname }}"
body:
location: eastus
- idempotency: yes
+ idempotency: true
register: output
- name: Assert that nothing has changed
- assert:
+ ansible.builtin.assert:
that: not output.changed
- name: Call REST API
@@ -49,11 +49,11 @@
tags:
a: "abc"
b: "cde"
- idempotency: yes
+ idempotency: true
register: output
- name: Assert that something has changed
- assert:
+ ansible.builtin.assert:
that: output.changed
- name: Try to get information about account
@@ -66,7 +66,7 @@
register: output
- name: Assert value was returned
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
- output.response[0]['name'] != None
@@ -80,7 +80,7 @@
resource_type: networksecuritygroups
register: output
- name: Assert value was returned
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
- output.response[0]['name'] != None
@@ -93,7 +93,7 @@
resource_type: networksecuritygroups
register: output
- name: Assert value was returned
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
- output.response[0]['name'] != None
@@ -105,7 +105,7 @@
resource_type: resources
register: output
- name: Assert value was returned
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
- output.response | length >= 1
@@ -127,7 +127,7 @@
register: output
- name: Assert that storage was successfully created
- assert:
+ ansible.builtin.assert:
that: "output['response']['name'] == '{{ storageaccountname }}'"
@@ -144,7 +144,7 @@
register: keys
- name: Assert that key was returned
- assert:
+ ansible.builtin.assert:
that: keys['response']['keys'][0]['value'] | length > 0
- name: Delete storage - without API version
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_resourcegroup/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_resourcegroup/tasks/main.yml
index 706a855e8..4f66237b7 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_resourcegroup/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_resourcegroup/tasks/main.yml
@@ -1,50 +1,55 @@
- name: Get resource group datalake info
azure_rm_resourcegroup_info:
- name: "{{ resource_group_datalake }}"
- list_resources: yes
+ name: "{{ resource_group_datalake }}"
+ list_resources: true
register: rg
-- assert:
+- name: Assert the resource group facts
+ ansible.builtin.assert:
that:
- - rg.resourcegroups | length == 1
- - rg.resourcegroups[0].resources | length >= 0
+ - rg.resourcegroups | length == 1
+ - rg.resourcegroups[0].resources | length >= 0
- name: Get resource group info
azure_rm_resourcegroup_info:
register: rg
-- assert:
+- name: Assert all resource group facts
+ ansible.builtin.assert:
that:
- - rg.resourcegroups | length >= 1
+ - rg.resourcegroups | length >= 1
- name: Get resource group info
azure_rm_resourcegroup_info:
- name: "{{ resource_group }}"
- list_resources: yes
+ name: "{{ resource_group }}"
+ list_resources: true
register: rg
-- assert:
+- name: Assert the resource group facts
+ ansible.builtin.assert:
that:
- - rg.resourcegroups | length == 1
- - rg.resourcegroups[0].resources | length >= 0
+ - rg.resourcegroups | length == 1
+ - rg.resourcegroups[0].resources | length >= 0
- name: Create resource group (idempontent)
azure_rm_resourcegroup:
- name: "{{ resource_group }}"
- location: "{{ rg.resourcegroups[0].location }}"
+ name: "{{ resource_group }}"
+ location: "{{ rg.resourcegroups[0].location }}"
register: output
-- assert:
+- name: Assert idempotent
+ ansible.builtin.assert:
that:
- - not output.changed
+ - not output.changed
-- name: delete resource group
+- name: Delete resource group
azure_rm_resourcegroup:
- name: "{{ resource_group }}"
- state: absent
- check_mode: yes
+ name: "{{ resource_group }}"
+ state: absent
+ check_mode: true
register: output
-- assert:
+- name: Assert the resource group deleted
+ ansible.builtin.assert:
that:
- - output.changed \ No newline at end of file
+ - output.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_roleassignment/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_roleassignment/tasks/main.yml
index c4e4d15d6..e918bdc19 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_roleassignment/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_roleassignment/tasks/main.yml
@@ -1,5 +1,5 @@
-- name: setup basic facts
- set_fact:
+- name: Setup basic facts
+ ansible.builtin.set_fact:
uuid: bb21a88b-30e1-42b5-84e8-1d3f322de033
# Disk Backup Reader, unlikely to be already assigned in ansible-test resource groups.
az_role_definition_guid: '3e5e47e6-65f7-47ef-90b5-e5dd4d455f24'
@@ -15,7 +15,7 @@
id: "{{ item.id | default(omit) }}"
role_definition_id: "{{ item.role_definition_id | default(omit) }}"
scope: "{{ item.scope | default(omit) }}"
- strict_scope_match: True
+ strict_scope_match: true
register: az_role_assignment_specific
loop:
- name: "{{ az_role_assignments.roleassignments[0].name }}"
@@ -25,10 +25,10 @@
role_definition_id: "{{ az_role_assignments.roleassignments[0].role_definition_id }}"
- id: "{{ az_role_assignments.roleassignments[0].id }}"
-- name: check specific fetch for single return
- assert:
+- name: Check specific fetch for single return
+ ansible.builtin.assert:
that:
- - "{{ ( item.roleassignments | length) == 1 }}"
+ - "{{ (item.roleassignments | length) == 1 }}"
loop: "{{ az_role_assignment_specific.results }}"
- name: Intentional mutual exclusion info
@@ -38,7 +38,7 @@
id: "{{ item.id | default(omit) }}"
scope: "{{ item.scope | default(omit) }}"
register: failures_info
- ignore_errors: True
+ ignore_errors: true
loop:
- name: "{{ az_role_assignments.roleassignments[0].name }}"
assignee: "{{ az_role_assignments.roleassignments[0].principal_id }}"
@@ -47,8 +47,8 @@
- name: "{{ az_role_assignments.roleassignments[0].name }}"
id: "{{ az_role_assignments.roleassignments[0].id }}"
-- name: check intended failures
- assert:
+- name: Check intended failures
+ ansible.builtin.assert:
that:
- item.failed
loop: "{{ failures_info.results }}"
@@ -62,7 +62,7 @@
role_definition_id: "{{ item.role_definition_id | default(omit) }}"
state: "{{ item.state | default(omit) }}"
register: failures_mutable
- ignore_errors: True
+ ignore_errors: true
loop:
# mutually exclusive
- scope: "{{ az_role_assignments.roleassignments[0].scope }}"
@@ -87,33 +87,33 @@
role_definition_id: "{{ az_role_assignments.roleassignments[0].role_definition_id }}"
state: "absent"
-- name: check intended failures
- assert:
+- name: Check intended failures
+ ansible.builtin.assert:
that:
- item.failed
loop: "{{ failures_mutable.results }} "
-- name: get resource group info
+- name: Get resource group info
azure_rm_resourcegroup_info:
name: "{{ resource_group }}"
register: az_resource_group
-- name: create role assignment by id
+- name: Create role assignment by id
azure_rm_roleassignment:
id: "{{ az_resource_group.resourcegroups[0].id }}/providers/Microsoft.Authorization/roleAssignments/{{ uuid }}"
assignee_object_id: "{{ az_role_assignments.roleassignments[0].principal_id }}"
role_definition_id: "/subscriptions/{{ az_resource_group.resourcegroups[0].id.split('/')[2] }}/providers/Microsoft.Authorization/roleDefinitions/{{ az_role_definition_guid }}"
register: az_role_assignment_create
-- name: create role assignment by scope
+- name: Create role assignment by scope
azure_rm_roleassignment:
scope: "{{ az_resource_group.resourcegroups[0].id }}"
assignee_object_id: "{{ az_role_assignments.roleassignments[0].principal_id }}"
role_definition_id: "/subscriptions/{{ az_resource_group.resourcegroups[0].id.split('/')[2] }}/providers/Microsoft.Authorization/roleDefinitions/{{ az_role_definition_guid }}"
register: az_role_assignment_idempotent
-- name: check idempotence
- assert:
+- name: Check idempotence
+ ansible.builtin.assert:
that:
- az_role_assignment_idempotent.changed == False
@@ -131,13 +131,13 @@
- name: List Role Assignments at scope with strict matching
azure_rm_roleassignment_info:
scope: "{{ az_role_assignments.roleassignments[0].scope }}"
- strict_scope_match: True
+ strict_scope_match: true
register: az_role_assignment_by_scope_strict
-- name: check strict scope matching
- assert:
+- name: Check strict scope matching
+ ansible.builtin.assert:
that:
- - item.scope == az_role_assignments.roleassignments[0].scope
+ - item.scope == az_role_assignments.roleassignments[0].scope
loop: "{{ az_role_assignment_by_scope_strict.roleassignments }}"
- name: List Role Assignments at id
@@ -157,12 +157,12 @@
register: az_role_assignment_delete
when: az_role_assignment_create.changed
-- name: create role assignment with name
+- name: Create role assignment with name
azure_rm_roleassignment:
scope: "{{ az_resource_group.resourcegroups[0].id }}"
assignee_object_id: "{{ az_role_assignments.roleassignments[0].principal_id }}"
role_definition_id: "/subscriptions/{{ az_resource_group.resourcegroups[0].id.split('/')[2] }}/providers/Microsoft.Authorization/roleDefinitions/{{ az_role_definition_guid }}"
- name: "{{ uuid }}"
+ name: "{{ uuid }}"
register: az_role_assignment_create
- name: Delete Role by Name
@@ -173,14 +173,14 @@
register: az_role_assignment_delete
when: az_role_assignment_create.changed
-- name: create role assignment by scope
+- name: Create role assignment by scope
azure_rm_roleassignment:
scope: "{{ az_resource_group.resourcegroups[0].id }}"
assignee_object_id: "{{ az_role_assignments.roleassignments[0].principal_id }}"
role_definition_id: "/subscriptions/{{ az_resource_group.resourcegroups[0].id.split('/')[2] }}/providers/Microsoft.Authorization/roleDefinitions/{{ az_role_definition_guid }}"
register: az_role_assignment_create_by_scope
-- name: delete by scope, assignee_object_id and role_definition_id
+- name: Delete by scope, assignee_object_id and role_definition_id
azure_rm_roleassignment:
scope: "{{ az_resource_group.resourcegroups[0].id }}"
assignee_object_id: "{{ az_role_assignments.roleassignments[0].principal_id }}"
@@ -189,20 +189,20 @@
register: az_role_assignment_delete
when: az_role_assignment_create.changed
-- name: absent assignment that doesn't exist - id
+- name: Absent assignment that doesn't exist - id
azure.azcollection.azure_rm_roleassignment:
id: "{{ az_role_assignment_delete.id }}"
state: absent
register: absent_nochange_id
-- name: absent assignment that doesn't exist - name
+- name: Absent assignment that doesn't exist - name
azure.azcollection.azure_rm_roleassignment:
name: "{{ az_role_assignment_delete.name }}"
scope: "{{ az_role_assignment_delete.scope }}"
state: absent
register: absent_nochange_name
-- name: absent assignment that doesn't exist - properties
+- name: Absent assignment that doesn't exist - properties
azure.azcollection.azure_rm_roleassignment:
scope: "{{ az_role_assignment_delete.scope }}"
assignee_object_id: "{{ az_role_assignment_delete.assignee_object_id }}"
@@ -210,11 +210,11 @@
state: absent
register: absent_nochange_properties
-- name: check intended failures info
- assert:
+- name: Check intended failures info
+ ansible.builtin.assert:
that:
- item.changed == false
- loop:
+ loop:
- "{{ absent_nochange_properties }}"
- "{{ absent_nochange_id }}"
- "{{ absent_nochange_name }}"
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_roledefinition/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_roledefinition/tasks/main.yml
index 15cf266b6..6367198a8 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_roledefinition/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_roledefinition/tasks/main.yml
@@ -1,13 +1,13 @@
- name: Fix resource prefix
- set_fact:
- role_name: "{{ (resource_group | replace('-','x'))[-8:] }}{{ 1000 | random }}testrole"
- subscription_id: "{{azure_subscription_id}}"
- principal_id: "{{azure_client_id}}"
- run_once: yes
+ ansible.builtin.set_fact:
+ my_role_name: "{{ (resource_group | replace('-', 'x'))[-8:] }}{{ 1000 | random }}testrole"
+ subscription_id: "{{ azure_subscription_id }}"
+ principal_id: "{{ azure_client_id }}"
+ run_once: true
- name: Create a role definition (Check Mode)
azure_rm_roledefinition:
- name: "{{ role_name }}"
+ name: "{{ my_role_name }}"
scope: "/subscriptions/{{ subscription_id }}/resourceGroups/{{ resource_group }}"
permissions:
- actions:
@@ -19,18 +19,18 @@
not_data_actions:
- "Microsoft.Storage/storageAccounts/blobServices/containers/blobs/write"
assignable_scopes:
- - "/subscriptions/{{ subscription_id }}/resourceGroups/{{ resource_group }}"
- check_mode: yes
+ - "/subscriptions/{{ subscription_id }}/resourceGroups/{{ resource_group }}"
+ check_mode: true
register: output
- name: Assert creating role definition check mode
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- name: Create a role definition
azure_rm_roledefinition:
- name: "{{ role_name }}"
+ name: "{{ my_role_name }}"
scope: "/subscriptions/{{ subscription_id }}/resourceGroups/{{ resource_group }}"
permissions:
- actions:
@@ -42,48 +42,48 @@
not_data_actions:
- "Microsoft.Storage/storageAccounts/blobServices/containers/blobs/write"
assignable_scopes:
- - "/subscriptions/{{ subscription_id }}/resourceGroups/{{ resource_group }}"
+ - "/subscriptions/{{ subscription_id }}/resourceGroups/{{ resource_group }}"
register: output
- name: Assert creating role definition
- assert:
+ ansible.builtin.assert:
that:
- output.changed
## because of the bug of azure service , the following tasks will cause failures randomly
#
-#- name: Get facts by type
+# - name: Get facts by type
# azure_rm_roledefinition_info:
# scope: "/subscriptions/{{ subscription_id }}/resourceGroups/{{ resource_group }}"
# type: custom
# register: facts
#
-#- name: Assert facts
-# assert:
+# - name: Assert facts
+# ansible.builtin.assert:
# that:
# - facts['roledefinitions'] | length > 1
#
-#- name: Get facts by name
+# - name: Get facts by name
# azure_rm_roledefinition_info:
# scope: "/subscriptions/{{ subscription_id }}/resourceGroups/{{ resource_group }}"
-# role_name: "{{ role_name }}"
+# role_name: "{{ my_role_name }}"
# register: facts
# until: facts.roledefinitions | length > 0
# retries: 50
# delay: 60
#
-#- name: Assert facts
-# assert:
+# - name: Assert facts
+# ansible.builtin.assert:
# that:
# - facts['roledefinitions'] | length == 1
# - facts['roledefinitions'][0]['permissions'] | length == 1
# - facts['roledefinitions'][0]['permissions'][0]['not_data_actions'] | length == 1
# - facts['roledefinitions'][0]['permissions'][0]['data_actions'] | length == 1
#
-#- name: Update the role definition (idempotent)
+# - name: Update the role definition (idempotent)
# azure_rm_roledefinition:
-# name: "{{ role_name }}"
+# name: "{{ my_role_name }}"
# scope: "/subscriptions/{{ subscription_id }}/resourceGroups/{{ resource_group }}"
# permissions:
# - actions:
@@ -98,14 +98,14 @@
# - "/subscriptions/{{ subscription_id }}/resourceGroups/{{ resource_group }}"
# register: output
#
-#- name: assert output not changed
-# assert:
+# - name: ansible.builtin.assert output not changed
+# ansible.builtin.assert:
# that:
# - not output.changed
#
-#- name: Update the role definition
+# - name: Update the role definition
# azure_rm_roledefinition:
-# name: "{{ role_name }}"
+# name: "{{ my_role_name }}"
# description: "update description"
# scope: "/subscriptions/{{ subscription_id }}/resourceGroups/{{ resource_group }}"
# permissions:
@@ -122,14 +122,14 @@
# - "/subscriptions/{{ subscription_id }}/resourceGroups/{{ resource_group }}"
# register: output
#
-#- name: assert output changed
-# assert:
+# - name: ansible.builtin.assert output changed
+# ansible.builtin.assert:
# that:
# - output.changed
#
-#- name: Get role definition facts
+# - name: Get role definition facts
# azure_rm_roledefinition_info:
-# role_name: "{{ role_name }}"
+# role_name: "{{ my_role_name }}"
# scope: "/subscriptions/{{ subscription_id }}/resourceGroups/{{ resource_group }}"
# type: custom
# register: roledef
@@ -137,13 +137,13 @@
# retries: 50
# delay: 60
#
-#- name: Assert role definition facts
-# assert:
+# - name: Assert role definition facts
+# ansible.builtin.assert:
# that:
# - roledef['roledefinitions'] | length == 1
# - roledef['roledefinitions'][0]['id']
#
-#- name: Create a role assignment (Check Mode)
+# - name: Create a role assignment (Check Mode)
# azure_rm_roleassignment:
# scope: "/subscriptions/{{ subscription_id }}/resourceGroups/{{ resource_group }}"
# assignee_object_id: "{{ principal_id }}"
@@ -151,61 +151,61 @@
# check_mode: yes
# register: output
#
-#- name: Assert creating role definition check mode
-# assert:
+# - name: Assert creating role definition check mode
+# ansible.builtin.assert:
# that:
# - output.changed
#
-#- name: Create a role assignment
+# - name: Create a role assignment
# azure_rm_roleassignment:
# scope: "/subscriptions/{{ subscription_id }}/resourceGroups/{{ resource_group }}"
# assignee_object_id: "{{ principal_id }}"
# role_definition_id: "{{ roledef['roledefinitions'][0]['id'] }}"
# register: output
#
-#- name: Assert creating role assignment
-# assert:
+# - name: Assert creating role assignment
+# ansible.builtin.assert:
# that:
# - output.changed
#
-#- name: Get facts
+# - name: Get facts
# azure_rm_roleassignment_info:
# scope: "/subscriptions/{{ subscription_id }}/resourceGroups/{{ resource_group }}"
# assignee: "{{ principal_id }}"
# role_definition_id: "{{ roledef['roledefinitions'][0]['id'] }}"
# register: facts
#
-#- name: assert role assignment facts
-# assert:
+# - name: ansible.builtin.assert role assignment facts
+# ansible.builtin.assert:
# that:
# - facts['roleassignments'] | length > 0
# - facts['roleassignments'][0]['id']
#
-#- name: delete role assignment
+# - name: delete role assignment
# azure_rm_roleassignment:
# name: "{{ facts['roleassignments'][0]['id'].split('/')[-1] }}"
# scope: "/subscriptions/{{ subscription_id }}"
# state: absent
#
-#- name: Delete the role definition (Check Mode)
+# - name: Delete the role definition (Check Mode)
# azure_rm_roledefinition:
-# name: "{{ role_name }}"
+# name: "{{ my_role_name }}"
# scope: "/subscriptions/{{ subscription_id }}/resourceGroups/{{ resource_group }}"
# state: absent
# check_mode: yes
# register: output
#
-#- name: assert deleting role definition check mode
-# assert:
+# - name: ansible.builtin.assert deleting role definition check mode
+# ansible.builtin.assert:
# that: output.changed
#
-#- name: Delete the role definition
+# - name: Delete the role definition
# azure_rm_roledefinition:
-# name: "{{ role_name }}"
+# name: "{{ my_role_name }}"
# scope: "/subscriptions/{{ subscription_id }}/resourceGroups/{{ resource_group }}"
# state: absent
# register: output
#
-#- assert:
+# - ansible.builtin.assert:
# that:
# - output.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_routetable/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_routetable/tasks/main.yml
index 98b3c752a..057e516ea 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_routetable/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_routetable/tasks/main.yml
@@ -1,55 +1,59 @@
- name: Prepare random number
- set_fact:
- name: "table{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
+ ansible.builtin.set_fact:
+ name_rpfx: "table{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
route_name: "route{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
- run_once: yes
+ run_once: true
- name: Create a route table (check mode)
azure_rm_routetable:
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
resource_group: "{{ resource_group }}"
tags:
purpose: testing
- check_mode: yes
+ check_mode: true
register: output
-- assert:
+- name: Assert check mode
+ ansible.builtin.assert:
that:
- not output.id
- output.changed
- name: Create a route table
azure_rm_routetable:
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
resource_group: "{{ resource_group }}"
tags:
- purpose: testing
+ purpose: testing
register: output
-- assert:
+- name: Assert the route table created
+ ansible.builtin.assert:
that:
- output.changed
- output.id
- name: Create a route table (idemponent)
azure_rm_routetable:
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
resource_group: "{{ resource_group }}"
tags:
purpose: testing
register: output
-- assert:
+- name: Assert idempotent
+ ansible.builtin.assert:
that:
- not output.changed
- name: Get facts of the table
azure_rm_routetable_info:
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
resource_group: "{{ resource_group }}"
register: output
-- assert:
+- name: Assert the route table facts
+ ansible.builtin.assert:
that:
- "output.route_tables | length == 1"
- "output.route_tables[0].routes | length == 0"
@@ -60,11 +64,12 @@
resource_group: "{{ resource_group }}"
next_hop_type: virtual_network_gateway
address_prefix: "10.1.0.0/16"
- route_table_name: "{{ name }}"
- check_mode: yes
+ route_table_name: "{{ name_rpfx }}"
+ check_mode: true
register: output
-- assert:
+- name: Assert check mode
+ ansible.builtin.assert:
that:
- output.changed
- not output.id
@@ -75,10 +80,11 @@
resource_group: "{{ resource_group }}"
next_hop_type: virtual_network_gateway
address_prefix: "10.1.0.0/16"
- route_table_name: "{{ name }}"
+ route_table_name: "{{ name_rpfx }}"
register: output
-- assert:
+- name: Assert the route created
+ ansible.builtin.assert:
that:
- output.changed
- output.id
@@ -89,23 +95,25 @@
resource_group: "{{ resource_group }}"
next_hop_type: virtual_network_gateway
address_prefix: "10.1.0.0/16"
- route_table_name: "{{ name }}"
+ route_table_name: "{{ name_rpfx }}"
register: output
-- assert:
+- name: Assert idempotent
+ ansible.builtin.assert:
that:
- not output.changed
-- name: update route
+- name: Update route
azure_rm_route:
name: "{{ route_name }}"
resource_group: "{{ resource_group }}"
next_hop_type: virtual_network_gateway
address_prefix: "10.1.0.0/24"
- route_table_name: "{{ name }}"
+ route_table_name: "{{ name_rpfx }}"
register: output
-- assert:
+- name: Assert the route updated
+ ansible.builtin.assert:
that:
- output.changed
@@ -113,21 +121,23 @@
azure_rm_route_info:
name: "{{ route_name }}"
resource_group: "{{ resource_group }}"
- route_table_name: "{{ name }}"
+ route_table_name: "{{ name_rpfx }}"
register: output
-- assert:
+- name: Assert the route facts
+ ansible.builtin.assert:
that:
- output.routes[0].address_prefix == "10.1.0.0/24"
- output.routes[0].next_hop_type == "VirtualNetworkGateway"
- name: Get facts of the table
azure_rm_routetable_info:
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
resource_group: "{{ resource_group }}"
register: output
-- assert:
+- name: Assert the route table facts
+ ansible.builtin.assert:
that:
- "output.route_tables | length == 1"
- "output.route_tables[0].routes | length == 1"
@@ -137,19 +147,20 @@
azure_rm_route:
name: "{{ route_name }}"
resource_group: "{{ resource_group }}"
- route_table_name: "{{ name }}"
+ route_table_name: "{{ name_rpfx }}"
state: absent
- check_mode: yes
+ check_mode: true
- name: Delete route
azure_rm_route:
name: "{{ route_name }}"
resource_group: "{{ resource_group }}"
state: absent
- route_table_name: "{{ name }}"
+ route_table_name: "{{ name_rpfx }}"
register: output
-- assert:
+- name: Assert the route deleted
+ ansible.builtin.assert:
that:
- output.changed
@@ -158,38 +169,41 @@
name: "{{ route_name }}"
resource_group: "{{ resource_group }}"
state: absent
- route_table_name: "{{ name }}"
+ route_table_name: "{{ name_rpfx }}"
register: output
-- assert:
+- name: Assert idempotent
+ ansible.builtin.assert:
that:
- not output.changed
- name: Delete route table (check mode)
azure_rm_routetable:
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
resource_group: "{{ resource_group }}"
state: absent
- check_mode: yes
+ check_mode: true
- name: Delete route table
azure_rm_routetable:
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
resource_group: "{{ resource_group }}"
state: absent
register: output
-- assert:
+- name: Assert the route table deleted
+ ansible.builtin.assert:
that:
- output.changed
- name: Delete route table (idemponent)
azure_rm_routetable:
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
resource_group: "{{ resource_group }}"
state: absent
register: output
-- assert:
+- name: Assert idempotent
+ ansible.builtin.assert:
that:
- not output.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_securitygroup/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_securitygroup/tasks/main.yml
index dd35db16a..6dc584a6f 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_securitygroup/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_securitygroup/tasks/main.yml
@@ -1,10 +1,10 @@
- name: Prepare random number
- set_fact:
+ ansible.builtin.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: yes
+ run_once: true
- name: Create security group
azure_rm_securitygroup:
@@ -15,7 +15,7 @@
delete: on-exit
foo: bar
testkey: testvalue
- purge_rules: yes
+ purge_rules: true
rules:
- name: DenySSH
protocol: Tcp
@@ -31,8 +31,8 @@
priority: 101
direction: Inbound
register: output
-- name: assert resource created
- assert:
+- name: Assert resource created
+ ansible.builtin.assert:
that: "{{ output.state.rules | length }} == 2"
- name: Gather facts by tags
@@ -43,8 +43,8 @@
- foo:bar
- testkey
register: output
-- name: assert resource retrieved
- assert:
+- name: Assert resource retrieved
+ ansible.builtin.assert:
that:
- output.securitygroups | length == 1
- output.securitygroups[0].default_rules | length > 0
@@ -77,8 +77,8 @@
- 443
priority: 103
register: output
-- name: assert resource updated
- assert:
+- name: Assert resource updated
+ ansible.builtin.assert:
that:
- "{{ output.state.rules | length }} == 4"
- output.state.rules[0].source_address_prefix == '174.108.158.0/24'
@@ -88,8 +88,8 @@
resource_group: "{{ resource_group }}"
name: "{{ secgroupname }}"
register: output
-- name: assert rules updated
- assert:
+- name: Assert rules updated
+ ansible.builtin.assert:
that:
- output.securitygroups[0].rules | length == 4
@@ -117,8 +117,8 @@
- 443
priority: 103
register: output
-- name: assert resource not updated
- assert:
+- name: Assert resource not updated
+ ansible.builtin.assert:
that: not output.changed
- name: Update tags
@@ -131,8 +131,8 @@
baz: bar
append_tags: false
register: output
-- name: assert resource updated
- assert:
+- name: Assert resource updated
+ ansible.builtin.assert:
that:
- output.state.tags | length == 3
- output.state.tags.delete == 'never'
@@ -146,8 +146,8 @@
testing: testing
delete: on-exit
register: output
-- name: assert resource updated
- assert:
+- name: Assert resource updated
+ ansible.builtin.assert:
that:
- output.state.tags | length == 2
- output.state.tags.delete == 'on-exit'
@@ -157,8 +157,8 @@
resource_group: "{{ resource_group }}"
name: "{{ secgroupname }}"
register: output
-- name: assert resource retrieved
- assert:
+- name: Assert resource retrieved
+ ansible.builtin.assert:
that:
- output.securitygroups | length == 1
@@ -168,8 +168,8 @@
tags:
- testing:testing
register: output_groups
-- name: assert resource retrieved
- assert:
+- name: Assert resource retrieved
+ ansible.builtin.assert:
that:
- output_groups.securitygroups | length > 0
@@ -181,7 +181,7 @@
testing: testing
delete: on-exit
foo: bar
- purge_rules: yes
+ purge_rules: true
rules:
- name: AllowSSH
protocol: Tcp
@@ -194,8 +194,8 @@
priority: 101
direction: Inbound
register: output
-- name: assert resource created
- assert:
+- name: Assert resource created
+ ansible.builtin.assert:
that:
- "{{ output.state.rules | length }} == 1"
- "{{ output.state.rules[0].source_address_prefixes | length }} == 3"
@@ -209,7 +209,7 @@
testing: testing
delete: on-exit
foo: bar
- purge_rules: yes
+ purge_rules: true
rules:
- name: AllowSSH
protocol: Tcp
@@ -222,8 +222,8 @@
priority: 101
direction: Inbound
register: output
-- name: assert resource not updated
- assert:
+- name: Assert resource not updated
+ ansible.builtin.assert:
that: not output.changed
- name: Add a single one group
@@ -244,8 +244,8 @@
priority: 102
direction: Inbound
register: output
-- name: assert resource updated
- assert:
+- name: Assert resource updated
+ ansible.builtin.assert:
that:
- output.changed
- "{{ output.state.rules | length }} == 2"
@@ -285,8 +285,8 @@
priority: 100
direction: Inbound
register: output
-- name: assert resource not updated
- assert:
+- name: Assert resource not updated
+ ansible.builtin.assert:
that:
- not output.changed
@@ -310,7 +310,7 @@
azure_rm_securitygroup:
resource_group: "{{ resource_group }}"
name: "{{ sg_name1 }}"
- purge_rules: yes
+ purge_rules: true
rules:
- name: AsgToAsg
protocol: Tcp
@@ -324,8 +324,8 @@
priority: 101
direction: Inbound
register: output
-- name: assert resource retrieved
- assert:
+- name: Assert resource retrieved
+ ansible.builtin.assert:
that:
- output.changed
@@ -333,7 +333,7 @@
azure_rm_securitygroup:
resource_group: "{{ resource_group }}"
name: "{{ sg_name1 }}"
- purge_rules: yes
+ purge_rules: true
rules:
- name: AsgToAsg
protocol: Tcp
@@ -347,8 +347,8 @@
priority: 101
direction: Inbound
register: output
-- name: assert resource not updated
- assert:
+- name: Assert resource not updated
+ ansible.builtin.assert:
that:
- not output.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_servicebus/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_servicebus/tasks/main.yml
index 1bc4c11f9..3b4495faf 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_servicebus/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_servicebus/tasks/main.yml
@@ -1,18 +1,19 @@
- name: Prepare random number
- set_fact:
+ ansible.builtin.set_fact:
rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
- run_once: yes
+ run_once: true
- name: Create a namespace
azure_rm_servicebus:
- name: "ns{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- sku: premium
- tags:
- key1: value1
+ name: "ns{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ sku: premium
+ tags:
+ key1: value1
register: namespace
-- assert:
+- name: Assert the namespace created
+ ansible.builtin.assert:
that:
- namespace.id
- namespace.changed
@@ -20,162 +21,171 @@
- name: Create a namespace (idempontent)
azure_rm_servicebus:
- name: "ns{{ rpfx }}"
- resource_group: "{{ resource_group }}"
+ name: "ns{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
register: namespace
-- assert:
+- name: Assert idempotent
+ ansible.builtin.assert:
that:
- not namespace.changed
- name: Create a queue
azure_rm_servicebusqueue:
- name: "queue{{ rpfx }}"
- namespace: "ns{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- max_message_size_in_kb: 2048
- max_size_in_mb: 2048
+ name: "queue{{ rpfx }}"
+ namespace: "ns{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ max_message_size_in_kb: 2048
+ max_size_in_mb: 2048
register: queue
-- assert:
- that:
- - queue.id
- - queue.changed
+- name: Assert the queue created
+ ansible.builtin.assert:
+ that:
+ - queue.id
+ - queue.changed
- name: Create a topic (check mode)
azure_rm_servicebustopic:
- name: "topic{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- namespace: "ns{{ rpfx }}"
- duplicate_detection_time_in_seconds: 600
- max_message_size_in_kb: 2048
- max_size_in_mb: 2048
- check_mode: yes
+ name: "topic{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ namespace: "ns{{ rpfx }}"
+ duplicate_detection_time_in_seconds: 600
+ max_message_size_in_kb: 2048
+ max_size_in_mb: 2048
+ check_mode: true
register: output
-- assert:
- that:
- - output.changed
+- name: Assert the check mode
+ ansible.builtin.assert:
+ that:
+ - output.changed
- name: Create a topic
azure_rm_servicebustopic:
- name: "topic{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- namespace: "ns{{ rpfx }}"
- duplicate_detection_time_in_seconds: 600
- max_message_size_in_kb: 2048
- max_size_in_mb: 2048
+ name: "topic{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ namespace: "ns{{ rpfx }}"
+ duplicate_detection_time_in_seconds: 600
+ max_message_size_in_kb: 2048
+ max_size_in_mb: 2048
register: output
-- assert:
- that:
- - output.changed
- - output.id
- - "'subscription_count' not in output"
+- name: Assert the topic created
+ ansible.builtin.assert:
+ that:
+ - output.changed
+ - output.id
+ - "'subscription_count' not in output"
- name: Create a topic (idempontent)
azure_rm_servicebustopic:
- name: "topic{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- namespace: "ns{{ rpfx }}"
- duplicate_detection_time_in_seconds: 600
- max_message_size_in_kb: 2048
- max_size_in_mb: 2048
+ name: "topic{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ namespace: "ns{{ rpfx }}"
+ duplicate_detection_time_in_seconds: 600
+ max_message_size_in_kb: 2048
+ max_size_in_mb: 2048
register: output
-- assert:
- that:
- - not output.changed
+- name: Assert idempotent
+ ansible.builtin.assert:
+ that:
+ - not output.changed
- name: Create test policy
azure_rm_servicebussaspolicy:
- name: testpolicy
- resource_group: "{{ resource_group }}"
- namespace: "ns{{ rpfx }}"
- topic: "topic{{ rpfx }}"
- rights: manage
+ name: testpolicy
+ resource_group: "{{ resource_group }}"
+ namespace: "ns{{ rpfx }}"
+ topic: "topic{{ rpfx }}"
+ rights: manage
- name: Create a subscription
azure_rm_servicebustopicsubscription:
- name: "subs{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- namespace: "ns{{ rpfx }}"
- topic: "topic{{ rpfx }}"
+ name: "subs{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ namespace: "ns{{ rpfx }}"
+ topic: "topic{{ rpfx }}"
register: subs
-- assert:
- that:
- - subs.id
- - subs.changed
+- name: Assert the subscription created
+ ansible.builtin.assert:
+ that:
+ - subs.id
+ - subs.changed
- name: Retrive topic
azure_rm_servicebus_info:
- type: topic
- name: "topic{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- namespace: "ns{{ rpfx }}"
- show_sas_policies: yes
+ type: topic
+ name: "topic{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ namespace: "ns{{ rpfx }}"
+ show_sas_policies: true
register: facts
-- assert:
- that:
- - "facts.servicebuses | length == 1"
- - facts.servicebuses[0].id == output.id
- - facts.servicebuses[0].subscription_count == 1
- - facts.servicebuses[0].sas_policies.testpolicy
- - facts.servicebuses[0].sas_policies.testpolicy.rights == 'manage'
+- name: Assert the topic facts
+ ansible.builtin.assert:
+ that:
+ - "facts.servicebuses | length == 1"
+ - facts.servicebuses[0].id == output.id
+ - facts.servicebuses[0].subscription_count == 1
+ - facts.servicebuses[0].sas_policies.testpolicy
+ - facts.servicebuses[0].sas_policies.testpolicy.rights == 'manage'
- name: Delete subscription
azure_rm_servicebustopicsubscription:
- name: "subs{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- namespace: "ns{{ rpfx }}"
- topic: "topic{{ rpfx }}"
- state: absent
+ name: "subs{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ namespace: "ns{{ rpfx }}"
+ topic: "topic{{ rpfx }}"
+ state: absent
- name: Retrive topic
azure_rm_servicebus_info:
- type: topic
- name: "topic{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- namespace: "ns{{ rpfx }}"
- show_sas_policies: yes
+ type: topic
+ name: "topic{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ namespace: "ns{{ rpfx }}"
+ show_sas_policies: true
register: facts
-- assert:
- that:
- - facts.servicebuses[0].subscription_count == 0
- - "facts.servicebuses | length == 1"
+- name: Assert the topic facts
+ ansible.builtin.assert:
+ that:
+ - facts.servicebuses[0].subscription_count == 0
+ - "facts.servicebuses | length == 1"
- name: Delete topic
azure_rm_servicebustopic:
- name: "topic{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- namespace: "ns{{ rpfx }}"
- state: absent
+ name: "topic{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ namespace: "ns{{ rpfx }}"
+ state: absent
- name: Retrive topic
azure_rm_servicebus_info:
- name: "topic{{ rpfx }}"
- type: topic
- resource_group: "{{ resource_group }}"
- namespace: "ns{{ rpfx }}"
- show_sas_policies: yes
+ name: "topic{{ rpfx }}"
+ type: topic
+ resource_group: "{{ resource_group }}"
+ namespace: "ns{{ rpfx }}"
+ show_sas_policies: true
register: facts
-- assert:
- that:
- - "facts.servicebuses | length == 0"
+- name: Assert the topic facts
+ ansible.builtin.assert:
+ that:
+ - "facts.servicebuses | length == 0"
- name: Delete queue
azure_rm_servicebusqueue:
- name: "queue{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- namespace: "ns{{ rpfx }}"
- state: absent
+ name: "queue{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ namespace: "ns{{ rpfx }}"
+ state: absent
- name: Delete namespace
azure_rm_servicebus:
- name: "ns{{ rpfx }}"
- resource_group: "{{ resource_group }}"
- state: absent
+ name: "ns{{ rpfx }}"
+ resource_group: "{{ resource_group }}"
+ state: absent
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_sqlmanagedinstance/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_sqlmanagedinstance/tasks/main.yml
index 99c9f80cb..822f1d188 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_sqlmanagedinstance/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_sqlmanagedinstance/tasks/main.yml
@@ -1,5 +1,5 @@
- name: Prepare random number
- set_fact:
+ ansible.builtin.set_fact:
random_postfix: "sqlmi{{ 1000 | random }}{{ resource_group | hash('md5') | truncate(7, True, '') }}"
- name: Create virtual network
@@ -29,7 +29,7 @@
testing: testing
delete: on-exit
foo: bar
- purge_rules: yes
+ purge_rules: true
rules:
- name: DenySSH
protocol: Tcp
@@ -83,7 +83,7 @@
register: output
- name: Assert the resource instance is not exist
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -108,7 +108,7 @@
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -132,7 +132,7 @@
register: output
- name: Assert the resource instance no changed
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
@@ -158,7 +158,7 @@
register: output
- name: Assert the resource instance is update
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -169,7 +169,7 @@
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.sql_managed_instance[0].tags | length == 1
- output.sql_managed_instance[0].storage_size_in_gb == 256
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_sqlserver/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_sqlserver/tasks/main.yml
index e71b620ca..25ee16b40 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_sqlserver/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_sqlserver/tasks/main.yml
@@ -1,11 +1,11 @@
- name: Prepare random number
- set_fact:
+ ansible.builtin.set_fact:
random_postfix: "{{ 1000 | random }}{{ resource_group | hash('md5') | truncate(7, True, '') }}"
tenant_id: "{{ azure_tenant }}"
run_azuread_tests: false
azuread_group_name: "Test Security Group"
azuread_group_id: "00000000-0000-0000-0000-000000000000"
- run_once: yes
+ run_once: true
- name: Create instance of SQL Server -- check mode
azure_rm_sqlserver:
@@ -14,10 +14,10 @@
location: eastus
admin_username: mylogin
admin_password: Password123!
- check_mode: yes
+ check_mode: true
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -32,7 +32,7 @@
aaa: bbb
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.state == 'Ready'
@@ -46,7 +46,7 @@
admin_password: Password123!
register: output
- name: Assert the state has not changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed == false
- output.state == 'Ready'
@@ -65,7 +65,7 @@
aaa: bbb
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.state == 'Ready'
@@ -84,7 +84,7 @@
aaa: bbb
register: output
- name: Assert the state has not changed
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
- output.state == 'Ready'
@@ -98,7 +98,7 @@
change_admin_password: true
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -118,7 +118,7 @@
register: output
when: run_azuread_tests | bool
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.state == 'Ready'
@@ -140,7 +140,7 @@
register: output
when: run_azuread_tests | bool
- name: Assert the state has not changed
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
- output.state == 'Ready'
@@ -154,7 +154,7 @@
server_name: "sqlsrv{{ random_postfix }}"
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.servers.sqlsrv{{ random_postfix }}.id != None
@@ -175,7 +175,7 @@
server_name: "sqlsrv-extended-{{ random_postfix }}"
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.servers['sqlsrv-extended-{{ random_postfix }}'].id != None
@@ -200,7 +200,7 @@
register: output
when: run_azuread_tests | bool
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.servers['sqlsrv-azuread-{{ random_postfix }}'].id != None
@@ -227,7 +227,7 @@
server_name: "unexisting"
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.servers == {}
@@ -237,7 +237,7 @@
resource_group: "{{ resource_group }}"
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.servers.sqlsrv{{ random_postfix }}.id != None
@@ -257,10 +257,10 @@
server_name: sqlsrv{{ random_postfix }}
name: database{{ random_postfix }}
location: eastus
- check_mode: yes
+ check_mode: true
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -275,7 +275,7 @@
aaa: bbb
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.status == 'Online'
@@ -291,7 +291,7 @@
aaa: bbb
register: output
- name: Assert the state has not changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed == false
- output.status == 'Online'
@@ -305,9 +305,9 @@
register: output
until: output.databases[0].earliest_restore_date != None
retries: 10
- delay: 20
+ delay: 60
- name: Assert that it can be restored from
- assert:
+ ansible.builtin.assert:
that:
- output.databases[0].id != None
- output.databases[0].earliest_restore_date != None
@@ -323,7 +323,7 @@
location: eastus
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -335,7 +335,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -354,7 +354,7 @@
name: database{{ random_postfix }}
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.databases[0].id != None
@@ -372,7 +372,7 @@
server_name: sqlsrv{{ random_postfix }}
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.databases[0].id != None
@@ -406,10 +406,10 @@
server_name: sqlsrv{{ random_postfix }}
name: database{{ random_postfix }}
state: absent
- check_mode: yes
+ check_mode: true
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -421,7 +421,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -433,7 +433,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed == false
@@ -447,14 +447,14 @@
sku:
name: S0
tier: Standard
- check_mode: yes
+ check_mode: true
register: output
- name: Assert the state has not changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
-- name: Create SQL Database with sku
+- name: Create SQL Database with sku
azure_rm_sqldatabase:
resource_group: "{{ resource_group }}"
server_name: sqlsrv{{ random_postfix }}
@@ -467,11 +467,11 @@
tier: Standard
register: output
- name: Assert the resource instance is well created with good SKU
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.status == 'Online'
-
+
- name: Gather facts SQL Database with good SKU
azure_rm_sqldatabase_info:
resource_group: "{{ resource_group }}"
@@ -479,7 +479,7 @@
name: database{{ random_postfix }}2
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.databases[0].id != None
@@ -490,7 +490,7 @@
- output.databases[0].sku.capacity != None
- output.databases[0].kind != None
- output.databases[0].status != None
-
+
- name: Create again instance of SQL Database with same SKU
azure_rm_sqldatabase:
resource_group: "{{ resource_group }}"
@@ -504,7 +504,7 @@
tier: Standard
register: output
- name: Assert the state has not changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed == false
- output.status == 'Online'
@@ -522,7 +522,7 @@
tier: Premium
register: output
- name: Assert the state has not changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.status == 'Online'
@@ -534,7 +534,7 @@
name: database{{ random_postfix }}2
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.databases[0].id != None
@@ -554,7 +554,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -566,7 +566,7 @@
name: database{{ random_postfix }}2
register: output
- name: Assert that empty dictionary was returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.databases | length == 0
@@ -577,7 +577,7 @@
server_name: sqlsrv{{ random_postfix }}
register: output
- name: Assert that empty dictionary was returned (one database is there by default)
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.databases | length == 1
@@ -591,10 +591,10 @@
name: firewallrule{{ random_postfix }}
start_ip_address: 172.28.10.136
end_ip_address: 172.28.10.138
- check_mode: yes
+ check_mode: true
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -607,7 +607,7 @@
end_ip_address: 172.28.10.138
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -620,7 +620,7 @@
end_ip_address: 172.28.10.138
register: output
- name: Assert the state has not changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed == false
@@ -643,7 +643,7 @@
name: firewallrule{{ random_postfix }}
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.rules[0].id != None
@@ -659,7 +659,7 @@
server_name: sqlsrv{{ random_postfix }}
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.rules[0].id != None
@@ -696,7 +696,7 @@
name: firewallrule{{ random_postfix }}
register: output
- name: Assert that empty dictionary was returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.rules | length == 0
@@ -708,13 +708,13 @@
resource_group: "{{ resource_group }}"
server_name: sqlsrv{{ random_postfix }}
name: EP{{ random_postfix }}
- zone_redundant: False
+ zone_redundant: false
tags:
aaa: bbb
- check_mode: yes
+ check_mode: true
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -723,13 +723,13 @@
resource_group: "{{ resource_group }}"
server_name: sqlsrv{{ random_postfix }}
name: EP{{ random_postfix }}
- zone_redundant: False
+ zone_redundant: false
tags:
aaa: bbb
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -738,13 +738,13 @@
resource_group: "{{ resource_group }}"
server_name: sqlsrv{{ random_postfix }}
name: EP{{ random_postfix }}
- zone_redundant: False
+ zone_redundant: false
tags:
aaa: bbb
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
@@ -753,13 +753,13 @@
resource_group: "{{ resource_group }}"
server_name: sqlsrv{{ random_postfix }}
name: EP{{ random_postfix }}
- zone_redundant: True
+ zone_redundant: true
tags:
aaa1: bbb1
register: output
- name: Assert the resource instance is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -771,7 +771,7 @@
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.elastic_pool[0].zone_redundant == true
@@ -786,7 +786,7 @@
register: output
- name: Assert the resource instance is deleted
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -797,10 +797,10 @@
resource_group: "{{ resource_group }}"
name: "sqlsrv{{ random_postfix }}"
state: absent
- check_mode: yes
+ check_mode: true
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -811,7 +811,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -822,7 +822,7 @@
state: absent
register: output
- name: Assert the state has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed == false
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_storageaccount/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_storageaccount/tasks/main.yml
index 8c738a627..dfeabed07 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_storageaccount/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_storageaccount/tasks/main.yml
@@ -1,5 +1,5 @@
- name: Set Storage Account Names
- set_fact:
+ ansible.builtin.set_fact:
storage_account_name_default: "sa{{ resource_group | hash('md5') | truncate(20, True, '') }}"
storage_account_name_explicit: "sa{{ resource_group | hash('sha1') | truncate(20, True, '') }}"
@@ -11,7 +11,7 @@
register: output
ignore_errors: true
- name: Check intentional name failure.
- assert:
+ ansible.builtin.assert:
that:
- output.failed
- output.msg is regex('AccountNameInvalid')
@@ -38,14 +38,14 @@
account_type: Standard_LRS
register: defaults_output
- name: Assert status succeeded and results match expectations
- assert:
+ ansible.builtin.assert:
that:
- defaults_output.changed
- defaults_output.state.name == storage_account_name_default
- defaults_output.state.id is defined
- defaults_output.state.https_only
- defaults_output.state.access_tier == None
- - defaults_output.state.allow_blob_public_access == true
+ - defaults_output.state.allow_blob_public_access == false
- defaults_output.state.minimum_tls_version == "TLS1_0"
- name: Create storage account with static website disabled
@@ -58,7 +58,7 @@
enabled: false
register: output
- name: Assert output
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.state.static_website is defined
@@ -76,7 +76,7 @@
enabled: false
register: output
- name: Assert not changed
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
@@ -90,7 +90,7 @@
enabled: true
register: output
- name: Assert output
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.state.static_website is defined
@@ -110,7 +110,7 @@
error_document404_path: "error.html"
register: output
- name: Assert output
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.state.static_website is defined
@@ -130,7 +130,7 @@
error_document404_path: "error.html"
register: output
- name: Assert not changed
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
@@ -143,7 +143,7 @@
is_hns_enabled: true
register: output
- name: Assert output
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -152,7 +152,8 @@
resource_group: "{{ resource_group }}"
name: "{{ storage_account_name_default }}06"
register: output
-- assert:
+- name: Assert the storage account facts
+ ansible.builtin.assert:
that:
- "output.storageaccounts | length == 1"
- output.storageaccounts[0].is_hns_enabled == true
@@ -168,7 +169,7 @@
index_document: "abc.htm"
register: output
- name: Assert output
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.state.static_website is defined
@@ -187,7 +188,7 @@
index_document: "abc.htm"
register: output
- name: Assert not changed
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
@@ -201,7 +202,7 @@
enabled: false
register: output
- name: Assert output
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.state.static_website is defined
@@ -217,7 +218,7 @@
kind: FileStorage
register: filestorage_output
- name: Assert status succeeded and results match I(kind=FileStorage)
- assert:
+ ansible.builtin.assert:
that:
- filestorage_output.changed
- filestorage_output.state.sku_name == "Premium_ZRS"
@@ -226,7 +227,7 @@
azure_rm_storageaccount:
access_tier: Hot
account_type: Premium_LRS
- allow_blob_public_access: False
+ allow_blob_public_access: false
append_tags: false
blob_cors:
- allowed_origins:
@@ -241,7 +242,7 @@
exposed_headers:
- x-ms-meta-*
max_age_in_seconds: 200
- https_only: False
+ https_only: false
kind: StorageV2
location: eastus
minimum_tls_version: 'TLS1_2'
@@ -258,7 +259,7 @@
galaxy: galaxy
register: explicit_output
- name: Assert status succeeded and correct parameter results
- assert:
+ ansible.builtin.assert:
that:
- explicit_output.changed
- explicit_output.state.id is defined
@@ -274,7 +275,7 @@
azure_rm_storageaccount:
access_tier: Hot
account_type: Premium_LRS
- allow_blob_public_access: False
+ allow_blob_public_access: false
append_tags: false
blob_cors:
- allowed_origins:
@@ -289,7 +290,7 @@
exposed_headers:
- x-ms-meta-*
max_age_in_seconds: 200
- https_only: False
+ https_only: false
kind: StorageV2
location: eastus
minimum_tls_version: 'TLS1_2'
@@ -306,7 +307,7 @@
galaxy: galaxy
register: output
- name: Assert that properties have not changed
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
- output.state.access_tier == explicit_output.state.access_tier
@@ -333,7 +334,7 @@
name: "{{ storage_account_name_explicit }}"
register: output
- name: Assert that properties have not changed
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
- output.state.access_tier == explicit_output.state.access_tier
@@ -358,7 +359,7 @@
azure_rm_storageaccount:
resource_group: "{{ resource_group }}"
name: "{{ storage_account_name_default }}"
- allow_blob_public_access: False
+ allow_blob_public_access: false
append_tags: false
blob_cors:
- allowed_origins:
@@ -373,7 +374,7 @@
exposed_headers:
- x-ms-meta-*
max_age_in_seconds: 200
- https_only: False
+ https_only: false
kind: StorageV2
minimum_tls_version: 'TLS1_1'
network_acls:
@@ -387,7 +388,7 @@
galaxy: galaxy
register: output
- name: Assert account change success
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.state.allow_blob_public_access == False
@@ -409,7 +410,7 @@
register: output
ignore_errors: true
- name: Assert account type change failed
- assert:
+ ansible.builtin.assert:
that:
- output.failed
- output.msg is regex('Storage account of type .* cannot be changed')
@@ -424,7 +425,7 @@
ignore_errors: true
register: output
- name: Assert CNAME failure
- assert:
+ ansible.builtin.assert:
that:
- output.failed
- output.msg is regex('custom domain name could not be verified')
@@ -440,7 +441,7 @@
public_network_access: 'Disabled'
register: output
- name: Assert desired account config
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.state.https_only
@@ -459,7 +460,7 @@
public_network_access: 'Disabled'
register: output
- name: Assert no change
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
@@ -470,7 +471,8 @@
- test
- galaxy
register: output
-- assert:
+- name: Assert the storage account facts
+ ansible.builtin.assert:
that: output.storageaccounts | length >= 1
- name: Update account tags
@@ -482,7 +484,8 @@
testing: testing
delete: never
register: output
-- assert:
+- name: Assert the storage account updated
+ ansible.builtin.assert:
that:
- "output.state.tags | length == 2"
- "output.state.tags.testing == 'testing'"
@@ -492,10 +495,11 @@
azure_rm_storageaccount_info:
resource_group: "{{ resource_group }}"
name: "{{ storage_account_name_explicit }}"
- show_connection_string: True
- show_blob_cors: True
+ show_connection_string: true
+ show_blob_cors: true
register: output
-- assert:
+- name: Assert the storage account facts
+ ansible.builtin.assert:
that:
- "output.storageaccounts | length == 1"
- not output.storageaccounts[0].custom_domain
@@ -514,7 +518,8 @@
resource_group: "{{ resource_group }}"
name: "{{ storage_account_name_default }}01"
register: output
-- assert:
+- name: Assert the storage account facts
+ ansible.builtin.assert:
that:
- output.storageaccounts | length == 1
- output.storageaccounts[0].static_website is defined
@@ -527,7 +532,8 @@
resource_group: "{{ resource_group }}"
name: "{{ storage_account_name_default }}04"
register: output
-- assert:
+- name: Assert the storage account facts
+ ansible.builtin.assert:
that:
- output.storageaccounts | length == 1
- output.storageaccounts[0].static_website is defined
@@ -551,7 +557,7 @@
register: encryption_output
- name: Assert storage account with (require_infrastructure_encryption=false) created
- assert:
+ ansible.builtin.assert:
that:
- encryption_output.changed
@@ -561,7 +567,8 @@
name: "{{ storage_account_name_default }}05"
register: encryption_output
-- assert:
+- name: Assert the storage account facts
+ ansible.builtin.assert:
that:
- output.storageaccounts | length == 1
- output.storageaccounts[0].encryption.key_source == 'Microsoft.Storage'
@@ -572,7 +579,8 @@
azure_rm_storageaccount_info:
resource_group: "{{ resource_group }}"
register: output
-- assert:
+- name: Assert all storage account facts
+ ansible.builtin.assert:
that:
- "output.storageaccounts | length >= 2"
@@ -581,7 +589,7 @@
resource_group: "{{ resource_group }}"
name: "{{ item }}"
state: absent
- force_delete_nonempty: True
+ force_delete_nonempty: true
loop:
- "{{ storage_account_name_default }}"
- "{{ storage_account_name_explicit }}"
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_storageblob/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_storageblob/tasks/main.yml
index 8ad07331f..307d52d27 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_storageblob/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_storageblob/tasks/main.yml
@@ -1,11 +1,11 @@
- name: Create storage account name
- set_fact:
+ ansible.builtin.set_fact:
storage_account: "sb{{ resource_group | hash('md5') | truncate(22, True, '') }}"
test1_file: "./targets/azure_rm_storageblob/files/Ratings.png"
- name: Create storage account
azure_rm_storageaccount:
- resource_group: "{{ resource_group }}"
+ resource_group: "{{ resource_group }}"
name: "{{ storage_account }}"
account_type: Standard_LRS
@@ -17,7 +17,7 @@
- name: Force upload blob
azure_rm_storageblob:
- resource_group: "{{ resource_group }}"
+ resource_group: "{{ resource_group }}"
account_name: "{{ storage_account }}"
container_name: my-blobs
blob: 'Ratings.png'
@@ -30,7 +30,7 @@
- name: Upload blob idempotence
azure_rm_storageblob:
- resource_group: "{{ resource_group }}"
+ resource_group: "{{ resource_group }}"
account_name: "{{ storage_account }}"
container_name: my-blobs
blob: 'Ratings.png'
@@ -40,71 +40,84 @@
val1: foo
val2: bar
register: upload_facts
-- assert:
+- name: Assert idempotent
+ ansible.builtin.assert:
that: "not upload_facts.changed"
-- name: Download file idempotence
+- name: Download file idempotence
azure_rm_storageblob:
- resource_group: "{{ resource_group }}"
+ resource_group: "{{ resource_group }}"
account_name: "{{ storage_account }}"
container_name: my-blobs
blob: 'Ratings.png'
dest: '{{ test1_file }}'
register: download_results
-- assert:
+- name: Assert idempotent
+ ansible.builtin.assert:
that: not download_results.changed
-- file: path="/tmp/Ratings.png" state=absent
+- name: Delete file
+ ansible.builtin.file:
+ path: "/tmp/Ratings.png"
+ state: absent
-- name: Download file
+- name: Download file
azure_rm_storageblob:
- resource_group: "{{ resource_group }}"
+ resource_group: "{{ resource_group }}"
account_name: "{{ storage_account }}"
container_name: my-blobs
blob: 'Ratings.png'
dest: '/tmp/Ratings.png'
register: download_results
-- assert:
+- name: Assert download file
+ ansible.builtin.assert:
that: "download_results.changed"
-- find: paths='/tmp' patterns="Ratings.png"
+- name: Find file
+ ansible.builtin.find:
+ paths: '/tmp'
+ patterns: "Ratings.png"
register: find_results
-- assert:
+- name: Assert matched the file
+ ansible.builtin.assert:
that: "find_results['matched'] == 1"
-- name: Do not delete container that has blobs
+- name: Do not delete container that has blobs
azure_rm_storageblob:
resource_group: "{{ resource_group }}"
account_name: "{{ storage_account }}"
- container_name: my-blobs
+ container_name: my-blobs
state: absent
register: output
-- assert:
+- name: Assert no blobs
+ ansible.builtin.assert:
that: "not output.changed"
- name: Delete blob object
azure_rm_storageblob:
- resource_group: "{{ resource_group }}"
+ resource_group: "{{ resource_group }}"
account_name: "{{ storage_account }}"
- container_name: my-blobs
+ container_name: my-blobs
blob: "Ratings.png"
state: absent
register: output
-- assert:
+- name: Assert the blob deleted
+ ansible.builtin.assert:
that: "output.changed"
-- name: Delete container
+- name: Delete container
azure_rm_storageblob:
resource_group: "{{ resource_group }}"
account_name: "{{ storage_account }}"
- container_name: my-blobs
+ container_name: my-blobs
state: absent
register: output
-- assert:
+- name: Assert delete the container
+ ansible.builtin.assert:
that: "output.changed"
- name: Delete storage account
azure_rm_storageaccount:
- resource_group: "{{ resource_group }}"
+ resource_group: "{{ resource_group }}"
name: "{{ storage_account }}"
- state: absent
+ state: absent
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_storageshare/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_storageshare/tasks/main.yml
index ffe672d4d..15ea83446 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_storageshare/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_storageshare/tasks/main.yml
@@ -1,7 +1,6 @@
----
- name: Set storage account name
- set_fact:
- storage_account: "sb{{ resource_group | hash('md5') | truncate(22, True, '') }}"
+ ansible.builtin.set_fact:
+ storage_account: "sb{{ resource_group | hash('md5') | truncate(22, True, '') }}"
- name: Create storage account
azure_rm_storageaccount:
@@ -11,7 +10,7 @@
kind: StorageV2
- name: Set storage share facts
- set_fact:
+ ansible.builtin.set_fact:
share_name: testshare
quota: 32
access_tier: Cool
@@ -30,7 +29,7 @@
register: create_result
- name: Assert create success
- assert:
+ ansible.builtin.assert:
that:
- create_result.changed
- create_result.state.name == share_name
@@ -49,7 +48,7 @@
register: create_result
- name: Assert idempotence
- assert:
+ ansible.builtin.assert:
that: not create_result.changed
- name: Get share details
@@ -60,7 +59,7 @@
register: share_facts
- name: Assert storage share details
- assert:
+ ansible.builtin.assert:
that:
- not share_facts.changed
- share_facts.storageshares.name == share_name
@@ -72,7 +71,7 @@
- share_facts.storageshares.etag is defined
- name: Set new storage share facts
- set_fact:
+ ansible.builtin.set_fact:
quota: 64
access_tier: Hot
@@ -86,7 +85,7 @@
register: update_result
- name: Assert share update success
- assert:
+ ansible.builtin.assert:
that: update_result.changed
- name: Get updated details
@@ -97,7 +96,7 @@
register: share_facts
- name: Assert storage share details
- assert:
+ ansible.builtin.assert:
that:
- share_facts.storageshares.name == share_name
- share_facts.storageshares.share_quota == quota
@@ -116,8 +115,9 @@
register: delete_output
- name: Pause for 3 minutes to waiting delete
- pause:
+ ansible.builtin.pause:
minutes: 3
+ changed_when: true
- name: Delete storage account
azure_rm_storageaccount:
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_subnet/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_subnet/tasks/main.yml
index 6e4e6cbb1..0caa850ce 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_subnet/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_subnet/tasks/main.yml
@@ -33,9 +33,10 @@
resource_group: "{{ resource_group }}"
address_prefix_cidr: "10.1.0/24"
register: output
- ignore_errors: yes
+ ignore_errors: true
-- assert:
+- name: Assert created fail
+ ansible.builtin.assert:
that: output.failed
- name: Add the subnet back
@@ -46,7 +47,8 @@
address_prefix_cidr: "10.1.0.0/24"
register: output
-- assert:
+- name: Assert the subnet created
+ ansible.builtin.assert:
that:
- output.changed
- output.state.address_prefix == "10.1.0.0/24"
@@ -58,7 +60,8 @@
resource_group: "{{ resource_group }}"
register: output
-- assert:
+- name: Assert idempotent
+ ansible.builtin.assert:
that: not output.changed
- name: Create network security group
@@ -94,7 +97,8 @@
- westus
register: output
-- assert:
+- name: Assert idempotent
+ ansible.builtin.assert:
that: not output.changed
- name: Able to completely remove service endpoints
@@ -106,7 +110,8 @@
service_endpoints: []
register: output
-- assert:
+- name: Assert the subnet updated
+ ansible.builtin.assert:
that: output.state.service_endpoints is not defined
- name: Create network security group in another resource group
@@ -127,10 +132,11 @@
resource_group: "{{ resource_group_secondary }}"
register: output
-- assert:
- that:
- - output.changed
- - output.state.network_security_group.id == nsg.state.id
+- name: Assert the subnet update
+ ansible.builtin.assert:
+ that:
+ - output.changed
+ - output.state.network_security_group.id == nsg.state.id
- name: Update the subnet (idempotent)
azure_rm_subnet:
@@ -142,7 +148,8 @@
security_group: "{{ nsg.state.id }}"
register: output
-- assert:
+- name: Assert idempotent
+ ansible.builtin.assert:
that: not output.changed
- name: Create subnet with IPv4 and IPv6
@@ -155,7 +162,8 @@
- "fdda:e69b:1587:495e::/64"
register: output
-- assert:
+- name: Assert the subnet created
+ ansible.builtin.assert:
that:
- output.changed
- not output.state.address_prefix
@@ -171,7 +179,8 @@
- "fdda:e69b:1587:495e::/64"
register: output
-- assert:
+- name: Assert the subnet updated
+ ansible.builtin.assert:
that: not output.changed
- name: Update the subnet's IPv4 and IPv6 address
@@ -185,7 +194,8 @@
security_group: "{{ nsg.state.id }}"
register: output
-- assert:
+- name: Assert the subnet update
+ ansible.builtin.assert:
that:
- output.changed
@@ -198,7 +208,8 @@
private_endpoint_network_policies: Enabled
register: output
-- assert:
+- name: Assert the subnet updated
+ ansible.builtin.assert:
that: output
- name: The subnet with network policies should be idempotent
@@ -210,7 +221,8 @@
private_endpoint_network_policies: Enabled
register: output
-- assert:
+- name: Assert idempotent
+ ansible.builtin.assert:
that: not output.changed
- name: Update the subnet with delegations
@@ -223,7 +235,8 @@
serviceName: 'Microsoft.ContainerInstance/containerGroups'
register: output
-- assert:
+- name: Assert the subnet updated
+ ansible.builtin.assert:
that: output
- name: The subnet with delegations should be idempotent
@@ -236,7 +249,8 @@
serviceName: 'Microsoft.ContainerInstance/containerGroups'
register: output
-- assert:
+- name: Assert idempotent
+ ansible.builtin.assert:
that: not output.changed
- name: Get subnet facts
@@ -247,7 +261,7 @@
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.subnets[0]['id'] != None
@@ -270,7 +284,7 @@
register: output
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
- output.subnets[0]['id'] != None
@@ -297,7 +311,8 @@
resource_group: "{{ resource_group }}"
register: output
-- assert:
+- name: Assert idempotent
+ ansible.builtin.assert:
that: not output.changed
- name: Remove subnet
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_subscription/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_subscription/tasks/main.yml
index 113cfe546..e8e58645c 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_subscription/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_subscription/tasks/main.yml
@@ -1,6 +1,6 @@
- name: Get list of all subscriptions
azure_rm_subscription_info:
- all: True
+ all: true
register: az_all_subscriptions
- name: Get a subscription by id
@@ -16,9 +16,9 @@
name: "{{ az_all_subscriptions.subscriptions[0].display_name }}"
id: "{{ az_all_subscriptions.subscriptions[0].subscription_id }}"
register: invalid_name
- ignore_errors: yes
+ ignore_errors: true
- name: Assert task failed
- assert:
- that:
+ ansible.builtin.assert:
+ that:
- "invalid_name['failed'] == True"
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_trafficmanagerprofile/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_trafficmanagerprofile/tasks/main.yml
index 865c56dc4..6e2a7f342 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_trafficmanagerprofile/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_trafficmanagerprofile/tasks/main.yml
@@ -1,127 +1,127 @@
- name: Prepare random number
- set_fact:
+ ansible.builtin.set_fact:
tmname: "tm{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
endpointname1: "ep1{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
endpointname2: "ep2{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
- run_once: yes
+ run_once: true
- name: Create a Traffic Manager profile(check mode)
azure_rm_trafficmanagerprofile:
- resource_group: "{{ resource_group }}"
- name: "{{ tmname }}"
- tags:
- testing: testing
- delete: on-exit
- foo: bar
- location: global
- profile_status: enabled
- routing_method: performance
- dns_config:
- relative_name: "{{ tmname }}"
- ttl: 60
- monitor_config:
- protocol: HTTPS
- port: 80
- path: '/'
- check_mode: yes
+ resource_group: "{{ resource_group }}"
+ name: "{{ tmname }}"
+ tags:
+ testing: testing
+ delete: on-exit
+ foo: bar
+ location: global
+ profile_status: enabled
+ routing_method: performance
+ dns_config:
+ relative_name: "{{ tmname }}"
+ ttl: 60
+ monitor_config:
+ protocol: HTTPS
+ port: 80
+ path: '/'
+ check_mode: true
- name: Check there is no Traffic Manager profile created
azure_rm_trafficmanagerprofile_info:
- resource_group: "{{ resource_group }}"
- name: "{{ tmname }}"
+ resource_group: "{{ resource_group }}"
+ name: "{{ tmname }}"
register: fact
- name: Check there is no Traffic Manager profile created
- assert: { that: "{{ fact.tms | length }} == 0" }
+ ansible.builtin.assert: { that: "{{ fact.tms | length }} == 0" }
- name: Create a Traffic Manager profile
azure_rm_trafficmanagerprofile:
- resource_group: "{{ resource_group }}"
- name: "{{ tmname }}"
- tags:
- testing: testing
- delete: on-exit
- foo: bar
- location: global
- profile_status: enabled
- routing_method: performance
- dns_config:
- relative_name: "{{ tmname }}"
- ttl: 60
- monitor_config:
- protocol: HTTPS
- port: 80
- path: '/'
+ resource_group: "{{ resource_group }}"
+ name: "{{ tmname }}"
+ tags:
+ testing: testing
+ delete: on-exit
+ foo: bar
+ location: global
+ profile_status: enabled
+ routing_method: performance
+ dns_config:
+ relative_name: "{{ tmname }}"
+ ttl: 60
+ monitor_config:
+ protocol: HTTPS
+ port: 80
+ path: '/'
register: tm
- name: Assert the Traffic Manager profile is well created
- assert:
+ ansible.builtin.assert:
that:
- tm.changed
- name: Gather Traffic Manager profile facts
azure_rm_trafficmanagerprofile_info:
- resource_group: "{{ resource_group }}"
- name: "{{ tmname }}"
+ resource_group: "{{ resource_group }}"
+ name: "{{ tmname }}"
register: fact
- name: Assert fact returns the created one
- assert:
- that:
- - "fact.tms | length == 1"
- - fact.tms[0].id == tm.id
- - fact.tms[0].endpoints | length == 0
+ ansible.builtin.assert:
+ that:
+ - "fact.tms | length == 1"
+ - fact.tms[0].id == tm.id
+ - fact.tms[0].endpoints | length == 0
- name: Create a Traffic Manager profile (idempotent)
azure_rm_trafficmanagerprofile:
- resource_group: "{{ resource_group }}"
- name: "{{ tmname }}"
- tags:
- testing: testing
- delete: on-exit
- foo: bar
- location: global
- profile_status: enabled
- routing_method: performance
- dns_config:
- relative_name: "{{ tmname }}"
- ttl: 60
- monitor_config:
- protocol: HTTPS
- port: 80
- path: '/'
+ resource_group: "{{ resource_group }}"
+ name: "{{ tmname }}"
+ tags:
+ testing: testing
+ delete: on-exit
+ foo: bar
+ location: global
+ profile_status: enabled
+ routing_method: performance
+ dns_config:
+ relative_name: "{{ tmname }}"
+ ttl: 60
+ monitor_config:
+ protocol: HTTPS
+ port: 80
+ path: '/'
register: output
- name: Assert idempotent
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
- name: Update the Traffic Manager profile
azure_rm_trafficmanagerprofile:
- resource_group: "{{ resource_group }}"
- name: "{{ tmname }}"
- tags:
- testing: testing
- delete: on-exit
- foo: bar
- location: global
- profile_status: disabled
- routing_method: priority
- dns_config:
- relative_name: "{{ tmname }}"
- ttl: 60
- monitor_config:
- protocol: HTTPS
- port: 80
- path: '/'
+ resource_group: "{{ resource_group }}"
+ name: "{{ tmname }}"
+ tags:
+ testing: testing
+ delete: on-exit
+ foo: bar
+ location: global
+ profile_status: disabled
+ routing_method: priority
+ dns_config:
+ relative_name: "{{ tmname }}"
+ ttl: 60
+ monitor_config:
+ protocol: HTTPS
+ port: 80
+ path: '/'
register: output
- name: Assert the Traffic Manager profile is updated
- assert:
+ ansible.builtin.assert:
that:
- - output.changed
+ - output.changed
- name: Create Traffic Manager endpoint(check mode)
azure_rm_trafficmanagerendpoint:
@@ -133,11 +133,11 @@
priority: 2
weight: 1
target: 1.2.3.4
- check_mode: yes
+ check_mode: true
register: output
- name: Assert check mode changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -148,7 +148,7 @@
register: facts
- name: Check no endpoint created in check mode
- assert:
+ ansible.builtin.assert:
that:
- facts.endpoints | length == 0
@@ -165,7 +165,7 @@
register: output
- name: Assert endpoint create changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -176,7 +176,7 @@
register: facts
- name: Check endpoint created
- assert:
+ ansible.builtin.assert:
that:
- facts.endpoints | length == 1
- facts.endpoints[0].name == "{{ endpointname1 }}"
@@ -199,7 +199,7 @@
register: facts
- name: Check 2 endpoint in profile
- assert:
+ ansible.builtin.assert:
that:
- facts.endpoints | length == 2
@@ -216,7 +216,7 @@
register: output
- name: Assert endpoint creation idempotent
- assert:
+ ansible.builtin.assert:
that:
- output.changed == False
@@ -230,7 +230,7 @@
register: output
- name: Assert endpoint deletion changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -241,7 +241,7 @@
register: facts
- name: Check 1 endpoint left in profile
- assert:
+ ansible.builtin.assert:
that:
- facts.endpoints | length == 1
@@ -250,20 +250,20 @@
resource_group: "{{ resource_group }}"
name: "{{ tmname }}"
state: absent
- check_mode: yes
+ check_mode: true
- name: Gather Traffic Manager profile facts
azure_rm_trafficmanagerprofile_info:
- resource_group: "{{ resource_group }}"
- name: "{{ tmname }}"
+ resource_group: "{{ resource_group }}"
+ name: "{{ tmname }}"
register: fact
- name: Assert the traffic manager profile is still there
- assert:
- that:
- - "fact.tms | length == 1"
- - fact.tms[0].id == tm.id
- - fact.tms[0].endpoints | length == 1
+ ansible.builtin.assert:
+ that:
+ - "fact.tms | length == 1"
+ - fact.tms[0].id == tm.id
+ - fact.tms[0].endpoints | length == 1
- name: Delete the Traffic Manager profile
azure_rm_trafficmanagerprofile:
@@ -273,17 +273,17 @@
register: output
- name: Assert the Traffic Manager profile is well deleted
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- name: Get Traffic Manager profile fact
azure_rm_trafficmanagerprofile_info:
- resource_group: "{{ resource_group }}"
- name: "{{ tmname }}"
+ resource_group: "{{ resource_group }}"
+ name: "{{ tmname }}"
register: fact
- name: Assert fact returns empty
- assert:
+ ansible.builtin.assert:
that:
- "fact.tms | length == 0"
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualhub/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualhub/tasks/main.yml
index 36707bec5..530e92524 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualhub/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualhub/tasks/main.yml
@@ -1,54 +1,55 @@
-- set_fact:
- name: "{{ resource_group | hash('md5') | truncate(22, True, '') }}"
+- name: Set varialbles
+ ansible.builtin.set_fact:
+ name_rpfx: "{{ resource_group | hash('md5') | truncate(22, True, '') }}"
- name: Create a VirtualHub (check mode)
azure_rm_virtualhub:
resource_group: "{{ resource_group }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
sku: Standard
- check_mode: yes
+ check_mode: true
- name: Create a VirtualHub
azure_rm_virtualhub:
resource_group: "{{ resource_group }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
sku: Standard
register: output
- name: Assert the virtual hub is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.state.provisioning_state == 'Succeeded'
-
+
- name: Create a VirtualHub (idempotent)
azure_rm_virtualhub:
resource_group: "{{ resource_group }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
sku: Standard
register: output
- name: Assert idempotent
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
- name: Get Virtual Hub Info
azure_rm_virtualhub_info:
resource_group: "{{ resource_group }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
register: output
- name: Assert fact returns
- assert:
+ ansible.builtin.assert:
that:
- - output.virtual_hubs[0].provisioning_state == "Succeeded"
+ - output.virtual_hubs[0].provisioning_state == "Succeeded"
- output.virtual_hubs[0].sku == "Standard"
- name: Create a VirtualWan
azure_rm_virtualwan:
resource_group: "{{ resource_group }}"
- name: "wan-{{ name }}"
+ name: "wan-{{ name_rpfx }}"
disable_vpn_encryption: true
allow_branch_to_branch_traffic: true
allow_vnet_to_vnet_traffic: true
@@ -58,7 +59,7 @@
- name: Create Second VirtualHub
azure_rm_virtualhub:
resource_group: "{{ resource_group }}"
- name: "{{ name }}-seondary"
+ name: "{{ name_rpfx }}-seondary"
sku: Standard
address_prefix: 12.0.0.0/16
virtual_wan:
@@ -70,7 +71,7 @@
register: output
- name: Assert the virtual hub is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.state.provisioning_state == 'Succeeded'
@@ -78,17 +79,17 @@
- name: Delete Second VirtualHub
azure_rm_virtualhub:
resource_group: "{{ resource_group }}"
- name: "{{ name }}-seondary"
+ name: "{{ name_rpfx }}-seondary"
state: absent
- name: Delete virtual hub
azure_rm_virtualhub:
resource_group: "{{ resource_group }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
state: absent
register: output
- name: Assert the AKS instance is upgraded
- assert:
+ ansible.builtin.assert:
that:
- output.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualhubconnection/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualhubconnection/tasks/main.yml
index 562ecbacc..c110bdd32 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualhubconnection/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualhubconnection/tasks/main.yml
@@ -1,163 +1,164 @@
- - set_fact:
- rpfx: "{{ resource_group | hash('md5') | truncate(8, True, '') }}"
+- name: Set variables
+ ansible.builtin.set_fact:
+ rpfx: "{{ resource_group | hash('md5') | truncate(8, True, '') }}"
- - name: Create virtual network
- azure_rm_virtualnetwork:
- name: "vnet{{ rpfx }}"
- address_prefixes_cidr:
- - 10.1.0.0/16
- - 172.100.0.0/16
- resource_group: "{{ resource_group }}"
- register: vnet_output
-
- - name: Create a Virtual Wan
- azure_rm_virtualwan:
- resource_group: "{{ resource_group }}"
- name: "virtualwan{{ rpfx }}"
- office365_local_breakout_category: All
- disable_vpn_encryption: true
- allow_branch_to_branch_traffic: true
- allow_vnet_to_vnet_traffic: true
- virtual_wan_type: Basic
- register: vwan_output
-
- - name: Create a VirtualHub
- azure_rm_virtualhub:
- resource_group: "{{ resource_group }}"
- name: "vhub{{ rpfx }}"
- sku: Standard
- address_prefix: 12.0.0.0/16
- virtual_wan:
- id: "{{ vwan_output.state.id }}"
- virtual_router_asn: 65515
- virtual_router_ips:
- - 12.0.32.4
- - 12.0.32.5
- register: output
-
- - name: Create virtual hub connection
- azure_rm_virtualhubconnection:
- resource_group: "{{ resource_group }}"
- vhub_name: "vhub{{ rpfx }}"
- name: "connection{{ rpfx }}"
- enable_internet_security: true
- allow_remote_vnet_to_use_hub_vnet_gateways: false
- allow_hub_to_remote_vnet_transit: true
- remote_virtual_network:
- id: "{{ vnet_output.state.id }}"
- routing_configuration:
- propagated_route_tables:
- labels:
- - labels1
- - labels3
- vnet_routes:
- static_routes:
- - name: route1
- address_prefixes:
- - 10.1.0.0/16
- - 10.2.0.0/16
- - 10.6.0.0/16
- next_hop_ip_address: 10.0.0.68
- - name: route2
- address_prefixes:
- - 10.4.0.0/16
- next_hop_ip_address: 10.0.0.65
- register: output
-
- - name: Assert the virtual hub connection is well created
- assert:
- that:
- - output.changed
-
- - name: Create virtual hub connection (idempotent test)
- azure_rm_virtualhubconnection:
- resource_group: "{{ resource_group }}"
- vhub_name: "vhub{{ rpfx }}"
- name: "connection{{ rpfx }}"
- enable_internet_security: true
- allow_remote_vnet_to_use_hub_vnet_gateways: false
- allow_hub_to_remote_vnet_transit: true
- remote_virtual_network:
- id: "{{ vnet_output.state.id }}"
- routing_configuration:
- propagated_route_tables:
- labels:
- - labels1
- - labels3
- vnet_routes:
- static_routes:
- - name: route1
- address_prefixes:
- - 10.1.0.0/16
- - 10.2.0.0/16
- - 10.6.0.0/16
- next_hop_ip_address: 10.0.0.68
- - name: route2
- address_prefixes:
- - 10.4.0.0/16
- next_hop_ip_address: 10.0.0.65
- register: output
-
- - name: Assert the virtual hub connection no changed
- assert:
- that:
- - not output.changed
-
- - name: Update virtual hub connection
- azure_rm_virtualhubconnection:
- resource_group: "{{ resource_group }}"
- vhub_name: "vhub{{ rpfx }}"
- name: "connection{{ rpfx }}"
- enable_internet_security: false
- allow_remote_vnet_to_use_hub_vnet_gateways: false
- allow_hub_to_remote_vnet_transit: true
- remote_virtual_network:
- id: "{{ vnet_output.state.id }}"
- routing_configuration:
- propagated_route_tables:
- labels:
- - labels1
- - labels2
- - labels3
- vnet_routes:
- static_routes:
- - name: route1
- address_prefixes:
- - 10.1.0.0/16
- - 10.2.0.0/16
- - 10.6.0.0/16
- - 10.7.0.0/16
- next_hop_ip_address: 10.0.0.68
- - name: route2
- address_prefixes:
- - 10.4.0.0/16
- next_hop_ip_address: 10.0.0.65
- register: output
-
- - name: Assert the virtual hub connection no changed
- assert:
- that:
- - output.changed
-
- - name: Get virtual hub connection info
- azure_rm_virtualhubconnection_info:
- resource_group: "{{ resource_group }}"
- virtual_hub_name: "vhub{{ rpfx }}"
- name: "connection{{ rpfx }}"
- register: output
-
- - name: Assert fact returns
- assert:
- that:
- - output.virtual_hub_connection[0].allow_hub_to_remote_vnet_transit
- - not output.virtual_hub_connection[0].allow_remote_vnet_to_use_hub_vnet_gateways
- - not output.virtual_hub_connection[0].enable_internet_security
- - output.virtual_hub_connection[0].routing_configuration.propagated_route_tables.labels | length == 3
- - output.virtual_hub_connection[0].routing_configuration.vnet_routes.static_routes | length == 2
-
- - name: Delete the virtual hub connection
- azure_rm_virtualhubconnection:
- resource_group: "{{ resource_group }}"
- vhub_name: "vhub{{ rpfx }}"
- name: "connection{{ rpfx }}"
- state: absent
+- name: Create virtual network
+ azure_rm_virtualnetwork:
+ name: "vnet{{ rpfx }}"
+ address_prefixes_cidr:
+ - 10.1.0.0/16
+ - 172.100.0.0/16
+ resource_group: "{{ resource_group }}"
+ register: vnet_output
+
+- name: Create a Virtual Wan
+ azure_rm_virtualwan:
+ resource_group: "{{ resource_group }}"
+ name: "virtualwan{{ rpfx }}"
+ office365_local_breakout_category: All
+ disable_vpn_encryption: true
+ allow_branch_to_branch_traffic: true
+ allow_vnet_to_vnet_traffic: true
+ virtual_wan_type: Basic
+ register: vwan_output
+
+- name: Create a VirtualHub
+ azure_rm_virtualhub:
+ resource_group: "{{ resource_group }}"
+ name: "vhub{{ rpfx }}"
+ sku: Standard
+ address_prefix: 12.0.0.0/16
+ virtual_wan:
+ id: "{{ vwan_output.state.id }}"
+ virtual_router_asn: 65515
+ virtual_router_ips:
+ - 12.0.32.4
+ - 12.0.32.5
+ register: output
+
+- name: Create virtual hub connection
+ azure_rm_virtualhubconnection:
+ resource_group: "{{ resource_group }}"
+ vhub_name: "vhub{{ rpfx }}"
+ name: "connection{{ rpfx }}"
+ enable_internet_security: true
+ allow_remote_vnet_to_use_hub_vnet_gateways: false
+ allow_hub_to_remote_vnet_transit: true
+ remote_virtual_network:
+ id: "{{ vnet_output.state.id }}"
+ routing_configuration:
+ propagated_route_tables:
+ labels:
+ - labels1
+ - labels3
+ vnet_routes:
+ static_routes:
+ - name: route1
+ address_prefixes:
+ - 10.1.0.0/16
+ - 10.2.0.0/16
+ - 10.6.0.0/16
+ next_hop_ip_address: 10.0.0.68
+ - name: route2
+ address_prefixes:
+ - 10.4.0.0/16
+ next_hop_ip_address: 10.0.0.65
+ register: output
+
+- name: Assert the virtual hub connection is well created
+ ansible.builtin.assert:
+ that:
+ - output.changed
+
+- name: Create virtual hub connection (idempotent test)
+ azure_rm_virtualhubconnection:
+ resource_group: "{{ resource_group }}"
+ vhub_name: "vhub{{ rpfx }}"
+ name: "connection{{ rpfx }}"
+ enable_internet_security: true
+ allow_remote_vnet_to_use_hub_vnet_gateways: false
+ allow_hub_to_remote_vnet_transit: true
+ remote_virtual_network:
+ id: "{{ vnet_output.state.id }}"
+ routing_configuration:
+ propagated_route_tables:
+ labels:
+ - labels1
+ - labels3
+ vnet_routes:
+ static_routes:
+ - name: route1
+ address_prefixes:
+ - 10.1.0.0/16
+ - 10.2.0.0/16
+ - 10.6.0.0/16
+ next_hop_ip_address: 10.0.0.68
+ - name: route2
+ address_prefixes:
+ - 10.4.0.0/16
+ next_hop_ip_address: 10.0.0.65
+ register: output
+
+- name: Assert the virtual hub connection no changed
+ ansible.builtin.assert:
+ that:
+ - not output.changed
+
+- name: Update virtual hub connection
+ azure_rm_virtualhubconnection:
+ resource_group: "{{ resource_group }}"
+ vhub_name: "vhub{{ rpfx }}"
+ name: "connection{{ rpfx }}"
+ enable_internet_security: false
+ allow_remote_vnet_to_use_hub_vnet_gateways: false
+ allow_hub_to_remote_vnet_transit: true
+ remote_virtual_network:
+ id: "{{ vnet_output.state.id }}"
+ routing_configuration:
+ propagated_route_tables:
+ labels:
+ - labels1
+ - labels2
+ - labels3
+ vnet_routes:
+ static_routes:
+ - name: route1
+ address_prefixes:
+ - 10.1.0.0/16
+ - 10.2.0.0/16
+ - 10.6.0.0/16
+ - 10.7.0.0/16
+ next_hop_ip_address: 10.0.0.68
+ - name: route2
+ address_prefixes:
+ - 10.4.0.0/16
+ next_hop_ip_address: 10.0.0.65
+ register: output
+
+- name: Assert the virtual hub connection no changed
+ ansible.builtin.assert:
+ that:
+ - output.changed
+
+- name: Get virtual hub connection info
+ azure_rm_virtualhubconnection_info:
+ resource_group: "{{ resource_group }}"
+ virtual_hub_name: "vhub{{ rpfx }}"
+ name: "connection{{ rpfx }}"
+ register: output
+
+- name: Assert fact returns
+ ansible.builtin.assert:
+ that:
+ - output.virtual_hub_connection[0].allow_hub_to_remote_vnet_transit
+ - not output.virtual_hub_connection[0].allow_remote_vnet_to_use_hub_vnet_gateways
+ - not output.virtual_hub_connection[0].enable_internet_security
+ - output.virtual_hub_connection[0].routing_configuration.propagated_route_tables.labels | length == 3
+ - output.virtual_hub_connection[0].routing_configuration.vnet_routes.static_routes | length == 2
+
+- name: Delete the virtual hub connection
+ azure_rm_virtualhubconnection:
+ resource_group: "{{ resource_group }}"
+ vhub_name: "vhub{{ rpfx }}"
+ name: "connection{{ rpfx }}"
+ state: absent
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/inventory.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/inventory.yml
index ceb88cd7e..88172852a 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/inventory.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/inventory.yml
@@ -36,6 +36,10 @@ all:
network: 10.42.6.0/24
subnet: 10.42.6.0/28
+ azure_test_vm_identity:
+ network: 10.42.7.0/24
+ subnet: 10.42.7.0/28
+
vars:
ansible_connection: local
ansible_python_interpreter: "{{ ansible_playbook_python }}"
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/main.yml
index c9c9158c4..9ba46c362 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/main.yml
@@ -1,7 +1,8 @@
+---
- name: Run Azure VM tests in parallel
hosts: all
- gather_facts: no
- strategy: free
+ gather_facts: false
+ strategy: linear
tasks:
- name: Include tasks based on inventory hostname
- include_tasks: tasks/{{ inventory_hostname }}.yml
+ ansible.builtin.include_tasks: tasks/{{ inventory_hostname }}.yml
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/runme.sh b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/runme.sh
index c7895c9d2..c7895c9d2 100644..100755
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/runme.sh
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/runme.sh
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_deallocate.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_deallocate.yml
index 3c86c7419..09bb56e9c 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_deallocate.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_deallocate.yml
@@ -1,4 +1,5 @@
-- include_tasks: setup.yml
+- name: Set parameters
+ ansible.builtin.include_tasks: setup.yml
- name: Create minimal VM with defaults
azure_rm_virtualmachine:
@@ -12,9 +13,9 @@
vm_size: Standard_B1ms
virtual_network: "{{ network_name }}"
image:
- offer: UbuntuServer
+ offer: 0001-com-ubuntu-server-focal
publisher: Canonical
- sku: 16.04-LTS
+ sku: 20_04-lts
version: latest
register: vm_output
@@ -25,18 +26,19 @@
register: vm_state
- name: Pause for 10 mimutes to VM updating
- shell: sleep 600
+ ansible.builtin.command: sleep 600
+ changed_when: true
- name: Restart the virtual machine
azure_rm_virtualmachine:
resource_group: "{{ resource_group }}"
name: "{{ vm_name }}"
- restarted: yes
+ restarted: true
vm_size: Standard_B1ms
register: restart_result
- name: Ensue VM was restarted
- assert:
+ ansible.builtin.assert:
that:
- "azure_vm.powerstate in ['starting', 'running']"
- restart_result is changed
@@ -45,12 +47,12 @@
azure_rm_virtualmachine:
resource_group: "{{ resource_group }}"
name: "{{ vm_name }}"
- allocated: no
+ allocated: false
vm_size: Standard_B1ms
register: deallocate_result
- name: Ensure VM was deallocated
- assert:
+ ansible.builtin.assert:
that:
- azure_vm.powerstate == 'deallocated'
- deallocate_result is changed
@@ -60,11 +62,11 @@
resource_group: "{{ resource_group }}"
name: "{{ vm_name }}"
vm_size: Standard_B1ms
- started: True
+ started: true
register: start_result
- name: Ensure VM was started
- assert:
+ ansible.builtin.assert:
that:
- "azure_vm.powerstate in ['starting', 'running']"
- start_result is changed
@@ -99,5 +101,5 @@
azure_rm_storageaccount:
resource_group: "{{ resource_group }}"
name: "{{ storage_account }}"
- force_delete_nonempty: yes
+ force_delete_nonempty: false
state: absent
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_dual_nic.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_dual_nic.yml
index 6202e3534..f6865b2e7 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_dual_nic.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_dual_nic.yml
@@ -1,4 +1,5 @@
-- include_tasks: setup.yml
+- name: Set variables
+ ansible.builtin.include_tasks: setup.yml
- name: Create virtual network in secondary resource group
azure_rm_virtualnetwork:
@@ -42,18 +43,18 @@
network_interfaces: "{{ nic_list }}"
availability_set: "{{ availability_set }}"
image:
- offer: UbuntuServer
+ offer: 0001-com-ubuntu-server-focal
publisher: Canonical
- sku: 16.04-LTS
+ sku: 20_04-lts
version: latest
tags:
abc: def
- name: Ensure VM was created properly
- assert:
+ ansible.builtin.assert:
that:
- - azure_vm.properties.availabilitySet.id
- - azure_vm.properties.storageProfile.osDisk.name == 'testosdiskxx'
+ - azure_vm.availability_set.id
+ - azure_vm.storage_profile.os_disk.name == 'testosdiskxx'
- name: Retrieve VM facts (filtering by name)
azure_rm_virtualmachine_info:
@@ -62,7 +63,7 @@
register: vm_facts_results
- name: Ensure facts module returned the second VM
- assert:
+ ansible.builtin.assert:
that:
- vm_facts_results.vms | length == 1
- vm_facts_results.vms[0].name == "{{ vm_name }}"
@@ -78,7 +79,7 @@
register: facts_by_tags_results
- name: Assert that facts module returned the second VM
- assert:
+ ansible.builtin.assert:
that:
- facts_by_tags_results.vms | length >= 1
@@ -101,14 +102,14 @@
network_interfaces: "{{ nic_list }}"
availability_set: "{{ availability_set }}"
image:
- offer: UbuntuServer
+ offer: 0001-com-ubuntu-server-focal
publisher: Canonical
- sku: 16.04-LTS
+ sku: 20_04-lts
version: latest
register: dual_nics_result
- name: Ensure nothing changed
- assert:
+ ansible.builtin.assert:
that: dual_nics_result is not changed
- name: Get VM facts
@@ -118,13 +119,14 @@
register: vm_state
- name: Pause for 10 mimutes to VM updating
- shell: sleep 600
+ ansible.builtin.command: sleep 600
+ changed_when: true
- name: Generalize VM
azure_rm_virtualmachine:
resource_group: "{{ resource_group }}" # Should this be resource_group_secondary?
name: "{{ vm_name }}"
- generalized: yes
+ generalized: true
- name: Gather facts and check if machine is generalized
azure_rm_virtualmachine_info:
@@ -133,7 +135,7 @@
register: generalized_output
- name: Ensure power state is generalized
- assert:
+ ansible.builtin.assert:
that: generalized_output.vms[0].power_state == 'generalized'
- name: Delete dual NIC VM
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_ephemeral_os.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_ephemeral_os.yml
index 4169333b9..1b18c71ef 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_ephemeral_os.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_ephemeral_os.yml
@@ -1,6 +1,7 @@
-- include_tasks: setup.yml
+- name: Set variables
+ ansible.builtin.include_tasks: setup.yml
-- name: create proximity placement group
+- name: Create proximity placement group
azure_rm_proximityplacementgroup:
resource_group: "{{ resource_group }}"
name: testproximityplacement
@@ -19,9 +20,9 @@
key_data: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDfoYlIV4lTPZTv7hXaVwQQuqBgGs4yeNRX0SPo2+HQt9u4X7IGwrtXc0nEUm6LfaCikMH58bOL8f20NTGz285kxdFHZRcBXtqmnMz2rXwhK9gwq5h1khc+GzHtdcJXsGA4y0xuaNcidcg04jxAlN/06fwb/VYwwWTVbypNC0gpGEpWckCNm8vlDlA55sU5et0SZ+J0RKVvEaweUOeNbFZqckGPA384imfeYlADppK/7eAxqfBVadVvZG8IJk4yvATgaIENIFj2cXxqu2mQ/Bp5Wr45uApvJsFXmi+v/nkiOEV1QpLOnEwAZo6EfFS4CCQtsymxJCl1PxdJ5LD4ZOtP xiuxi.sun@qq.com"
vm_size: Standard_DS2_v2
image:
- offer: UbuntuServer
+ offer: 0001-com-ubuntu-server-focal
publisher: Canonical
- sku: 16.04-LTS
+ sku: 20_04-lts
version: latest
register: vm_output
@@ -32,13 +33,14 @@
register: vm_state
- name: Pause for 10 mimutes to VM updating
- shell: sleep 600
+ ansible.builtin.command: sleep 600
+ changed_when: true
- name: Generalize VM
azure_rm_virtualmachine:
resource_group: "{{ resource_group }}"
name: "{{ vm_name }}"
- generalized: yes
+ generalized: true
- name: Create an image from VM
azure_rm_image:
@@ -48,7 +50,8 @@
os_type: Linux
register: output
-- assert:
+- name: Assert the VM created
+ ansible.builtin.assert:
that:
- output.changed
@@ -63,11 +66,12 @@
key_data: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDfoYlIV4lTPZTv7hXaVwQQuqBgGs4yeNRX0SPo2+HQt9u4X7IGwrtXc0nEUm6LfaCikMH58bOL8f20NTGz285kxdFHZRcBXtqmnMz2rXwhK9gwq5h1khc+GzHtdcJXsGA4y0xuaNcidcg04jxAlN/06fwb/VYwwWTVbypNC0gpGEpWckCNm8vlDlA55sU5et0SZ+J0RKVvEaweUOeNbFZqckGPA384imfeYlADppK/7eAxqfBVadVvZG8IJk4yvATgaIENIFj2cXxqu2mQ/Bp5Wr45uApvJsFXmi+v/nkiOEV1QpLOnEwAZo6EfFS4CCQtsymxJCl1PxdJ5LD4ZOtP xiuxi.sun@qq.com"
vm_size: Standard_DS2_v2
os_disk_caching: ReadOnly
- ephemeral_os_disk: True
+ ephemeral_os_disk: true
image: testimage
register: output
-- assert:
+- name: Assert the vm created
+ ansible.builtin.assert:
that:
- output.changed
- output.ansible_facts.azure_vm.properties.storageProfile.osDisk.diffDiskSettings.option == 'Local'
@@ -83,11 +87,12 @@
key_data: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDfoYlIV4lTPZTv7hXaVwQQuqBgGs4yeNRX0SPo2+HQt9u4X7IGwrtXc0nEUm6LfaCikMH58bOL8f20NTGz285kxdFHZRcBXtqmnMz2rXwhK9gwq5h1khc+GzHtdcJXsGA4y0xuaNcidcg04jxAlN/06fwb/VYwwWTVbypNC0gpGEpWckCNm8vlDlA55sU5et0SZ+J0RKVvEaweUOeNbFZqckGPA384imfeYlADppK/7eAxqfBVadVvZG8IJk4yvATgaIENIFj2cXxqu2mQ/Bp5Wr45uApvJsFXmi+v/nkiOEV1QpLOnEwAZo6EfFS4CCQtsymxJCl1PxdJ5LD4ZOtP xiuxi.sun@qq.com"
vm_size: Standard_DS2_v2
os_disk_caching: ReadOnly
- ephemeral_os_disk: True
+ ephemeral_os_disk: true
image: testimage
register: output
-- assert:
+- name: Assert idempotent
+ ansible.builtin.assert:
that:
- not output.changed
@@ -102,12 +107,13 @@
key_data: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDfoYlIV4lTPZTv7hXaVwQQuqBgGs4yeNRX0SPo2+HQt9u4X7IGwrtXc0nEUm6LfaCikMH58bOL8f20NTGz285kxdFHZRcBXtqmnMz2rXwhK9gwq5h1khc+GzHtdcJXsGA4y0xuaNcidcg04jxAlN/06fwb/VYwwWTVbypNC0gpGEpWckCNm8vlDlA55sU5et0SZ+J0RKVvEaweUOeNbFZqckGPA384imfeYlADppK/7eAxqfBVadVvZG8IJk4yvATgaIENIFj2cXxqu2mQ/Bp5Wr45uApvJsFXmi+v/nkiOEV1QpLOnEwAZo6EfFS4CCQtsymxJCl1PxdJ5LD4ZOtP xiuxi.sun@qq.com"
vm_size: Standard_DS2_v2
os_disk_caching: ReadOnly
- ephemeral_os_disk: False
+ ephemeral_os_disk: false
image: testimage
- ignore_errors: yes
+ ignore_errors: true
register: ouput
-- assert:
+- name: Assert the vm updated
+ ansible.builtin.assert:
that:
- not output.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_image_latest.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_image_latest.yml
index 812ef48d3..54e070d69 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_image_latest.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_image_latest.yml
@@ -1,15 +1,16 @@
-- include_tasks: setup.yml
+- name: Set variables
+ ansible.builtin.include_tasks: setup.yml
-- name: List available versions for UbuntuServer image
+- name: List available versions for 0001-com-ubuntu-server-focal image
azure_rm_virtualmachineimage_info:
location: eastus
publisher: Canonical
- offer: UbuntuServer
- sku: 16.04-LTS
+ offer: 0001-com-ubuntu-server-focal
+ sku: 20_04-lts
register: image_list
-- name: Get latest UbuntuServer image name
- set_fact:
+- name: Get latest 0001-com-ubuntu-server-focal image name
+ ansible.builtin.set_fact:
latest_image_name: "{{ (image_list['vmimages'] | map(attribute='name') | sort(reverse=True))[0] }}"
- name: Create minimal VM with defaults
@@ -24,14 +25,14 @@
vm_size: Standard_B1ms
virtual_network: "{{ network_name }}"
image:
- offer: UbuntuServer
+ offer: 0001-com-ubuntu-server-focal
publisher: Canonical
- sku: 16.04-LTS
+ sku: 20_04-lts
version: latest
register: vm_output
-- name: Ensure VM was created using the latest UbuntuServer image version / name
- assert:
+- name: Ensure VM was created using the latest 0001-com-ubuntu-server-focal image version / name
+ ansible.builtin.assert:
that:
- vm_output.azure_vm.properties.storageProfile.imageReference.version == latest_image_name
@@ -65,5 +66,5 @@
azure_rm_storageaccount:
resource_group: "{{ resource_group }}"
name: "{{ storage_account }}"
- force_delete_nonempty: yes
+ force_delete_nonempty: true
state: absent
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_image_specific.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_image_specific.yml
index 12fc28154..6f7d21386 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_image_specific.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_image_specific.yml
@@ -1,7 +1,8 @@
-- include_tasks: setup.yml
+- name: Set variables
+ ansible.builtin.include_tasks: setup.yml
-- name: Set specific UbuntuServer image version
- set_fact:
+- name: Set specific 0001-com-ubuntu-server-focal image version
+ ansible.builtin.set_fact:
specific_image_name: "16.04.202104140"
- name: Create minimal VM with defaults
@@ -16,14 +17,14 @@
vm_size: Standard_B1ms
virtual_network: "{{ network_name }}"
image:
- offer: UbuntuServer
+ offer: 0001-com-ubuntu-server-focal
publisher: Canonical
- sku: 16.04-LTS
+ sku: 20_04-lts
version: "{{ specific_image_name }}"
register: vm_output
-- name: Ensure VM was created using the specific UbuntuServer image version / name
- assert:
+- name: Ensure VM was created using the specific 0001-com-ubuntu-server-focal image version / name
+ ansible.builtin.assert:
that:
- vm_output.azure_vm.properties.storageProfile.imageReference.version == specific_image_name
@@ -57,5 +58,5 @@
azure_rm_storageaccount:
resource_group: "{{ resource_group }}"
name: "{{ storage_account }}"
- force_delete_nonempty: yes
+ force_delete_nonempty: true
state: absent
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_invalid.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_invalid.yml
index 86ec72de1..e4bc5b3db 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_invalid.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_invalid.yml
@@ -4,7 +4,7 @@
resource_group: "{{ resource_group }}"
name: "{{ vm_name }}"
image:
- offer: UbuntuServer
+ offer: 0001-com-ubuntu-server-focal
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]"'
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_minimal.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_minimal.yml
index 750cbe0b4..bf6035750 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_minimal.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_minimal.yml
@@ -1,4 +1,5 @@
-- include_tasks: setup.yml
+- name: Set variables
+ ansible.builtin.include_tasks: setup.yml
# # Tests possible when CI user acccount setup with required authority
# - name: Create virtual machine with image and plan which requires acceptance of terms
@@ -18,7 +19,7 @@
# plan_paid: "{{ plan_paid }}"
# register: create_image_plan_result
-# - assert:
+# - ansible.builtin.assert:
# that:
# - create_image_plan_result is changed
# - create_image_plan_result.ansible_facts.azure_vm.properties.storageProfile.imageReference.publisher == image_paid.publisher
@@ -40,7 +41,7 @@
# plan_paid: "{{ plan_paid }}"
# register: create_image_plan_again_result
-# - assert:
+# - ansible.builtin.assert:
# that: create_image_plan_again is not changed
- name: Create minimal VM with defaults
@@ -55,9 +56,9 @@
vm_size: Standard_B1ms
virtual_network: "{{ network_name }}"
image:
- offer: UbuntuServer
+ offer: 0001-com-ubuntu-server-focal
publisher: Canonical
- sku: 16.04-LTS
+ sku: 20_04-lts
version: latest
register: vm_output
@@ -68,7 +69,7 @@
register: nsg_result
- name: Assert that security group were exist before deleting
- assert:
+ ansible.builtin.assert:
that:
- nsg_result.securitygroups | length == 1
- nsg_result.securitygroups[0].network_interfaces | length == 1
@@ -99,7 +100,7 @@
register: pip_result
- name: Assert that autocreated resources were deleted
- assert:
+ ansible.builtin.assert:
that:
# what about the default storage group?
- nic_result.networkinterfaces | length == 0
@@ -129,5 +130,5 @@
azure_rm_storageaccount:
resource_group: "{{ resource_group }}"
name: "{{ storage_account }}"
- force_delete_nonempty: yes
+ force_delete_nonempty: true
state: absent
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_minimal_manageddisk.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_minimal_manageddisk.yml
index 27274b0de..423baa71c 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_minimal_manageddisk.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_minimal_manageddisk.yml
@@ -38,14 +38,14 @@
vm_size: Standard_D4s_v3
virtual_network: "{{ network_name }}-disk"
image:
- offer: UbuntuServer
+ offer: 0001-com-ubuntu-server-focal
publisher: Canonical
- sku: 16.04-LTS
+ sku: 20_04-lts
version: latest
register: vm_output
- name: Assert status succeeded
- assert:
+ ansible.builtin.assert:
that:
- vm_output.changed
@@ -62,6 +62,7 @@
name: "{{ interface_name }}-disk"
state: absent
ignore_errors: true
+ register: ignore_errors_register
- name: Delete network security group
azure_rm_securitygroup:
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_no_nsg.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_no_nsg.yml
index 7b88dd8d8..62a8e16fe 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_no_nsg.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_no_nsg.yml
@@ -1,4 +1,5 @@
-- include_tasks: setup.yml
+- name: Set variables
+ ansible.builtin.include_tasks: setup.yml
- name: Create minimal VM with defaults
azure_rm_virtualmachine:
@@ -13,9 +14,9 @@
virtual_network: "{{ network_name }}"
created_nsg: false
image:
- offer: UbuntuServer
+ offer: 0001-com-ubuntu-server-focal
publisher: Canonical
- sku: 16.04-LTS
+ sku: 20_04-lts
version: latest
register: vm_output
@@ -26,7 +27,7 @@
register: nsg_result
- name: Assert that security group were not exist before deleting
- assert:
+ ansible.builtin.assert:
that:
- nsg_result.securitygroups | length == 0
@@ -50,7 +51,7 @@
register: pip_result
- name: Assert that autocreated resources were deleted
- assert:
+ ansible.builtin.assert:
that:
# what about the default storage group?
- nic_result.networkinterfaces | length == 0
@@ -79,5 +80,5 @@
azure_rm_storageaccount:
resource_group: "{{ resource_group }}"
name: "{{ storage_account }}"
- force_delete_nonempty: yes
+ force_delete_nonempty: true
state: absent
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_no_public_ip.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_no_public_ip.yml
index 5b41a6eb9..bcec8da62 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_no_public_ip.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_no_public_ip.yml
@@ -1,4 +1,5 @@
-- include_tasks: setup.yml
+- name: Set variables
+ ansible.builtin.include_tasks: setup.yml
- name: Create virtual machine without public ip address and with boot diagnostics enabled
azure_rm_virtualmachine:
@@ -17,22 +18,22 @@
availability_set: "{{ availability_set }}"
virtual_network: "{{ network_name }}"
boot_diagnostics:
- enabled: yes
+ enabled: true
image:
- offer: UbuntuServer
+ offer: 0001-com-ubuntu-server-focal
publisher: Canonical
- sku: 16.04-LTS
+ sku: 20_04-lts
version: latest
register: create_vm_public_result
- name: Ensure VM was created properly
- assert:
+ ansible.builtin.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
+ - azure_vm.diagnostics_profile.boot_diagnostics.enabled
+ - azure_vm.diagnostics_profile.boot_diagnostics.storage_uri is defined
+ - azure_vm.instance_view.boot_diagnostics.console_screenshot_blob_uri is defined
+ - azure_vm.instance_view.boot_diagnostics.serial_console_log_blob_uri is defined
+ - not 'public_ip_address' in create_vm_public_result.ansible_facts.azure_vm.network_profile.network_interfaces[0].properties.ip_configurations[0]
- name: Delete VM with no public ip
azure_rm_virtualmachine:
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_public_ip.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_public_ip.yml
index 6e3e47ea1..2ee786b34 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_public_ip.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_public_ip.yml
@@ -1,4 +1,5 @@
-- include_tasks: setup.yml
+- name: Set variables
+ ansible.builtin.include_tasks: setup.yml
- name: Create public ip
azure_rm_publicipaddress:
@@ -10,7 +11,7 @@
azure_rm_securitygroup:
resource_group: "{{ resource_group }}"
name: "{{ security_group }}"
- purge_rules: yes
+ purge_rules: true
rules:
- name: ALLOW_SSH
protocol: Tcp
@@ -54,23 +55,23 @@
network_interfaces: "{{ interface_name }}"
availability_set: "{{ availability_set }}"
image:
- offer: UbuntuServer
+ offer: 0001-com-ubuntu-server-focal
publisher: Canonical
- sku: 16.04-LTS
+ sku: 20_04-lts
version: latest
custom_data: |
#!/bin/sh
echo "custom_data was executed" > /tmp/custom_data.txt
- name: Ensure VM was created properly
- assert:
+ ansible.builtin.assert:
that:
- - azure_vm.properties.provisioningState == 'Succeeded'
- - azure_vm.properties.availabilitySet.id
+ - azure_vm.provisioning_state == 'Succeeded'
+ - azure_vm.availability_set.id
# initial response from creation has no diagnosticsProfile
# if you run it again however, there is one in the response
# so we handle both cases
- - "'diagnosticsProfile' not in azure_vm.properties or not azure_vm.properties.diagnosticsProfile.bootDiagnostics.enabled"
+ - "'diagnostics_profile' not in azure_vm or not azure_vm.diagnostics_profile.boot_diagnostics.enabled"
- name: Get facts for virtual machine without boot diagnostics disabled
azure_rm_virtualmachine_info:
@@ -79,7 +80,7 @@
register: vm_facts_no_boot_diag_result
- name: Ensure VM facts are correct
- assert:
+ ansible.builtin.assert:
that:
- vm_facts_no_boot_diag_result.vms != []
- not vm_facts_no_boot_diag_result.vms[0].boot_diagnostics.enabled
@@ -92,23 +93,24 @@
register: vm_state
- name: Pause for 10 mimutes to VM updating
- shell: sleep 600
+ ansible.builtin.command: sleep 600
+ changed_when: true
- name: Enable boot diagnostics on an existing VM for the first time without specifying a storage account
azure_rm_virtualmachine:
resource_group: "{{ resource_group }}"
name: "{{ vm_name }}"
boot_diagnostics:
- enabled: yes
+ enabled: true
# without specifying storage_account you get a new default storage account for the VM
- name: Ensure VM properties are correct
- assert:
+ ansible.builtin.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
+ - azure_vm.diagnostics_profile.boot_diagnostics.enabled
+ - azure_vm.diagnostics_profile.boot_diagnostics.storage_uri is defined
+ - azure_vm.instance_view.boot_diagnostics.console_screenshot_blob_uri is defined
+ - azure_vm.instance_view.boot_diagnostics.serial_console_log_blob_uri is defined
- name: Get facts for virtual machine with boot diagnostics enabled
azure_rm_virtualmachine_info:
@@ -117,7 +119,7 @@
register: vm_facts_boot_diag_result
- name: Ensure VM facts were returned
- assert:
+ ansible.builtin.assert:
that:
- vm_facts_boot_diag_result.vms != []
- vm_facts_boot_diag_result.vms[0].boot_diagnostics.enabled
@@ -130,38 +132,39 @@
resource_group: "{{ resource_group }}"
name: "{{ vm_name }}"
boot_diagnostics:
- enabled: yes
+ enabled: true
storage_account: "{{ storage_account }}"
- ignore_errors: yes
+ ignore_errors: true
+ register: ignore_errors_register
- name: Disable boot diagnostics and change the storage account at the same time
azure_rm_virtualmachine:
- resource_group: "{{ resource_group }}"
- name: "{{ vm_name }}"
- boot_diagnostics:
- enabled: no
- storage_account: "{{ storage_account }}"
+ resource_group: "{{ resource_group }}"
+ name: "{{ vm_name }}"
+ boot_diagnostics:
+ enabled: false
+ storage_account: "{{ storage_account }}"
- name: Ensure boot diagnostics was disabled
- assert:
+ ansible.builtin.assert:
that:
- - not azure_vm.properties.diagnosticsProfile.bootDiagnostics.enabled
+ - not azure_vm.diagnostics_profile.boot_diagnostics.enabled
- name: Re-enable boot diagnostics on an existing VM where it was previously configured
azure_rm_virtualmachine:
- resource_group: "{{ resource_group }}"
- name: "{{ vm_name }}"
- boot_diagnostics:
- enabled: yes
+ resource_group: "{{ resource_group }}"
+ name: "{{ vm_name }}"
+ boot_diagnostics:
+ enabled: true
register: reenable_boot_diag_result
- name: Ensure boot diagnostics was reenabled
- assert:
+ ansible.builtin.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
+ - azure_vm.diagnostics_profile.boot_diagnostics.enabled
+ - azure_vm.diagnostics_profile.boot_diagnostics.storage_uri is defined
+ - azure_vm.instance_view.boot_diagnostics.console_screenshot_blob_uri is defined
+ - azure_vm.instance_view.boot_diagnostics.serial_console_log_blob_uri is defined
# - add_host:
# name: new_azure_vm
@@ -188,8 +191,8 @@
# raw: cat /tmp/custom_data.txt
# register: custom_data_content
-# - name: assert contents
-# assert:
+# - name: ansible.builtin.assert contents
+# ansible.builtin.assert:
# that: custom_data_content.stdout | regex_search('custom_data was executed')
# delegate_to: new_azure_vm
@@ -220,14 +223,14 @@
os_type: Linux
network_interfaces: "{{ interface_name }}"
image:
- offer: UbuntuServer
+ offer: 0001-com-ubuntu-server-focal
publisher: Canonical
- sku: 16.04-LTS
+ sku: 20_04-lts
version: latest
register: single_nic_result
- name: Ensure nothing changed
- assert:
+ ansible.builtin.assert:
that: single_nic_result is not changed
- name: Resize VM
@@ -247,17 +250,17 @@
os_type: Linux
network_interfaces: "{{ interface_name }}"
image:
- offer: UbuntuServer
+ offer: 0001-com-ubuntu-server-focal
publisher: Canonical
- sku: 16.04-LTS
+ sku: 20_04-lts
version: latest
register: resize_result
- name: Esure VM was resized
- assert:
+ ansible.builtin.assert:
that:
- resize_result is changed
- - resize_result.ansible_facts.azure_vm.properties.hardwareProfile.vmSize == "Standard_A1"
+ - resize_result.ansible_facts.azure_vm.hardware_profile.vm_size == "Standard_A1"
- name: Delete VM
azure_rm_virtualmachine:
@@ -273,7 +276,7 @@
register: output
- name: Ensure NIC was removed
- assert:
+ ansible.builtin.assert:
that: output.networkinterfaces | length == 0
- name: Public IP should be gone
@@ -283,7 +286,7 @@
register: output
- name: Ensure public IP was removed
- assert:
+ ansible.builtin.assert:
that: output.publicipaddresses | length == 0
- name: Destroy NIC
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_spot.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_spot.yml
index a967e050d..43944e511 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_spot.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_spot.yml
@@ -1,4 +1,5 @@
-- include_tasks: setup.yml
+- name: Set variables
+ ansible.builtin.include_tasks: setup.yml
- name: Create minimal VM with Spot Instance default values
azure_rm_virtualmachine:
@@ -21,7 +22,7 @@
register: vm_output
- name: Ensure VM was created using Spot Instance default values
- assert:
+ ansible.builtin.assert:
that:
- azure_vm.properties.priority == 'Spot'
- azure_vm.properties.evictionPolicy == 'Deallocate'
@@ -56,7 +57,7 @@
register: vm_output
- name: Ensure VM was created using custom spot instance values
- assert:
+ ansible.builtin.assert:
that:
- azure_vm.properties.priority == 'Spot'
- azure_vm.properties.evictionPolicy == 'Delete'
@@ -80,4 +81,4 @@
azure_rm_virtualnetwork:
resource_group: "{{ resource_group }}"
name: "{{ network_name }}"
- state: absent \ No newline at end of file
+ state: absent
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_vm_identity.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_vm_identity.yml
new file mode 100644
index 000000000..c39cc10d1
--- /dev/null
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_vm_identity.yml
@@ -0,0 +1,209 @@
+- name: Create virtual network
+ azure_rm_virtualnetwork:
+ resource_group: "{{ resource_group }}"
+ name: "{{ network_name }}-identity"
+ address_prefixes: "{{ network }}"
+ location: westeurope
+
+- name: Create subnet
+ azure_rm_subnet:
+ resource_group: "{{ resource_group }}"
+ name: "{{ subnet_name }}"
+ address_prefix: "{{ subnet }}"
+ virtual_network: "{{ network_name }}-identity"
+
+- name: Create network interface
+ azure_rm_networkinterface:
+ resource_group: "{{ resource_group }}"
+ name: "{{ interface_name }}-identity"
+ virtual_network: "{{ network_name }}-identity"
+ subnet: "{{ subnet_name }}"
+ location: westeurope
+
+- name: Create User Managed Identities
+ azure_rm_resource:
+ resource_group: "{{ resource_group }}"
+ provider: ManagedIdentity
+ resource_type: userAssignedIdentities
+ resource_name: "{{ item }}"
+ api_version: "2023-01-31"
+ body:
+ location: westeurope
+ state: present
+ loop:
+ - "ansible-test-vm-identity"
+ - "ansible-test-vm-identity-2"
+
+- name: Set identities IDs to test. Identities ansible-test-vm-identity and ansible-test-vm-identity-2 have to be created previously
+ ansible.builtin.set_fact:
+ user_identity_1: "/subscriptions/{{ azure_subscription_id }}/resourcegroups/{{ resource_group }}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/ansible-test-vm-identity"
+ user_identity_2: "/subscriptions/{{ azure_subscription_id }}/resourcegroups/{{ resource_group }}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/ansible-test-vm-identity-2"
+
+- name: Create minimal VM with UserAssigned Identity
+ azure_rm_virtualmachine:
+ allocated: false
+ resource_group: "{{ resource_group }}"
+ name: "{{ vm_name }}"
+ vm_identity:
+ type: UserAssigned
+ user_assigned_identities:
+ id:
+ - "{{ user_identity_1 }}"
+ admin_username: "testuser"
+ ssh_password_enabled: false
+ public_ip_allocation_method: Disabled
+ location: westeurope
+ network_interface_names:
+ - name: "{{ interface_name }}-identity"
+ resource_group: "{{ resource_group }}"
+ ssh_public_keys:
+ - path: /home/testuser/.ssh/authorized_keys
+ key_data: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDfoYlIV4lTPZTv7hXaVwQQuqBgGs4yeNRX0SPo2+HQt9u4X7IGwrtXc0nEUm6LfaCikMH58bOL8f20NTGz285kxdFHZRcBXtqmnMz2rXwhK9gwq5h1khc+GzHtdcJXsGA4y0xuaNcidcg04jxAlN/06fwb/VYwwWTVbypNC0gpGEpWckCNm8vlDlA55sU5et0SZ+J0RKVvEaweUOeNbFZqckGPA384imfeYlADppK/7eAxqfBVadVvZG8IJk4yvATgaIENIFj2cXxqu2mQ/Bp5Wr45uApvJsFXmi+v/nkiOEV1QpLOnEwAZo6EfFS4CCQtsymxJCl1PxdJ5LD4ZOtP xiuxi.sun@qq.com"
+ vm_size: Standard_D4s_v3
+ virtual_network: "{{ network_name }}-identity"
+ image:
+ offer: 0001-com-ubuntu-server-focal
+ publisher: Canonical
+ sku: 20_04-lts
+ version: latest
+ register: vm_output
+
+- name: Assert User identity assigned
+ ansible.builtin.assert:
+ that:
+ - vm_output.ansible_facts.azure_vm.identity.type == 'UserAssigned'
+ - "\"{{ user_identity_1 }}\" in vm_output.ansible_facts.azure_vm.identity.user_assigned_identities"
+
+- name: Append another UserAssigned
+ azure_rm_virtualmachine:
+ name: "{{ vm_name }}"
+ resource_group: "{{ resource_group }}"
+ vm_identity:
+ type: "UserAssigned"
+ user_assigned_identities:
+ id:
+ - "{{ user_identity_2 }}"
+ append: true
+ register: vm_output
+
+- name: Assert appended user identity
+ ansible.builtin.assert:
+ that:
+ - vm_output.ansible_facts.azure_vm.identity.type == 'UserAssigned'
+ - "\"{{ user_identity_1 }}\" in vm_output.ansible_facts.azure_vm.identity.user_assigned_identities"
+ - "\"{{ user_identity_2 }}\" in vm_output.ansible_facts.azure_vm.identity.user_assigned_identities"
+
+- name: Add SystemAssigned
+ azure_rm_virtualmachine:
+ name: "{{ vm_name }}"
+ resource_group: "{{ resource_group }}"
+ vm_identity:
+ type: "SystemAssigned, UserAssigned"
+ user_assigned_identities:
+ append: true
+ register: vm_output
+
+- name: Assert System identity assigned
+ ansible.builtin.assert:
+ that:
+ - vm_output.ansible_facts.azure_vm.identity.type == 'SystemAssigned, UserAssigned'
+ - "\"{{ user_identity_1 }}\" in vm_output.ansible_facts.azure_vm.identity.user_assigned_identities"
+ - "\"{{ user_identity_2 }}\" in vm_output.ansible_facts.azure_vm.identity.user_assigned_identities"
+
+- name: Force only one UserAssigned
+ azure_rm_virtualmachine:
+ name: "{{ vm_name }}"
+ resource_group: "{{ resource_group }}"
+ vm_identity:
+ type: "SystemAssigned, UserAssigned"
+ user_assigned_identities:
+ id:
+ - "{{ user_identity_2 }}"
+ append: false
+ register: vm_output
+
+- name: Assert appended user identity
+ ansible.builtin.assert:
+ that:
+ - vm_output.ansible_facts.azure_vm.identity.type == 'SystemAssigned, UserAssigned'
+ - "\"{{ user_identity_1 }}\" not in vm_output.ansible_facts.azure_vm.identity.user_assigned_identities"
+ - "\"{{ user_identity_2 }}\" in vm_output.ansible_facts.azure_vm.identity.user_assigned_identities"
+
+- name: Remove UserAssigned
+ azure_rm_virtualmachine:
+ name: "{{ vm_name }}"
+ resource_group: "{{ resource_group }}"
+ vm_identity:
+ type: "SystemAssigned"
+ register: vm_output
+
+- name: Assert removed user identities
+ ansible.builtin.assert:
+ that:
+ - vm_output.ansible_facts.azure_vm.identity.type == 'SystemAssigned'
+ - "'user_assigned_identities' not in vm_output.ansible_facts.azure_vm.identity"
+
+- name: Disable SystemAssigned
+ azure_rm_virtualmachine:
+ name: "{{ vm_name }}"
+ resource_group: "{{ resource_group }}"
+ vm_identity:
+ type: "None"
+ register: vm_output
+
+- name: Assert no managed identities
+ ansible.builtin.assert:
+ that:
+ - "'identity' not in vm_output.ansible_facts.azure_vm"
+
+- name: Delete VM
+ azure_rm_virtualmachine:
+ resource_group: "{{ resource_group }}"
+ name: "{{ vm_name }}"
+ remove_on_absent: all_autocreated
+ state: absent
+
+- name: Destroy NIC
+ azure_rm_networkinterface:
+ resource_group: "{{ resource_group }}"
+ name: "{{ interface_name }}-identity"
+ state: absent
+ ignore_errors: true
+ register: ignore_errors_register
+
+- name: Delete network security group
+ azure_rm_securitygroup:
+ resource_group: "{{ resource_group }}"
+ name: "{{ interface_name }}-identity"
+ state: absent
+
+- name: Destroy subnet
+ azure_rm_subnet:
+ resource_group: "{{ resource_group }}"
+ virtual_network: "{{ network_name }}"
+ name: "{{ subnet_name }}-identity"
+ state: absent
+
+- name: Destroy virtual network
+ azure_rm_virtualnetwork:
+ resource_group: "{{ resource_group }}"
+ name: "{{ network_name }}-identity"
+ state: absent
+
+- name: Destroy SA of the machine
+ azure_rm_storageaccount:
+ resource_group: "{{ resource_group }}"
+ name: "{{ vm_output.ansible_facts.azure_vm.tags._own_sa_ }}"
+ state: absent
+
+- name: Destroy User Managed Identities
+ azure_rm_resource:
+ resource_group: "{{ resource_group }}"
+ provider: ManagedIdentity
+ resource_type: userAssignedIdentities
+ resource_name: "{{ item }}"
+ api_version: "2023-01-31"
+ state: absent
+ loop:
+ - "ansible-test-vm-identity"
+ - "ansible-test-vm-identity-2"
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/setup.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/setup.yml
index f053cac03..a14fa7eff 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/setup.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachine/tasks/setup.yml
@@ -1,4 +1,5 @@
-- debug:
+- name: Set variables
+ ansible.builtin.debug:
msg: "UID is {{ uid_short }}"
- name: SETUP | Create storage account
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachineextension/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachineextension/tasks/main.yml
index a4a1e62ee..e053cf0b8 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachineextension/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachineextension/tasks/main.yml
@@ -1,5 +1,5 @@
- name: Create Random Storage Account Name
- set_fact:
+ ansible.builtin.set_fact:
storage_account: "vme{{ resource_group | hash('md5') | truncate(21, True, '') }}"
public_settings_file: "files/test-public-settings.json"
protected_settings_file: "files/test-protected-settings.json"
@@ -44,7 +44,7 @@
public_ip_name: testPublicIP
security_group_name: testNetworkSecurityGroup
-- name: create a storage account
+- name: Create a storage account
azure_rm_storageaccount:
resource_group: "{{ resource_group }}"
name: "{{ storage_account }}"
@@ -84,7 +84,7 @@
settings: {"commandToExecute": "date"}
register: results
- name: Assert that VM Extension ran
- assert:
+ ansible.builtin.assert:
that: results.changed
- name: Query extension
@@ -94,7 +94,7 @@
virtual_machine_name: testVM
register: results
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- results.changed == False
- results.extensions[0]['id'] != None
@@ -120,7 +120,7 @@
settings: {"commandToExecute": "date"}
register: results
- name: Assert no updates
- assert:
+ ansible.builtin.assert:
that: not results.changed
- name: Create VM Extension (force update)
@@ -136,7 +136,7 @@
force_update_tag: true
register: results
- name: Assert updates
- assert:
+ ansible.builtin.assert:
that: results.changed
- name: List extensions
@@ -145,7 +145,7 @@
virtual_machine_name: testVM
register: results
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- results.changed == False
- results.extensions[0]['id'] != None
@@ -167,7 +167,7 @@
state: absent
register: results
- name: Assert that VM Extension deleted
- assert:
+ ansible.builtin.assert:
that: results.changed
- name: Delete VM Extension (idempotent)
@@ -178,7 +178,7 @@
state: absent
register: results
- name: Assert no changes
- assert:
+ ansible.builtin.assert:
that: not results.changed
- name: Create VM Extension to configure python required for VM diagnostic extension
@@ -193,7 +193,7 @@
settings: {"commandToExecute": "apt-get update && apt-get install -y python2 && update-alternatives --install /usr/bin/python python /usr/bin/python2 1"}
register: results
- name: Assert that VM Extension ran
- assert:
+ ansible.builtin.assert:
that: results.changed
- name: Install VM Extension for diagnostics
@@ -209,7 +209,7 @@
protected_settings: "{{ lookup('file', protected_settings_file) }}"
register: results
- name: Assert extension installed
- assert:
+ ansible.builtin.assert:
that: results.changed
- name: Install VM Extension for diagnostics (idempotent)
@@ -225,7 +225,7 @@
protected_settings: "{{ lookup('file', protected_settings_file) }}"
register: results
- name: Assert no updates
- assert:
+ ansible.builtin.assert:
that: not results.changed
- name: List extensions
@@ -234,7 +234,7 @@
virtual_machine_name: testVM
register: results
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- results.changed == False
- results.extensions | length >= 2
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachineimage_info/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachineimage_info/tasks/main.yml
index 88fd5ce19..8252214a4 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachineimage_info/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachineimage_info/tasks/main.yml
@@ -1,5 +1,5 @@
-- name: set location
- set_fact:
+- name: Set location
+ ansible.builtin.set_fact:
location: eastus
- name: Get facts for a specific image
@@ -11,8 +11,9 @@
version: '7.5.201808150'
register: output
-- assert:
- that: output['vmimages'] | length == 1
+- name: Assert the image facts
+ ansible.builtin.assert:
+ that: output['vmimages'] | length == 1
- name: List available versions
azure_rm_virtualmachineimage_info:
@@ -22,8 +23,9 @@
sku: '7.5'
register: output
-- assert:
- that: output['vmimages'] | length > 0
+- name: Assert all image version facts
+ ansible.builtin.assert:
+ that: output['vmimages'] | length > 0
- name: List available offers
azure_rm_virtualmachineimage_info:
@@ -31,16 +33,18 @@
publisher: OpenLogic
register: output
-- assert:
- that: output['vmimages'] | length > 0
+- name: Assert image facts
+ ansible.builtin.assert:
+ that: output['vmimages'] | length > 0
- name: List available publishers
azure_rm_virtualmachineimage_info:
location: "{{ location }}"
register: output
-- assert:
- that: output['vmimages'] | length > 0
+- name: Assert image facts
+ ansible.builtin.assert:
+ that: output['vmimages'] | length > 0
- name: Get facts for a specific image's latest version
azure_rm_virtualmachineimage_info:
@@ -51,5 +55,6 @@
version: 'latest'
register: output
-- assert:
- that: output['vmimages'] | length == 1 \ No newline at end of file
+- name: Assert image facts
+ ansible.builtin.assert:
+ that: output['vmimages'] | length == 1
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachinescaleset/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachinescaleset/tasks/main.yml
index d027146c2..98f51ee9f 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachinescaleset/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachinescaleset/tasks/main.yml
@@ -1,7 +1,7 @@
- name: Prepare random number
- set_fact:
+ ansible.builtin.set_fact:
rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
- run_once: yes
+ run_once: true
- name: Create virtual network
azure_rm_virtualnetwork:
@@ -69,9 +69,9 @@
vm_size: Standard_B1ms
network_interfaces: "vmforimage{{ rpfx }}nic"
image:
- offer: UbuntuServer
+ offer: 0001-com-ubuntu-server-focal
publisher: Canonical
- sku: 18.04-LTS
+ sku: 20_04-lts
version: latest
- name: Get VM facts
azure_rm_virtualmachine_info:
@@ -79,12 +79,13 @@
name: "vmforimage{{ rpfx }}"
register: vm_state
- name: Pause for 10 mimutes to VM updating
- shell: sleep 600
+ ansible.builtin.command: sleep 600
+ changed_when: true
- name: Generalize VM
azure_rm_virtualmachine:
resource_group: "{{ resource_group }}"
name: "vmforimage{{ rpfx }}"
- generalized: yes
+ generalized: true
- name: Create image A
azure_rm_image:
resource_group: "{{ resource_group }}"
@@ -107,9 +108,9 @@
name: testVMSS{{ rpfx }}
vm_size: Standard_A1_v2
admin_username: testuser
- single_placement_group: False
+ single_placement_group: false
platform_fault_domain_count: 1
- public_ip_per_vm: True
+ public_ip_per_vm: true
ssh_password_enabled: false
ssh_public_keys:
- path: /home/testuser/.ssh/authorized_keys
@@ -120,9 +121,9 @@
orchestration_mode: Flexible
os_disk_caching: ReadWrite
image:
- offer: UbuntuServer
+ offer: 0001-com-ubuntu-server-focal
publisher: Canonical
- sku: 18.04-LTS
+ sku: 20_04-lts
version: latest
data_disks:
- lun: 0
@@ -132,7 +133,7 @@
register: results
- name: Assert that VMSS can be created
- assert:
+ ansible.builtin.assert:
that: results.changed
- name: Create VMSS with I(orchestration_mode=Flexible) again --- Idempotent
@@ -141,9 +142,9 @@
name: testVMSS{{ rpfx }}
vm_size: Standard_A1_v2
admin_username: testuser
- single_placement_group: False
+ single_placement_group: false
platform_fault_domain_count: 1
- public_ip_per_vm: True
+ public_ip_per_vm: true
ssh_password_enabled: false
ssh_public_keys:
- path: /home/testuser/.ssh/authorized_keys
@@ -154,9 +155,9 @@
orchestration_mode: Flexible
os_disk_caching: ReadWrite
image:
- offer: UbuntuServer
+ offer: 0001-com-ubuntu-server-focal
publisher: Canonical
- sku: 18.04-LTS
+ sku: 20_04-lts
version: latest
data_disks:
- lun: 0
@@ -166,7 +167,7 @@
register: results
- name: Assert that VMSS can be created
- assert:
+ ansible.builtin.assert:
that: not results.changed
- name: Retrieve scaleset VMSS fact
@@ -175,9 +176,10 @@
resource_group: "{{ resource_group }}"
register: output_scaleset
-- assert:
+- name: Assert vmss facts
+ ansible.builtin.assert:
that:
- - output_scaleset.vmss[0].properties.orchestrationMode == "Flexible"
+ - output_scaleset.vmss[0].orchestration_mode == "Flexible"
- name: Delete VMSS
azure_rm_virtualmachinescaleset:
@@ -193,7 +195,7 @@
admin_username: testuser
priority: Spot
eviction_policy: Deallocate
- single_placement_group: True
+ single_placement_group: true
ssh_password_enabled: false
ssh_public_keys:
- path: /home/testuser/.ssh/authorized_keys
@@ -206,9 +208,9 @@
managed_disk_type: Standard_LRS
os_disk_caching: ReadWrite
image:
- offer: UbuntuServer
+ offer: 0001-com-ubuntu-server-focal
publisher: Canonical
- sku: 18.04-LTS
+ sku: 20_04-lts
version: latest
data_disks:
- lun: 0
@@ -218,11 +220,11 @@
register: results
- name: Assert that VMSS was created using Spot Instance default values
- assert:
+ ansible.builtin.assert:
that:
- - results.ansible_facts.azure_vmss.properties.virtualMachineProfile.priority == 'Spot'
- - results.ansible_facts.azure_vmss.properties.virtualMachineProfile.evictionPolicy == 'Deallocate'
- - results.ansible_facts.azure_vmss.properties.virtualMachineProfile.billingProfile.maxPrice == -1.0
+ - results.ansible_facts.azure_vmss.virtual_machine_profile.priority == 'Spot'
+ - results.ansible_facts.azure_vmss.virtual_machine_profile.eviction_policy == 'Deallocate'
+ - results.ansible_facts.azure_vmss.virtual_machine_profile.billing_profile.max_price == -1.0
- name: Delete VMSS
azure_rm_virtualmachinescaleset:
@@ -250,11 +252,11 @@
tier: Standard
managed_disk_type: Standard_LRS
os_disk_caching: ReadWrite
- single_placement_group: True
+ single_placement_group: true
image:
- offer: UbuntuServer
+ offer: 0001-com-ubuntu-server-focal
publisher: Canonical
- sku: 18.04-LTS
+ sku: 20_04-lts
version: latest
data_disks:
- lun: 0
@@ -264,17 +266,17 @@
register: results
- name: Assert that VMSS was created using Spot Instance custom values
- assert:
+ ansible.builtin.assert:
that:
- - results.ansible_facts.azure_vmss.properties.virtualMachineProfile.priority == 'Spot'
- - results.ansible_facts.azure_vmss.properties.virtualMachineProfile.evictionPolicy == 'Delete'
- - results.ansible_facts.azure_vmss.properties.virtualMachineProfile.billingProfile.maxPrice == 1.0
+ - results.ansible_facts.azure_vmss.virtual_machine_profile.priority == 'Spot'
+ - results.ansible_facts.azure_vmss.virtual_machine_profile.eviction_policy == 'Delete'
+ - results.ansible_facts.azure_vmss.virtual_machine_profile.billing_profile.max_price == 1.0
- name: Delete VMSS
azure_rm_virtualmachinescaleset:
resource_group: "{{ resource_group }}"
name: testVMSS{{ rpfx }}
- state: absent
+ state: absent
- name: Create VMSS (check mode)
azure_rm_virtualmachinescaleset:
@@ -294,11 +296,11 @@
tier: Standard
managed_disk_type: Standard_LRS
os_disk_caching: ReadWrite
- single_placement_group: True
+ single_placement_group: true
image:
- offer: UbuntuServer
+ offer: 0001-com-ubuntu-server-focal
publisher: Canonical
- sku: 18.04-LTS
+ sku: 20_04-lts
version: latest
data_disks:
- lun: 0
@@ -306,13 +308,13 @@
caching: ReadWrite
managed_disk_type: Standard_LRS
register: results
- check_mode: yes
+ check_mode: true
- name: Assert that VMSS can be created
- assert:
+ ansible.builtin.assert:
that: results.changed
-- name: Get VMSS to assert no VMSS is created in check mode
+- name: Get VMSS to ansible.builtin.assert no VMSS is created in check mode
azure_rm_virtualmachinescaleset_info:
resource_group: "{{ resource_group }}"
name: testVMSS{{ rpfx }}
@@ -320,7 +322,7 @@
register: output_scaleset
- name: Assert no VMSS created in check mode
- assert:
+ ansible.builtin.assert:
that:
- output_scaleset.vmss | length == 0
@@ -343,11 +345,11 @@
managed_disk_type: Standard_LRS
os_disk_caching: ReadWrite
custom_data: "#cloud-config"
- single_placement_group: True
+ single_placement_group: true
image:
- offer: UbuntuServer
+ offer: 0001-com-ubuntu-server-focal
publisher: Canonical
- sku: 18.04-LTS
+ sku: 20_04-lts
version: latest
data_disks:
- lun: 0
@@ -358,7 +360,7 @@
register: results
- name: Assert that VMSS was created
- assert:
+ ansible.builtin.assert:
that: results.changed
- name: Create VMSS -- test upgrade_policy idempotence and load balancer
@@ -380,11 +382,11 @@
managed_disk_type: Standard_LRS
os_disk_caching: ReadWrite
custom_data: "#cloud-config"
- single_placement_group: True
+ single_placement_group: true
image:
- offer: UbuntuServer
+ offer: 0001-com-ubuntu-server-focal
publisher: Canonical
- sku: 18.04-LTS
+ sku: 20_04-lts
version: latest
data_disks:
- lun: 0
@@ -394,7 +396,7 @@
register: results
- name: Assert that VMSS was created
- assert:
+ ansible.builtin.assert:
that: results.changed
- name: Retrieve scaleset facts
@@ -404,9 +406,10 @@
format: curated
register: output_scaleset
-- assert:
+- name: Assert the vmss facts
+ ansible.builtin.assert:
that:
- - output_scaleset.vmss[0].load_balancer == "testLB1"
+ - output_scaleset.vmss[0].load_balancer == "testLB1"
- name: Retrieve scaleset VMs facts
azure_rm_virtualmachinescalesetinstance_info:
@@ -415,7 +418,7 @@
register: instances
- name: Assert that facts returned correctly
- assert:
+ ansible.builtin.assert:
that:
- instances.instances | length == 1
- instances.instances[0].id != None
@@ -427,7 +430,7 @@
- instances.instances[0].power_state != None
- name: Get scaleset body
- set_fact:
+ ansible.builtin.set_fact:
body: "{{ output_scaleset.vmss[0] }}"
- name: Try to update VMSS using output as input
@@ -451,11 +454,11 @@
image: "{{ body.image }}"
data_disks: "{{ body.data_disks }}"
overprovision: "{{ body.overprovision }}"
- single_placement_group: True
+ single_placement_group: true
register: results
- name: Assert that nothing was changed
- assert:
+ ansible.builtin.assert:
that: not results.changed
- name: Install VMSS Extension
@@ -471,7 +474,7 @@
register: results
- name: Assert that something was changed
- assert:
+ ansible.builtin.assert:
that: results.changed
- name: Install Again VMSS Extension - again
@@ -487,7 +490,7 @@
register: results
- name: Assert that nothing was changed
- assert:
+ ansible.builtin.assert:
that: not results.changed
- name: Query extension
@@ -498,7 +501,7 @@
register: results
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- results.changed == False
- results.extensions[0]['id'] != None
@@ -518,7 +521,7 @@
register: results
- name: Assert that facts are returned
- assert:
+ ansible.builtin.assert:
that:
- results.changed == False
- results.extensions[0]['id'] != None
@@ -540,7 +543,7 @@
register: results
- name: Assert that change was reported
- assert:
+ ansible.builtin.assert:
that: results.changed
- name: Upgrade instance to the latest image
@@ -548,11 +551,11 @@
resource_group: "{{ resource_group }}"
vmss_name: testVMSS{{ rpfx }}
instance_id: "{{ instances.instances[0].instance_id }}"
- latest_model: yes
+ latest_model: true
register: results
- name: Assert that something has changed
- assert:
+ ansible.builtin.assert:
that: results.changed
- name: Stop virtual machine
@@ -564,7 +567,7 @@
register: results
- name: Assert that something has changed
- assert:
+ ansible.builtin.assert:
that: results.changed
- name: Delete instance
@@ -576,7 +579,7 @@
register: results
- name: Assert that something has changed
- assert:
+ ansible.builtin.assert:
that: results.changed
- name: Delete VMSS
@@ -603,13 +606,13 @@
resource_group: "{{ resource_group }}"
upgrade_policy: Manual
security_group: testNetworkSecurityGroup
- enable_accelerated_networking: yes
- single_placement_group: True
+ enable_accelerated_networking: true
+ single_placement_group: true
register: results
- check_mode: yes
+ check_mode: true
- name: Assert that VMSS can be created
- assert:
+ ansible.builtin.assert:
that: results.changed
- name: Create VMSS with security group in same resource group, with accelerated networking.
@@ -630,16 +633,16 @@
resource_group: "{{ resource_group }}"
upgrade_policy: Manual
security_group: testNetworkSecurityGroup
- enable_accelerated_networking: yes
- single_placement_group: True
+ enable_accelerated_networking: true
+ single_placement_group: true
register: results
- name: Assert that VMSS ran
- assert:
+ ansible.builtin.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 != {}'
+ - 'results.ansible_facts.azure_vmss.virtual_machine_profile.network_profile.network_interface_configurations[0].enable_accelerated_networking == true'
+ - 'results.ansible_facts.azure_vmss.virtual_machine_profile.network_profile.network_interface_configurations[0].network_security_group != {}'
- name: Create VMSS with security group in same resource group, with accelerated networking.
azure_rm_virtualmachinescaleset:
@@ -659,12 +662,12 @@
resource_group: "{{ resource_group }}"
upgrade_policy: Manual
security_group: testNetworkSecurityGroup
- enable_accelerated_networking: yes
- single_placement_group: True
+ enable_accelerated_networking: true
+ single_placement_group: true
register: results
- name: Assert that nothing has changed
- assert:
+ ansible.builtin.assert:
that:
- not results.changed
@@ -686,16 +689,16 @@
resource_group: "{{ resource_group }}"
upgrade_policy: Manual
security_group: testNetworkSecurityGroup
- enable_accelerated_networking: yes
- single_placement_group: True
+ enable_accelerated_networking: true
+ single_placement_group: true
register: results
- name: Assert that something has changed
- assert:
+ ansible.builtin.assert:
that:
- results.changed
-- name: update VMSS with security group in different resource group.
+- name: Update VMSS with security group in different resource group.
azure_rm_virtualmachinescaleset:
resource_group: "{{ resource_group }}"
name: testVMSS{{ rpfx }}2
@@ -715,12 +718,12 @@
security_group:
name: testNetworkSecurityGroup2
resource_group: "{{ resource_group_secondary }}"
- single_placement_group: True
+ single_placement_group: true
register: results
# disable for now
-#- name: Assert that security group is correct
-# assert:
+# - name: Assert that security group is correct
+# ansible.builtin.assert:
# that:
# - 'results.changed'
# - '"testNetworkSecurityGroup2" in results.ansible_facts.azure_vmss.properties.virtualMachineProfile.networkProfile.networkInterfaceConfigurations.0.properties.networkSecurityGroup.id'
@@ -742,9 +745,9 @@
admin_username: testuser
ssh_password_enabled: false
ssh_public_keys:
- - path: /home/testuser/.ssh/authorized_keys
- key_data: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDfoYlIV4lTPZTv7hXaVwQQuqBgGs4yeNRX0SPo2+HQt9u4X7IGwrtXc0nEUm6LfaCikMH58bOL8f20NTGz285kxdFHZRcBXtqmnMz2rXwhK9gwq5h1khc+GzHtdcJXsGA4y0xuaNcidcg04jxAlN/06fwb/VYwwWTVbypNC0gpGEpWckCNm8vlDlA55sU5et0SZ+J0RKVvEaweUOeNbFZqckGPA384imfeYlADppK/7eAxqfBVadVvZG8IJk4yvATgaIENIFj2cXxqu2mQ/Bp5Wr45uApvJsFXmi+v/nkiOEV1QpLOnEwAZo6EfFS4CCQtsymxJCl1PxdJ5LD4ZOtP xiuxi.sun@qq.com"
- ephemeral_os_disk: True
+ - path: /home/testuser/.ssh/authorized_keys
+ key_data: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDfoYlIV4lTPZTv7hXaVwQQuqBgGs4yeNRX0SPo2+HQt9u4X7IGwrtXc0nEUm6LfaCikMH58bOL8f20NTGz285kxdFHZRcBXtqmnMz2rXwhK9gwq5h1khc+GzHtdcJXsGA4y0xuaNcidcg04jxAlN/06fwb/VYwwWTVbypNC0gpGEpWckCNm8vlDlA55sU5et0SZ+J0RKVvEaweUOeNbFZqckGPA384imfeYlADppK/7eAxqfBVadVvZG8IJk4yvATgaIENIFj2cXxqu2mQ/Bp5Wr45uApvJsFXmi+v/nkiOEV1QpLOnEwAZo6EfFS4CCQtsymxJCl1PxdJ5LD4ZOtP xiuxi.sun@qq.com"
+ ephemeral_os_disk: true
image:
name: testimageb
resource_group: "{{ resource_group }}"
@@ -752,13 +755,14 @@
security_group:
name: testNetworkSecurityGroup2
resource_group: "{{ resource_group_secondary }}"
- single_placement_group: True
+ single_placement_group: true
register: results
-- assert:
+- name: Assert vmss created
+ ansible.builtin.assert:
that:
- results.changed
- - results.ansible_facts.azure_vmss.properties.virtualMachineProfile.storageProfile.osDisk.diffDiskSettings.option == 'Local'
+ - results.ansible_facts.azure_vmss.virtual_machine_profile.storage_profile.os_disk.diff_disk_settings.option == 'Local'
- name: Check VMSS ephmeral OS disk can't udpate
azure_rm_virtualmachinescaleset:
@@ -773,7 +777,7 @@
ssh_public_keys:
- path: /home/testuser/.ssh/authorized_keys
key_data: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDfoYlIV4lTPZTv7hXaVwQQuqBgGs4yeNRX0SPo2+HQt9u4X7IGwrtXc0nEUm6LfaCikMH58bOL8f20NTGz285kxdFHZRcBXtqmnMz2rXwhK9gwq5h1khc+GzHtdcJXsGA4y0xuaNcidcg04jxAlN/06fwb/VYwwWTVbypNC0gpGEpWckCNm8vlDlA55sU5et0SZ+J0RKVvEaweUOeNbFZqckGPA384imfeYlADppK/7eAxqfBVadVvZG8IJk4yvATgaIENIFj2cXxqu2mQ/Bp5Wr45uApvJsFXmi+v/nkiOEV1QpLOnEwAZo6EfFS4CCQtsymxJCl1PxdJ5LD4ZOtP xiuxi.sun@qq.com"
- ephemeral_os_disk: False
+ ephemeral_os_disk: false
image:
name: testimageb
resource_group: "{{ resource_group }}"
@@ -781,8 +785,9 @@
security_group:
name: testNetworkSecurityGroup2
resource_group: "{{ resource_group_secondary }}"
- single_placement_group: True
- ignore_errors: yes
+ single_placement_group: true
+ ignore_errors: true
+ register: ignore_errors_register
- name: Delete VMSS
azure_rm_virtualmachinescaleset:
@@ -803,18 +808,18 @@
- path: /home/testuser/.ssh/authorized_keys
key_data: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDfoYlIV4lTPZTv7hXaVwQQuqBgGs4yeNRX0SPo2+HQt9u4X7IGwrtXc0nEUm6LfaCikMH58bOL8f20NTGz285kxdFHZRcBXtqmnMz2rXwhK9gwq5h1khc+GzHtdcJXsGA4y0xuaNcidcg04jxAlN/06fwb/VYwwWTVbypNC0gpGEpWckCNm8vlDlA55sU5et0SZ+J0RKVvEaweUOeNbFZqckGPA384imfeYlADppK/7eAxqfBVadVvZG8IJk4yvATgaIENIFj2cXxqu2mQ/Bp5Wr45uApvJsFXmi+v/nkiOEV1QpLOnEwAZo6EfFS4CCQtsymxJCl1PxdJ5LD4ZOtP xiuxi.sun@qq.com"
image:
- offer: UbuntuServer
+ offer: 0001-com-ubuntu-server-focal
publisher: Canonical
- sku: 18.04-LTS
+ sku: 20_04-lts
version: latest
upgrade_policy: Manual
- enable_accelerated_networking: yes
- single_placement_group: True
+ enable_accelerated_networking: true
+ single_placement_group: true
register: results
- ignore_errors: yes
+ ignore_errors: true
- name: Assert failure to show that accelerated networking is enabled only with supported instance types.
- assert:
+ ansible.builtin.assert:
that:
- '"VMSizeIsNotPermittedToEnableAcceleratedNetworkingForVmss" in results.msg'
@@ -857,41 +862,41 @@
# TODO: Until we have a module to create/delete images this is the best tests
# I can do
-- name: assert error thrown with invalid image dict
+- name: Assert error thrown with invalid image dict
azure_rm_virtualmachinescaleset:
- resource_group: "{{ resource_group }}"
- name: testvm002
- vm_size: Standard_B1s
- image:
- offer: UbuntuServer
+ resource_group: "{{ resource_group }}"
+ name: testvm002
+ vm_size: Standard_B1s
+ image:
+ offer: 0001-com-ubuntu-server-focal
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]"'
-- name: assert error thrown with invalid image type
+- name: Assert error thrown with invalid image type
azure_rm_virtualmachinescaleset:
- resource_group: "{{ resource_group }}"
- name: testvm002
- vm_size: Standard_B1s
- image:
+ resource_group: "{{ resource_group }}"
+ name: testvm002
+ vm_size: Standard_B1s
+ image:
- testing
register: fail_invalid_image_type
failed_when: 'fail_invalid_image_type.msg != "parameter error: expecting image to be a string or dict not list"'
-- name: assert error finding missing custom image
+- name: Assert error finding missing custom image
azure_rm_virtualmachinescaleset:
- resource_group: "{{ resource_group }}"
- name: testvm002
- vm_size: Standard_B1s
- image: invalid-image
+ resource_group: "{{ resource_group }}"
+ name: testvm002
+ vm_size: Standard_B1s
+ image: invalid-image
register: fail_missing_custom_image
failed_when: fail_missing_custom_image.msg != "Error could not find image with name invalid-image"
-- name: assert error finding missing custom image (dict style)
+- name: Assert error finding missing custom image (dict style)
azure_rm_virtualmachinescaleset:
- resource_group: "{{ resource_group }}"
- name: testvm002
- vm_size: Standard_B1s
- image:
- name: invalid-image
+ resource_group: "{{ resource_group }}"
+ name: testvm002
+ vm_size: Standard_B1s
+ image:
+ name: invalid-image
register: fail_missing_custom_image_dict
failed_when: fail_missing_custom_image_dict.msg != "Error could not find image with name invalid-image"
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachinesize_info/meta/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachinesize_info/meta/main.yml
index 48f5726d8..95e1952f9 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachinesize_info/meta/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachinesize_info/meta/main.yml
@@ -1,2 +1,2 @@
dependencies:
- - setup_azure \ No newline at end of file
+ - setup_azure
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachinesize_info/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachinesize_info/tasks/main.yml
index d3aad3f72..289cda25e 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachinesize_info/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualmachinesize_info/tasks/main.yml
@@ -1,5 +1,5 @@
-- name: set location
- set_fact:
+- name: Set location
+ ansible.builtin.set_fact:
location: eastus
- name: Get specific size information for a specific location
@@ -8,13 +8,15 @@
name: Standard_A1_v2
register: output
-- assert:
- that: output['sizes'] | length == 1
+- name: Assert the virtuam machine size
+ ansible.builtin.assert:
+ that: output['sizes'] | length == 1
- name: Get available sizes for a specific location
azure_rm_virtualmachinesize_info:
location: "{{ location }}"
register: output
-- assert:
- that: output['sizes'] | length > 0
+- name: Assert the virtualmachine size
+ ansible.builtin.assert:
+ that: output['sizes'] | length > 0
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualnetwork/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualnetwork/tasks/main.yml
index 143396720..79bbb608f 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualnetwork/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualnetwork/tasks/main.yml
@@ -1,5 +1,5 @@
- name: Prepare random number
- set_fact:
+ ansible.builtin.set_fact:
vnetname: "vnet{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
- name: Delete virtual network, if it exists
@@ -37,7 +37,8 @@
resource_group: "{{ resource_group }}"
register: output
-- assert:
+- name: Assert the virtual network update
+ ansible.builtin.assert:
that:
- "output.state.address_prefixes | length == 3"
- "output.state.flow_timeout_in_minutes == 8"
@@ -60,7 +61,8 @@
- testing
register: facts
-- assert:
+- name: Assert the virtual network facts
+ ansible.builtin.assert:
that:
- "facts.virtualnetworks | length == 1"
- "facts.virtualnetworks[0].dns_servers | length == 2"
@@ -75,7 +77,8 @@
- testing
register: facts
-- assert:
+- name: Assert the virtualnetwork facts
+ ansible.builtin.assert:
that: "facts.virtualnetworks | length >= 1"
- name: Gather facts by tags
@@ -84,7 +87,8 @@
- testing
register: facts
-- assert:
+- name: Assert the virtual network facts
+ ansible.builtin.assert:
that: "facts.virtualnetworks | length >= 1"
- name: Should be idempotent
@@ -103,7 +107,8 @@
resource_group: "{{ resource_group }}"
register: output
-- assert:
+- name: Assert the virtual network idempotent
+ ansible.builtin.assert:
that: not output.changed
- name: Update tags
@@ -116,22 +121,24 @@
resource_group: "{{ resource_group }}"
register: output
-- assert:
- that: output.state.tags | length == 3
+- name: Assert the virtual network updated
+ ansible.builtin.assert:
+ that: output.state.tags | length == 3
- name: Purge tags
azure_rm_virtualnetwork:
name: "{{ vnetname }}"
- append_tags: no
+ append_tags: false
tags:
testing: 'always'
resource_group: "{{ resource_group }}"
register: output
-- assert:
- that:
- - output.state.tags | length == 1
- - output.state.tags.testing == 'always'
+- name: Assert the virtual network updated
+ ansible.builtin.assert:
+ that:
+ - output.state.tags | length == 1
+ - output.state.tags.testing == 'always'
- name: Should require address_prefixes_cidr when purge_address_prefixes
azure_rm_virtualnetwork:
@@ -139,10 +146,11 @@
purge_address_prefixes: true
resource_group: "{{ resource_group }}"
register: output
- ignore_errors: yes
+ ignore_errors: true
-- assert:
- that: output.failed
+- name: Assert the virtual network updated
+ ansible.builtin.assert:
+ that: output.failed
- name: Purge address prefixes
azure_rm_virtualnetwork:
@@ -152,12 +160,13 @@
resource_group: "{{ resource_group }}"
register: output
-- assert:
+- name: Assert the virtual network updated
+ ansible.builtin.assert:
that:
- - output.state.address_prefixes | length == 1
- - output.state.address_prefixes[0] == '10.1.0.0/16'
- - output.state.dns_servers | length == 2
- - output.state.dns_servers[0] == '127.0.0.1'
+ - output.state.address_prefixes | length == 1
+ - output.state.address_prefixes[0] == '10.1.0.0/16'
+ - output.state.dns_servers | length == 2
+ - output.state.dns_servers[0] == '127.0.0.1'
- name: Purge DNS servers
azure_rm_virtualnetwork:
@@ -166,7 +175,8 @@
resource_group: "{{ resource_group }}"
register: output
-- assert:
+- name: Assert the virtual network DNS server purged
+ ansible.builtin.assert:
that: output.state['dns_servers'] is undefined
- name: Gather facts
@@ -175,7 +185,8 @@
name: "{{ vnetname }}"
register: facts
-- assert:
+- name: Assert the virtual network facts
+ ansible.builtin.assert:
that:
- facts.virtualnetworks | length == 1
- "facts.virtualnetworks[0].subnets | length == 1"
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualnetworkgateway/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualnetworkgateway/tasks/main.yml
index 9dbd87e69..4b692fd1c 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualnetworkgateway/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualnetworkgateway/tasks/main.yml
@@ -1,13 +1,13 @@
# FIXME: needs minimal tests (check mode?) that can run quickly, VNG creation takes > 20min
- name: Prepare random number
- set_fact:
+ ansible.builtin.set_fact:
vnetname: "vnet{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
vngname: "vng{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
pubipname: "testPublicIP{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
- name: Create virtual network gateway without bgp settings (check mode)
- check_mode: yes
+ check_mode: true
azure_rm_virtualnetworkgateway:
resource_group: "{{ resource_group }}"
name: "{{ vngname }}"
@@ -20,11 +20,12 @@
common: "xyz"
register: output
-- assert:
+- name: Assert the virtual network gateway check mode
+ ansible.builtin.assert:
that: output.changed
- name: Create virtual network gateway Generation2 (check mode)
- check_mode: yes
+ check_mode: true
azure_rm_virtualnetworkgateway:
resource_group: "{{ resource_group }}"
name: "{{ vngname }}"
@@ -38,153 +39,159 @@
tags:
common: "xyz"
-- assert:
+- name: Assert the virtual network gateway check mode
+ ansible.builtin.assert:
that: output.changed
-
-- name: long-running virtualnetworkgateway tests [run with `--tags long_run,untagged` to enable]
+- name: Long-running virtualnetworkgateway tests [run with `--tags long_run,untagged` to enable]
tags: [long_run, never]
block:
- - name: Create virtual network
- azure_rm_virtualnetwork:
+ - name: Create virtual network
+ azure_rm_virtualnetwork:
resource_group: "{{ resource_group }}"
name: "{{ vnetname }}"
address_prefixes: "10.0.0.0/16"
- - name: Add subnet
- azure_rm_subnet:
+ - name: Add subnet
+ azure_rm_subnet:
resource_group: "{{ resource_group }}"
name: GatewaySubnet
address_prefix: "10.0.2.0/24"
virtual_network: "{{ vnetname }}"
- - name: Create public IP address
- azure_rm_publicipaddress:
+ - name: Create public IP address
+ azure_rm_publicipaddress:
resource_group: "{{ resource_group }}"
allocation_method: Dynamic
name: "{{ pubipname }}"
- - name: Create virtual network gateway without bgp settings
- azure_rm_virtualnetworkgateway:
- resource_group: "{{ resource_group }}"
- name: "{{ vngname }}"
- ip_configurations:
- - name: testipconfig
- private_ip_allocation_method: Dynamic
- public_ip_address_name: testPublicIP
- virtual_network: "{{ vnetname }}"
- tags:
- common: "xyz"
- register: output
-
- - assert:
- that: output.changed
-
- - name: Create virtual network gateway without bgp settings - idempotent
- azure_rm_virtualnetworkgateway:
- resource_group: "{{ resource_group }}"
- name: "{{ vngname }}"
- ip_configurations:
- - name: testipconfig
- private_ip_allocation_method: Dynamic
- public_ip_address_name: "{{ pubipname }}"
- virtual_network: "{{ vnetname }}"
- tags:
- common: "xyz"
- register: output
-
- - assert:
- that: not output.changed
-
- - name: Update virtual network gateway
- azure_rm_virtualnetworkgateway:
- resource_group: "{{ resource_group }}"
- name: "{{ vngname }}"
- ip_configurations:
- - name: testipconfig
- private_ip_allocation_method: Dynamic
- public_ip_address_name: "{{ pubipname }}"
- virtual_network: "{{ vnetname }}"
- tags:
- common: "mno"
- register: output
- - assert:
- that: output.changed
-
- - name: Delete virtual network gateway
- azure_rm_virtualnetworkgateway:
- resource_group: "{{ resource_group }}"
- name: "{{ vngname }}"
- state: absent
- register: output
- - assert:
- that: output.changed
-
-- name: long-running generation virtualnetworkgateway tests [run with `--tags long_run_gen,untagged` to enable]
+ - name: Create virtual network gateway without bgp settings
+ azure_rm_virtualnetworkgateway:
+ resource_group: "{{ resource_group }}"
+ name: "{{ vngname }}"
+ ip_configurations:
+ - name: testipconfig
+ private_ip_allocation_method: Dynamic
+ public_ip_address_name: testPublicIP
+ virtual_network: "{{ vnetname }}"
+ tags:
+ common: "xyz"
+ register: output
+
+ - name: Assert the virtual network gateway created
+ ansible.builtin.assert:
+ that: output.changed
+
+ - name: Create virtual network gateway without bgp settings - idempotent
+ azure_rm_virtualnetworkgateway:
+ resource_group: "{{ resource_group }}"
+ name: "{{ vngname }}"
+ ip_configurations:
+ - name: testipconfig
+ private_ip_allocation_method: Dynamic
+ public_ip_address_name: "{{ pubipname }}"
+ virtual_network: "{{ vnetname }}"
+ tags:
+ common: "xyz"
+ register: output
+
+ - name: Assert the idempotent
+ ansible.builtin.assert:
+ that: not output.changed
+
+ - name: Update virtual network gateway
+ azure_rm_virtualnetworkgateway:
+ resource_group: "{{ resource_group }}"
+ name: "{{ vngname }}"
+ ip_configurations:
+ - name: testipconfig
+ private_ip_allocation_method: Dynamic
+ public_ip_address_name: "{{ pubipname }}"
+ virtual_network: "{{ vnetname }}"
+ tags:
+ common: "mno"
+ register: output
+ - name: Assert the virtual network gateway updated
+ ansible.builtin.assert:
+ that: output.changed
+
+ - name: Delete virtual network gateway
+ azure_rm_virtualnetworkgateway:
+ resource_group: "{{ resource_group }}"
+ name: "{{ vngname }}"
+ state: absent
+ register: output
+ - name: Assert the virtual network gateway deleted
+ ansible.builtin.assert:
+ that: output.changed
+
+- name: Long-running generation virtualnetworkgateway tests [run with `--tags long_run_gen,untagged` to enable]
tags: [long_run_gen, never]
block:
- - name: Create virtual network
- azure_rm_virtualnetwork:
+ - name: Create virtual network
+ azure_rm_virtualnetwork:
resource_group: "{{ resource_group }}"
name: "{{ vnetname }}"
address_prefixes: "10.0.0.0/16"
- - name: Add subnet
- azure_rm_subnet:
+ - name: Add subnet
+ azure_rm_subnet:
resource_group: "{{ resource_group }}"
name: GatewaySubnet
address_prefix: "10.0.2.0/24"
virtual_network: "{{ vnetname }}"
- - name: Create public IP address
- azure_rm_publicipaddress:
+ - name: Create public IP address
+ azure_rm_publicipaddress:
resource_group: "{{ resource_group }}"
allocation_method: Dynamic
name: "{{ pubipname }}"
- - name: Create virtual network gateway w/ sku and Generation2
- azure_rm_virtualnetworkgateway:
- resource_group: "{{ resource_group }}"
- name: "{{ vngname }}"
- sku: VpnGw2
- vpn_gateway_generation: Generation2
- ip_configurations:
- - name: testipconfig
- private_ip_allocation_method: Dynamic
- public_ip_address_name: "{{ pubipname }}"
- virtual_network: "{{ vnetname }}"
- tags:
- common: "xyz"
-
- - assert:
- that: output.changed
-
- - name: Update virtual network gateway
- azure_rm_virtualnetworkgateway:
- resource_group: "{{ resource_group }}"
- name: "{{ vngname }}"
- sku: VpnGw2
- vpn_gateway_generation: Generation2
- ip_configurations:
- - name: testipconfig
- private_ip_allocation_method: Dynamic
- public_ip_address_name: "{{ pubipname }}"
- virtual_network: "{{ vnetname }}"
- tags:
- common: "mno"
-
- register: output
- - assert:
- that: output.changed
-
- - name: Delete virtual network gateway
- azure_rm_virtualnetworkgateway:
- resource_group: "{{ resource_group }}"
- name: "{{ vngname }}"
- state: absent
- register: output
- - assert:
- that: output.changed
+ - name: Create virtual network gateway w/ sku and Generation2
+ azure_rm_virtualnetworkgateway:
+ resource_group: "{{ resource_group }}"
+ name: "{{ vngname }}"
+ sku: VpnGw2
+ vpn_gateway_generation: Generation2
+ ip_configurations:
+ - name: testipconfig
+ private_ip_allocation_method: Dynamic
+ public_ip_address_name: "{{ pubipname }}"
+ virtual_network: "{{ vnetname }}"
+ tags:
+ common: "xyz"
+
+ - name: Assert the virtual network gateay created
+ ansible.builtin.assert:
+ that: output.changed
+
+ - name: Update virtual network gateway
+ azure_rm_virtualnetworkgateway:
+ resource_group: "{{ resource_group }}"
+ name: "{{ vngname }}"
+ sku: VpnGw2
+ vpn_gateway_generation: Generation2
+ ip_configurations:
+ - name: testipconfig
+ private_ip_allocation_method: Dynamic
+ public_ip_address_name: "{{ pubipname }}"
+ virtual_network: "{{ vnetname }}"
+ tags:
+ common: "mno"
+ register: output
+ - name: Assert the virtual network gateway updated
+ ansible.builtin.assert:
+ that: output.changed
+
+ - name: Delete virtual network gateway
+ azure_rm_virtualnetworkgateway:
+ resource_group: "{{ resource_group }}"
+ name: "{{ vngname }}"
+ state: absent
+ register: output
+ - name: Assert the virtual network gateway deleted
+ ansible.builtin.assert:
+ that: output.changed
- name: Delete virtual network gateway - idempotent
azure_rm_virtualnetworkgateway:
@@ -192,7 +199,8 @@
name: "{{ vngname }}"
state: absent
register: output
-- assert:
+- name: Assert the virtual network gateway deleted
+ ansible.builtin.assert:
that: not output.changed
# Clean up networking components after test
@@ -202,7 +210,6 @@
name: GatewaySubnet
virtual_network: "{{ vnetname }}"
state: absent
-
- name: Delete public IP address
azure_rm_publicipaddress:
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualnetworkpeering/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualnetworkpeering/tasks/main.yml
index bf7a4aa13..3464847c1 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualnetworkpeering/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualnetworkpeering/tasks/main.yml
@@ -1,5 +1,5 @@
- name: Prepare random number
- set_fact:
+ ansible.builtin.set_fact:
vnetname1: "vnet1{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
vnetname2: "vnet2{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
peering_name: "peering1{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 100 | random }}"
@@ -23,7 +23,8 @@
resource_group: "{{ resource_group_secondary }}"
register: vnet2
-- assert:
+- name: Assert the second virtual network created
+ ansible.builtin.assert:
that:
- vnet1.changed
- vnet2.changed
@@ -38,10 +39,11 @@
name: "{{ vnetname2 }}"
allow_virtual_network_access: false
allow_forwarded_traffic: true
- check_mode: yes
+ check_mode: true
register: output
-- assert:
+- name: Assert the virtual network peering check mode
+ ansible.builtin.assert:
that: output.changed
- name: Create virtual network peering
@@ -56,7 +58,8 @@
allow_forwarded_traffic: true
register: output
-- assert:
+- name: Assert the virtual network peering created
+ ansible.builtin.assert:
that: output.changed
- name: Update virtual network peering (idempotent)
@@ -71,7 +74,8 @@
allow_forwarded_traffic: true
register: output
-- assert:
+- name: Assert the virtual network peering idempotent
+ ansible.builtin.assert:
that: not output.changed
- name: Update virtual network peering
@@ -86,7 +90,8 @@
allow_forwarded_traffic: false
register: output
-- assert:
+- name: Assert the virtual network peering updated
+ ansible.builtin.assert:
that: output.changed
- name: Get facts
@@ -97,7 +102,7 @@
register: facts
- name: Assert Facts
- assert:
+ ansible.builtin.assert:
that:
- facts['vnetpeerings'] | length == 1
- facts['vnetpeerings'][0]['id']
@@ -123,4 +128,4 @@
azure_rm_virtualnetwork:
name: "{{ vnetname2 }}"
resource_group: "{{ resource_group_secondary }}"
- state: absent \ No newline at end of file
+ state: absent
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualwan/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualwan/tasks/main.yml
index c53b7d513..cb9a21554 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualwan/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_virtualwan/tasks/main.yml
@@ -1,61 +1,65 @@
- - name: Prepare random number
- set_fact:
- rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
- run_once: yes
-
- - name: Create a VirtualWan
- azure_rm_virtualwan:
- resource_group: "{{ resource_group }}"
- name: "virtualwan{{ rpfx }}"
- office365_local_breakout_category: All
- disable_vpn_encryption: true
- allow_branch_to_branch_traffic: true
- allow_vnet_to_vnet_traffic: true
- virtual_wan_type: Basic
- register: output
-
- - assert:
- that:
- - output.changed
-
- - name: Create a VirtualWan again (Idempotent test)
- azure_rm_virtualwan:
- resource_group: "{{ resource_group }}"
- name: "virtualwan{{ rpfx }}"
- register: output
-
- - assert:
- that:
- - not output.changed
-
- - name: Update the VirtualWan
- azure_rm_virtualwan:
- resource_group: "{{ resource_group }}"
- office365_local_breakout_category: All
- name: "virtualwan{{ rpfx }}"
- disable_vpn_encryption: false
- allow_branch_to_branch_traffic: true
- allow_vnet_to_vnet_traffic: true
- virtual_wan_type: Basic
- register: output
-
- - assert:
- that:
- - output.changed
-
- - name: Get VirtualWan info
- azure_rm_virtualwan_info:
- resource_group: "{{ resource_group }}"
- name: "virtualwan{{ rpfx }}"
- register: output
-
- - assert:
- that:
- - output.virtual_wans[0]['allow_branch_to_branch_traffic'] == true
- - output.virtual_wans[0]['disable_vpn_encryption'] == false
-
- - name: Delete the VirtualWan
- azure_rm_virtualwan:
- resource_group: "{{ resource_group }}"
- name: "virtualwan{{ rpfx }}"
- state: absent
+- name: Prepare random number
+ ansible.builtin.set_fact:
+ rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
+ run_once: true
+
+- name: Create a VirtualWan
+ azure_rm_virtualwan:
+ resource_group: "{{ resource_group }}"
+ name: "virtualwan{{ rpfx }}"
+ office365_local_breakout_category: All
+ disable_vpn_encryption: true
+ allow_branch_to_branch_traffic: true
+ allow_vnet_to_vnet_traffic: true
+ virtual_wan_type: Basic
+ register: output
+
+- name: Assert the virtual wan created
+ ansible.builtin.assert:
+ that:
+ - output.changed
+
+- name: Create a VirtualWan again (Idempotent test)
+ azure_rm_virtualwan:
+ resource_group: "{{ resource_group }}"
+ name: "virtualwan{{ rpfx }}"
+ register: output
+
+- name: Assert idempotent
+ ansible.builtin.assert:
+ that:
+ - not output.changed
+
+- name: Update the VirtualWan
+ azure_rm_virtualwan:
+ resource_group: "{{ resource_group }}"
+ office365_local_breakout_category: All
+ name: "virtualwan{{ rpfx }}"
+ disable_vpn_encryption: false
+ allow_branch_to_branch_traffic: true
+ allow_vnet_to_vnet_traffic: true
+ virtual_wan_type: Basic
+ register: output
+
+- name: Assert the virtual wan updated
+ ansible.builtin.assert:
+ that:
+ - output.changed
+
+- name: Get VirtualWan info
+ azure_rm_virtualwan_info:
+ resource_group: "{{ resource_group }}"
+ name: "virtualwan{{ rpfx }}"
+ register: output
+
+- name: Assert the virtual wan facts
+ ansible.builtin.assert:
+ that:
+ - output.virtual_wans[0]['allow_branch_to_branch_traffic'] == true
+ - output.virtual_wans[0]['disable_vpn_encryption'] == false
+
+- name: Delete the VirtualWan
+ azure_rm_virtualwan:
+ resource_group: "{{ resource_group }}"
+ name: "virtualwan{{ rpfx }}"
+ state: absent
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_vmbackuppolicy/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_vmbackuppolicy/tasks/main.yml
index 9eb906f90..46ec87281 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_vmbackuppolicy/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_vmbackuppolicy/tasks/main.yml
@@ -1,13 +1,13 @@
- name: Fix resource prefix
- set_fact:
- name: "myPolicy{{ resource_group | hash('md5') | truncate(22, True, '') }}"
+ ansible.builtin.set_fact:
+ name_rpfx: "myPolicy{{ resource_group | hash('md5') | truncate(22, True, '') }}"
vault_name: "myVault"
location: "eastus"
- name: Create Azure Recovery Service vault
azure_rm_recoveryservicesvault:
resource_group: "{{ resource_group }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
location: "{{ location }}"
state: "present"
register: vault
@@ -15,38 +15,38 @@
- name: Create VM Backup Policy
azure_rm_vmbackuppolicy:
resource_group: "{{ resource_group }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
vault_name: "{{ vault.response.name }}"
state: "present"
register: output
- name: Assert that output has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
-
+
- name: Create VM Backup Policy (idempotent)
azure_rm_vmbackuppolicy:
resource_group: "{{ resource_group }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
vault_name: "{{ vault.response.name }}"
state: "present"
register: output
- name: Assert that output has no changed
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
- name: Get VM Backup Policy Details
azure_rm_vmbackuppolicy_info:
resource_group: "{{ resource_group }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
vault_name: "{{ vault.response.name }}"
register: output
- name: Assert that output has changed
- assert:
+ ansible.builtin.assert:
that:
- output.response.id != None
- output.response.name != None
@@ -54,13 +54,13 @@
- name: Delete VM Backup Policy
azure_rm_vmbackuppolicy:
resource_group: "{{ resource_group }}"
- name: "{{ name }}"
+ name: "{{ name_rpfx }}"
vault_name: "{{ vault.response.name }}"
state: "absent"
register: output
- name: Assert that output has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -73,6 +73,6 @@
register: output
- name: Assert that output has changed
- assert:
+ ansible.builtin.assert:
that:
- output.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_vpnsite/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_vpnsite/tasks/main.yml
index 07cb7dd45..7e6dbdf6f 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_vpnsite/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_vpnsite/tasks/main.yml
@@ -1,102 +1,106 @@
- - name: Create vpn site name
- set_fact:
- vpn_site: "vpn{{ resource_group | hash('md5') | truncate(22, True, '') }}"
+- name: Create vpn site name
+ ansible.builtin.set_fact:
+ vpn_site: "vpn{{ resource_group | hash('md5') | truncate(22, True, '') }}"
- - name: Create a VpnSite
- azure_rm_vpnsite:
- resource_group: "{{ resource_group }}"
- name: "{{ vpn_site }}"
- ip_address: 10.0.0.0
- is_security_site: true
- device_properties:
- device_vendor: 10.0.0.23
- device_model: test_model
- link_speed_in_mbps: 10
- address_space:
- address_prefixes:
- - 10.0.0.0/16
- bgp_properties:
- asn: 1234
- bgp_peering_address: 192.168.0.0
- o365_policy:
- break_out_categories:
- allow: false
- optimize: false
- default: false
- register: output
-
- - assert:
- that:
- - output.changed
+- name: Create a VpnSite
+ azure_rm_vpnsite:
+ resource_group: "{{ resource_group }}"
+ name: "{{ vpn_site }}"
+ ip_address: 10.0.0.0
+ is_security_site: true
+ device_properties:
+ device_vendor: 10.0.0.23
+ device_model: test_model
+ link_speed_in_mbps: 10
+ address_space:
+ address_prefixes:
+ - 10.0.0.0/16
+ bgp_properties:
+ asn: 1234
+ bgp_peering_address: 192.168.0.0
+ o365_policy:
+ break_out_categories:
+ allow: false
+ optimize: false
+ default: false
+ register: output
- - name: Create the VpnSite without change (Idempotent test)
- azure_rm_vpnsite:
- resource_group: "{{ resource_group }}"
- name: "{{ vpn_site }}"
- ip_address: 10.0.0.0
- is_security_site: true
- device_properties:
- device_vendor: 10.0.0.23
- device_model: test_model
- link_speed_in_mbps: 10
- address_space:
- address_prefixes:
- - 10.0.0.0/16
- bgp_properties:
- asn: 1234
- bgp_peering_address: 192.168.0.0
- o365_policy:
- break_out_categories:
- allow: false
- optimize: false
- default: false
- register: output
-
- - assert:
- that:
- - not output.changed
-
- - name: Update the VpnSite's device properties
- azure_rm_vpnsite:
- resource_group: "{{ resource_group }}"
- name: "{{ vpn_site }}"
- ip_address: 10.0.0.0
- is_security_site: true
- device_properties:
- device_vendor: 10.0.0.23
- device_model: test_model
- link_speed_in_mbps: 100
- address_space:
- address_prefixes:
- - 10.0.0.0/16
- bgp_properties:
- asn: 1234
- bgp_peering_address: 192.168.0.0
- o365_policy:
- break_out_categories:
- allow: false
- optimize: false
- default: false
- register: output
-
- - assert:
- that:
- - output.changed
-
- - name: Get the VpnSite info
- azure_rm_vpnsite_info:
- resource_group: "{{ resource_group }}"
- name: "{{ vpn_site }}"
- register: output
+- name: Assert the vpn site created
+ ansible.builtin.assert:
+ that:
+ - output.changed
- - assert:
- that:
- - "output.vpn_sites[0].is_security_site == true"
- - "output.vpn_sites[0].ip_address == '10.0.0.0'"
- - "output.vpn_sites[0].device_properties.link_speed_in_mbps == 100"
+- name: Create the VpnSite without change (Idempotent test)
+ azure_rm_vpnsite:
+ resource_group: "{{ resource_group }}"
+ name: "{{ vpn_site }}"
+ ip_address: 10.0.0.0
+ is_security_site: true
+ device_properties:
+ device_vendor: 10.0.0.23
+ device_model: test_model
+ link_speed_in_mbps: 10
+ address_space:
+ address_prefixes:
+ - 10.0.0.0/16
+ bgp_properties:
+ asn: 1234
+ bgp_peering_address: 192.168.0.0
+ o365_policy:
+ break_out_categories:
+ allow: false
+ optimize: false
+ default: false
+ register: output
- - name: Delete the VpnSite
- azure_rm_vpnsite:
- resource_group: "{{ resource_group }}"
- name: "{{ vpn_site }}"
- state: absent
+- name: Assert idempotent
+ ansible.builtin.assert:
+ that:
+ - not output.changed
+
+- name: Update the VpnSite's device properties
+ azure_rm_vpnsite:
+ resource_group: "{{ resource_group }}"
+ name: "{{ vpn_site }}"
+ ip_address: 10.0.0.0
+ is_security_site: true
+ device_properties:
+ device_vendor: 10.0.0.23
+ device_model: test_model
+ link_speed_in_mbps: 100
+ address_space:
+ address_prefixes:
+ - 10.0.0.0/16
+ bgp_properties:
+ asn: 1234
+ bgp_peering_address: 192.168.0.0
+ o365_policy:
+ break_out_categories:
+ allow: false
+ optimize: false
+ default: false
+ register: output
+
+- name: Assert the vpn site updated
+ ansible.builtin.assert:
+ that:
+ - output.changed
+
+- name: Get the VpnSite info
+ azure_rm_vpnsite_info:
+ resource_group: "{{ resource_group }}"
+ name: "{{ vpn_site }}"
+ register: output
+
+- name: Assert the vpn site facts
+ ansible.builtin.assert:
+ that:
+ - "output.vpn_sites[0].is_security_site == true"
+ - "output.vpn_sites[0].ip_address == '10.0.0.0'"
+ - "output.vpn_sites[0].device_properties.link_speed_in_mbps == 100"
+
+- name: Delete the VpnSite
+ azure_rm_vpnsite:
+ resource_group: "{{ resource_group }}"
+ name: "{{ vpn_site }}"
+ state: absent
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_webapp/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_webapp/tasks/main.yml
index b286bfe13..42a3abe3c 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_webapp/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_webapp/tasks/main.yml
@@ -1,15 +1,15 @@
- name: Prepare facts
- set_fact:
+ ansible.builtin.set_fact:
resource_prefix: "{{ resource_group_secondary | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
- run_once: yes
+ run_once: true
- name: Fix resource prefix
- set_fact:
+ ansible.builtin.set_fact:
linux_app_plan_resource_group: "{{ resource_group_secondary }}"
- win_app_name: "{{ (resource_prefix | replace('-','x'))[-8:] }}{{ 1000 | random}}winapp"
- linux_app_name: "{{ (resource_prefix | replace('-','x'))[-8:] }}{{ 1000 | random}}linuxapp"
- win_plan_name: "{{ (resource_prefix | replace('-','x'))[-8:] }}winplan"
- linux_plan_name: "{{ (resource_group_secondary | replace('-','x'))[-8:] }}linplan"
+ win_app_name: "{{ (resource_prefix | replace('-', 'x'))[-8:] }}{{ 1000 | random }}winapp"
+ linux_app_name: "{{ (resource_prefix | replace('-', 'x'))[-8:] }}{{ 1000 | random }}linuxapp"
+ 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
@@ -29,7 +29,7 @@
plan: "{{ win_plan_name }}"
register: output
-- name: stop the web app
+- name: Stop the web app
azure_rm_webapp:
resource_group: "{{ resource_group }}"
name: "{{ win_app_name }}2"
@@ -37,19 +37,19 @@
app_state: stopped
register: output
-- name: assert output changed
- assert:
+- name: Assert output changed
+ ansible.builtin.assert:
that:
output.changed
-- name: get the web app
+- name: Get the web app
azure_rm_webapp_info:
resource_group: "{{ resource_group }}"
name: "{{ win_app_name }}2"
register: stopped
-- name: assert web app is stopped
- assert:
+- name: Assert web app is stopped
+ ansible.builtin.assert:
that:
- stopped.webapps[0].app_state == "Stopped"
@@ -63,7 +63,7 @@
testwebapptag: test
register: output
-- name: get web app with resource group and tag
+- name: Get web app with resource group and tag
azure_rm_webapp_info:
resource_group: "{{ resource_group }}"
name: "{{ win_app_name }}3"
@@ -71,7 +71,8 @@
- testwebapptag
register: output
-- assert:
+- name: Assert the web app facts
+ ansible.builtin.assert:
that:
- output.webapps | length == 1
@@ -90,17 +91,18 @@
testkey: "testvalue"
register: output
-- name: assert the web app was created
- assert:
+- name: Assert web app was created
+ ansible.builtin.assert:
that: output.changed
-- name: get web app with name
+- name: Get web app with name
azure_rm_webapp_info:
resource_group: "{{ resource_group }}"
name: "{{ win_app_name }}4"
register: output
-- assert:
+- name: Assert the web app facts
+ ansible.builtin.assert:
that:
- output.webapps | length == 1
- output.webapps[0].app_settings | length == 1
@@ -122,31 +124,32 @@
register: output
- name: Assert the web app was updated
- assert:
+ ansible.builtin.assert:
that:
- - output.changed
+ - output.changed
-- name: get web app with name
+- name: Get web app with name
azure_rm_webapp_info:
resource_group: "{{ resource_group }}"
name: "{{ win_app_name }}4"
register: output
- name: Assert updating
- assert:
+ ansible.builtin.assert:
that:
- - output.webapps[0].app_settings | length == 2
- - output.webapps[0].app_settings['testkey'] == 'testvalue'
- - output.webapps[0].app_settings['testkey2'] == 'testvalue2'
+ - 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
+- name: Get web app with return publishing profile
azure_rm_webapp_info:
resource_group: "{{ resource_group }}"
name: "{{ win_app_name }}4"
return_publish_profile: true
register: output
-- assert:
+- name: Assert the web app facts
+ ansible.builtin.assert:
that:
- output.webapps | length == 1
- output.webapps[0].publishing_username != ""
@@ -161,7 +164,7 @@
register: output
- name: Assert the web app was updated
- assert:
+ ansible.builtin.assert:
that: output.changed
- name: Create a win web app with python run time and php run time
@@ -179,7 +182,7 @@
register: output
- name: Assert the web app was created
- assert:
+ ansible.builtin.assert:
that: output.changed
- name: Create a docker web app with some app settings
@@ -197,7 +200,7 @@
register: output
- name: Assert the web app was created
- assert:
+ ansible.builtin.assert:
that: output.changed
- name: Create a docker web app with private acr registry
@@ -215,7 +218,7 @@
register: output
- name: Assert the web app was created
- assert:
+ ansible.builtin.assert:
that: output.changed
- name: Create a linux web app with nodejs framework
@@ -242,9 +245,10 @@
version: "6.6"
register: output
-- assert:
+- name: Assert idempotent
+ ansible.builtin.assert:
that: not output.changed
-
+
- name: Update nodejs framework
azure_rm_webapp:
resource_group: "{{ resource_group }}"
@@ -258,7 +262,7 @@
register: output
- name: Assert the web app was created
- assert:
+ ansible.builtin.assert:
that: output.changed
- name: Create a linux web app with deployment source github
@@ -275,7 +279,7 @@
register: output
- name: Assert the web app was created
- assert:
+ ansible.builtin.assert:
that: output.changed
- name: Delete web app
@@ -286,10 +290,10 @@
register: output
- name: Assert the web app was deleted
- assert:
+ ansible.builtin.assert:
that: output.changed
-- name: assert error that java is mutually exclusive with frameworks
+- name: Assert error that java is mutually exclusive with frameworks
azure_rm_webapp:
resource_group: "{{ resource_group }}"
name: "{{ win_app_name }}11"
@@ -302,7 +306,7 @@
register: fail_win_java_version_mutual_exclusive
failed_when: 'fail_win_java_version_mutual_exclusive.msg != "Java is mutually exclusive with other frameworks."'
-- name: assert error when linux web app, only can specify one framework
+- name: Assert error when linux web app, only can specify one framework
azure_rm_webapp:
resource_group: "{{ resource_group }}"
name: "{{ linux_plan_name }}12"
@@ -333,7 +337,7 @@
register: output
- name: Assert the web app was created
- assert:
+ ansible.builtin.assert:
that: output.changed
- name: Get facts with publish profile
@@ -344,7 +348,7 @@
register: facts
- name: Assert publish profile returned
- assert:
+ ansible.builtin.assert:
that:
- facts.webapps[0].ftp_publish_url != ''
@@ -370,7 +374,7 @@
ftps_state: "Disabled"
register: output
- name: Assert the web app was created
- assert:
+ ansible.builtin.assert:
that: output.changed
- name: Create a web app with various site config params - idempotent
@@ -395,7 +399,7 @@
ftps_state: "Disabled"
register: output
- name: Assert the web app not changed
- assert:
+ ansible.builtin.assert:
that: not output.changed
- name: Get facts for site config params
@@ -404,7 +408,7 @@
name: "{{ linux_app_name }}-siteconfig"
register: facts
- name: Assert site config params meet expectations
- assert:
+ ansible.builtin.assert:
that:
- facts.webapps[0].always_on
- facts.webapps[0].min_tls_version == '1.2'
@@ -432,7 +436,7 @@
ftps_state: "FtpsOnly"
register: output
- name: Assert the web app was updated
- assert:
+ ansible.builtin.assert:
that: output.changed
- name: Get facts for site config params
@@ -441,7 +445,7 @@
name: "{{ linux_app_name }}-siteconfig"
register: facts
- name: Assert site config params meet expectations
- assert:
+ ansible.builtin.assert:
that:
- facts.webapps[0].always_on
- facts.webapps[0].min_tls_version == '1.2'
@@ -454,12 +458,12 @@
name: "{{ slot1_name }}"
configuration_source: "{{ win_app_name }}13"
app_settings:
- testkey: testvalue
- check_mode: yes
+ testkey: testvalue
+ check_mode: true
register: output
- name: Assert slot check mode creation
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -470,11 +474,11 @@
name: "{{ slot1_name }}"
configuration_source: "{{ win_app_name }}13"
app_settings:
- testkey: testvalueslot
+ testkey: testvalueslot
register: output
- name: Assert slot creation
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -484,11 +488,11 @@
webapp_name: "{{ win_app_name }}13"
name: "{{ slot1_name }}"
app_settings:
- testkey: testvalueslot
+ testkey: testvalueslot
register: output
- name: Assert idempotence
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
@@ -501,11 +505,11 @@
- name: "node"
version: "10.1"
app_settings:
- testkey: testvalue2
+ testkey: testvalue2
register: output
- name: Assert updating
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -519,7 +523,7 @@
register: output
- name: Assert swap
- assert:
+ ansible.builtin.assert:
that:
- output.changed
@@ -532,6 +536,6 @@
register: output
- name: Assert stopped
- assert:
+ ansible.builtin.assert:
that:
- output.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_webappaccessrestriction/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_webappaccessrestriction/tasks/main.yml
index 05061d195..9850dd148 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_webappaccessrestriction/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_webappaccessrestriction/tasks/main.yml
@@ -1,5 +1,5 @@
- name: Prepare random number
- set_fact:
+ ansible.builtin.set_fact:
rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
run_once: true
@@ -30,7 +30,7 @@
register: output
check_mode: true
- name: Assert the resource is well created
- assert:
+ ansible.builtin.assert:
that: output.changed
- name: "Create webapp access restriction"
@@ -49,7 +49,7 @@
scm_ip_security_restrictions_use_main: true
register: output
- name: Assert the resource is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.ip_security_restrictions | length == 2
@@ -65,7 +65,7 @@
resource_group: "{{ resource_group }}"
register: output
- name: Assert restrictions
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
- output.ip_security_restrictions | length == 2
@@ -91,7 +91,7 @@
scm_ip_security_restrictions_use_main: true
register: output
- name: Assert the resource is not changed
- assert:
+ ansible.builtin.assert:
that: not output.changed
- name: "Delete specific webapp access restriction"
@@ -106,7 +106,7 @@
scm_ip_security_restrictions_use_main: true
register: output
- name: Assert the resource is updated
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.ip_security_restrictions | length == 1
@@ -126,7 +126,7 @@
scm_ip_security_restrictions_use_main: true
register: output
- name: Assert the resource is updated
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.ip_security_restrictions | length == 1
@@ -146,7 +146,7 @@
scm_ip_security_restrictions_use_main: false
register: output
- name: Assert the resource is updated
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.ip_security_restrictions | length == 1
@@ -171,7 +171,7 @@
scm_ip_security_restrictions_use_main: false
register: output
- name: Assert the resource is updated
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.ip_security_restrictions | length == 1
@@ -203,7 +203,7 @@
scm_ip_security_restrictions_use_main: false
register: output
- name: Assert the resource is updated
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.ip_security_restrictions | length == 1
@@ -237,7 +237,7 @@
scm_ip_security_restrictions_use_main: false
register: output
- name: Assert the resource is not changed
- assert:
+ ansible.builtin.assert:
that: not output.changed
- name: "Delete webapp access restrictions"
@@ -247,7 +247,7 @@
state: "absent"
register: output
- name: Assert the resource is deleted
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.ip_security_restrictions | length == 0
@@ -260,7 +260,7 @@
resource_group: "{{ resource_group }}"
register: output
- name: Assert no restrictions
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
- output.ip_security_restrictions | length <= 1
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_webappvnetconnection/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_webappvnetconnection/tasks/main.yml
index 66a1b55cf..9478e6516 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_webappvnetconnection/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_webappvnetconnection/tasks/main.yml
@@ -1,5 +1,5 @@
- name: Prepare random number
- set_fact:
+ ansible.builtin.set_fact:
rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
run_once: true
@@ -42,7 +42,7 @@
check_mode: true
register: output
- name: Assert the resource is well created
- assert:
+ ansible.builtin.assert:
that: output.changed
- name: "Check webapp vnetconnection facts 1"
@@ -51,7 +51,7 @@
resource_group: "{{ resource_group }}"
register: output
- name: Assert the resource has no connections
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
- output.connection | length == 0
@@ -64,7 +64,7 @@
subnet: subnet{{ rpfx }}
register: output
- name: Assert the resource is well created
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.connection.vnet_name == 'vnet{{ rpfx }}'
@@ -77,7 +77,7 @@
resource_group: "{{ resource_group }}"
register: output
- name: Assert the connection exists
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
- output.connection.vnet_name == 'vnet{{ rpfx }}'
@@ -92,7 +92,7 @@
subnet: subnet{{ rpfx }}
register: output
- name: Assert the resource is not changed
- assert:
+ ansible.builtin.assert:
that: not output.changed
- name: "Delete webapp vnetconnection"
@@ -102,7 +102,7 @@
state: "absent"
register: output
- name: Assert the connection is deleted
- assert:
+ ansible.builtin.assert:
that:
- output.changed
- output.connection | length == 0
@@ -113,7 +113,7 @@
resource_group: "{{ resource_group }}"
register: output
- name: Assert the resource has no connections
- assert:
+ ansible.builtin.assert:
that:
- not output.changed
- output.connection | length == 0
@@ -125,5 +125,5 @@
state: "absent"
register: output
- name: Assert the resource is not changed
- assert:
+ ansible.builtin.assert:
that: not output.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_workspace/tasks/main.yml b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_workspace/tasks/main.yml
index 7f9a05f79..9a7ea1efa 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_workspace/tasks/main.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_workspace/tasks/main.yml
@@ -1,128 +1,140 @@
- name: Prepare random number
- set_fact:
- name: "workspace{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
+ ansible.builtin.set_fact:
+ name_rpfx: "workspace{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
- name: Create workspace (check mode)
azure_rm_loganalyticsworkspace:
- name: "{{ name }}"
- resource_group: "{{ resource_group }}"
- retention_in_days: 40
- check_mode: yes
+ name: "{{ name_rpfx }}"
+ resource_group: "{{ resource_group }}"
+ retention_in_days: 40
+ check_mode: true
register: output
-- assert:
- that:
- - output.changed
+- name: Assert the workspace check mode
+ ansible.builtin.assert:
+ that:
+ - output.changed
- name: Get workspace
azure_rm_loganalyticsworkspace_info:
- name: "{{ name }}"
- resource_group: "{{ resource_group }}"
+ name: "{{ name_rpfx }}"
+ resource_group: "{{ resource_group }}"
register: facts
-- assert:
- that:
- - facts.workspaces | length == 0
+- name: Assert the workspace facts
+ ansible.builtin.assert:
+ that:
+ - facts.workspaces | length == 0
- name: Create workspace
azure_rm_loganalyticsworkspace:
- name: "{{ name }}"
- resource_group: "{{ resource_group }}"
- retention_in_days: 40
+ name: "{{ name_rpfx }}"
+ resource_group: "{{ resource_group }}"
+ retention_in_days: 40
register: output
-- assert:
+- name: Assert the workspace created
+ ansible.builtin.assert:
that:
- - output.retention_in_days == 40
- - output.changed
- - output.intelligence_packs
+ - output.retention_in_days == 40
+ - output.changed
+ - output.intelligence_packs
- name: Create workspace (idempontent)
azure_rm_loganalyticsworkspace:
- name: "{{ name }}"
- resource_group: "{{ resource_group }}"
- retention_in_days: 40
+ name: "{{ name_rpfx }}"
+ resource_group: "{{ resource_group }}"
+ retention_in_days: 40
register: output
-- assert:
+- name: Assert idempotent
+ ansible.builtin.assert:
that:
- - not output.changed
+ - not output.changed
- name: Get workspace
azure_rm_loganalyticsworkspace_info:
- name: "{{ name }}"
- resource_group: "{{ resource_group }}"
+ name: "{{ name_rpfx }}"
+ resource_group: "{{ resource_group }}"
register: facts
-- assert:
- that:
- - facts.workspaces | length == 1
- - facts.workspaces[0].id == output.id
+- name: Assert the loganalytics workspace facts
+ ansible.builtin.assert:
+ that:
+ - facts.workspaces | length == 1
+ - facts.workspaces[0].id == output.id
-- set_fact:
- pack: "{{ pack | default({}) | combine({output.intelligence_packs[0].name: not output.intelligence_packs[0].enabled}) }}"
+- name: Set parameters
+ ansible.builtin.set_fact:
+ pack: "{{ pack | default({}) | combine({output.intelligence_packs[0].name: not output.intelligence_packs[0].enabled}) }}"
- name: Update intelligence pack
azure_rm_loganalyticsworkspace:
- name: "{{ name }}"
- resource_group: "{{ resource_group }}"
- intelligence_packs: "{{ pack }}"
+ name: "{{ name_rpfx }}"
+ resource_group: "{{ resource_group }}"
+ intelligence_packs: "{{ pack }}"
register: intelligence
-- assert:
- that:
- - intelligence.intelligence_packs[0].enabled != output.intelligence_packs[0].enabled
+- name: Assert the loganalytics workspace updated
+ ansible.builtin.assert:
+ that:
+ - intelligence.intelligence_packs[0].enabled != output.intelligence_packs[0].enabled
- name: Remove workspace (check mode)
azure_rm_loganalyticsworkspace:
- name: "{{ name }}"
- resource_group: "{{ resource_group }}"
- state: absent
- check_mode: yes
+ name: "{{ name_rpfx }}"
+ resource_group: "{{ resource_group }}"
+ state: absent
+ check_mode: true
register: output
-- assert:
- that:
- - output.changed
+- name: Assert the loganalytics workspace check mode
+ ansible.builtin.assert:
+ that:
+ - output.changed
- name: Get workspace
azure_rm_loganalyticsworkspace_info:
- name: "{{ name }}"
- resource_group: "{{ resource_group }}"
+ name: "{{ name_rpfx }}"
+ resource_group: "{{ resource_group }}"
register: facts
-- assert:
- that:
- - facts.workspaces | length == 1
+- name: Assert the loganalystics workspace facts
+ ansible.builtin.assert:
+ that:
+ - facts.workspaces | length == 1
- name: Remove workspace
azure_rm_loganalyticsworkspace:
- name: "{{ name }}"
- resource_group: "{{ resource_group }}"
- state: absent
+ name: "{{ name_rpfx }}"
+ resource_group: "{{ resource_group }}"
+ state: absent
register: output
-- assert:
- that:
- - output.changed
+- name: Assert the loganalytics workspace deleted
+ ansible.builtin.assert:
+ that:
+ - output.changed
- name: Get workspace
azure_rm_loganalyticsworkspace_info:
- name: "{{ name }}"
- resource_group: "{{ resource_group }}"
+ name: "{{ name_rpfx }}"
+ resource_group: "{{ resource_group }}"
register: facts
-- assert:
- that:
- - facts.workspaces | length == 0
+- name: Assert the loganalystics workspace facts
+ ansible.builtin.assert:
+ that:
+ - facts.workspaces | length == 0
- name: Remove workspace (idempontent)
azure_rm_loganalyticsworkspace:
- name: "{{ name }}"
- resource_group: "{{ resource_group }}"
- state: absent
+ name: "{{ name_rpfx }}"
+ resource_group: "{{ resource_group }}"
+ state: absent
register: output
-- assert:
- that:
- - not output.changed
+- name: Assert the loganalystics workspace deleted
+ ansible.builtin.assert:
+ that:
+ - not output.changed
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/inventory_azure/playbooks/create_inventory_config.yml b/ansible_collections/azure/azcollection/tests/integration/targets/inventory_azure/playbooks/create_inventory_config.yml
index 6ed4067af..79699d69b 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/inventory_azure/playbooks/create_inventory_config.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/inventory_azure/playbooks/create_inventory_config.yml
@@ -1,11 +1,13 @@
---
-- hosts: localhost
+- name: Config inventory file
+ hosts: localhost
connection: local
- gather_facts: no
+ gather_facts: false
vars:
template_name: "../templates/{{ template | default('basic.yml') }}"
tasks:
- - name: write inventory config file
- copy:
+ - name: Write inventory config file
+ ansible.builtin.copy:
dest: ../test.azure_rm.yml
content: "{{ lookup('template', template_name) }}"
+ mode: preserve
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/inventory_azure/playbooks/empty_inventory_config.yml b/ansible_collections/azure/azcollection/tests/integration/targets/inventory_azure/playbooks/empty_inventory_config.yml
index 06a427931..41811854b 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/inventory_azure/playbooks/empty_inventory_config.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/inventory_azure/playbooks/empty_inventory_config.yml
@@ -1,9 +1,11 @@
---
-- hosts: localhost
+- name: Empty inventory file
+ hosts: localhost
connection: local
- gather_facts: no
+ gather_facts: false
tasks:
- - name: write inventory config file
- copy:
+ - name: Write inventory config file
+ ansible.builtin.copy:
dest: ../test.azure_rm.yml
content: ""
+ mode: preserve
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/inventory_azure/playbooks/setup.yml b/ansible_collections/azure/azcollection/tests/integration/targets/inventory_azure/playbooks/setup.yml
index a8358089f..f162e9134 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/inventory_azure/playbooks/setup.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/inventory_azure/playbooks/setup.yml
@@ -1,48 +1,49 @@
---
-- hosts: localhost
+- name: Set hosts
+ hosts: localhost
connection: local
- gather_facts: no
-
+ gather_facts: false
tasks:
- - include_vars: vars.yml
- - name: SETUP | Create storage account
- azure_rm_storageaccount:
- resource_group: "{{ resource_group }}"
- name: "{{ storage_account }}"
- account_type: Standard_LRS
+ - name: Set facts
+ ansible.builtin.include_vars: vars.yml
+ - name: SETUP | Create storage account
+ azure_rm_storageaccount:
+ resource_group: "{{ resource_group }}"
+ name: "{{ storage_account }}"
+ account_type: Standard_LRS
- - name: SETUP | Create availability set
- azure_rm_availabilityset:
- name: "{{ availability_set }}"
- resource_group: "{{ resource_group }}"
+ - name: SETUP | Create availability set
+ azure_rm_availabilityset:
+ name: "{{ availability_set }}"
+ resource_group: "{{ resource_group }}"
- - name: SETUP | Create virtual network
- azure_rm_virtualnetwork:
- resource_group: "{{ resource_group }}"
- name: "{{ network_name }}"
- address_prefixes: "{{ network }}"
+ - name: SETUP | Create virtual network
+ azure_rm_virtualnetwork:
+ resource_group: "{{ resource_group }}"
+ name: "{{ network_name }}"
+ address_prefixes: "{{ network }}"
- - name: SETUP | Create subnet
- azure_rm_subnet:
- resource_group: "{{ resource_group }}"
- name: "{{ subnet_name }}"
- address_prefix: "{{ subnet }}"
- virtual_network: "{{ network_name }}"
+ - name: SETUP | Create subnet
+ azure_rm_subnet:
+ resource_group: "{{ resource_group }}"
+ name: "{{ subnet_name }}"
+ address_prefix: "{{ subnet }}"
+ virtual_network: "{{ network_name }}"
- - name: Create minimal VM with defaults
- azure_rm_virtualmachine:
- resource_group: "{{ resource_group }}"
- name: "{{ vm_name }}"
- admin_username: testuser
- ssh_password_enabled: false
- ssh_public_keys:
- - path: /home/testuser/.ssh/authorized_keys
- key_data: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDfoYlIV4lTPZTv7hXaVwQQuqBgGs4yeNRX0SPo2+HQt9u4X7IGwrtXc0nEUm6LfaCikMH58bOL8f20NTGz285kxdFHZRcBXtqmnMz2rXwhK9gwq5h1khc+GzHtdcJXsGA4y0xuaNcidcg04jxAlN/06fwb/VYwwWTVbypNC0gpGEpWckCNm8vlDlA55sU5et0SZ+J0RKVvEaweUOeNbFZqckGPA384imfeYlADppK/7eAxqfBVadVvZG8IJk4yvATgaIENIFj2cXxqu2mQ/Bp5Wr45uApvJsFXmi+v/nkiOEV1QpLOnEwAZo6EfFS4CCQtsymxJCl1PxdJ5LD4ZOtP xiuxi.sun@qq.com"
- vm_size: Standard_B1ms
- virtual_network: "{{ network_name }}"
- image:
- offer: UbuntuServer
- publisher: Canonical
- sku: 16.04-LTS
- version: latest
- register: vm_output
+ - name: Create minimal VM with defaults
+ azure_rm_virtualmachine:
+ resource_group: "{{ resource_group }}"
+ name: "{{ vm_name }}"
+ admin_username: testuser
+ ssh_password_enabled: false
+ ssh_public_keys:
+ - path: /home/testuser/.ssh/authorized_keys
+ key_data: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDfoYlIV4lTPZTv7hXaVwQQuqBgGs4yeNRX0SPo2+HQt9u4X7IGwrtXc0nEUm6LfaCikMH58bOL8f20NTGz285kxdFHZRcBXtqmnMz2rXwhK9gwq5h1khc+GzHtdcJXsGA4y0xuaNcidcg04jxAlN/06fwb/VYwwWTVbypNC0gpGEpWckCNm8vlDlA55sU5et0SZ+J0RKVvEaweUOeNbFZqckGPA384imfeYlADppK/7eAxqfBVadVvZG8IJk4yvATgaIENIFj2cXxqu2mQ/Bp5Wr45uApvJsFXmi+v/nkiOEV1QpLOnEwAZo6EfFS4CCQtsymxJCl1PxdJ5LD4ZOtP xiuxi.sun@qq.com"
+ vm_size: Standard_B1ms
+ virtual_network: "{{ network_name }}"
+ image:
+ offer: 0001-com-ubuntu-server-focal
+ publisher: Canonical
+ sku: 20_04-lts
+ version: latest
+ register: vm_output
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/inventory_azure/playbooks/teardown.yml b/ansible_collections/azure/azcollection/tests/integration/targets/inventory_azure/playbooks/teardown.yml
index 3a1adfdd4..2a131033a 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/inventory_azure/playbooks/teardown.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/inventory_azure/playbooks/teardown.yml
@@ -1,40 +1,42 @@
---
-- hosts: localhost
+- name: Destroy all resource
+ hosts: localhost
connection: local
- gather_facts: no
+ gather_facts: false
tasks:
- - include_vars: vars.yml
+ - name: Set facts
+ ansible.builtin.include_vars: vars.yml
- - name: Delete VM
- azure_rm_virtualmachine:
- resource_group: "{{ resource_group }}"
- name: "{{ vm_name }}"
- remove_on_absent: all_autocreated
- state: absent
+ - name: Delete VM
+ azure_rm_virtualmachine:
+ resource_group: "{{ resource_group }}"
+ name: "{{ vm_name }}"
+ remove_on_absent: all_autocreated
+ state: absent
- - name: Destroy subnet
- azure_rm_subnet:
- resource_group: "{{ resource_group }}"
- virtual_network: "{{ network_name }}"
- name: "{{ subnet_name }}"
- state: absent
+ - name: Destroy subnet
+ azure_rm_subnet:
+ resource_group: "{{ resource_group }}"
+ virtual_network: "{{ network_name }}"
+ name: "{{ subnet_name }}"
+ state: absent
- - name: Destroy virtual network
- azure_rm_virtualnetwork:
- resource_group: "{{ resource_group }}"
- name: "{{ network_name }}"
- state: absent
+ - name: Destroy virtual network
+ azure_rm_virtualnetwork:
+ resource_group: "{{ resource_group }}"
+ name: "{{ network_name }}"
+ state: absent
- - name: Destroy availability set
- azure_rm_availabilityset:
- resource_group: "{{ resource_group }}"
- name: "{{ availability_set }}"
- state: absent
+ - name: Destroy availability set
+ azure_rm_availabilityset:
+ resource_group: "{{ resource_group }}"
+ name: "{{ availability_set }}"
+ state: absent
- - name: Destroy storage account
- azure_rm_storageaccount:
- resource_group: "{{ resource_group }}"
- name: "{{ storage_account }}"
- force_delete_nonempty: yes
- state: absent \ No newline at end of file
+ - name: Destroy storage account
+ azure_rm_storageaccount:
+ resource_group: "{{ resource_group }}"
+ name: "{{ storage_account }}"
+ force_delete_nonempty: true
+ state: absent
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/inventory_azure/playbooks/test_inventory.yml b/ansible_collections/azure/azcollection/tests/integration/targets/inventory_azure/playbooks/test_inventory.yml
index fd39a273c..b00e48247 100644
--- a/ansible_collections/azure/azcollection/tests/integration/targets/inventory_azure/playbooks/test_inventory.yml
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/inventory_azure/playbooks/test_inventory.yml
@@ -1,16 +1,20 @@
---
-- hosts: localhost
+- name: Config hosts
+ hosts: localhost
connection: local
- gather_facts: no
+ gather_facts: false
tasks:
- - include_vars: vars.yml
+ - name: Set facts
+ ansible.builtin.include_vars: vars.yml
- - name: Pause for 10 mimutes for updating
- shell: sleep 600
+ - name: Pause for 10 mimutes for updating
+ ansible.builtin.command: sleep 600
+ changed_when: false
- - meta: refresh_inventory
+ - name: Refresh inventory
+ ansible.builtin.meta: refresh_inventory
- - name: Test Inventory
- assert:
- that:
- - vm_name in hostvars
+ - name: Test Inventory
+ ansible.builtin.assert:
+ that:
+ - vm_name in hostvars
diff --git a/ansible_collections/azure/azcollection/tests/integration/targets/inventory_azure/runme.sh b/ansible_collections/azure/azcollection/tests/integration/targets/inventory_azure/runme.sh
index 6f381c0a5..6f381c0a5 100644..100755
--- a/ansible_collections/azure/azcollection/tests/integration/targets/inventory_azure/runme.sh
+++ b/ansible_collections/azure/azcollection/tests/integration/targets/inventory_azure/runme.sh