├── .github └── sha.json ├── .gitignore ├── .travis.yml ├── README.md ├── SECURITY.md ├── defaults └── main.yml ├── files └── requirements-azure.txt ├── library ├── __init__.py ├── _azure.py ├── _azure_rm_aks_facts.py ├── _azure_rm_aksversion_facts.py ├── _azure_rm_applicationsecuritygroup_facts.py ├── _azure_rm_appserviceplan_facts.py ├── _azure_rm_automationaccount_facts.py ├── _azure_rm_autoscale_facts.py ├── _azure_rm_availabilityset_facts.py ├── _azure_rm_cdnendpoint_facts.py ├── _azure_rm_cdnprofile_facts.py ├── _azure_rm_containerinstance_facts.py ├── _azure_rm_containerregistry_facts.py ├── _azure_rm_cosmosdbaccount_facts.py ├── _azure_rm_deployment_facts.py ├── _azure_rm_devtestlab_facts.py ├── _azure_rm_devtestlabarmtemplate_facts.py ├── _azure_rm_devtestlabartifact_facts.py ├── _azure_rm_devtestlabartifactsource_facts.py ├── _azure_rm_devtestlabcustomimage_facts.py ├── _azure_rm_devtestlabenvironment_facts.py ├── _azure_rm_devtestlabpolicy_facts.py ├── _azure_rm_devtestlabschedule_facts.py ├── _azure_rm_devtestlabvirtualmachine_facts.py ├── _azure_rm_devtestlabvirtualnetwork_facts.py ├── _azure_rm_dnsrecordset_facts.py ├── _azure_rm_dnszone_facts.py ├── _azure_rm_functionapp_facts.py ├── _azure_rm_hdinsightcluster_facts.py ├── _azure_rm_image_facts.py ├── _azure_rm_loadbalancer_facts.py ├── _azure_rm_lock_facts.py ├── _azure_rm_loganalyticsworkspace_facts.py ├── _azure_rm_managed_disk.py ├── _azure_rm_managed_disk_facts.py ├── _azure_rm_manageddisk_facts.py ├── _azure_rm_mariadbconfiguration_facts.py ├── _azure_rm_mariadbdatabase_facts.py ├── _azure_rm_mariadbfirewallrule_facts.py ├── _azure_rm_mariadbserver_facts.py ├── _azure_rm_mysqlconfiguration_facts.py ├── _azure_rm_mysqldatabase_facts.py ├── _azure_rm_mysqlfirewallrule_facts.py ├── _azure_rm_mysqlserver_facts.py ├── _azure_rm_networkinterface_facts.py ├── _azure_rm_postgresqlconfiguration_facts.py ├── _azure_rm_postgresqldatabase_facts.py ├── _azure_rm_postgresqlfirewallrule_facts.py ├── _azure_rm_postgresqlserver_facts.py ├── _azure_rm_publicipaddress_facts.py ├── _azure_rm_rediscache_facts.py ├── _azure_rm_resource_facts.py ├── _azure_rm_resourcegroup_facts.py ├── _azure_rm_roleassignment_facts.py ├── _azure_rm_roledefinition_facts.py ├── _azure_rm_routetable_facts.py ├── _azure_rm_securitygroup_facts.py ├── _azure_rm_servicebus_facts.py ├── _azure_rm_sqldatabase_facts.py ├── _azure_rm_sqlfirewallrule_facts.py ├── _azure_rm_sqlserver_facts.py ├── _azure_rm_storageaccount_facts.py ├── _azure_rm_subnet_facts.py ├── _azure_rm_trafficmanagerendpoint_facts.py ├── _azure_rm_trafficmanagerprofile_facts.py ├── _azure_rm_virtualmachine_extension.py ├── _azure_rm_virtualmachine_facts.py ├── _azure_rm_virtualmachine_scaleset.py ├── _azure_rm_virtualmachine_scaleset_facts.py ├── _azure_rm_virtualmachineextension_facts.py ├── _azure_rm_virtualmachineimage_facts.py ├── _azure_rm_virtualmachinescaleset_facts.py ├── _azure_rm_virtualmachinescalesetextension_facts.py ├── _azure_rm_virtualmachinescalesetinstance_facts.py ├── _azure_rm_virtualnetwork_facts.py ├── _azure_rm_virtualnetworkpeering_facts.py ├── _azure_rm_webapp_facts.py ├── azure_rm_aks.py ├── azure_rm_aks_info.py ├── azure_rm_aksversion_info.py ├── azure_rm_appgateway.py ├── azure_rm_applicationsecuritygroup.py ├── azure_rm_applicationsecuritygroup_info.py ├── azure_rm_appserviceplan.py ├── azure_rm_appserviceplan_info.py ├── azure_rm_automationaccount.py ├── azure_rm_automationaccount_info.py ├── azure_rm_autoscale.py ├── azure_rm_autoscale_info.py ├── azure_rm_availabilityset.py ├── azure_rm_availabilityset_info.py ├── azure_rm_azurefirewall.py ├── azure_rm_azurefirewall_info.py ├── azure_rm_batchaccount.py ├── azure_rm_cdnendpoint.py ├── azure_rm_cdnendpoint_info.py ├── azure_rm_cdnprofile.py ├── azure_rm_cdnprofile_info.py ├── azure_rm_containerinstance.py ├── azure_rm_containerinstance_info.py ├── azure_rm_containerregistry.py ├── azure_rm_containerregistry_info.py ├── azure_rm_containerregistryreplication.py ├── azure_rm_containerregistryreplication_facts.py ├── azure_rm_containerregistrywebhook.py ├── azure_rm_containerregistrywebhook_facts.py ├── azure_rm_cosmosdbaccount.py ├── azure_rm_cosmosdbaccount_info.py ├── azure_rm_deployment.py ├── azure_rm_deployment_info.py ├── azure_rm_devtestlab.py ├── azure_rm_devtestlab_info.py ├── azure_rm_devtestlabarmtemplate_info.py ├── azure_rm_devtestlabartifact_info.py ├── azure_rm_devtestlabartifactsource.py ├── azure_rm_devtestlabartifactsource_info.py ├── azure_rm_devtestlabcustomimage.py ├── azure_rm_devtestlabcustomimage_info.py ├── azure_rm_devtestlabenvironment.py ├── azure_rm_devtestlabenvironment_info.py ├── azure_rm_devtestlabpolicy.py ├── azure_rm_devtestlabpolicy_info.py ├── azure_rm_devtestlabschedule.py ├── azure_rm_devtestlabschedule_info.py ├── azure_rm_devtestlabvirtualmachine.py ├── azure_rm_devtestlabvirtualmachine_info.py ├── azure_rm_devtestlabvirtualnetwork.py ├── azure_rm_devtestlabvirtualnetwork_info.py ├── azure_rm_dnsrecordset.py ├── azure_rm_dnsrecordset_info.py ├── azure_rm_dnszone.py ├── azure_rm_dnszone_info.py ├── azure_rm_functionapp.py ├── azure_rm_functionapp_info.py ├── azure_rm_gallery.py ├── azure_rm_gallery_info.py ├── azure_rm_galleryimage.py ├── azure_rm_galleryimage_info.py ├── azure_rm_galleryimageversion.py ├── azure_rm_galleryimageversion_info.py ├── azure_rm_hdinsightcluster.py ├── azure_rm_hdinsightcluster_info.py ├── azure_rm_image.py ├── azure_rm_image_info.py ├── azure_rm_iotdevice.py ├── azure_rm_iotdevice_info.py ├── azure_rm_iotdevicemodule.py ├── azure_rm_iothub.py ├── azure_rm_iothub_info.py ├── azure_rm_iothubconsumergroup.py ├── azure_rm_keyvault.py ├── azure_rm_keyvault_info.py ├── azure_rm_keyvaultkey.py ├── azure_rm_keyvaultkey_info.py ├── azure_rm_keyvaultsecret.py ├── azure_rm_keyvaultsecret_info.py ├── azure_rm_loadbalancer.py ├── azure_rm_loadbalancer_info.py ├── azure_rm_lock.py ├── azure_rm_lock_info.py ├── azure_rm_loganalyticsworkspace.py ├── azure_rm_loganalyticsworkspace_info.py ├── azure_rm_manageddisk.py ├── azure_rm_manageddisk_info.py ├── azure_rm_mariadbconfiguration.py ├── azure_rm_mariadbconfiguration_info.py ├── azure_rm_mariadbdatabase.py ├── azure_rm_mariadbdatabase_info.py ├── azure_rm_mariadbfirewallrule.py ├── azure_rm_mariadbfirewallrule_info.py ├── azure_rm_mariadbserver.py ├── azure_rm_mariadbserver_info.py ├── azure_rm_monitorlogprofile.py ├── azure_rm_mysqlconfiguration.py ├── azure_rm_mysqlconfiguration_info.py ├── azure_rm_mysqldatabase.py ├── azure_rm_mysqldatabase_info.py ├── azure_rm_mysqlfirewallrule.py ├── azure_rm_mysqlfirewallrule_info.py ├── azure_rm_mysqlserver.py ├── azure_rm_mysqlserver_info.py ├── azure_rm_networkinterface.py ├── azure_rm_networkinterface_info.py ├── azure_rm_postgresqlconfiguration.py ├── azure_rm_postgresqlconfiguration_info.py ├── azure_rm_postgresqldatabase.py ├── azure_rm_postgresqldatabase_info.py ├── azure_rm_postgresqlfirewallrule.py ├── azure_rm_postgresqlfirewallrule_info.py ├── azure_rm_postgresqlserver.py ├── azure_rm_postgresqlserver_info.py ├── azure_rm_publicipaddress.py ├── azure_rm_publicipaddress_info.py ├── azure_rm_rediscache.py ├── azure_rm_rediscache_info.py ├── azure_rm_rediscachefirewallrule.py ├── azure_rm_resource.py ├── azure_rm_resource_info.py ├── azure_rm_resourcegroup.py ├── azure_rm_resourcegroup_info.py ├── azure_rm_roleassignment.py ├── azure_rm_roleassignment_info.py ├── azure_rm_roledefinition.py ├── azure_rm_roledefinition_info.py ├── azure_rm_route.py ├── azure_rm_routetable.py ├── azure_rm_routetable_info.py ├── azure_rm_securitygroup.py ├── azure_rm_securitygroup_info.py ├── azure_rm_servicebus.py ├── azure_rm_servicebus_info.py ├── azure_rm_servicebusqueue.py ├── azure_rm_servicebussaspolicy.py ├── azure_rm_servicebustopic.py ├── azure_rm_servicebustopicsubscription.py ├── azure_rm_snapshot.py ├── azure_rm_sqldatabase.py ├── azure_rm_sqldatabase_info.py ├── azure_rm_sqlelasticpool.py ├── azure_rm_sqlelasticpool_facts.py ├── azure_rm_sqlfirewallrule.py ├── azure_rm_sqlfirewallrule_info.py ├── azure_rm_sqlserver.py ├── azure_rm_sqlserver_info.py ├── azure_rm_storageaccount.py ├── azure_rm_storageaccount_info.py ├── azure_rm_storageblob.py ├── azure_rm_subnet.py ├── azure_rm_subnet_info.py ├── azure_rm_trafficmanager.py ├── azure_rm_trafficmanagerendpoint.py ├── azure_rm_trafficmanagerendpoint_info.py ├── azure_rm_trafficmanagerprofile.py ├── azure_rm_trafficmanagerprofile_info.py ├── azure_rm_virtualmachine.py ├── azure_rm_virtualmachine_info.py ├── azure_rm_virtualmachineextension.py ├── azure_rm_virtualmachineextension_info.py ├── azure_rm_virtualmachineimage_info.py ├── azure_rm_virtualmachinescaleset.py ├── azure_rm_virtualmachinescaleset_info.py ├── azure_rm_virtualmachinescalesetextension.py ├── azure_rm_virtualmachinescalesetextension_info.py ├── azure_rm_virtualmachinescalesetinstance.py ├── azure_rm_virtualmachinescalesetinstance_info.py ├── azure_rm_virtualnetwork.py ├── azure_rm_virtualnetwork_info.py ├── azure_rm_virtualnetworkgateway.py ├── azure_rm_virtualnetworkpeering.py ├── azure_rm_virtualnetworkpeering_info.py ├── azure_rm_webapp.py ├── azure_rm_webapp_info.py └── azure_rm_webappslot.py ├── lookup_plugins └── azure_keyvault_secret.py ├── meta └── main.yml ├── module_utils ├── azure_rm_common.py ├── azure_rm_common_ext.py ├── azure_rm_common_rest.py └── common │ └── dict_transformations.py ├── tasks └── main.yml └── tests └── integration ├── clear_all.yml ├── main.yml └── targets ├── azure_rm_acs ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_aks ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_appgateway ├── aliases ├── files │ ├── cert1.txt │ └── cert2.txt ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_appserviceplan ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_automationaccount ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_autoscale ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_availabilityset ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_azurefirewall ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_batchaccount ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_cdnprofile ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_containerinstance ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_containerregistry ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_cosmosdbaccount ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_deployment ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_devtestlab ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_dnsrecordset ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_dnsrecordset_facts ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_dnszone ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_functionapp ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_gallery ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_hdinsightcluster ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_image ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_iothub ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_keyvault ├── aliases ├── lookup_plugins │ └── azure_service_principal_attribute.py ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_keyvaultkey ├── aliases ├── lookup_plugins │ └── azure_service_principal_attribute.py ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_keyvaultsecret ├── aliases ├── lookup_plugins │ └── azure_service_principal_attribute.py ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_loadbalancer ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_lock ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_manageddisk ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_mariadbserver ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_monitorlogprofile ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_mysqlserver ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_networkinterface ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_postgresqlserver ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_publicipaddress ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_rediscache ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_resource ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_resourcegroup ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_roledefinition ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_routetable ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_securitygroup ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_servicebus ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_sqlserver ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_storageaccount ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_storageblob ├── aliases ├── files │ └── Ratings.png ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_subnet ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_trafficmanagerprofile ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_virtualmachine ├── aliases ├── inventory.yml ├── main.yml ├── runme.sh └── tasks │ ├── azure_test_deallocate.yml │ ├── azure_test_dual_nic.yml │ ├── azure_test_invalid.yml │ ├── azure_test_minimal.yml │ ├── azure_test_no_public_ip.yml │ ├── azure_test_public_ip.yml │ └── setup.yml ├── azure_rm_virtualmachineextension ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_virtualmachineimage_facts ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_virtualmachinescaleset ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_virtualnetwork ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_virtualnetworkgateway ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_virtualnetworkpeering ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml ├── azure_rm_webapp ├── aliases ├── meta │ └── main.yml └── tasks │ └── main.yml └── azure_rm_workspace ├── aliases ├── meta └── main.yml └── tasks └── main.yml /.github/sha.json: -------------------------------------------------------------------------------- 1 | { 2 | "lib/ansible/module_utils/azure_rm_common.py": "c7bf3e035b3cc3304b0dcafc3437ba8ea0db30b4", 3 | "lib/ansible/module_utils/azure_rm_common_ext.py": "c9d82024c7b5f461b44f504e51c996428ca7f274", 4 | "lib/ansible/modules/cloud/azure": "21accb132e748344e0938b7bc7b658bf3faaf22a", 5 | "packaging/requirements/requirements-azure.txt": "cb201bfba1ed1a1ed97d325e0f4d045597f63300", 6 | "test/integration/targets": "e3cf76533c489a913a00619b19507a7476430a95" 7 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .DS_Store 3 | .vscode -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # This repo is not maintained anymore, instead please go to [AzCollection](https://github.com/ansible-collections/azure). 3 | 4 | 5 | azure.azure_preview_modules 6 | ========= 7 | 8 | This role is the most complete and includes all the latest Azure modules. The update and bug fix are done in a more timely manner than official Ansible release. 9 | 10 | If you use Ansible for Azure resource provisioning purpose, you're strongly encouraged to install this role. 11 | 12 | Prerequisite 13 | ------------ 14 | 15 | The usage of this playbook role assumes that you've already setup an Ansible environment for Azure. For details, please refer to Ansible tutorial [Getting Started with Azure](http://docs.ansible.com/ansible/latest/guide_azure.html) or [Install and configure Ansible](https://docs.microsoft.com/en-us/azure/virtual-machines/linux/ansible-install-configure). 16 | 17 | 18 | Installation 19 | ------------ 20 | 21 | 1. Install the role. 22 | 23 | ``` bash 24 | $ ansible-galaxy install azure.azure_preview_modules 25 | ``` 26 | 27 | 2. Upgrade Azure Python SDKs required by new Azure modules. 28 | 29 | ``` bash 30 | $ pip install -r ~/.ansible/roles/azure.azure_preview_modules/files/requirements-azure.txt 31 | ``` 32 | 33 |     or 34 | 35 | ``` bash 36 | $ sudo pip install -r ~/.ansible/roles/azure.azure_preview_modules/files/requirements-azure.txt 37 | ``` 38 | 39 | Several reasons for installing Python SDKs are listed here. 40 | 41 | - New module is added to the role and this module is for one new Azure resource, which is not included in existing Ansible releases yet. Corresponding SDK for this new resource needs to be installed. 42 | 43 | - Newer versions of SDKs may introduce breaking API change. One specific working version should be installed here. 44 | 45 | The required SDKs are listed in the *[~/files/requirements-azure.txt](files/requirements-azure.txt)* file. The `requirements-azure.txt` file can be found in the installed role folder, which is usually at `~/.ansible/roles/files` folder. 46 | 47 | The tricky part is the installation location, which has to be the same as where existing Azure Python SDKs are installed. If you meet any error when executing above command, please read below part carefully to double check the installation location. 48 | 49 | Taking Ubuntu for example, the existing SDKs may be located in folders like `/home//.local/lib/python2.7/site-packages` or `/usr/local/lib/python2.7/dist-packages`. The former is a user folder and the latter is a system folder, which requires sudo access. This depends on how you have installed `ansible`. In short, you should install the SDKs the same way as you installed `ansible` so that the SDKs are in the same `site-packages` folder. 50 | 51 | On macOS, the existing SDKs may be located in folders like `/Users//Library/Python/2.7/lib/python/site-packages` or `/Library/Python/2.7/site-packages`. Like Ubuntu, the former is an user folder and the latter is a system folder. 52 | 53 | One way to figure out the correct `site-packages` path is to check the details of existing packages, say `azure-mgmt-storage` by running below command. 54 | 55 | ``` bash 56 | $ pip show azure-mgmt-storage 57 | ``` 58 | 59 | You can get the output like below. 60 | 61 | ``` bash 62 | your-user-name@ansible:~$ pip show azure-mgmt-storage 63 | Name: azure-mgmt-storage 64 | Version: 1.5.0 65 | Summary: Microsoft Azure Storage Management Client Library for Python 66 | Home-page: https://github.com/Azure/azure-sdk-for-python 67 | Author: Microsoft Corporation 68 | Author-email: azpysdkhelp@microsoft.com 69 | License: MIT License 70 | Location: /home//.local/lib/python2.7/site-packages 71 | Requires: azure-common, azure-mgmt-nspkg, msrestazure 72 | ``` 73 | 74 | From above information you can learn that the SDKs are installed in *user* `site-packages` folder and use `pip install` to install the listed packages. If the SDKs are installed in *system* path, use `sudo pip install` to install the listed packages. 75 | 76 | Role Variables 77 | -------------- 78 | 79 | No. 80 | 81 | Dependencies 82 | ------------ 83 | 84 | No dependencies on other roles. 85 | 86 | Example Playbook 87 | ---------------- 88 | 89 | - hosts: localhost 90 | roles: 91 | - { role: azure.azure_preview_modules } 92 | tasks: 93 | - name: create storage account 94 | azure_rm_storageaccount: 95 | resource_group: resourcegroupname 96 | name: storagename 97 | account_type: Standard_LRS 98 | 99 | License 100 | ------- 101 | MIT 102 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Security 4 | 5 | Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). 6 | 7 | If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below. 8 | 9 | ## Reporting Security Issues 10 | 11 | **Please do not report security vulnerabilities through public GitHub issues.** 12 | 13 | Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report). 14 | 15 | If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey). 16 | 17 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc). 18 | 19 | Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: 20 | 21 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) 22 | * Full paths of source file(s) related to the manifestation of the issue 23 | * The location of the affected source code (tag/branch/commit or direct URL) 24 | * Any special configuration required to reproduce the issue 25 | * Step-by-step instructions to reproduce the issue 26 | * Proof-of-concept or exploit code (if possible) 27 | * Impact of the issue, including how an attacker might exploit the issue 28 | 29 | This information will help us triage your report more quickly. 30 | 31 | If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs. 32 | 33 | ## Preferred Languages 34 | 35 | We prefer all communications to be in English. 36 | 37 | ## Policy 38 | 39 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd). 40 | 41 | 42 | -------------------------------------------------------------------------------- /defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | skip_azure_sdk: true 3 | -------------------------------------------------------------------------------- /files/requirements-azure.txt: -------------------------------------------------------------------------------- 1 | packaging 2 | requests[security] 3 | xmltodict 4 | azure-cli-core==2.0.35 5 | azure-cli-nspkg==3.0.2 6 | azure-common==1.1.11 7 | azure-mgmt-authorization==0.51.1 8 | azure-mgmt-batch==5.0.1 9 | azure-mgmt-cdn==3.0.0 10 | azure-mgmt-compute==10.0.0 11 | azure-mgmt-containerinstance==1.4.0 12 | azure-mgmt-containerregistry==2.0.0 13 | azure-mgmt-containerservice==4.4.0 14 | azure-mgmt-dns==2.1.0 15 | azure-mgmt-keyvault==1.1.0 16 | azure-mgmt-marketplaceordering==0.1.0 17 | azure-mgmt-monitor==0.5.2 18 | azure-mgmt-network==4.0.0 19 | azure-mgmt-nspkg==2.0.0 20 | azure-mgmt-redis==5.0.0 21 | azure-mgmt-resource==2.1.0 22 | azure-mgmt-rdbms==1.4.1 23 | azure-mgmt-servicebus==0.5.3 24 | azure-mgmt-sql==0.10.0 25 | azure-mgmt-storage==3.1.0 26 | azure-mgmt-trafficmanager==0.50.0 27 | azure-mgmt-web==0.41.0 28 | azure-nspkg==2.0.0 29 | azure-storage==0.35.1 30 | msrest==0.6.10 31 | msrestazure==0.6.2 32 | azure-keyvault==1.0.0a1 33 | azure-graphrbac==0.40.0 34 | azure-mgmt-cosmosdb==0.5.2 35 | azure-mgmt-hdinsight==0.1.0 36 | azure-mgmt-devtestlabs==3.0.0 37 | azure-mgmt-loganalytics==0.2.0 38 | azure-mgmt-automation==0.1.1 39 | azure-mgmt-iothub==0.7.0 40 | -------------------------------------------------------------------------------- /library/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure_preview_modules/f3bcca65d4c2bb528faf1e7f4fbb7cc3846a8b95/library/__init__.py -------------------------------------------------------------------------------- /library/_azure.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # 3 | # Copyright (c) Ansible Project 4 | # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 5 | 6 | from __future__ import absolute_import, division, print_function 7 | __metaclass__ = type 8 | 9 | 10 | ANSIBLE_METADATA = {'metadata_version': '1.1', 11 | 'status': ['removed'], 12 | 'supported_by': 'community'} 13 | 14 | 15 | from ansible.module_utils.common.removed import removed_module 16 | 17 | 18 | if __name__ == '__main__': 19 | removed_module(removed_in='2.8') 20 | -------------------------------------------------------------------------------- /library/_azure_rm_aks_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_aks_info.py -------------------------------------------------------------------------------- /library/_azure_rm_aksversion_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_aksversion_info.py -------------------------------------------------------------------------------- /library/_azure_rm_applicationsecuritygroup_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_applicationsecuritygroup_info.py -------------------------------------------------------------------------------- /library/_azure_rm_appserviceplan_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_appserviceplan_info.py -------------------------------------------------------------------------------- /library/_azure_rm_automationaccount_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_automationaccount_info.py -------------------------------------------------------------------------------- /library/_azure_rm_autoscale_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_autoscale_info.py -------------------------------------------------------------------------------- /library/_azure_rm_availabilityset_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_availabilityset_info.py -------------------------------------------------------------------------------- /library/_azure_rm_cdnendpoint_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_cdnendpoint_info.py -------------------------------------------------------------------------------- /library/_azure_rm_cdnprofile_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_cdnprofile_info.py -------------------------------------------------------------------------------- /library/_azure_rm_containerinstance_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_containerinstance_info.py -------------------------------------------------------------------------------- /library/_azure_rm_containerregistry_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_containerregistry_info.py -------------------------------------------------------------------------------- /library/_azure_rm_cosmosdbaccount_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_cosmosdbaccount_info.py -------------------------------------------------------------------------------- /library/_azure_rm_deployment_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_deployment_info.py -------------------------------------------------------------------------------- /library/_azure_rm_devtestlab_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_devtestlab_info.py -------------------------------------------------------------------------------- /library/_azure_rm_devtestlabarmtemplate_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_devtestlabarmtemplate_info.py -------------------------------------------------------------------------------- /library/_azure_rm_devtestlabartifact_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_devtestlabartifact_info.py -------------------------------------------------------------------------------- /library/_azure_rm_devtestlabartifactsource_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_devtestlabartifactsource_info.py -------------------------------------------------------------------------------- /library/_azure_rm_devtestlabcustomimage_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_devtestlabcustomimage_info.py -------------------------------------------------------------------------------- /library/_azure_rm_devtestlabenvironment_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_devtestlabenvironment_info.py -------------------------------------------------------------------------------- /library/_azure_rm_devtestlabpolicy_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_devtestlabpolicy_info.py -------------------------------------------------------------------------------- /library/_azure_rm_devtestlabschedule_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_devtestlabschedule_info.py -------------------------------------------------------------------------------- /library/_azure_rm_devtestlabvirtualmachine_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_devtestlabvirtualmachine_info.py -------------------------------------------------------------------------------- /library/_azure_rm_devtestlabvirtualnetwork_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_devtestlabvirtualnetwork_info.py -------------------------------------------------------------------------------- /library/_azure_rm_dnsrecordset_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_dnsrecordset_info.py -------------------------------------------------------------------------------- /library/_azure_rm_dnszone_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_dnszone_info.py -------------------------------------------------------------------------------- /library/_azure_rm_functionapp_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_functionapp_info.py -------------------------------------------------------------------------------- /library/_azure_rm_hdinsightcluster_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_hdinsightcluster_info.py -------------------------------------------------------------------------------- /library/_azure_rm_image_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_image_info.py -------------------------------------------------------------------------------- /library/_azure_rm_loadbalancer_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_loadbalancer_info.py -------------------------------------------------------------------------------- /library/_azure_rm_lock_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_lock_info.py -------------------------------------------------------------------------------- /library/_azure_rm_loganalyticsworkspace_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_loganalyticsworkspace_info.py -------------------------------------------------------------------------------- /library/_azure_rm_managed_disk.py: -------------------------------------------------------------------------------- 1 | azure_rm_manageddisk.py -------------------------------------------------------------------------------- /library/_azure_rm_managed_disk_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_manageddisk_info.py -------------------------------------------------------------------------------- /library/_azure_rm_manageddisk_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_manageddisk_info.py -------------------------------------------------------------------------------- /library/_azure_rm_mariadbconfiguration_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_mariadbconfiguration_info.py -------------------------------------------------------------------------------- /library/_azure_rm_mariadbdatabase_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_mariadbdatabase_info.py -------------------------------------------------------------------------------- /library/_azure_rm_mariadbfirewallrule_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_mariadbfirewallrule_info.py -------------------------------------------------------------------------------- /library/_azure_rm_mariadbserver_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_mariadbserver_info.py -------------------------------------------------------------------------------- /library/_azure_rm_mysqlconfiguration_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_mysqlconfiguration_info.py -------------------------------------------------------------------------------- /library/_azure_rm_mysqldatabase_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_mysqldatabase_info.py -------------------------------------------------------------------------------- /library/_azure_rm_mysqlfirewallrule_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_mysqlfirewallrule_info.py -------------------------------------------------------------------------------- /library/_azure_rm_mysqlserver_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_mysqlserver_info.py -------------------------------------------------------------------------------- /library/_azure_rm_networkinterface_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_networkinterface_info.py -------------------------------------------------------------------------------- /library/_azure_rm_postgresqlconfiguration_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_postgresqlconfiguration_info.py -------------------------------------------------------------------------------- /library/_azure_rm_postgresqldatabase_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_postgresqldatabase_info.py -------------------------------------------------------------------------------- /library/_azure_rm_postgresqlfirewallrule_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_postgresqlfirewallrule_info.py -------------------------------------------------------------------------------- /library/_azure_rm_postgresqlserver_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_postgresqlserver_info.py -------------------------------------------------------------------------------- /library/_azure_rm_publicipaddress_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_publicipaddress_info.py -------------------------------------------------------------------------------- /library/_azure_rm_rediscache_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_rediscache_info.py -------------------------------------------------------------------------------- /library/_azure_rm_resource_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_resource_info.py -------------------------------------------------------------------------------- /library/_azure_rm_resourcegroup_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_resourcegroup_info.py -------------------------------------------------------------------------------- /library/_azure_rm_roleassignment_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_roleassignment_info.py -------------------------------------------------------------------------------- /library/_azure_rm_roledefinition_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_roledefinition_info.py -------------------------------------------------------------------------------- /library/_azure_rm_routetable_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_routetable_info.py -------------------------------------------------------------------------------- /library/_azure_rm_securitygroup_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_securitygroup_info.py -------------------------------------------------------------------------------- /library/_azure_rm_servicebus_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_servicebus_info.py -------------------------------------------------------------------------------- /library/_azure_rm_sqldatabase_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_sqldatabase_info.py -------------------------------------------------------------------------------- /library/_azure_rm_sqlfirewallrule_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_sqlfirewallrule_info.py -------------------------------------------------------------------------------- /library/_azure_rm_sqlserver_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_sqlserver_info.py -------------------------------------------------------------------------------- /library/_azure_rm_storageaccount_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_storageaccount_info.py -------------------------------------------------------------------------------- /library/_azure_rm_subnet_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_subnet_info.py -------------------------------------------------------------------------------- /library/_azure_rm_trafficmanagerendpoint_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_trafficmanagerendpoint_info.py -------------------------------------------------------------------------------- /library/_azure_rm_trafficmanagerprofile_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_trafficmanagerprofile_info.py -------------------------------------------------------------------------------- /library/_azure_rm_virtualmachine_extension.py: -------------------------------------------------------------------------------- 1 | azure_rm_virtualmachineextension.py -------------------------------------------------------------------------------- /library/_azure_rm_virtualmachine_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_virtualmachine_info.py -------------------------------------------------------------------------------- /library/_azure_rm_virtualmachine_scaleset.py: -------------------------------------------------------------------------------- 1 | azure_rm_virtualmachinescaleset.py -------------------------------------------------------------------------------- /library/_azure_rm_virtualmachine_scaleset_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_virtualmachinescaleset_info.py -------------------------------------------------------------------------------- /library/_azure_rm_virtualmachineextension_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_virtualmachineextension_info.py -------------------------------------------------------------------------------- /library/_azure_rm_virtualmachineimage_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_virtualmachineimage_info.py -------------------------------------------------------------------------------- /library/_azure_rm_virtualmachinescaleset_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_virtualmachinescaleset_info.py -------------------------------------------------------------------------------- /library/_azure_rm_virtualmachinescalesetextension_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_virtualmachinescalesetextension_info.py -------------------------------------------------------------------------------- /library/_azure_rm_virtualmachinescalesetinstance_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_virtualmachinescalesetinstance_info.py -------------------------------------------------------------------------------- /library/_azure_rm_virtualnetwork_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_virtualnetwork_info.py -------------------------------------------------------------------------------- /library/_azure_rm_virtualnetworkpeering_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_virtualnetworkpeering_info.py -------------------------------------------------------------------------------- /library/_azure_rm_webapp_facts.py: -------------------------------------------------------------------------------- 1 | azure_rm_webapp_info.py -------------------------------------------------------------------------------- /library/azure_rm_aksversion_info.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # 3 | # Copyright (c) 2018 Yuwei Zhou, 4 | # 5 | # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 6 | 7 | from __future__ import absolute_import, division, print_function 8 | __metaclass__ = type 9 | 10 | 11 | ANSIBLE_METADATA = {'metadata_version': '1.1', 12 | 'status': ['preview'], 13 | 'supported_by': 'community'} 14 | 15 | DOCUMENTATION = ''' 16 | --- 17 | module: azure_rm_aksversion_info 18 | 19 | version_added: "2.9" 20 | 21 | short_description: Get available kubernetes versions supported by Azure Kubernetes Service 22 | 23 | description: 24 | - Get available kubernetes versions supported by Azure Kubernetes Service. 25 | 26 | options: 27 | location: 28 | description: 29 | - Get the versions available for creating a managed Kubernetes cluster. 30 | required: true 31 | version: 32 | description: 33 | - Get the upgrade versions available for a managed Kubernetes cluster version. 34 | 35 | extends_documentation_fragment: 36 | - azure 37 | 38 | author: 39 | - Yuwei Zhou (@yuwzho) 40 | ''' 41 | 42 | EXAMPLES = ''' 43 | - name: Get available versions for AKS in location eastus 44 | azure_rm_aksversion_info: 45 | location: eastus 46 | - name: Get available versions an AKS can be upgrade to 47 | azure_rm_aksversion_info: 48 | location: eastis 49 | version: 1.11.6 50 | ''' 51 | 52 | RETURN = ''' 53 | azure_aks_versions: 54 | description: List of supported kubernetes versions. 55 | returned: always 56 | type: list 57 | ''' 58 | 59 | from ansible.module_utils.azure_rm_common import AzureRMModuleBase 60 | 61 | try: 62 | from msrestazure.azure_exceptions import CloudError 63 | from azure.common import AzureHttpError 64 | except Exception: 65 | # handled in azure_rm_common 66 | pass 67 | 68 | 69 | class AzureRMAKSVersion(AzureRMModuleBase): 70 | 71 | def __init__(self): 72 | 73 | self.module_args = dict( 74 | location=dict(type='str', required=True), 75 | version=dict(type='str') 76 | ) 77 | 78 | self.results = dict( 79 | changed=False, 80 | azure_aks_versions=[] 81 | ) 82 | 83 | self.location = None 84 | self.version = None 85 | 86 | super(AzureRMAKSVersion, self).__init__( 87 | derived_arg_spec=self.module_args, 88 | supports_tags=False, 89 | facts_module=True 90 | ) 91 | 92 | def exec_module(self, **kwargs): 93 | 94 | is_old_facts = self.module._name == 'azure_rm_aksversion_facts' 95 | if is_old_facts: 96 | self.module.deprecate("The 'azure_rm_aksversion_facts' module has been renamed to 'azure_rm_aksversion_info'", version='2.13') 97 | 98 | for key in self.module_args: 99 | setattr(self, key, kwargs[key]) 100 | 101 | self.results['azure_aks_versions'] = self.get_all_versions(self.location, self.version) 102 | 103 | return self.results 104 | 105 | def get_all_versions(self, location, version): 106 | ''' 107 | Get all kubernetes version supported by AKS 108 | :return: ordered version list 109 | ''' 110 | try: 111 | result = dict() 112 | response = self.containerservice_client.container_services.list_orchestrators(self.location, resource_type='managedClusters') 113 | orchestrators = response.orchestrators 114 | for item in orchestrators: 115 | result[item.orchestrator_version] = [x.orchestrator_version for x in item.upgrades] if item.upgrades else [] 116 | if version: 117 | return result.get(version) or [] 118 | else: 119 | keys = list(result.keys()) 120 | keys.sort() 121 | return keys 122 | except Exception as exc: 123 | self.fail('Error when getting AKS supported kubernetes version list for location {0} - {1}'.format(self.location, exc.message or str(exc))) 124 | 125 | 126 | def main(): 127 | """Main module execution code path""" 128 | 129 | AzureRMAKSVersion() 130 | 131 | 132 | if __name__ == '__main__': 133 | main() 134 | -------------------------------------------------------------------------------- /library/azure_rm_loadbalancer_info.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | 4 | # Copyright: (c) 2016, Thomas Stringer 5 | # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 6 | 7 | 8 | from __future__ import absolute_import, division, print_function 9 | __metaclass__ = type 10 | 11 | 12 | ANSIBLE_METADATA = {'metadata_version': '1.1', 13 | 'status': ['preview'], 14 | 'supported_by': 'community'} 15 | 16 | DOCUMENTATION = ''' 17 | --- 18 | module: azure_rm_loadbalancer_info 19 | 20 | version_added: "2.9" 21 | 22 | short_description: Get load balancer facts 23 | 24 | description: 25 | - Get facts for a specific load balancer or all load balancers. 26 | 27 | options: 28 | name: 29 | description: 30 | - Limit results to a specific resource group. 31 | resource_group: 32 | description: 33 | - The resource group to search for the desired load balancer. 34 | tags: 35 | description: 36 | - Limit results by providing a list of tags. Format tags as 'key' or 'key:value'. 37 | 38 | extends_documentation_fragment: 39 | - azure 40 | 41 | author: 42 | - Thomas Stringer (@trstringer) 43 | ''' 44 | 45 | EXAMPLES = ''' 46 | - name: Get facts for one load balancer 47 | azure_rm_loadbalancer_info: 48 | name: Testing 49 | resource_group: myResourceGroup 50 | 51 | - name: Get facts for all load balancers 52 | azure_rm_loadbalancer_info: 53 | 54 | - name: Get facts for all load balancers in a specific resource group 55 | azure_rm_loadbalancer_info: 56 | resource_group: myResourceGroup 57 | 58 | - name: Get facts by tags 59 | azure_rm_loadbalancer_info: 60 | tags: 61 | - testing 62 | ''' 63 | 64 | RETURN = ''' 65 | azure_loadbalancers: 66 | description: 67 | - List of load balancer dicts. 68 | returned: always 69 | type: list 70 | ''' 71 | 72 | from ansible.module_utils.azure_rm_common import AzureRMModuleBase 73 | 74 | try: 75 | from msrestazure.azure_exceptions import CloudError 76 | from azure.common import AzureHttpError 77 | except Exception: 78 | # handled in azure_rm_common 79 | pass 80 | 81 | AZURE_OBJECT_CLASS = 'LoadBalancer' 82 | 83 | 84 | class AzureRMLoadBalancerInfo(AzureRMModuleBase): 85 | """Utility class to get load balancer facts""" 86 | 87 | def __init__(self): 88 | 89 | self.module_args = dict( 90 | name=dict(type='str'), 91 | resource_group=dict(type='str'), 92 | tags=dict(type='list') 93 | ) 94 | 95 | self.results = dict( 96 | changed=False, 97 | ansible_info=dict( 98 | azure_loadbalancers=[] 99 | ) 100 | ) 101 | 102 | self.name = None 103 | self.resource_group = None 104 | self.tags = None 105 | 106 | super(AzureRMLoadBalancerInfo, self).__init__( 107 | derived_arg_spec=self.module_args, 108 | supports_tags=False, 109 | facts_module=True 110 | ) 111 | 112 | def exec_module(self, **kwargs): 113 | 114 | is_old_facts = self.module._name == 'azure_rm_loadbalancer_facts' 115 | if is_old_facts: 116 | self.module.deprecate("The 'azure_rm_loadbalancer_facts' module has been renamed to 'azure_rm_loadbalancer_info'", version='2.13') 117 | 118 | for key in self.module_args: 119 | setattr(self, key, kwargs[key]) 120 | 121 | self.results['ansible_info']['azure_loadbalancers'] = ( 122 | self.get_item() if self.name 123 | else self.list_items() 124 | ) 125 | 126 | return self.results 127 | 128 | def get_item(self): 129 | """Get a single load balancer""" 130 | 131 | self.log('Get properties for {0}'.format(self.name)) 132 | 133 | item = None 134 | result = [] 135 | 136 | try: 137 | item = self.network_client.load_balancers.get(self.resource_group, self.name) 138 | except CloudError: 139 | pass 140 | 141 | if item and self.has_tags(item.tags, self.tags): 142 | result = [self.serialize_obj(item, AZURE_OBJECT_CLASS)] 143 | 144 | return result 145 | 146 | def list_items(self): 147 | """Get all load balancers""" 148 | 149 | self.log('List all load balancers') 150 | 151 | if self.resource_group: 152 | try: 153 | response = self.network_client.load_balancers.list(self.resource_group) 154 | except AzureHttpError as exc: 155 | self.fail('Failed to list items in resource group {0} - {1}'.format(self.resource_group, str(exc))) 156 | else: 157 | try: 158 | response = self.network_client.load_balancers.list_all() 159 | except AzureHttpError as exc: 160 | self.fail('Failed to list all items - {0}'.format(str(exc))) 161 | 162 | results = [] 163 | for item in response: 164 | if self.has_tags(item.tags, self.tags): 165 | results.append(self.serialize_obj(item, AZURE_OBJECT_CLASS)) 166 | 167 | return results 168 | 169 | 170 | def main(): 171 | """Main module execution code path""" 172 | 173 | AzureRMLoadBalancerInfo() 174 | 175 | 176 | if __name__ == '__main__': 177 | main() 178 | -------------------------------------------------------------------------------- /meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependencies: [] 3 | galaxy_info: 4 | author: ZhijunZhao 5 | company: Microsoft 6 | description: "latest Azure modules for provisioning Azure resources" 7 | galaxy_tags: ["azure", "cloud", "system", "development", "networking", "docker", "container", "kubernetes"] 8 | license: MIT 9 | min_ansible_version: "2.5.0" 10 | platforms: 11 | - name: GenericLinux 12 | versions: 13 | - any 14 | 15 | - name: macOS 16 | versions: 17 | - Sierra 18 | 19 | - name: MacOSX 20 | versions: 21 | - 10.7 22 | - 10.8 23 | - 10.9 24 | - "10.10" 25 | - 10.11 26 | - 10.12 27 | 28 | - name: Windows 29 | versions: 30 | - 2012R2 31 | 32 | cloud_platforms: 33 | - Azure 34 | -------------------------------------------------------------------------------- /module_utils/azure_rm_common_rest.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2018 Zim Kalinowski, 2 | # 3 | # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 4 | 5 | from ansible.module_utils.ansible_release import __version__ as ANSIBLE_VERSION 6 | 7 | try: 8 | from msrestazure.azure_exceptions import CloudError 9 | from msrestazure.azure_configuration import AzureConfiguration 10 | from msrest.service_client import ServiceClient 11 | from msrest.pipeline import ClientRawResponse 12 | from msrest.polling import LROPoller 13 | from msrestazure.polling.arm_polling import ARMPolling 14 | import uuid 15 | import json 16 | except ImportError: 17 | # This is handled in azure_rm_common 18 | AzureConfiguration = object 19 | 20 | ANSIBLE_USER_AGENT = 'Ansible/{0}'.format(ANSIBLE_VERSION) 21 | 22 | 23 | class GenericRestClientConfiguration(AzureConfiguration): 24 | 25 | def __init__(self, credentials, subscription_id, base_url=None): 26 | 27 | if credentials is None: 28 | raise ValueError("Parameter 'credentials' must not be None.") 29 | if subscription_id is None: 30 | raise ValueError("Parameter 'subscription_id' must not be None.") 31 | if not base_url: 32 | base_url = 'https://management.azure.com' 33 | 34 | super(GenericRestClientConfiguration, self).__init__(base_url) 35 | 36 | self.add_user_agent(ANSIBLE_USER_AGENT) 37 | 38 | self.credentials = credentials 39 | self.subscription_id = subscription_id 40 | 41 | 42 | class GenericRestClient(object): 43 | 44 | def __init__(self, credentials, subscription_id, base_url=None): 45 | self.config = GenericRestClientConfiguration(credentials, subscription_id, base_url) 46 | self._client = ServiceClient(self.config.credentials, self.config) 47 | self.models = None 48 | 49 | def query(self, url, method, query_parameters, header_parameters, body, expected_status_codes, polling_timeout, polling_interval): 50 | # Construct and send request 51 | operation_config = {} 52 | 53 | request = None 54 | 55 | if header_parameters is None: 56 | header_parameters = {} 57 | 58 | header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) 59 | 60 | if method == 'GET': 61 | request = self._client.get(url, query_parameters) 62 | elif method == 'PUT': 63 | request = self._client.put(url, query_parameters) 64 | elif method == 'POST': 65 | request = self._client.post(url, query_parameters) 66 | elif method == 'HEAD': 67 | request = self._client.head(url, query_parameters) 68 | elif method == 'PATCH': 69 | request = self._client.patch(url, query_parameters) 70 | elif method == 'DELETE': 71 | request = self._client.delete(url, query_parameters) 72 | elif method == 'MERGE': 73 | request = self._client.merge(url, query_parameters) 74 | 75 | response = self._client.send(request, header_parameters, body, **operation_config) 76 | 77 | if response.status_code not in expected_status_codes: 78 | exp = CloudError(response) 79 | exp.request_id = response.headers.get('x-ms-request-id') 80 | raise exp 81 | elif response.status_code == 202 and polling_timeout > 0: 82 | def get_long_running_output(response): 83 | return response 84 | poller = LROPoller(self._client, 85 | ClientRawResponse(None, response), 86 | get_long_running_output, 87 | ARMPolling(polling_interval, **operation_config)) 88 | response = self.get_poller_result(poller, polling_timeout) 89 | 90 | return response 91 | 92 | def get_poller_result(self, poller, timeout): 93 | try: 94 | poller.wait(timeout=timeout) 95 | return poller.result() 96 | except Exception as exc: 97 | raise 98 | -------------------------------------------------------------------------------- /module_utils/common/dict_transformations.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Copyright: (c) 2018, Ansible Project 4 | # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 5 | 6 | from __future__ import absolute_import, division, print_function 7 | __metaclass__ = type 8 | 9 | 10 | import re 11 | from copy import deepcopy 12 | 13 | 14 | def camel_dict_to_snake_dict(camel_dict, reversible=False, ignore_list=()): 15 | """ 16 | reversible allows two way conversion of a camelized dict 17 | such that snake_dict_to_camel_dict(camel_dict_to_snake_dict(x)) == x 18 | 19 | This is achieved through mapping e.g. HTTPEndpoint to h_t_t_p_endpoint 20 | where the default would be simply http_endpoint, which gets turned into 21 | HttpEndpoint if recamelized. 22 | 23 | ignore_list is used to avoid converting a sub-tree of a dict. This is 24 | particularly important for tags, where keys are case-sensitive. We convert 25 | the 'Tags' key but nothing below. 26 | """ 27 | 28 | def value_is_list(camel_list): 29 | 30 | checked_list = [] 31 | for item in camel_list: 32 | if isinstance(item, dict): 33 | checked_list.append(camel_dict_to_snake_dict(item, reversible)) 34 | elif isinstance(item, list): 35 | checked_list.append(value_is_list(item)) 36 | else: 37 | checked_list.append(item) 38 | 39 | return checked_list 40 | 41 | snake_dict = {} 42 | for k, v in camel_dict.items(): 43 | if isinstance(v, dict) and k not in ignore_list: 44 | snake_dict[_camel_to_snake(k, reversible=reversible)] = camel_dict_to_snake_dict(v, reversible) 45 | elif isinstance(v, list) and k not in ignore_list: 46 | snake_dict[_camel_to_snake(k, reversible=reversible)] = value_is_list(v) 47 | else: 48 | snake_dict[_camel_to_snake(k, reversible=reversible)] = v 49 | 50 | return snake_dict 51 | 52 | 53 | def snake_dict_to_camel_dict(snake_dict, capitalize_first=False): 54 | """ 55 | Perhaps unexpectedly, snake_dict_to_camel_dict returns dromedaryCase 56 | rather than true CamelCase. Passing capitalize_first=True returns 57 | CamelCase. The default remains False as that was the original implementation 58 | """ 59 | 60 | def camelize(complex_type, capitalize_first=False): 61 | if complex_type is None: 62 | return 63 | new_type = type(complex_type)() 64 | if isinstance(complex_type, dict): 65 | for key in complex_type: 66 | new_type[_snake_to_camel(key, capitalize_first)] = camelize(complex_type[key], capitalize_first) 67 | elif isinstance(complex_type, list): 68 | for i in range(len(complex_type)): 69 | new_type.append(camelize(complex_type[i], capitalize_first)) 70 | else: 71 | return complex_type 72 | return new_type 73 | 74 | return camelize(snake_dict, capitalize_first) 75 | 76 | 77 | def _snake_to_camel(snake, capitalize_first=False): 78 | if capitalize_first: 79 | return ''.join(x.capitalize() or '_' for x in snake.split('_')) 80 | else: 81 | return snake.split('_')[0] + ''.join(x.capitalize() or '_' for x in snake.split('_')[1:]) 82 | 83 | 84 | def _camel_to_snake(name, reversible=False): 85 | 86 | def prepend_underscore_and_lower(m): 87 | return '_' + m.group(0).lower() 88 | 89 | if reversible: 90 | upper_pattern = r'[A-Z]' 91 | else: 92 | # Cope with pluralized abbreviations such as TargetGroupARNs 93 | # that would otherwise be rendered target_group_ar_ns 94 | upper_pattern = r'[A-Z]{3,}s$' 95 | 96 | s1 = re.sub(upper_pattern, prepend_underscore_and_lower, name) 97 | # Handle when there was nothing before the plural_pattern 98 | if s1.startswith("_") and not name.startswith("_"): 99 | s1 = s1[1:] 100 | if reversible: 101 | return s1 102 | 103 | # Remainder of solution seems to be https://stackoverflow.com/a/1176023 104 | first_cap_pattern = r'(.)([A-Z][a-z]+)' 105 | all_cap_pattern = r'([a-z0-9])([A-Z]+)' 106 | s2 = re.sub(first_cap_pattern, r'\1_\2', s1) 107 | return re.sub(all_cap_pattern, r'\1_\2', s2).lower() 108 | 109 | 110 | def dict_merge(a, b): 111 | '''recursively merges dicts. not just simple a['key'] = b['key'], if 112 | both a and b have a key whose value is a dict then dict_merge is called 113 | on both values and the result stored in the returned dictionary.''' 114 | if not isinstance(b, dict): 115 | return b 116 | result = deepcopy(a) 117 | for k, v in b.items(): 118 | if k in result and isinstance(result[k], dict): 119 | result[k] = dict_merge(result[k], v) 120 | else: 121 | result[k] = deepcopy(v) 122 | return result 123 | 124 | 125 | def recursive_diff(dict1, dict2): 126 | left = dict((k, v) for (k, v) in dict1.items() if k not in dict2) 127 | right = dict((k, v) for (k, v) in dict2.items() if k not in dict1) 128 | for k in (set(dict1.keys()) & set(dict2.keys())): 129 | if isinstance(dict1[k], dict) and isinstance(dict2[k], dict): 130 | result = recursive_diff(dict1[k], dict2[k]) 131 | if result: 132 | left[k] = result[0] 133 | right[k] = result[1] 134 | elif dict1[k] != dict2[k]: 135 | left[k] = dict1[k] 136 | right[k] = dict2[k] 137 | if left or right: 138 | return left, right 139 | else: 140 | return None 141 | -------------------------------------------------------------------------------- /tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Install Azure Python SDK required by modules. 3 | pip: 4 | requirements: "{{ role_path }}/files/requirements-azure.txt" 5 | extra_args: -I 6 | when: skip_azure_sdk 7 | 8 | - debug: 9 | msg: 10 | - "Your Ansible version is lower than 2.5.0" 11 | - "You may need to perform additional steps to install this roles:" 12 | - " sudo pip install -r {{ role_path }}/files/requirements-azure.txt" 13 | - "or" 14 | - " pip install --user -r {{ role_path }}/files/requirements-azure.txt" 15 | - "depending on your ansible setup." 16 | when: ansible_version.full < "2.5.0" 17 | -------------------------------------------------------------------------------- /tests/integration/clear_all.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | tasks: 4 | - name: query 5 | azure_rm_resourcegroup_facts: 6 | register: output 7 | - name: delete 8 | azure_rm_resourcegroup: 9 | name: "{{ item }}" 10 | state: absent 11 | force: yes 12 | with_items: "{{ output | json_query('ansible_facts.azure_resourcegroups[*].name') | select('match', 'asb-roletest') | list }}" 13 | async: 10000 14 | poll: 0 15 | register: jobs 16 | - name: Wait for complete 17 | async_status: jid={{ item.ansible_job_id }} 18 | register: job 19 | until: job.finished 20 | retries: 300 21 | with_items: "{{ jobs.results }}" -------------------------------------------------------------------------------- /tests/integration/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | roles: 4 | - { role: azure_preview_modules } 5 | vars_files: 6 | - ~/arg.json 7 | tasks: 8 | - name: Create resource group 9 | azure_rm_resourcegroup: 10 | name: "{{ item }}" 11 | location: eastus 12 | with_items: 13 | - "{{ resource_group }}" 14 | - "{{ resource_group_secondary }}" 15 | - name: run integration test 16 | block: 17 | - include_role: 18 | name: "./targets/{{ test }}" 19 | always: 20 | - name: Delete resource group 21 | azure_rm_resourcegroup: 22 | name: "{{ item }}" 23 | state: absent 24 | force: True 25 | with_items: 26 | - "{{ resource_group }}" 27 | - "{{ resource_group_secondary }}" 28 | async: 5000 29 | poll: 0 30 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_acs/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | destructive 3 | unsupported 4 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_acs/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_aks/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | unsupported 3 | destructive -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_aks/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_appgateway/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | destructive 3 | shippable/azure/group6 4 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_appgateway/files/cert1.txt: -------------------------------------------------------------------------------- 1 | MIIMAjCCCeqgAwIBAgITLQAAMpnXBx230XCKQgAAAAAymTANBgkqhkiG9w0BAQsFADCBizELMAkGA1UEBhMCVVMxEzARBgNVBAgTCldhc2hpbmd0b24xEDAOBgNVBAcTB1JlZG1vbmQxHjAcBgNVBAoTFU1pY3Jvc29mdCBDb3Jwb3JhdGlvbjEVMBMGA1UECxMMTWljcm9zb2Z0IElUMR4wHAYDVQQDExVNaWNyb3NvZnQgSVQgVExTIENBIDUwHhcNMTcwNzIwMTc0NzA4WhcNMTkwNzEwMTc0NzA4WjAXMRUwEwYDVQQDEwx3d3cuYmluZy5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC6jsg+/7DlIrdgFOcaDlK3RQ9sIgkJsgpj+ZxAbIe3ziyimIxjVlHX87pqgXcNhaYNbCFD0iPm+aUfbv4GDTLR+AIr8eSegqxZ+CBToYM67NhpVYra1KAvY4XgqxorO4FB9IWYJRqhI3SZeZ3lLK5t9XuUMicG8l52nJfpPdXXvBca2wUCq8FHEObG81vJzESA0htLLPTjdUWBQnXPiW5bqzlGHzzv8ISV6jtDLNNa5JRlhSlXho+6pCedhNF7MP4yTaantPvAELLRWX13VhjgoCcRCCu0s8rxW5DuVWl2Pb2iw35MFnNWlcoVwq0AjAfGA+xEba/WLid6qfkQctYjAgMBAAGjggfQMIIHzDAdBgNVHQ4EFgQUCYflhSl4MCAls91+3GztpSmoA3AwCwYDVR0PBAQDAgSwMB8GA1UdIwQYMBaAFAj+JZ906ocEwry7jqg4XzPG0WxlMIGsBgNVHR8EgaQwgaEwgZ6ggZuggZiGS2h0dHA6Ly9tc2NybC5taWNyb3NvZnQuY29tL3BraS9tc2NvcnAvY3JsL01pY3Jvc29mdCUyMElUJTIwVExTJTIwQ0ElMjA1LmNybIZJaHR0cDovL2NybC5taWNyb3NvZnQuY29tL3BraS9tc2NvcnAvY3JsL01pY3Jvc29mdCUyMElUJTIwVExTJTIwQ0ElMjA1LmNybDCBhQYIKwYBBQUHAQEEeTB3MFEGCCsGAQUFBzAChkVodHRwOi8vd3d3Lm1pY3Jvc29mdC5jb20vcGtpL21zY29ycC9NaWNyb3NvZnQlMjBJVCUyMFRMUyUyMENBJTIwNS5jcnQwIgYIKwYBBQUHMAGGFmh0dHA6Ly9vY3NwLm1zb2NzcC5jb20wPgYJKwYBBAGCNxUHBDEwLwYnKwYBBAGCNxUIh9qGdYPu2QGCyYUbgbWeYYX062CBXYTS30KC55N6AgFkAgEQMB0GA1UdJQQWMBQGCCsGAQUFBwMCBggrBgEFBQcDATBNBgNVHSAERjBEMEIGCSsGAQQBgjcqATA1MDMGCCsGAQUFBwIBFidodHRwOi8vd3d3Lm1pY3Jvc29mdC5jb20vcGtpL21zY29ycC9jcHMwJwYJKwYBBAGCNxUKBBowGDAKBggrBgEFBQcDAjAKBggrBgEFBQcDATCCBW0GA1UdEQSCBWQwggVgggx3d3cuYmluZy5jb22CEGRpY3QuYmluZy5jb20uY26CEyoucGxhdGZvcm0uYmluZy5jb22CCiouYmluZy5jb22CCGJpbmcuY29tghZpZW9ubGluZS5taWNyb3NvZnQuY29tghMqLndpbmRvd3NzZWFyY2guY29tghljbi5pZW9ubGluZS5taWNyb3NvZnQuY29tghEqLm9yaWdpbi5iaW5nLmNvbYINKi5tbS5iaW5nLm5ldIIOKi5hcGkuYmluZy5jb22CGGVjbi5kZXYudmlydHVhbGVhcnRoLm5ldIINKi5jbi5iaW5nLm5ldIINKi5jbi5iaW5nLmNvbYIQc3NsLWFwaS5iaW5nLmNvbYIQc3NsLWFwaS5iaW5nLm5ldIIOKi5hcGkuYmluZy5uZXSCDiouYmluZ2FwaXMuY29tgg9iaW5nc2FuZGJveC5jb22CFmZlZWRiYWNrLm1pY3Jvc29mdC5jb22CG2luc2VydG1lZGlhLmJpbmcub2ZmaWNlLm5ldIIOci5iYXQuYmluZy5jb22CECouci5iYXQuYmluZy5jb22CEiouZGljdC5iaW5nLmNvbS5jboIPKi5kaWN0LmJpbmcuY29tgg4qLnNzbC5iaW5nLmNvbYIQKi5hcHBleC5iaW5nLmNvbYIWKi5wbGF0Zm9ybS5jbi5iaW5nLmNvbYINd3AubS5iaW5nLmNvbYIMKi5tLmJpbmcuY29tgg9nbG9iYWwuYmluZy5jb22CEXdpbmRvd3NzZWFyY2guY29tgg5zZWFyY2gubXNuLmNvbYIRKi5iaW5nc2FuZGJveC5jb22CGSouYXBpLnRpbGVzLmRpdHUubGl2ZS5jb22CDyouZGl0dS5saXZlLmNvbYIYKi50MC50aWxlcy5kaXR1LmxpdmUuY29tghgqLnQxLnRpbGVzLmRpdHUubGl2ZS5jb22CGCoudDIudGlsZXMuZGl0dS5saXZlLmNvbYIYKi50My50aWxlcy5kaXR1LmxpdmUuY29tghUqLnRpbGVzLmRpdHUubGl2ZS5jb22CCzNkLmxpdmUuY29tghNhcGkuc2VhcmNoLmxpdmUuY29tghRiZXRhLnNlYXJjaC5saXZlLmNvbYIVY253ZWIuc2VhcmNoLmxpdmUuY29tggxkZXYubGl2ZS5jb22CDWRpdHUubGl2ZS5jb22CEWZhcmVjYXN0LmxpdmUuY29tgg5pbWFnZS5saXZlLmNvbYIPaW1hZ2VzLmxpdmUuY29tghFsb2NhbC5saXZlLmNvbS5hdYIUbG9jYWxzZWFyY2gubGl2ZS5jb22CFGxzNGQuc2VhcmNoLmxpdmUuY29tgg1tYWlsLmxpdmUuY29tghFtYXBpbmRpYS5saXZlLmNvbYIObG9jYWwubGl2ZS5jb22CDW1hcHMubGl2ZS5jb22CEG1hcHMubGl2ZS5jb20uYXWCD21pbmRpYS5saXZlLmNvbYINbmV3cy5saXZlLmNvbYIcb3JpZ2luLmNud2ViLnNlYXJjaC5saXZlLmNvbYIWcHJldmlldy5sb2NhbC5saXZlLmNvbYIPc2VhcmNoLmxpdmUuY29tghJ0ZXN0Lm1hcHMubGl2ZS5jb22CDnZpZGVvLmxpdmUuY29tgg92aWRlb3MubGl2ZS5jb22CFXZpcnR1YWxlYXJ0aC5saXZlLmNvbYIMd2FwLmxpdmUuY29tghJ3ZWJtYXN0ZXIubGl2ZS5jb22CE3dlYm1hc3RlcnMubGl2ZS5jb22CFXd3dy5sb2NhbC5saXZlLmNvbS5hdYIUd3d3Lm1hcHMubGl2ZS5jb20uYXUwDQYJKoZIhvcNAQELBQADggIBADTpW/UWeupk40OP6k4yxihKStswxwqPAfMRmx4XyqmTAawAKRNM+6EZth1BQdPdOplwRTvs69kkmUHJH+ZjYXBezEACWkzEiNUQnzkRWajdSQIz08Ubj/mBD6U8xLYD+NXgiB0xNWabd8aiPsqPaj6I3qkNw4JvtgtHZQG1zlwC5/Lu6yV3DM3sKpQMyBmOnX6nVUiS0MTOzLgZOQzRk07nO7EXWGcKTmDBjE8cqv5IA/jQ6gtaxCI5pDxfXK4ct7oQyoChfxOXcEDKMmMndFmg9ch5c4an/FRM2cgzDfjR01A71LNUpLUdOjNV0T+ZEStqEpdyDFfjrHGDtzLyqEz3iyvvQFyjmlGh6OtZXwjCPpnVSrKCmfJKio0kUxyq+6t5tZAQbPVgFKiMrVnU+sgvmNVip1toijyz8vMVCkwJ2G++7xjJukoELMxZ50W4/SAMZLy1Asx02NBwYCu9+CTQPVnmPe7rmxhlQRBOfDNa1+5jwRHY64YudEzKhWR1uqS3ABd/fk+TL86yuNYGAgxnOm1FtOGieRgViV3+NzC+bDbuUOtmbD/GvDGmRwJRcCTHL7jBmkHePh2ABY93NE/IbkaDP6l1Kw98AfqkzSUxhqHXuThe7KIoX9/0zv4AA1WZFis1QvAG7dpl9eio6vCdC/73HvBAlqRL+7Mb1uu0 2 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_appgateway/files/cert2.txt: -------------------------------------------------------------------------------- 1 | MIIKsQIBAzCCCm0GCSqGSIb3DQEHAaCCCl4EggpaMIIKVjCCBg8GCSqGSIb3DQEHAaCCBgAEggX8MIIF+DCCBfQGCyqGSIb3DQEMCgECoIIE/jCCBPowHAYKKoZIhvcNAQwBAzAOBAj37r+wRsc6/gICB9AEggTY1V5HNscO+2bZb7JSMme1ljERe7DCiRE2cJsPKlwW2/NEiSqAUX7gXKK0ISr6Dto71rFdza0uPwbcQoPN1QwkJHSAkxWg4OcAx2kf7077tlHhf5rzxTn5V3wXM0Q3h6NsDjSqSHjYVISIiXItUzlDaBpMY/NUFNCTyJR5I91MWsljrJ/bQaAIo57HJR9nzjY5DaBA9P3bAhmX5LJRGsJWoCEaGeeVQ3Yn6yD06ordiJnf6dNxqQGN+o2x54gqfmw+RnoC2f8VAsTIfb3fwJPKdg2JiJIa6Ms2Sc8VR7VGmZt34qZwTPBrzeqJjtIMT41bBae46lmma8ypYwErqzOYSrHqXPXzaxlloYy81HYWAsJTWyBxTsVBcLom5m9ru79+SKG35xY1wSkzZmWMNFfVRFCJy/X+h2ErrGYjogCHYaIUmiosvUccwRUXGU083ul9iTcz/Dl79VBz63OFX/CnZMDTQ8ugbqpvW78pAnBU0r8MUubHciD1sJG2zmMlxCAzan6BLm9OMyhTNIbzYOjQQw99MQQys/ZeyNLqTFHTeGRfU2ewqgHjbH2PYCQfjipXSmdmsSsGxlLA9AOtwAk3QKJ77P03HRGOeXmy/I4iIHuIQuaQcjfprNR2fI36dftDo7U4gvRQHkiti+zNVqpi3/hIc2k7O8bCcMeSvfIlUvWIPUrUceZmpVPpLdcFcQbN9+1nZwiFYydOhrPnlp40rSO3RM08EmQUfRYt8fwRFcoWBX3b411vOqZVGeMfMtThMYI53R4Cmh5tUp93FslHNmIfnuewhHfIm+vtCicLcW6TaC2l4EqmNf0flK5m5nANotCfqj87MPsB83qPwol/91BTKaxuH2hKrZDgU1ibPE8NhzBinp2ANi0BHK3Sl0CsC2MPyZpFY+4MWvk/SI9ex4VsKYKmhubOFkhDLLBZH0UEmUdNTH4Gd76GsDnfI9arR2ctM9ecTPeu74hKiHlNZhc4U3TX20FBeqF5tZYnfCLRhvdiNM9AlwEKqqQEe0W7PrALcNVdjhJl0X9+0Br28E3RKZQRITWa10Vjmh0WcYrzEQ3/qEZYbqVpHMp+kdrHxB65v0zlGxjdwyKzafLzqYXmaHOyVlFnkayNaAkVVxOCzNrxB9HfhjvhjWafeMvA0p7O9CxTD2xPEhUaHQ5j7L8F0alfMYcg73SdGHAcY6AV8+eh0jqs3IF68cquXOl5Bm8uYKRjtgl9nY6hYc0lRDdtFHZo8ayNDr0cltNU7XZTaCKVNSDTRn92rTNJY0E3PD5HSKcRi58WJrIgEDGasyleRkRlGTY7512Qut0rg7m1Eyp6MK+sNmSSA7cR70pH7I1dwy4VrJMODdMH11y1QJF2EQWQdN00Js54tjVgTIO3btb5N7jhNYpRedv0a4UZ8TdDI4ZMCMf3SdP3xbQ06M1pFrS8WQzwp3KTk8vmnseJL84n0hC8KqWmGmTWHTa9dwmopeM6Xh/Jm1pkrgrloxqfSlscGEJE0plAnk1mLx29FxswfZ6a7pNKg7CydK4SiDkqM+pWukPbgKODqYPUvS0nk3RGGXvZSIzTbvm77tF+MqXOb6Rn+IflIk4yZsjIBQA0I/bQ78YDzXUVsrtAi9waRoCZs+L48NUy4zpKn25FMqkrziVn+TGB4jANBgkrBgEEAYI3EQIxADATBgkqhkiG9w0BCRUxBgQEAQAAADBdBgkqhkiG9w0BCRQxUB5OAHQAZQAtAGMANwBmADEAYwBhADYAMQAtADQAOAA1ADQALQA0ADgAZQBmAC0AYQAwADgANQAtAGQANABhADIAZgA1AGYAOAAyADcAZAAxMF0GCSsGAQQBgjcRATFQHk4ATQBpAGMAcgBvAHMAbwBmAHQAIABTAHQAcgBvAG4AZwAgAEMAcgB5AHAAdABvAGcAcgBhAHAAaABpAGMAIABQAHIAbwB2AGkAZABlAHIwggQ/BgkqhkiG9w0BBwagggQwMIIELAIBADCCBCUGCSqGSIb3DQEHATAcBgoqhkiG9w0BDAEDMA4ECFcAfrkm3ibUAgIH0ICCA/hlBog8GY9GCpucTwAxBGa0cOGQ29EK0xfrmY/Dv59IeJhRr47Mvl1XNk5PIInb64RsOVr00jrJAbfgLLKMBowcQLT7k6jGbGBdOzC57x9DNP0VuHsIIym0Z+SpJgEWBbtdBTGzgNw/YoXYxT4Rtka9ScSyCFjmmCzXz7bGLqC7yrGb7BzigQ9y4u4bg0pf75pERzN8rJM29Ob2IydkgARfpmbNKjdMCtD6dI7tafG2lQfUX6sgQY+Sy5HTz3ansN8X1yv2WQTu8Drxf2ce55v4WrFbPTTND94ubgDt7jvbCe1DuNP1DAYmQ5pbW0GGqF1x2csK5WWD7J8FD08VaQFM8y8pGIUeUkN4rYU3eTdTAQe+ec2hOr9QZn1Sb/p5u4KqIMn4MSCQ8EU0gXa2JETdUjXPr/5JFZTidJYagRyMIkYnwg9uusikctulaBsHMBKMYQ0Z19CEbcd2phdoxWTrtp7kwwjnu64zPgE6ALe9yJOT8AFEB6H1c16Z+aPGj9hbhkh6tcdGWUvzDYq08wjKjP3nA78StIisUmeZPfAXJUquPzRZr0pmcwYWfyP54TdC2BvPlLW/QXVV44IGxUdLuI6mz4p+O2+xKu9QMFwdcpij2ZK4uMrBLDo7ZoTQ4rBRnn471AMUKgeP0D5tbl8PygUU1RqHv34ok3fwx0WglzdMQJyt53PiPWW4lipwUtUfd0eD8CXoMccf8XJmugVUBCD1wQsyCW6RrR9RX8HXVBrm5O2HKfJcQYznl3qHqXb6ofvbOQ3S+v0ALN+sma8Tn6JceVTAOH+UuMdcu0FIDYnpmrvMecnJ2kbs1Y35mj4rSJyP5PGLg+ygb9VlBPwCCem/jHL+YivN38+0oWqfn2slyI4FNKX+5U8M6xpiEaq6McKwKZC1d51A4dUdMAkO2d1Z6rVjqhKeqE6HWD9A0cyPBFZpNQskUfNDW8qILLEfEjhBi+s1LkHzKDykCN/ReFfRiQS84DekoC59cymM8Hs1geMWCMFWfut4HTd7ItYaiJz5qpYVY4U/8myhyWnrktjLjQ6OkdM9bBDIpRHj95MYEC26NlWQZwjk+yynPTZf0w5p2Ok6Dq2shJFykuJ1VkelgvsPe8qMa55Wp11dpREIFzXouPXNP/vFpziZcl1OKTd7Dwa+ruQFRfsoZGzupsBOYxrmYqr6kOm5mzMW0HAlsWwl5mY2aSQMvXBE6k32xTkPIlIp763Ee4m6cmx4+SDcO5D+a9t05QY4JmssL+x3T9qsbXSXDPEsg0cfVvuQYy9AYkIFOes4G45IagRAvhQQj9bEh8kTvp8CFDDtIrbWjX50zreb51VcAcEkIOLyROtIdLem0zA7MB8wBwYFKw4DAhoEFC0i4I5iwNYQug0vTVS0JC/Qm+/NBBTsUM0D9QxIZYUi+qlDy14sOcEaUwICB9A= 2 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_appgateway/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_appserviceplan/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group4 3 | unstable 4 | destructive 5 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_appserviceplan/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_appserviceplan/tasks/main.yml: -------------------------------------------------------------------------------- 1 | - name: Prepare facts 2 | set_fact: 3 | linux_plan_resource_group: "{{ resource_group_secondary }}" 4 | win_plan_name: "{{ (resource_prefix | replace('-','x'))[-8:] }}winplan" 5 | linux_plan_name: "{{ (resource_prefix | replace('-','x'))[-8:] }}linplan" 6 | 7 | - name: create a windows plan 8 | azure_rm_appserviceplan: 9 | name: "{{ win_plan_name }}1" 10 | resource_group: "{{ resource_group }}" 11 | sku: B1 12 | register: output 13 | 14 | - name: assert app service was created 15 | assert: 16 | that: 17 | - output.changed 18 | - output.id 19 | 20 | - name: create a linux plan 21 | azure_rm_appserviceplan: 22 | resource_group: "{{ linux_plan_resource_group }}" 23 | name: "{{ linux_plan_name }}1" 24 | sku: S1 25 | is_linux: true 26 | number_of_workers: 1 27 | register: output 28 | 29 | - name: assert app service was created 30 | assert: 31 | that: 32 | - output.changed 33 | - output.id 34 | 35 | - name: get app service plan by name 36 | azure_rm_appserviceplan_facts: 37 | resource_group: "{{ linux_plan_resource_group }}" 38 | name: "{{ linux_plan_name }}1" 39 | register: output 40 | 41 | - name: assert is_linux is True 42 | assert: 43 | that: 44 | - output.appserviceplans | length == 1 45 | - output.appserviceplans[0].is_linux == True 46 | 47 | - name: create linux app service plan idempotent 48 | azure_rm_appserviceplan: 49 | resource_group: "{{ linux_plan_resource_group }}" 50 | name: "{{ linux_plan_name }}1" 51 | sku: S1 52 | is_linux: true 53 | number_of_workers: 1 54 | register: output 55 | 56 | - name: assert app service was created 57 | assert: 58 | that: not output.changed 59 | 60 | - name: update a windows plan sku 61 | azure_rm_appserviceplan: 62 | name: "{{ win_plan_name }}1" 63 | resource_group: "{{ resource_group }}" 64 | sku: B2 65 | register: output 66 | 67 | - name: assert app service was updated 68 | assert: 69 | that: 70 | - output.changed 71 | 72 | - name: update a linux plan number of workers 73 | azure_rm_appserviceplan: 74 | resource_group: "{{ linux_plan_resource_group }}" 75 | name: "{{ linux_plan_name }}1" 76 | sku: S1 77 | is_linux: true 78 | number_of_workers: 2 79 | register: output 80 | 81 | - name: assert app service was updated 82 | assert: 83 | that: 84 | - output.changed 85 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_automationaccount/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group4 3 | destructive 4 | azure_rm_automationaccount_facts 5 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_automationaccount/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_automationaccount/tasks/main.yml: -------------------------------------------------------------------------------- 1 | - name: Prepare random number 2 | set_fact: 3 | rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}" 4 | name: "account{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}" 5 | run_once: yes 6 | 7 | - name: Create automation account 8 | azure_rm_automationaccount: 9 | name: "{{ name }}" 10 | resource_group: "{{ resource_group }}" 11 | check_mode: yes 12 | register: output 13 | 14 | - assert: 15 | that: 16 | - output.changed 17 | 18 | - name: Create automation account 19 | azure_rm_automationaccount: 20 | name: "{{ name }}" 21 | resource_group: "{{ resource_group }}" 22 | register: output 23 | 24 | - assert: 25 | that: 26 | - output.changed 27 | - output.id 28 | 29 | - name: Create automation account 30 | azure_rm_automationaccount: 31 | name: "{{ name }}" 32 | resource_group: "{{ resource_group }}" 33 | register: output 34 | 35 | - assert: 36 | that: 37 | - not output.changed 38 | 39 | - name: Get automation account 40 | azure_rm_automationaccount_facts: 41 | name: "{{ name }}" 42 | resource_group: "{{ resource_group }}" 43 | list_statistics: yes 44 | list_usages: yes 45 | list_keys: yes 46 | register: facts 47 | 48 | - assert: 49 | that: 50 | - facts.automation_accounts | length == 1 51 | - facts.automation_accounts[0].keys 52 | - facts.automation_accounts[0].usages 53 | - facts.automation_accounts[0].statistics 54 | - facts.automation_accounts[0].state == "Ok" 55 | 56 | - name: Delete account 57 | azure_rm_automationaccount: 58 | name: "{{ name }}" 59 | resource_group: "{{ resource_group }}" 60 | state: absent 61 | check_mode: yes 62 | register: output 63 | 64 | - assert: 65 | that: 66 | - output.changed 67 | 68 | - name: Delete account 69 | azure_rm_automationaccount: 70 | name: "{{ name }}" 71 | resource_group: "{{ resource_group }}" 72 | state: absent 73 | register: output 74 | 75 | - assert: 76 | that: 77 | - output.changed 78 | 79 | - name: Delete account 80 | azure_rm_automationaccount: 81 | name: "{{ name }}" 82 | resource_group: "{{ resource_group }}" 83 | state: absent 84 | register: output 85 | 86 | - assert: 87 | that: 88 | - not output.changed 89 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_autoscale/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group5 3 | destructive 4 | azure_rm_autoscale 5 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_autoscale/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_availabilityset/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group2 3 | destructive 4 | azure_rm_availalibityset_facts 5 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_availabilityset/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_availabilityset/tasks/main.yml: -------------------------------------------------------------------------------- 1 | - name: Create an availability set with default options 2 | azure_rm_availabilityset: 3 | name: myavailabilityset1 4 | resource_group: "{{ resource_group }}" 5 | tags: 6 | tag1: testtag 7 | register: results 8 | 9 | - assert: 10 | that: results.changed 11 | 12 | - name: Create an availability set with advanced options 13 | azure_rm_availabilityset: 14 | name: myavailabilityset2 15 | resource_group: "{{ resource_group }}" 16 | platform_update_domain_count: 5 17 | platform_fault_domain_count: 2 18 | sku: Aligned 19 | register: results 20 | 21 | - assert: 22 | that: results.changed 23 | 24 | - name: Modify availabilty set immutable options - no changes, fail for immutable options 25 | azure_rm_availabilityset: 26 | name: myavailabilityset2 27 | resource_group: "{{ resource_group }}" 28 | platform_update_domain_count: 2 29 | platform_fault_domain_count: 2 30 | sku: Aligned 31 | register: results 32 | ignore_errors: yes 33 | 34 | - assert: 35 | that: 36 | - not results.changed 37 | - results.msg == 'You tried to change platform_update_domain_count but is was unsuccessful. An Availability Set is immutable, except tags' 38 | 39 | - name: Modify availabilty set immutable options and set tags - change tags and fail for immutable options 40 | azure_rm_availabilityset: 41 | name: myavailabilityset2 42 | resource_group: "{{ resource_group }}" 43 | platform_update_domain_count: 2 44 | platform_fault_domain_count: 2 45 | sku: Aligned 46 | tags: 47 | test1: modified 48 | register: results 49 | ignore_errors: yes 50 | 51 | - assert: 52 | that: 53 | - not results.changed 54 | - results.msg == 'You tried to change platform_update_domain_count but is was unsuccessful. An Availability Set is immutable, except tags' 55 | 56 | - name: Modify availabilty set options to update tags 57 | azure_rm_availabilityset: 58 | name: myavailabilityset2 59 | resource_group: "{{ resource_group }}" 60 | platform_update_domain_count: 5 61 | platform_fault_domain_count: 2 62 | sku: Aligned 63 | tags: 64 | test2: modified 65 | register: results 66 | 67 | - assert: 68 | that: 69 | - results.state.tags.test2 == 'modified' 70 | 71 | - name: Create availability set with incorrect fault domain parameter 72 | azure_rm_availabilityset: 73 | name: myavailabilityset3 74 | resource_group: "{{ resource_group }}" 75 | platform_update_domain_count: 5 76 | platform_fault_domain_count: 4 77 | sku: Aligned 78 | register: results 79 | ignore_errors: yes 80 | 81 | - assert: 82 | { that: "'The specified fault domain count 4 must fall in the range 1 to' in results['msg']" } 83 | 84 | - name: Test check_mode 85 | azure_rm_availabilityset: 86 | name: myavailabilityset2 87 | resource_group: "{{ resource_group }}" 88 | platform_update_domain_count: 5 89 | platform_fault_domain_count: 2 90 | sku: Aligned 91 | tags: 92 | checktest1: modified1 93 | checktest2: modified2 94 | check_mode: yes 95 | register: results 96 | 97 | - assert: 98 | that: 99 | - not results.changed 100 | - results.state.tags.checktest1 == 'modified1' 101 | 102 | # 103 | # azure_rm_availabilityset_facts tests 104 | # 105 | - name: Get facts for created availability set 106 | azure_rm_availabilityset_info: 107 | name: myavailabilityset2 108 | resource_group: "{{ resource_group }}" 109 | register: results 110 | 111 | - debug: 112 | var: results 113 | 114 | - assert: 115 | that: 116 | - not results.changed 117 | - not results.failed 118 | - results.ansible_info.azure_availabilitysets[0].properties.platformFaultDomainCount == 2 119 | - results.ansible_info.azure_availabilitysets[0].properties.platformUpdateDomainCount == 5 120 | - results.ansible_info.azure_availabilitysets[0].sku == 'Aligned' 121 | 122 | 123 | - name: Delete an availability set 124 | azure_rm_availabilityset: 125 | name: myavailabilityset1 126 | resource_group: "{{ resource_group }}" 127 | state: absent 128 | 129 | - name: Delete an availability set 130 | azure_rm_availabilityset: 131 | name: myavailabilityset2 132 | resource_group: "{{ resource_group }}" 133 | state: absent 134 | 135 | - name: Delete an availability set 136 | azure_rm_availabilityset: 137 | name: myavailabilityset3 138 | resource_group: "{{ resource_group }}" 139 | state: absent 140 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_azurefirewall/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group2 3 | destructive 4 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_azurefirewall/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_batchaccount/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | destructive 3 | shippable/azure/group2 4 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_batchaccount/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_batchaccount/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # ---------------------------------------------------------------------------- 3 | # 4 | # *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** 5 | # 6 | # ---------------------------------------------------------------------------- 7 | # 8 | # This file is automatically generated by Magic Modules and manual 9 | # changes will be clobbered when the file is regenerated. 10 | # 11 | # 12 | # ---------------------------------------------------------------------------- 13 | - name: Prepare random number 14 | set_fact: 15 | storage_account_name: "st{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}" 16 | batch_account_name: "ba{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}" 17 | run_once: yes 18 | 19 | - name: Create Storage Account 20 | azure_rm_storageaccount: 21 | resource_group: "{{ resource_group }}" 22 | name: "{{ storage_account_name }}" 23 | location: eastus 24 | account_type: Standard_LRS 25 | 26 | - name: Create Batch Account 27 | azure_rm_batchaccount: 28 | resource_group: "{{ resource_group }}" 29 | name: "{{ batch_account_name }}" 30 | location: eastus 31 | auto_storage_account: 32 | name: "{{ storage_account_name }}" 33 | pool_allocation_mode: batch_service 34 | register: output 35 | 36 | - name: Assert the resource was created 37 | assert: 38 | that: 39 | - output.changed 40 | 41 | - name: Create Batch Account -- idempotent 42 | azure_rm_batchaccount: 43 | resource_group: "{{ resource_group }}" 44 | name: "{{ batch_account_name }}" 45 | location: eastus 46 | auto_storage_account: 47 | name: "{{ storage_account_name }}" 48 | pool_allocation_mode: batch_service 49 | register: output 50 | 51 | - name: Assert the resource was created 52 | assert: 53 | that: 54 | - not output.changed 55 | 56 | - name: Delete Batch Account 57 | azure_rm_batchaccount: 58 | resource_group: "{{ resource_group }}" 59 | name: "{{ batch_account_name }}" 60 | location: eastus 61 | auto_storage_account: 62 | name: "{{ storage_account_name }}" 63 | pool_allocation_mode: batch_service 64 | state: absent 65 | register: output 66 | 67 | - name: Assert that state has changed 68 | assert: 69 | that: 70 | - output.changed 71 | 72 | - name: Clean up storage account 73 | azure_rm_storageaccount: 74 | resource_group: "{{ resource_group }}" 75 | name: "{{ storage_account_name }}" 76 | state: absent 77 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_cdnprofile/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group2 3 | destructive 4 | azure_rm_cdnprofile_facts 5 | azure_rm_cdnendpoint 6 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_cdnprofile/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_containerinstance/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | destructive 3 | shippable/azure/group2 4 | azure_rm_containerinstance_facts 5 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_containerinstance/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_containerregistry/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group2 3 | destructive 4 | azure_rm_containerregistry_facts 5 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_containerregistry/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_containerregistry/tasks/main.yml: -------------------------------------------------------------------------------- 1 | - name: Create an container registry 2 | azure_rm_containerregistry: 3 | name: "acr{{ resource_group | hash('md5') | truncate(7, True, '') }}" 4 | resource_group: "{{ resource_group }}" 5 | location: eastus2 6 | admin_user_enabled: true 7 | sku: Premium 8 | tags: 9 | Release: beta1 10 | Environment: Production 11 | register: output 12 | 13 | - name: Assert the container registry instance is well created 14 | assert: 15 | that: 16 | - output.changed 17 | - output.admin_user_enabled 18 | - output.location == 'eastus2' 19 | - output.sku == 'Premium' 20 | - output.tags['Environment'] == 'Production' 21 | - output.tags['Release'] == 'beta1' 22 | - output.provisioning_state == 'Succeeded' 23 | - output.credentials['password'] is defined 24 | - output.credentials['password2'] is defined 25 | 26 | - name: Update the ACR instance sku, tags and admin_user_enabled 27 | azure_rm_containerregistry: 28 | name: "acr{{ resource_group | hash('md5') | truncate(7, True, '') }}" 29 | resource_group: "{{ resource_group }}" 30 | location: eastus2 31 | admin_user_enabled: false 32 | sku: Standard 33 | tags: 34 | NewTag: newtag 35 | Release: beta1 36 | Environment: Production 37 | register: output 38 | 39 | - name: Create second container registry (to test facts) 40 | azure_rm_containerregistry: 41 | name: "acr{{ resource_group | hash('md5') | truncate(7, True, '') }}sec" 42 | resource_group: "{{ resource_group }}" 43 | location: eastus2 44 | admin_user_enabled: false 45 | sku: Premium 46 | tags: 47 | Release: beta1 48 | Environment: Production 49 | 50 | - name: Assert the ACR instance is well updated 51 | assert: 52 | that: 53 | - output.changed == True 54 | - output.admin_user_enabled == False 55 | - output.sku == 'Standard' 56 | - output.tags['NewTag'] == 'newtag' 57 | - output.credentials | length == 0 58 | - output.credentials['password'] is not defined 59 | - output.credentials['password2'] is not defined 60 | 61 | - name: Gather facts for single Container Registry 62 | azure_rm_containerregistry_facts: 63 | resource_group: "{{ resource_group }}" 64 | name: "acr{{ resource_group | hash('md5') | truncate(7, True, '') }}" 65 | register: output 66 | 67 | - name: Assert that facts are returned 68 | assert: 69 | that: 70 | - output.changed == False 71 | - output.registries[0]['name'] != None 72 | - output.registries[0]['location'] != None 73 | - output.registries[0]['admin_user_enabled'] != None 74 | - output.registries[0]['sku'] != None 75 | - output.registries[0]['provisioning_state'] != None 76 | - output.registries[0]['login_server'] != None 77 | - output.registries[0]['id'] != None 78 | - output.registries[0]['credentials'] != None 79 | 80 | - name: Gather facts for all Container Registries in the resource group 81 | azure_rm_containerregistry_facts: 82 | resource_group: "{{ resource_group }}" 83 | register: output 84 | 85 | - name: Assert that facts are returned 86 | assert: 87 | that: 88 | - output.changed == False 89 | - output.registries[0]['name'] != None 90 | - output.registries[0]['location'] != None 91 | - output.registries[0]['admin_user_enabled'] != None 92 | - output.registries[0]['sku'] != None 93 | - output.registries[0]['provisioning_state'] != None 94 | - output.registries[0]['login_server'] != None 95 | - output.registries[0]['id'] != None 96 | - output.registries[0]['credentials'] != None 97 | - output.registries[1]['name'] != None 98 | - output.registries[1]['location'] != None 99 | - output.registries[1]['admin_user_enabled'] != None 100 | - output.registries[1]['sku'] != None 101 | - output.registries[1]['provisioning_state'] != None 102 | - output.registries[1]['login_server'] != None 103 | - output.registries[1]['id'] != None 104 | - output.registries[1]['credentials'] != None 105 | 106 | - name: Delete first container registry 107 | azure_rm_containerregistry: 108 | name: "acr{{ resource_group | hash('md5') | truncate(7, True, '') }}" 109 | resource_group: "{{ resource_group }}" 110 | state: absent 111 | 112 | - name: Delete second container registry 113 | azure_rm_containerregistry: 114 | name: "acr{{ resource_group | hash('md5') | truncate(7, True, '') }}sec" 115 | resource_group: "{{ resource_group }}" 116 | state: absent 117 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_cosmosdbaccount/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | destructive 3 | shippable/azure/group1 4 | azure_rm_cosmosdbaccount_facts 5 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_cosmosdbaccount/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_deployment/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | destructive 3 | shippable/azure/group1 4 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_deployment/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_deployment/tasks/main.yml: -------------------------------------------------------------------------------- 1 | - name: Create random dns label 2 | set_fact: 3 | dns_label: "test{{ resource_group | hash('md5') | truncate(16, True, '') + (65535 | random | string) }}" 4 | 5 | - name: Create Azure Deploy 6 | azure_rm_deployment: 7 | resource_group: "{{ resource_group }}" 8 | location: "eastus" 9 | template_link: 'https://raw.githubusercontent.com/Azure/azure-quickstart-templates/d01a5c06f4f1bc03a049ca17bbbd6e06d62657b3/101-vm-simple-linux/azuredeploy.json' 10 | deployment_name: "{{ dns_label }}" 11 | parameters: 12 | adminUsername: 13 | value: chouseknecht 14 | adminPassword: 15 | value: password123! 16 | dnsLabelPrefix: 17 | value: "{{ dns_label }}" 18 | ubuntuOSVersion: 19 | value: "16.04.0-LTS" 20 | register: output 21 | 22 | - name: Add new instance to host group 23 | add_host: 24 | hostname: "{{ item.vm_name }}" 25 | ansible_host: "{{ item['ips'][0].public_ip }}" 26 | ansible_user: chouseknecht 27 | ansible_ssh_pass: password123! 28 | groupname: azure_vms 29 | with_items: "{{ output.deployment.instances }}" 30 | 31 | - name: Get Deployment Facts 32 | azure_rm_deployment_facts: 33 | resource_group: "{{ resource_group }}" 34 | name: "{{ dns_label }}" 35 | register: output 36 | - debug: 37 | var: output 38 | 39 | - name: Assert that values are returned 40 | assert: 41 | that: 42 | - not output.changed 43 | - output.deployments[0]['provisioning_state'] != None 44 | - output.deployments[0]['output_resources'] | length > 0 45 | - output.deployments[0]['outputs'] | length > 0 46 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_devtestlab/aliases: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure_preview_modules/f3bcca65d4c2bb528faf1e7f4fbb7cc3846a8b95/tests/integration/targets/azure_rm_devtestlab/aliases -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_devtestlab/meta/main.yml: -------------------------------------------------------------------------------- 1 | #dependencies: 2 | # - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_devtestlab/tasks/main.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure_preview_modules/f3bcca65d4c2bb528faf1e7f4fbb7cc3846a8b95/tests/integration/targets/azure_rm_devtestlab/tasks/main.yml -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_dnsrecordset/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group1 3 | destructive 4 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_dnsrecordset/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_dnsrecordset/tasks/main.yml: -------------------------------------------------------------------------------- 1 | - name: Create random domain name 2 | set_fact: 3 | domain_name: "{{ resource_group | hash('md5') | truncate(16, True, '') + (65535 | random | string) }}" 4 | 5 | - name: Create a DNS zone 6 | azure_rm_dnszone: 7 | resource_group: "{{ resource_group }}" 8 | name: "{{ domain_name }}.com" 9 | state: present 10 | register: results 11 | 12 | - name: Assert that DNS zone was created 13 | assert: 14 | that: results.changed 15 | 16 | - name: create "A" record set with multiple records 17 | azure_rm_dnsrecordset: 18 | resource_group: "{{ resource_group }}" 19 | relative_name: www 20 | zone_name: "{{ domain_name }}.com" 21 | record_type: A 22 | records: 23 | - entry: 192.168.100.101 24 | - entry: 192.168.100.102 25 | - entry: 192.168.100.103 26 | register: results 27 | 28 | - name: Assert that A record set was created 29 | assert: 30 | that: results.changed 31 | 32 | - name: re-run "A" record with same values 33 | azure_rm_dnsrecordset: 34 | resource_group: "{{ resource_group }}" 35 | relative_name: www 36 | zone_name: "{{ domain_name }}.com" 37 | record_type: A 38 | records: 39 | - entry: 192.168.100.101 40 | - entry: 192.168.100.102 41 | - entry: 192.168.100.103 42 | register: results 43 | 44 | - name: Assert that A record set was not changed 45 | assert: 46 | that: not results.changed 47 | 48 | - name: Update "A" record set with additional record 49 | azure_rm_dnsrecordset: 50 | resource_group: "{{ resource_group }}" 51 | relative_name: www 52 | zone_name: "{{ domain_name }}.com" 53 | record_type: A 54 | record_mode: append 55 | records: 56 | - entry: 192.168.100.104 57 | register: results 58 | 59 | - name: Assert that new record was appended 60 | assert: 61 | that: 62 | - results.changed 63 | 64 | - name: re-update "A" record set with additional record 65 | azure_rm_dnsrecordset: 66 | resource_group: "{{ resource_group }}" 67 | relative_name: www 68 | zone_name: "{{ domain_name }}.com" 69 | record_type: A 70 | record_mode: append 71 | records: 72 | - entry: 192.168.100.104 73 | register: results 74 | 75 | - name: Assert that A record set was not changed 76 | assert: 77 | that: 78 | - not results.changed 79 | 80 | - name: Remove 1 record from record set 81 | azure_rm_dnsrecordset: 82 | resource_group: "{{ resource_group }}" 83 | relative_name: www 84 | zone_name: "{{ domain_name }}.com" 85 | record_type: A 86 | records: 87 | - entry: 192.168.100.101 88 | - entry: 192.168.100.102 89 | - entry: 192.168.100.103 90 | register: results 91 | 92 | - name: Assert that record was deleted 93 | assert: 94 | that: 95 | - results.changed 96 | 97 | - name: Check_mode test 98 | azure_rm_dnsrecordset: 99 | resource_group: "{{ resource_group }}" 100 | relative_name: www 101 | zone_name: "{{ domain_name }}.com" 102 | record_type: A 103 | records: 104 | - entry: 192.168.100.105 105 | check_mode: yes 106 | register: results 107 | 108 | - name: Assert that check_mode returns new state 109 | assert: 110 | that: 111 | - results.changed 112 | 113 | # FUTURE: add facts module calls to ensure that we really didn't touch anything 114 | 115 | - name: delete a record set 116 | azure_rm_dnsrecordset: 117 | resource_group: "{{ resource_group }}" 118 | relative_name: www 119 | zone_name: "{{ domain_name }}.com" 120 | record_type: A 121 | state: absent 122 | register: results 123 | 124 | - name: Assert that record set deleted 125 | assert: 126 | that: results.changed 127 | 128 | - name: (idempotence test) re-run record set absent 129 | azure_rm_dnsrecordset: 130 | resource_group: "{{ resource_group }}" 131 | relative_name: www 132 | zone_name: "{{ domain_name }}.com" 133 | record_type: A 134 | state: absent 135 | register: results 136 | 137 | - name: 138 | assert: 139 | that: not results.changed 140 | 141 | - name: create SRV records in a new record set 142 | azure_rm_dnsrecordset: 143 | resource_group: "{{ resource_group }}" 144 | relative_name: "_sip._tcp.{{ domain_name }}.com" 145 | zone_name: "{{ domain_name }}.com" 146 | time_to_live: 7200 147 | record_type: SRV 148 | state: present 149 | records: 150 | - entry: sip.{{ domain_name }}.com 151 | priority: 20 152 | weight: 10 153 | port: 5060 154 | register: results 155 | 156 | - name: Assert that SRV record set was created 157 | assert: 158 | that: 159 | - results.changed 160 | 161 | - name: create TXT records in a new record set 162 | azure_rm_dnsrecordset: 163 | resource_group: "{{ resource_group }}" 164 | relative_name: "_txt.{{ domain_name }}.com" 165 | zone_name: "{{ domain_name }}.com" 166 | record_type: TXT 167 | state: present 168 | records: 169 | - entry: "v=spf1 a -all" 170 | - entry: "foo" 171 | - entry: 172 | - "bar" 173 | - "baz" 174 | register: results 175 | 176 | - name: Assert that TXT record set was created 177 | assert: 178 | that: 179 | - results.changed 180 | 181 | - name: Delete DNS zone 182 | azure_rm_dnszone: 183 | resource_group: "{{ resource_group }}" 184 | name: "{{ domain_name }}.com" 185 | state: absent 186 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_dnsrecordset_facts/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group1 3 | destructive 4 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_dnsrecordset_facts/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_dnsrecordset_facts/tasks/main.yml: -------------------------------------------------------------------------------- 1 | - name: Create random domain name 2 | set_fact: 3 | domain_name: "{{ resource_group | hash('md5') | truncate(16, True, '') + (65535 | random | string) }}" 4 | 5 | - name: Create a DNS zone 6 | azure_rm_dnszone: 7 | resource_group: "{{ resource_group }}" 8 | name: "{{ domain_name }}.com" 9 | state: present 10 | tags: 11 | tag1: tag1 12 | register: results 13 | 14 | - name: Assert DNS Zone was created 15 | assert: 16 | that: results.changed 17 | 18 | - name: create new "A" record set with multiple records 19 | azure_rm_dnsrecordset: 20 | resource_group: "{{ resource_group }}" 21 | relative_name: www 22 | zone_name: "{{ domain_name }}.com" 23 | record_type: A 24 | records: 25 | - entry: 192.168.100.101 26 | - entry: 192.168.100.102 27 | - entry: 192.168.100.103 28 | register: results 29 | 30 | - name: Retrieve DNS Record Set Facts for single Record Set 31 | azure_rm_dnsrecordset_facts: 32 | resource_group: "{{ resource_group }}" 33 | zone_name: "{{ domain_name }}.com" 34 | relative_name: www 35 | record_type: A 36 | register: results 37 | 38 | - name: Assert that facts module returned result for single Record Set 39 | assert: 40 | that: 41 | - not results.changed 42 | - results.ansible_facts.azure_dnsrecordset[0].name == 'www' 43 | 44 | - name: Retrieve DNS Record Set Facts for all Record Sets 45 | azure_rm_dnsrecordset_facts: 46 | resource_group: "{{ resource_group }}" 47 | zone_name: "{{ domain_name }}.com" 48 | register: results 49 | 50 | - name: Assert that facts module returned result for all Record Sets 51 | assert: 52 | that: 53 | - not results.changed 54 | - results.ansible_facts.azure_dnsrecordset[0].name == '@' 55 | - results.ansible_facts.azure_dnsrecordset[1].name == '@' 56 | - results.ansible_facts.azure_dnsrecordset[2].name == 'www' 57 | 58 | - name: Delete DNS zone 59 | azure_rm_dnszone: 60 | resource_group: "{{ resource_group }}" 61 | name: "{{ domain_name }}.com" 62 | state: absent 63 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_dnszone/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group2 3 | destructive 4 | azure_rm_dnszone_facts 5 | azure_rm_dnsrecordset 6 | azure_rm_dnsrecordset_facts 7 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_dnszone/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_functionapp/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group2 3 | destructive 4 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_functionapp/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_functionapp/tasks/main.yml: -------------------------------------------------------------------------------- 1 | - name: Fix resource prefix 2 | set_fact: 3 | fixed_resource_prefix: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}" 4 | 5 | - name: Fix resource prefix 6 | set_fact: 7 | funcapp_name_basic: "fa{{ fixed_resource_prefix }}basic" 8 | funcapp_name_container: "fa{{ fixed_resource_prefix }}container" 9 | funcapp_name_params: "fa{{ fixed_resource_prefix }}params" 10 | storage_account_name: "sa{{ fixed_resource_prefix }}" 11 | plan_name: "ap{{ fixed_resource_prefix }}" 12 | 13 | - name: create storage account for function apps 14 | azure_rm_storageaccount: 15 | resource_group: '{{ resource_group }}' 16 | name: "{{ storage_account_name }}" 17 | account_type: Standard_LRS 18 | 19 | - name: create basic function app 20 | azure_rm_functionapp: 21 | resource_group: "{{ resource_group }}" 22 | name: "{{ funcapp_name_basic }}" 23 | storage_account: "{{ storage_account_name }}" 24 | register: output 25 | 26 | - name: assert the function was created 27 | assert: 28 | that: output.changed 29 | 30 | - name: list facts for function 31 | azure_rm_functionapp_info: 32 | resource_group: '{{ resource_group }}' 33 | name: "{{ funcapp_name_basic }}" 34 | register: results 35 | 36 | - debug: 37 | var: results 38 | 39 | - name: assert the facts were retrieved 40 | assert: 41 | that: 42 | - results.ansible_info.azure_functionapps|length == 1 43 | - results.ansible_info.azure_functionapps[0].name == "{{ funcapp_name_basic }}" 44 | 45 | - name: delete basic function app 46 | azure_rm_functionapp: 47 | resource_group: '{{ resource_group }}' 48 | name: "{{ funcapp_name_basic }}" 49 | state: absent 50 | register: output 51 | 52 | - name: assert the function was deleted 53 | assert: 54 | that: output.changed 55 | 56 | - name: create a function with app settings 57 | azure_rm_functionapp: 58 | resource_group: '{{ resource_group }}' 59 | name: "{{ funcapp_name_params }}" 60 | storage_account: "{{ storage_account_name }}" 61 | app_settings: 62 | hello: world 63 | things: more stuff 64 | FUNCTIONS_EXTENSION_VERSION: "~2" 65 | register: output 66 | 67 | - name: assert the function with app settings was created 68 | assert: 69 | that: output.changed 70 | 71 | - name: change app settings 72 | azure_rm_functionapp: 73 | resource_group: '{{ resource_group }}' 74 | name: "{{ funcapp_name_params }}" 75 | storage_account: "{{ storage_account_name }}" 76 | app_settings: 77 | hello: world 78 | things: more stuff 79 | FUNCTIONS_EXTENSION_VERSION: "~2" 80 | another: one 81 | register: output 82 | 83 | - name: assert the function was changed 84 | assert: 85 | that: output.changed 86 | 87 | - name: delete the function app 88 | azure_rm_functionapp: 89 | resource_group: '{{ resource_group }}' 90 | name: "{{ funcapp_name_params }}" 91 | state: absent 92 | register: output 93 | 94 | - name: assert the function was deleted 95 | assert: 96 | that: output.changed 97 | 98 | - name: Create a linux app service plan 99 | azure_rm_appserviceplan: 100 | resource_group: "{{ resource_group }}" 101 | name: "{{ plan_name }}" 102 | sku: S1 103 | is_linux: true 104 | number_of_workers: 1 105 | 106 | - name: "Create azure function app {{ function_app }}" 107 | azure_rm_functionapp: 108 | resource_group: "{{ resource_group }}" 109 | name: "{{ funcapp_name_container }}" 110 | storage_account: "{{ storage_account_name }}" 111 | plan: 112 | resource_group: "{{ resource_group }}" 113 | name: "{{ plan_name }}" 114 | container_settings: 115 | name: httpd 116 | app_settings: 117 | FUNCTIONS_EXTENSION_VERSION: "~2" 118 | register: output 119 | 120 | - name: assert the function was changed 121 | assert: 122 | that: output.changed 123 | 124 | - name: delete the function app 125 | azure_rm_functionapp: 126 | resource_group: '{{ resource_group }}' 127 | name: "{{ funcapp_name_container }}" 128 | state: absent 129 | 130 | - name: delete storage account 131 | azure_rm_storageaccount: 132 | resource_group: '{{ resource_group }}' 133 | name: "{{ storage_account_name }}" 134 | state: absent 135 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_gallery/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group4 3 | destructive 4 | azure_rm_galleryimage 5 | azure_rm_galleryimageversion 6 | disabled 7 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_gallery/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_hdinsightcluster/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | destructive 3 | shippable/azure/group1 4 | unstable # test is slow (~30 minute run time), not unstable, but this is better than unsupported 5 | azure_rm_hdinsightcluster_facts 6 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_hdinsightcluster/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_image/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group3 3 | destructive 4 | azure_rm_image_facts 5 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_image/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_image/tasks/main.yml: -------------------------------------------------------------------------------- 1 | - name: Create storage account name 2 | set_fact: 3 | vm_name: "vm{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}x" 4 | public_ip_name: "pip{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}" 5 | security_group_name: "sg{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}" 6 | empty_disk_name: "emptydisk{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}" 7 | 8 | - name: Create virtual network 9 | azure_rm_virtualnetwork: 10 | resource_group: "{{ resource_group }}" 11 | name: "{{ vm_name }}" 12 | address_prefixes: "10.10.0.0/16" 13 | 14 | - name: Add subnet 15 | azure_rm_subnet: 16 | resource_group: "{{ resource_group }}" 17 | name: "{{ vm_name }}" 18 | address_prefix: "10.10.0.0/24" 19 | virtual_network: "{{ vm_name }}" 20 | 21 | - name: Create public ip 22 | azure_rm_publicipaddress: 23 | resource_group: "{{ resource_group }}" 24 | allocation_method: Static 25 | name: "{{ public_ip_name }}" 26 | 27 | - name: Create security group 28 | azure_rm_securitygroup: 29 | resource_group: "{{ resource_group }}" 30 | name: "{{ security_group_name }}" 31 | 32 | - name: Create NIC 33 | azure_rm_networkinterface: 34 | resource_group: "{{ resource_group }}" 35 | name: "{{ vm_name }}" 36 | virtual_network: "{{ vm_name }}" 37 | subnet: "{{ vm_name }}" 38 | public_ip_name: "{{ public_ip_name }}" 39 | security_group: "{{ security_group_name }}" 40 | 41 | - name: Create virtual machine 42 | azure_rm_virtualmachine: 43 | resource_group: "{{ resource_group }}" 44 | name: "{{ vm_name }}" 45 | vm_size: Standard_A0 46 | managed_disk_type: Standard_LRS 47 | admin_username: adminuser 48 | admin_password: Password123! 49 | os_type: Linux 50 | network_interfaces: "{{ vm_name }}" 51 | image: 52 | offer: UbuntuServer 53 | publisher: Canonical 54 | sku: 16.04-LTS 55 | version: latest 56 | register: vm 57 | 58 | - name: Create new empty managed disk 59 | azure_rm_manageddisk: 60 | resource_group: "{{ resource_group }}" 61 | name: "{{ empty_disk_name }}" 62 | storage_account_type: "Standard_LRS" 63 | disk_size_gb: 1 64 | register: emptydisk 65 | 66 | - name: Create an image from VM (check mode) 67 | azure_rm_image: 68 | resource_group: "{{ resource_group }}" 69 | source: "{{ vm.ansible_facts.azure_vm.properties.storageProfile.osDisk.managedDisk.id }}" 70 | name: testimage001 71 | os_type: Linux 72 | data_disk_sources: 73 | - "{{ empty_disk_name }}" 74 | check_mode: yes 75 | register: output 76 | 77 | - assert: 78 | that: output.changed 79 | 80 | - name: Create an image from VM 81 | azure_rm_image: 82 | resource_group: "{{ resource_group }}" 83 | source: 84 | name: "{{ vm_name }}" 85 | type: disks 86 | name: testimage001 87 | os_type: Linux 88 | register: output 89 | 90 | - assert: 91 | that: 92 | - output.changed 93 | - output.id 94 | 95 | - name: Create an image from VM (idempotent) 96 | azure_rm_image: 97 | resource_group: "{{ resource_group }}" 98 | source: "{{ vm.ansible_facts.azure_vm.properties.storageProfile.osDisk.managedDisk.id }}" 99 | name: testimage001 100 | os_type: Linux 101 | register: output 102 | 103 | - assert: 104 | that: 105 | - not output.changed 106 | - output.id 107 | 108 | - name: Gather information about image created 109 | azure_rm_image_facts: 110 | resource_group: "{{ resource_group }}" 111 | name: testimage001 112 | register: output 113 | 114 | - assert: 115 | that: 116 | - output.images != [] 117 | 118 | - name: Delete image (check mode) 119 | azure_rm_image: 120 | resource_group: "{{ resource_group }}" 121 | name: testimage001 122 | state: absent 123 | register: output 124 | check_mode: yes 125 | 126 | - assert: 127 | that: 128 | - output.changed 129 | 130 | - name: Delete image 131 | azure_rm_image: 132 | resource_group: "{{ resource_group }}" 133 | name: testimage001 134 | state: absent 135 | register: output 136 | 137 | - assert: 138 | that: 139 | - output.changed 140 | 141 | - name: Delete image (idempotent) 142 | azure_rm_image: 143 | resource_group: "{{ resource_group }}" 144 | name: testimage001 145 | state: absent 146 | register: output 147 | 148 | - assert: 149 | that: 150 | - not output.changed 151 | 152 | - name: Delete empty disk 153 | azure_rm_manageddisk: 154 | resource_group: "{{ resource_group }}" 155 | name: "{{ empty_disk_name }}" 156 | state: absent 157 | 158 | - name: Delete VM 159 | azure_rm_virtualmachine: 160 | resource_group: "{{ resource_group }}" 161 | name: "{{ vm_name }}" 162 | state: absent 163 | vm_size: Standard_A0 164 | register: output 165 | 166 | - name: Delete public ip 167 | azure_rm_publicipaddress: 168 | resource_group: "{{ resource_group }}" 169 | allocation_method: Static 170 | name: "{{ public_ip_name }}" 171 | state: absent 172 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_iothub/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group2 3 | destructive 4 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_iothub/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_iothub/tasks/main.yml: -------------------------------------------------------------------------------- 1 | - set_fact: 2 | rpfx: "{{ resource_group | hash('md5') | truncate(8, True, '') }}" 3 | 4 | - name: Create IoT Hub (check mode) 5 | azure_rm_iothub: 6 | name: "hub{{ rpfx }}" 7 | resource_group: "{{ resource_group }}" 8 | ip_filters: 9 | - name: filter1 10 | action: reject 11 | ip_mask: 40.60.80.10 12 | check_mode: yes 13 | register: iothub 14 | 15 | - assert: 16 | that: 17 | - iothub.changed 18 | 19 | - name: Query IoT Hub 20 | azure_rm_iothub_info: 21 | name: "hub{{ rpfx }}" 22 | resource_group: "{{ resource_group }}" 23 | register: iothub 24 | ignore_errors: yes 25 | 26 | - name: Create IoT Hub 27 | azure_rm_iothub: 28 | name: "hub{{ rpfx }}" 29 | resource_group: "{{ resource_group }}" 30 | ip_filters: 31 | - name: filter1 32 | action: reject 33 | ip_mask: 40.60.80.10 34 | register: iothub 35 | 36 | - assert: 37 | that: 38 | - iothub.changed 39 | 40 | - name: Create IoT Hub (idempontent) 41 | azure_rm_iothub: 42 | name: "hub{{ rpfx }}" 43 | resource_group: "{{ resource_group }}" 44 | ip_filters: 45 | - name: filter1 46 | action: reject 47 | ip_mask: 40.60.80.10 48 | register: iothub 49 | 50 | - assert: 51 | that: 52 | - not iothub.changed 53 | 54 | - name: Query IoT Hub 55 | azure_rm_iothub_info: 56 | name: "hub{{ rpfx }}" 57 | resource_group: "{{ resource_group }}" 58 | list_keys: yes 59 | register: iothub 60 | 61 | - assert: 62 | that: 63 | - iothub.iothubs | length == 1 64 | 65 | - set_fact: 66 | registry_write_name: "{{ item.key_name }}" 67 | registry_write_key: "{{ item.primary_key }}" 68 | with_items: "{{ iothub.iothubs[0]['keys'] }}" 69 | when: item.rights == 'RegistryWrite, ServiceConnect, DeviceConnect' 70 | 71 | - name: Create devices 72 | azure_rm_iotdevice: 73 | hub: "hub{{ rpfx }}" 74 | hub_policy_name: "{{ registry_write_name }}" 75 | hub_policy_key: "{{ registry_write_key }}" 76 | name: "mydevice{{ item }}" 77 | twin_tags: 78 | location: 79 | country: US 80 | city: Redmond 81 | sensor: humidity 82 | with_items: 83 | - 1 84 | - 2 85 | 86 | - name: Query devices 87 | azure_rm_iotdevice_info: 88 | hub: "hub{{ rpfx }}" 89 | hub_policy_name: "{{ registry_write_name }}" 90 | hub_policy_key: "{{ registry_write_key }}" 91 | register: devices 92 | 93 | - assert: 94 | that: 95 | - devices.iot_devices | length == 2 96 | 97 | - name: Query devices 98 | azure_rm_iotdevice_info: 99 | hub: "hub{{ rpfx }}" 100 | name: "mydevice1" 101 | hub_policy_name: "{{ registry_write_name }}" 102 | hub_policy_key: "{{ registry_write_key }}" 103 | register: devices 104 | 105 | - assert: 106 | that: 107 | - devices.iot_devices | length == 1 108 | - devices.iot_devices[0].deviceId == 'mydevice1' 109 | 110 | - name: Query devices twin 111 | azure_rm_iotdevice_info: 112 | hub: "hub{{ rpfx }}" 113 | query: "SELECT * FROM devices WHERE tags.location.country = 'US'" 114 | hub_policy_name: "{{ registry_write_name }}" 115 | hub_policy_key: "{{ registry_write_key }}" 116 | register: devices 117 | 118 | - assert: 119 | that: 120 | - devices.iot_devices | length == 2 121 | 122 | - name: Update devices 123 | azure_rm_iotdevice: 124 | hub: "hub{{ rpfx }}" 125 | hub_policy_name: "{{ registry_write_name }}" 126 | hub_policy_key: "{{ registry_write_key }}" 127 | name: "mydevice{{ item }}" 128 | edge_enabled: yes 129 | twin_tags: 130 | location: 131 | country: China 132 | city: Shanghai 133 | sensor: humidity 134 | with_items: 135 | - 1 136 | - 3 137 | 138 | - name: Query devices twin 139 | azure_rm_iotdevice_info: 140 | hub: "hub{{ rpfx }}" 141 | query: "SELECT * FROM devices WHERE tags.location.country = 'US'" 142 | hub_policy_name: "{{ registry_write_name }}" 143 | hub_policy_key: "{{ registry_write_key }}" 144 | register: devices 145 | 146 | - assert: 147 | that: 148 | - devices.iot_devices | length == 1 149 | - devices.iot_devices[0].deviceId == 'mydevice2' 150 | 151 | - name: Delete IoT Hub (check mode) 152 | azure_rm_iothub: 153 | name: "hub{{ rpfx }}" 154 | resource_group: "{{ resource_group }}" 155 | state: absent 156 | check_mode: yes 157 | register: iothub 158 | 159 | - assert: 160 | that: 161 | - iothub.changed 162 | 163 | - name: Delete IoT Hub 164 | azure_rm_iothub: 165 | name: "hub{{ rpfx }}" 166 | resource_group: "{{ resource_group }}" 167 | state: absent 168 | register: iothub 169 | 170 | - assert: 171 | that: 172 | - iothub.changed 173 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_keyvault/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | destructive 3 | shippable/azure/group9 4 | azure_rm_keyvaultkey 5 | azure_rm_keyvaultsecret 6 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_keyvault/lookup_plugins/azure_service_principal_attribute.py: -------------------------------------------------------------------------------- 1 | # (c) 2018 Yunge Zhu, 2 | # (c) 2017 Ansible Project 3 | # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 4 | from __future__ import (absolute_import, division, print_function) 5 | __metaclass__ = type 6 | 7 | DOCUMENTATION = """ 8 | lookup: azure_service_principal_attribute 9 | 10 | requirements: 11 | - azure-graphrbac 12 | 13 | author: 14 | - Yunge Zhu 15 | 16 | version_added: "2.7" 17 | 18 | short_description: Look up Azure service principal attributes. 19 | 20 | description: 21 | - Describes object id of your Azure service principal account. 22 | options: 23 | azure_client_id: 24 | description: azure service principal client id. 25 | azure_secret: 26 | description: azure service principal secret 27 | azure_tenant: 28 | description: azure tenant 29 | azure_cloud_environment: 30 | description: azure cloud environment 31 | """ 32 | 33 | EXAMPLES = """ 34 | set_fact: 35 | object_id: "{{ lookup('azure_service_principal_attribute', 36 | azure_client_id=azure_client_id, 37 | azure_secret=azure_secret, 38 | azure_tenant=azure_secret) }}" 39 | """ 40 | 41 | RETURN = """ 42 | _raw: 43 | description: 44 | Returns object id of service principal. 45 | """ 46 | 47 | from ansible.errors import AnsibleError 48 | from ansible.plugins import AnsiblePlugin 49 | from ansible.plugins.lookup import LookupBase 50 | from ansible.module_utils._text import to_native 51 | 52 | try: 53 | from azure.common.credentials import ServicePrincipalCredentials 54 | from azure.graphrbac import GraphRbacManagementClient 55 | from msrestazure import azure_cloud 56 | from msrestazure.azure_exceptions import CloudError 57 | except ImportError: 58 | raise AnsibleError( 59 | "The lookup azure_service_principal_attribute requires azure.graphrbac, msrest") 60 | 61 | 62 | class LookupModule(LookupBase): 63 | def run(self, terms, variables, **kwargs): 64 | 65 | self.set_options(direct=kwargs) 66 | 67 | credentials = {} 68 | credentials['azure_client_id'] = self.get_option('azure_client_id', None) 69 | credentials['azure_secret'] = self.get_option('azure_secret', None) 70 | credentials['azure_tenant'] = self.get_option('azure_tenant', 'common') 71 | 72 | if credentials['azure_client_id'] is None or credentials['azure_secret'] is None: 73 | raise AnsibleError("Must specify azure_client_id and azure_secret") 74 | 75 | _cloud_environment = azure_cloud.AZURE_PUBLIC_CLOUD 76 | if self.get_option('azure_cloud_environment', None) is not None: 77 | cloud_environment = azure_cloud.get_cloud_from_metadata_endpoint(credentials['azure_cloud_environment']) 78 | 79 | try: 80 | azure_credentials = ServicePrincipalCredentials(client_id=credentials['azure_client_id'], 81 | secret=credentials['azure_secret'], 82 | tenant=credentials['azure_tenant'], 83 | resource=_cloud_environment.endpoints.active_directory_graph_resource_id) 84 | 85 | client = GraphRbacManagementClient(azure_credentials, credentials['azure_tenant'], 86 | base_url=_cloud_environment.endpoints.active_directory_graph_resource_id) 87 | 88 | response = list(client.service_principals.list(filter="appId eq '{0}'".format(credentials['azure_client_id']))) 89 | sp = response[0] 90 | 91 | return sp.object_id.split(',') 92 | except CloudError as ex: 93 | raise AnsibleError("Failed to get service principal object id: %s" % to_native(ex)) 94 | return False 95 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_keyvault/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_keyvaultkey/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group1 3 | destructive 4 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_keyvaultkey/lookup_plugins/azure_service_principal_attribute.py: -------------------------------------------------------------------------------- 1 | # (c) 2018 Yunge Zhu, 2 | # (c) 2017 Ansible Project 3 | # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 4 | from __future__ import (absolute_import, division, print_function) 5 | __metaclass__ = type 6 | 7 | DOCUMENTATION = """ 8 | lookup: azure_service_principal_attribute 9 | 10 | requirements: 11 | - azure-graphrbac 12 | 13 | author: 14 | - Yunge Zhu 15 | 16 | version_added: "2.7" 17 | 18 | short_description: Look up Azure service principal attributes. 19 | 20 | description: 21 | - Describes object id of your Azure service principal account. 22 | options: 23 | azure_client_id: 24 | description: azure service principal client id. 25 | azure_secret: 26 | description: azure service principal secret 27 | azure_tenant: 28 | description: azure tenant 29 | azure_cloud_environment: 30 | description: azure cloud environment 31 | """ 32 | 33 | EXAMPLES = """ 34 | set_fact: 35 | object_id: "{{ lookup('azure_service_principal_attribute', 36 | azure_client_id=azure_client_id, 37 | azure_secret=azure_secret, 38 | azure_tenant=azure_secret) }}" 39 | """ 40 | 41 | RETURN = """ 42 | _raw: 43 | description: 44 | Returns object id of service principal. 45 | """ 46 | 47 | from ansible.errors import AnsibleError 48 | from ansible.plugins import AnsiblePlugin 49 | from ansible.plugins.lookup import LookupBase 50 | from ansible.module_utils._text import to_native 51 | 52 | try: 53 | from azure.common.credentials import ServicePrincipalCredentials 54 | from azure.graphrbac import GraphRbacManagementClient 55 | from msrestazure import azure_cloud 56 | from msrestazure.azure_exceptions import CloudError 57 | except ImportError: 58 | raise AnsibleError( 59 | "The lookup azure_service_principal_attribute requires azure.graphrbac, msrest") 60 | 61 | 62 | class LookupModule(LookupBase): 63 | def run(self, terms, variables, **kwargs): 64 | 65 | self.set_options(direct=kwargs) 66 | 67 | credentials = {} 68 | credentials['azure_client_id'] = self.get_option('azure_client_id', None) 69 | credentials['azure_secret'] = self.get_option('azure_secret', None) 70 | credentials['azure_tenant'] = self.get_option('azure_tenant', 'common') 71 | 72 | if credentials['azure_client_id'] is None or credentials['azure_secret'] is None: 73 | raise AnsibleError("Must specify azure_client_id and azure_secret") 74 | 75 | _cloud_environment = azure_cloud.AZURE_PUBLIC_CLOUD 76 | if self.get_option('azure_cloud_environment', None) is not None: 77 | cloud_environment = azure_cloud.get_cloud_from_metadata_endpoint(credentials['azure_cloud_environment']) 78 | 79 | try: 80 | azure_credentials = ServicePrincipalCredentials(client_id=credentials['azure_client_id'], 81 | secret=credentials['azure_secret'], 82 | tenant=credentials['azure_tenant'], 83 | resource=_cloud_environment.endpoints.active_directory_graph_resource_id) 84 | 85 | client = GraphRbacManagementClient(azure_credentials, credentials['azure_tenant'], 86 | base_url=_cloud_environment.endpoints.active_directory_graph_resource_id) 87 | 88 | response = list(client.service_principals.list(filter="appId eq '{0}'".format(credentials['azure_client_id']))) 89 | sp = response[0] 90 | 91 | return sp.object_id.split(',') 92 | except CloudError as ex: 93 | raise AnsibleError("Failed to get service principal object id: %s" % to_native(ex)) 94 | return False 95 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_keyvaultkey/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_keyvaultkey/tasks/main.yml: -------------------------------------------------------------------------------- 1 | - name: Prepare random number 2 | set_fact: 3 | rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}" 4 | tenant_id: "{{ lookup('env','AZURE_TENANT') }}" 5 | run_once: yes 6 | 7 | - name: set service principal info 8 | set_fact: 9 | azure_client_id: "{{ lookup('env','AZURE_CLIENT_ID') }}" 10 | azure_secret: "{{ lookup('env','AZURE_SECRET') }}" 11 | no_log: yes 12 | 13 | - name: lookup service principal object id 14 | set_fact: 15 | object_id: "{{ lookup('azure_service_principal_attribute', 16 | azure_client_id=azure_client_id, 17 | azure_secret=azure_secret, 18 | azure_tenant=tenant_id) }}" 19 | register: object_id 20 | 21 | - name: Create instance of Key Vault 22 | azure_rm_keyvault: 23 | resource_group: "{{ resource_group }}" 24 | vault_name: "vault{{ rpfx }}" 25 | enabled_for_deployment: yes 26 | vault_tenant: "{{ tenant_id }}" 27 | sku: 28 | name: standard 29 | family: A 30 | access_policies: 31 | - tenant_id: "{{ tenant_id }}" 32 | object_id: '{{ object_id }}' 33 | keys: 34 | - get 35 | - list 36 | - update 37 | - create 38 | - import 39 | - delete 40 | - recover 41 | - backup 42 | - restore 43 | - encrypt 44 | - decrypt 45 | - wrapkey 46 | - unwrapkey 47 | - sign 48 | - verify 49 | secrets: 50 | - get 51 | - list 52 | - set 53 | - delete 54 | - recover 55 | - backup 56 | - restore 57 | register: output 58 | 59 | - name: create a kevyault key 60 | block: 61 | - azure_rm_keyvaultkey: 62 | keyvault_uri: https://vault{{ rpfx }}.vault.azure.net 63 | key_name: testkey 64 | tags: 65 | testing: test 66 | delete: on-exit 67 | register: output 68 | - assert: 69 | that: output.changed 70 | rescue: 71 | - azure_rm_keyvaultkey: 72 | keyvault_uri: https://vault{{ rpfx }}.vault.azure.net 73 | state: absent 74 | key_name: testkey 75 | 76 | - name: delete a kevyault key 77 | azure_rm_keyvaultkey: 78 | keyvault_uri: https://vault{{ rpfx }}.vault.azure.net 79 | state: absent 80 | key_name: testkey 81 | register: output 82 | 83 | - assert: 84 | that: output.changed 85 | 86 | - name: Delete instance of Key Vault 87 | azure_rm_keyvault: 88 | resource_group: "{{ resource_group }}" 89 | vault_name: "vault{{ rpfx }}" 90 | state: absent 91 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_keyvaultsecret/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group1 3 | destructive -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_keyvaultsecret/lookup_plugins/azure_service_principal_attribute.py: -------------------------------------------------------------------------------- 1 | # (c) 2018 Yunge Zhu, 2 | # (c) 2017 Ansible Project 3 | # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 4 | from __future__ import (absolute_import, division, print_function) 5 | __metaclass__ = type 6 | 7 | DOCUMENTATION = """ 8 | lookup: azure_service_principal_attribute 9 | 10 | requirements: 11 | - azure-graphrbac 12 | 13 | author: 14 | - Yunge Zhu 15 | 16 | version_added: "2.7" 17 | 18 | short_description: Look up Azure service principal attributes. 19 | 20 | description: 21 | - Describes object id of your Azure service principal account. 22 | options: 23 | azure_client_id: 24 | description: azure service principal client id. 25 | azure_secret: 26 | description: azure service principal secret 27 | azure_tenant: 28 | description: azure tenant 29 | azure_cloud_environment: 30 | description: azure cloud environment 31 | """ 32 | 33 | EXAMPLES = """ 34 | set_fact: 35 | object_id: "{{ lookup('azure_service_principal_attribute', 36 | azure_client_id=azure_client_id, 37 | azure_secret=azure_secret, 38 | azure_tenant=azure_secret) }}" 39 | """ 40 | 41 | RETURN = """ 42 | _raw: 43 | description: 44 | Returns object id of service principal. 45 | """ 46 | 47 | from ansible.errors import AnsibleError 48 | from ansible.plugins import AnsiblePlugin 49 | from ansible.plugins.lookup import LookupBase 50 | from ansible.module_utils._text import to_native 51 | 52 | try: 53 | from azure.common.credentials import ServicePrincipalCredentials 54 | from azure.graphrbac import GraphRbacManagementClient 55 | from msrestazure import azure_cloud 56 | from msrestazure.azure_exceptions import CloudError 57 | except ImportError: 58 | raise AnsibleError( 59 | "The lookup azure_service_principal_attribute requires azure.graphrbac, msrest") 60 | 61 | 62 | class LookupModule(LookupBase): 63 | def run(self, terms, variables, **kwargs): 64 | 65 | self.set_options(direct=kwargs) 66 | 67 | credentials = {} 68 | credentials['azure_client_id'] = self.get_option('azure_client_id', None) 69 | credentials['azure_secret'] = self.get_option('azure_secret', None) 70 | credentials['azure_tenant'] = self.get_option('azure_tenant', 'common') 71 | 72 | if credentials['azure_client_id'] is None or credentials['azure_secret'] is None: 73 | raise AnsibleError("Must specify azure_client_id and azure_secret") 74 | 75 | _cloud_environment = azure_cloud.AZURE_PUBLIC_CLOUD 76 | if self.get_option('azure_cloud_environment', None) is not None: 77 | cloud_environment = azure_cloud.get_cloud_from_metadata_endpoint(credentials['azure_cloud_environment']) 78 | 79 | try: 80 | azure_credentials = ServicePrincipalCredentials(client_id=credentials['azure_client_id'], 81 | secret=credentials['azure_secret'], 82 | tenant=credentials['azure_tenant'], 83 | resource=_cloud_environment.endpoints.active_directory_graph_resource_id) 84 | 85 | client = GraphRbacManagementClient(azure_credentials, credentials['azure_tenant'], 86 | base_url=_cloud_environment.endpoints.active_directory_graph_resource_id) 87 | 88 | response = list(client.service_principals.list(filter="appId eq '{0}'".format(credentials['azure_client_id']))) 89 | sp = response[0] 90 | 91 | return sp.object_id.split(',') 92 | except CloudError as ex: 93 | raise AnsibleError("Failed to get service principal object id: %s" % to_native(ex)) 94 | return False 95 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_keyvaultsecret/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_keyvaultsecret/tasks/main.yml: -------------------------------------------------------------------------------- 1 | - name: Prepare random number 2 | set_fact: 3 | rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}" 4 | tenant_id: "{{ lookup('env','AZURE_TENANT') }}" 5 | run_once: yes 6 | 7 | - name: set service principal info 8 | set_fact: 9 | azure_client_id: "{{ lookup('env','AZURE_CLIENT_ID') }}" 10 | azure_secret: "{{ lookup('env','AZURE_SECRET') }}" 11 | no_log: yes 12 | 13 | - name: lookup service principal object id 14 | set_fact: 15 | object_id: "{{ lookup('azure_service_principal_attribute', 16 | azure_client_id=azure_client_id, 17 | azure_secret=azure_secret, 18 | azure_tenant=tenant_id) }}" 19 | register: object_id 20 | 21 | - name: Create instance of Key Vault 22 | azure_rm_keyvault: 23 | resource_group: "{{ resource_group }}" 24 | vault_name: "vault{{ rpfx }}" 25 | enabled_for_deployment: yes 26 | vault_tenant: "{{ tenant_id }}" 27 | sku: 28 | name: standard 29 | family: A 30 | access_policies: 31 | - tenant_id: "{{ tenant_id }}" 32 | object_id: "{{ object_id }}" 33 | keys: 34 | - get 35 | - list 36 | - update 37 | - create 38 | - import 39 | - delete 40 | - recover 41 | - backup 42 | - restore 43 | secrets: 44 | - get 45 | - list 46 | - set 47 | - delete 48 | - recover 49 | - backup 50 | - restore 51 | register: output 52 | 53 | - name: create a kevyault secret 54 | block: 55 | - azure_rm_keyvaultsecret: 56 | keyvault_uri: https://vault{{ rpfx }}.vault.azure.net 57 | secret_name: testsecret 58 | secret_value: 'mysecret' 59 | tags: 60 | testing: test 61 | delete: on-exit 62 | register: output 63 | - assert: 64 | that: output.changed 65 | rescue: 66 | - azure_rm_keyvaultsecret: 67 | keyvault_uri: https://vault{{ rpfx }}.vault.azure.net 68 | state: absent 69 | secret_name: testsecret 70 | 71 | - name: delete a kevyault secret 72 | azure_rm_keyvaultsecret: 73 | keyvault_uri: https://vault{{ rpfx }}.vault.azure.net 74 | state: absent 75 | secret_name: testsecret 76 | register: output 77 | 78 | - assert: 79 | that: output.changed -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_loadbalancer/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group5 3 | destructive 4 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_loadbalancer/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_lock/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | destructive 3 | unsupported 4 | azure_rm_lock_info 5 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_lock/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_lock/tasks/main.yml: -------------------------------------------------------------------------------- 1 | - name: Create a virtual network 2 | azure_rm_virtualnetwork: 3 | name: mytestvirtualnetworklock 4 | resource_group: "{{ resource_group }}" 5 | address_prefixes_cidr: 6 | - "10.1.0.0/16" 7 | register: vn 8 | 9 | - name: Add lock to resource (check_mode) 10 | azure_rm_lock: 11 | name: keep 12 | managed_resource_id: "{{ vn.state.id }}" 13 | level: read_only 14 | register: lock 15 | check_mode: yes 16 | 17 | - assert: 18 | that: 19 | - lock.changed 20 | 21 | - name: Query lock 22 | azure_rm_lock_info: 23 | managed_resource_id: "{{ vn.state.id }}" 24 | register: locks 25 | 26 | - assert: 27 | that: 28 | - locks.locks | length == 0 29 | 30 | - name: Add lock to resource 31 | azure_rm_lock: 32 | name: keep 33 | managed_resource_id: "{{ vn.state.id }}" 34 | level: read_only 35 | register: lock 36 | 37 | - assert: 38 | that: 39 | - lock.changed 40 | - lock.id 41 | 42 | - name: Query lock 43 | azure_rm_lock_info: 44 | name: keep 45 | managed_resource_id: "{{ vn.state.id }}" 46 | register: locks 47 | 48 | - assert: 49 | that: 50 | - locks.locks | length == 1 51 | 52 | - name: Update lock to resource (idempontent) 53 | azure_rm_lock: 54 | name: keep 55 | managed_resource_id: "{{ vn.state.id }}" 56 | level: read_only 57 | register: lock1 58 | 59 | - assert: 60 | that: 61 | - not lock1.changed 62 | - lock1.id == lock.id 63 | 64 | - name: Update lock level 65 | azure_rm_lock: 66 | name: keep 67 | managed_resource_id: "{{ vn.state.id }}" 68 | level: can_not_delete 69 | register: lock 70 | 71 | - assert: 72 | that: 73 | - lock.changed 74 | - lock.level == 'can_not_delete' 75 | 76 | - name: Delete lock 77 | azure_rm_lock: 78 | name: keep 79 | managed_resource_id: "{{ vn.state.id }}" 80 | register: lock 81 | 82 | - assert: 83 | that: 84 | - lock.changed 85 | 86 | - name: Query lock 87 | azure_rm_lock_info: 88 | managed_resource_id: "{{ vn.state.id }}" 89 | register: locks 90 | 91 | - assert: 92 | that: 93 | - locks.locks | length == 0 94 | 95 | - name: Clean up 96 | azure_rm_virtualnetwork: 97 | name: mytestvirtualnetworklock 98 | resource_group: "{{ resource_group }}" 99 | state: absent -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_manageddisk/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group3 3 | destructive 4 | azure_rm_manageddisk_facts 5 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_manageddisk/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_mariadbserver/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | destructive 3 | shippable/azure/group9 4 | azure_rm_mariadbserver_facts 5 | azure_rm_mariadbdatabase 6 | azure_rm_mariadbdatabase_facts 7 | azure_rm_mariadbfirewallrule 8 | azure_rm_mariadbfirewallrule_facts 9 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_mariadbserver/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_monitorlogprofile/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | destructive 3 | unsupported -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_monitorlogprofile/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_monitorlogprofile/tasks/main.yml: -------------------------------------------------------------------------------- 1 | - name: Prepare random number 2 | set_fact: 3 | profile_name: "profile{{ resource_group | hash('md5') | truncate(5, True, '') }}{{ 1000 | random }}" 4 | location: eastus 5 | run_once: yes 6 | 7 | - name: create Azure storage account 8 | azure_rm_storageaccount: 9 | name: '{{ profile_name }}' 10 | resource_group: "{{ resource_group }}" 11 | account_type: Standard_LRS 12 | 13 | - name: create log profile (idempotence) 14 | azure_rm_monitorlogprofile: 15 | name: "{{ profile_name }}" 16 | location: "{{ location }}" 17 | locations: 18 | - eastus 19 | - westus 20 | categories: 21 | - Write 22 | - Action 23 | retention_policy: 24 | enabled: False 25 | days: 1 26 | storage_account: 27 | resource_group: "{{ resource_group }}" 28 | name: "{{ profile_name }}" 29 | check_mode: yes 30 | register: output 31 | 32 | - name: assert create idempotence 33 | assert: 34 | that: 35 | - output.changed 36 | 37 | - name: create log profile 38 | azure_rm_monitorlogprofile: 39 | name: "{{ profile_name }}" 40 | location: "{{ location }}" 41 | locations: 42 | - eastus 43 | - westus 44 | categories: 45 | - Write 46 | - Action 47 | retention_policy: 48 | enabled: False 49 | days: 1 50 | storage_account: 51 | resource_group: "{{ resource_group }}" 52 | name: "{{ profile_name }}" 53 | register: output 54 | 55 | - name: assert create 56 | assert: 57 | that: 58 | - output.changed 59 | - output.id 60 | 61 | - name: update log profile (idempotence) 62 | azure_rm_monitorlogprofile: 63 | name: "{{ profile_name }}" 64 | location: "{{ location }}" 65 | locations: 66 | - eastus 67 | - westus 68 | categories: 69 | - Write 70 | - Action 71 | retention_policy: 72 | enabled: False 73 | days: 1 74 | storage_account: 75 | resource_group: "{{ resource_group }}" 76 | name: "{{ storage_name }}" 77 | register: output 78 | 79 | - name: assert update idempotence 80 | assert: 81 | that: 82 | - output.changed == False 83 | 84 | - name: update log profile 85 | azure_rm_monitorlogprofile: 86 | name: "{{ profile_name }}" 87 | location: "{{ location }}" 88 | locations: 89 | - eastus 90 | categories: 91 | - Write 92 | - Action 93 | retention_policy: 94 | enabled: False 95 | days: 2 96 | storage_account: 97 | resource_group: "{{ resource_group }}" 98 | name: "{{ profile_name }}" 99 | register: output 100 | 101 | - name: assert update 102 | assert: 103 | that: 104 | - output.changed 105 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_mysqlserver/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | destructive 3 | shippable/azure/group8 4 | azure_rm_mysqlserver_facts 5 | azure_rm_mysqldatabase 6 | azure_rm_mysqldatabase_facts 7 | azure_rm_mysqlfirewallrule 8 | azure_rm_mysqlfirewallrule_facts 9 | azure_rm_mysqlconfiguration 10 | azure_rm_mysqlconfiguration_facts 11 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_mysqlserver/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_networkinterface/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group5 3 | destructive 4 | azure_rm_applicationsecuritygroup -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_networkinterface/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_postgresqlserver/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | destructive 3 | shippable/azure/group8 4 | azure_rm_postgresqlserver_facts 5 | azure_rm_postgresqldatabase 6 | azure_rm_postgresqldatabase_facts 7 | azure_rm_postgresqlfirewallrule 8 | azure_rm_postgresqlfirewallrule_facts 9 | azure_rm_postgresqlserverconfiguration 10 | azure_rm_postgresqlserverconfiguration_facts 11 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_postgresqlserver/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_publicipaddress/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group2 3 | destructive 4 | azure_rm_publicipaddress_facts 5 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_publicipaddress/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_publicipaddress/tasks/main.yml: -------------------------------------------------------------------------------- 1 | - name: Create domain name 2 | set_fact: 3 | domain_name: "ansible-{{ resource_group | hash('md5') | truncate(24, True, '') }}" 4 | rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}" 5 | 6 | - name: Remove public ip 7 | azure_rm_publicipaddress: 8 | resource_group: "{{ resource_group }}" 9 | name: "pip{{ rpfx }}" 10 | state: absent 11 | 12 | - name: Create public ip 13 | azure_rm_publicipaddress: 14 | resource_group: "{{ resource_group }}" 15 | name: "pip{{ rpfx }}" 16 | allocation_method: Static 17 | domain_name: "{{ domain_name }}" 18 | tags: 19 | testing: testing 20 | delete: on-exit 21 | register: output 22 | 23 | - assert: 24 | that: 25 | - output.state.public_ip_allocation_method == 'static' 26 | - output.state.dns_settings.domain_name_label == domain_name 27 | - output.state.tags | length == 2 28 | - output.state.tags.testing == 'testing' 29 | 30 | - name: Should be idempotent 31 | azure_rm_publicipaddress: 32 | resource_group: "{{ resource_group }}" 33 | name: "pip{{ rpfx }}" 34 | allocation_method: static 35 | domain_name: "{{ domain_name }}" 36 | register: output 37 | 38 | - assert: 39 | that: not output.changed 40 | 41 | - name: Update tags 42 | azure_rm_publicipaddress: 43 | resource_group: "{{ resource_group }}" 44 | name: "pip{{ rpfx }}" 45 | allocation_method: static 46 | domain_name: "{{ domain_name }}" 47 | append_tags: yes 48 | tags: 49 | delete: never 50 | foo: bar 51 | register: output 52 | 53 | - assert: 54 | that: 55 | - output.state.tags | length == 3 56 | - output.state.tags.delete == 'never' 57 | 58 | - name: Gather facts, filtering by tag 59 | azure_rm_publicipaddress_facts: 60 | resource_group: "{{ resource_group }}" 61 | tags: 62 | - testing 63 | - foo:bar 64 | 65 | - assert: 66 | that: azure_publicipaddresses | length == 1 67 | 68 | - name: Purge all tags 69 | azure_rm_publicipaddress: 70 | resource_group: "{{ resource_group }}" 71 | name: "pip{{ rpfx }}" 72 | allocation_method: static 73 | domain_name: "{{ domain_name }}" 74 | append_tags: no 75 | register: output 76 | 77 | - assert: 78 | that: 79 | - output.state.tags | length == 0 80 | 81 | - name: Gather facts for a public ip 82 | azure_rm_publicipaddress_facts: 83 | resource_group: "{{ resource_group }}" 84 | name: "pip{{ rpfx }}" 85 | register: pip 86 | 87 | - assert: 88 | that: 89 | - "pip.publicipaddresses | length == 1" 90 | - pip.publicipaddresses[0].name == "pip{{ rpfx }}" 91 | - pip.publicipaddresses[0].allocation_method == 'static' 92 | - pip.publicipaddresses[0].dns_settings.domain_name_label == domain_name 93 | 94 | - name: Gather facts for all public ips 95 | azure_rm_publicipaddress_facts: 96 | resource_group: "{{ resource_group }}" 97 | 98 | - assert: 99 | that: azure_publicipaddresses | length > 0 100 | 101 | - name: Remove public ip 102 | azure_rm_publicipaddress: 103 | resource_group: "{{ resource_group }}" 104 | name: "pip{{ rpfx }}" 105 | state: absent 106 | 107 | - name: Gather facts for a public ip 108 | azure_rm_publicipaddress_facts: 109 | resource_group: "{{ resource_group }}" 110 | name: "pip{{ rpfx }}" 111 | 112 | - assert: 113 | that: azure_publicipaddresses | length == 0 114 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_rediscache/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group2 3 | destructive 4 | azure_rm_rediscache_facts 5 | azure_rm_rediscachefirewallrule 6 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_rediscache/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_resource/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | destructive 3 | shippable/azure/group2 4 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_resource/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_resource/tasks/main.yml: -------------------------------------------------------------------------------- 1 | - name: Prepare random number 2 | set_fact: 3 | nsgname: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}" 4 | storageaccountname: "stacc{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}" 5 | dbname: "mdb{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}" 6 | run_once: yes 7 | 8 | - name: Call REST API 9 | azure_rm_resource: 10 | api_version: '2018-02-01' 11 | resource_group: "{{ resource_group }}" 12 | provider: network 13 | resource_type: networksecuritygroups 14 | resource_name: "{{ nsgname }}" 15 | body: 16 | location: eastus 17 | idempotency: yes 18 | register: output 19 | 20 | - name: Assert that something has changed 21 | assert: 22 | that: output.changed 23 | 24 | - name: Call REST API 25 | azure_rm_resource: 26 | api_version: '2018-02-01' 27 | resource_group: "{{ resource_group }}" 28 | provider: network 29 | resource_type: networksecuritygroups 30 | resource_name: "{{ nsgname }}" 31 | body: 32 | location: eastus 33 | idempotency: yes 34 | register: output 35 | 36 | - name: Assert that nothing has changed 37 | assert: 38 | that: not output.changed 39 | 40 | - name: Call REST API 41 | azure_rm_resource: 42 | api_version: '2018-02-01' 43 | resource_group: "{{ resource_group }}" 44 | provider: network 45 | resource_type: networksecuritygroups 46 | resource_name: "{{ nsgname }}" 47 | body: 48 | location: eastus 49 | tags: 50 | a: "abc" 51 | b: "cde" 52 | idempotency: yes 53 | register: output 54 | 55 | - name: Assert that something has changed 56 | assert: 57 | that: output.changed 58 | 59 | - name: Try to get information about account 60 | azure_rm_resource_facts: 61 | api_version: '2018-02-01' 62 | resource_group: "{{ resource_group }}" 63 | provider: network 64 | resource_type: networksecuritygroups 65 | resource_name: "{{ nsgname }}" 66 | register: output 67 | 68 | - name: Assert value was returned 69 | assert: 70 | that: 71 | - not output.changed 72 | - output.response[0]['name'] != None 73 | - output.response | length == 1 74 | 75 | - name: Try to query a list 76 | azure_rm_resource_facts: 77 | api_version: '2018-02-01' 78 | resource_group: "{{ resource_group }}" 79 | provider: network 80 | resource_type: networksecuritygroups 81 | register: output 82 | - name: Assert value was returned 83 | assert: 84 | that: 85 | - not output.changed 86 | - output.response[0]['name'] != None 87 | - output.response | length >= 1 88 | 89 | - name: Try to query a list - same without API version 90 | azure_rm_resource_facts: 91 | resource_group: "{{ resource_group }}" 92 | provider: network 93 | resource_type: networksecuritygroups 94 | register: output 95 | - name: Assert value was returned 96 | assert: 97 | that: 98 | - not output.changed 99 | - output.response[0]['name'] != None 100 | - output.response | length >= 1 101 | 102 | - name: Query all the resources in the resource group 103 | azure_rm_resource_facts: 104 | resource_group: "{{ resource_group }}" 105 | resource_type: resources 106 | register: output 107 | - name: Assert value was returned 108 | assert: 109 | that: 110 | - not output.changed 111 | - output.response | length >= 1 112 | 113 | - name: Create storage account that requires LRO polling 114 | azure_rm_resource: 115 | polling_timeout: 600 116 | polling_interval: 60 117 | api_version: '2018-07-01' 118 | resource_group: "{{ resource_group }}" 119 | provider: Storage 120 | resource_type: storageAccounts 121 | resource_name: "{{ storageaccountname }}" 122 | body: 123 | sku: 124 | name: Standard_GRS 125 | kind: Storage 126 | location: eastus 127 | register: output 128 | 129 | - name: Assert that storage was successfully created 130 | assert: 131 | that: "output['response']['name'] == '{{ storageaccountname }}'" 132 | 133 | 134 | - name: Try to storage keys -- special case when subresource part has no name 135 | azure_rm_resource: 136 | resource_group: "{{ resource_group }}" 137 | provider: storage 138 | resource_type: storageAccounts 139 | resource_name: "{{ storageaccountname }}" 140 | subresource: 141 | - type: listkeys 142 | api_version: '2018-03-01-preview' 143 | method: POST 144 | register: keys 145 | 146 | - name: Assert that key was returned 147 | assert: 148 | that: keys['response']['keys'][0]['value'] | length > 0 149 | 150 | - name: Delete storage - without API version 151 | azure_rm_resource: 152 | polling_timeout: 600 153 | polling_interval: 60 154 | method: DELETE 155 | resource_group: "{{ resource_group }}" 156 | provider: Storage 157 | resource_type: storageAccounts 158 | resource_name: "{{ storageaccountname }}" 159 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_resourcegroup/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group3 3 | destructive 4 | azure_rm_resourcegroup_info 5 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_resourcegroup/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_resourcegroup/tasks/main.yml: -------------------------------------------------------------------------------- 1 | - name: Get resource group info 2 | azure_rm_resourcegroup_info: 3 | register: rg 4 | 5 | - assert: 6 | that: 7 | - rg.resourcegroups | length >= 1 8 | 9 | - name: Get resource group info 10 | azure_rm_resourcegroup_info: 11 | name: "{{ resource_group }}" 12 | list_resources: yes 13 | register: rg 14 | 15 | - assert: 16 | that: 17 | - rg.resourcegroups | length == 1 18 | - rg.resourcegroups[0].resources | length >= 0 19 | 20 | - name: Create resource group (idempontent) 21 | azure_rm_resourcegroup: 22 | name: "{{ resource_group }}" 23 | location: "{{ rg.resourcegroups[0].location }}" 24 | register: output 25 | 26 | - assert: 27 | that: 28 | - not output.changed 29 | 30 | - name: delete resource group 31 | azure_rm_resourcegroup: 32 | name: "{{ resource_group }}" 33 | state: absent 34 | check_mode: yes 35 | register: output 36 | 37 | - assert: 38 | that: 39 | - output.changed -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_roledefinition/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | destructive 3 | unsupported -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_roledefinition/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_routetable/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group3 3 | destructive 4 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_routetable/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_routetable/tasks/main.yml: -------------------------------------------------------------------------------- 1 | - name: Prepare random number 2 | set_fact: 3 | name: "table{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}" 4 | route_name: "route{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}" 5 | run_once: yes 6 | 7 | - name: Create a route table (check mode) 8 | azure_rm_routetable: 9 | name: "{{ name }}" 10 | resource_group: "{{ resource_group }}" 11 | tags: 12 | purpose: testing 13 | check_mode: yes 14 | register: output 15 | 16 | - assert: 17 | that: 18 | - not output.id 19 | - output.changed 20 | 21 | - name: Create a route table 22 | azure_rm_routetable: 23 | name: "{{ name }}" 24 | resource_group: "{{ resource_group }}" 25 | tags: 26 | purpose: testing 27 | register: output 28 | 29 | - assert: 30 | that: 31 | - output.changed 32 | - output.id 33 | 34 | - name: Create a route table (idemponent) 35 | azure_rm_routetable: 36 | name: "{{ name }}" 37 | resource_group: "{{ resource_group }}" 38 | tags: 39 | purpose: testing 40 | register: output 41 | 42 | - assert: 43 | that: 44 | - not output.changed 45 | 46 | - name: Get facts of the table 47 | azure_rm_routetable_facts: 48 | name: "{{ name }}" 49 | resource_group: "{{ resource_group }}" 50 | register: output 51 | 52 | - assert: 53 | that: 54 | - "output.route_tables | length == 1" 55 | - "output.route_tables[0].routes | length == 0" 56 | 57 | - name: Create route (check mode) 58 | azure_rm_route: 59 | name: "{{ route_name }}" 60 | resource_group: "{{ resource_group }}" 61 | next_hop_type: virtual_network_gateway 62 | address_prefix: "10.1.0.0/16" 63 | route_table_name: "{{ name }}" 64 | check_mode: yes 65 | register: output 66 | 67 | - assert: 68 | that: 69 | - output.changed 70 | - not output.id 71 | 72 | - name: Create route 73 | azure_rm_route: 74 | name: "{{ route_name }}" 75 | resource_group: "{{ resource_group }}" 76 | next_hop_type: virtual_network_gateway 77 | address_prefix: "10.1.0.0/16" 78 | route_table_name: "{{ name }}" 79 | register: output 80 | 81 | - assert: 82 | that: 83 | - output.changed 84 | - output.id 85 | 86 | - name: Create route (idemponent) 87 | azure_rm_route: 88 | name: "{{ route_name }}" 89 | resource_group: "{{ resource_group }}" 90 | next_hop_type: virtual_network_gateway 91 | address_prefix: "10.1.0.0/16" 92 | route_table_name: "{{ name }}" 93 | register: output 94 | 95 | - assert: 96 | that: 97 | - not output.changed 98 | 99 | - name: update route 100 | azure_rm_route: 101 | name: "{{ route_name }}" 102 | resource_group: "{{ resource_group }}" 103 | next_hop_type: virtual_network_gateway 104 | address_prefix: "10.1.0.0/24" 105 | route_table_name: "{{ name }}" 106 | register: output 107 | 108 | - assert: 109 | that: 110 | - output.changed 111 | 112 | - name: Get facts of the table 113 | azure_rm_routetable_facts: 114 | name: "{{ name }}" 115 | resource_group: "{{ resource_group }}" 116 | register: output 117 | 118 | - assert: 119 | that: 120 | - "output.route_tables | length == 1" 121 | - "output.route_tables[0].routes | length == 1" 122 | - output.route_tables[0].routes[0].address_prefix == '10.1.0.0/24' 123 | 124 | - name: Delete route (check mode) 125 | azure_rm_route: 126 | name: "{{ route_name }}" 127 | resource_group: "{{ resource_group }}" 128 | route_table_name: "{{ name }}" 129 | state: absent 130 | check_mode: yes 131 | 132 | - name: Delete route 133 | azure_rm_route: 134 | name: "{{ route_name }}" 135 | resource_group: "{{ resource_group }}" 136 | state: absent 137 | route_table_name: "{{ name }}" 138 | register: output 139 | 140 | - assert: 141 | that: 142 | - output.changed 143 | 144 | - name: Delete route (idemponent) 145 | azure_rm_route: 146 | name: "{{ route_name }}" 147 | resource_group: "{{ resource_group }}" 148 | state: absent 149 | route_table_name: "{{ name }}" 150 | register: output 151 | 152 | - assert: 153 | that: 154 | - not output.changed 155 | 156 | - name: Delete route table (check mode) 157 | azure_rm_routetable: 158 | name: "{{ name }}" 159 | resource_group: "{{ resource_group }}" 160 | state: absent 161 | check_mode: yes 162 | 163 | - name: Delete route table 164 | azure_rm_routetable: 165 | name: "{{ name }}" 166 | resource_group: "{{ resource_group }}" 167 | state: absent 168 | register: output 169 | 170 | - assert: 171 | that: 172 | - output.changed 173 | 174 | - name: Delete route table (idemponent) 175 | azure_rm_routetable: 176 | name: "{{ name }}" 177 | resource_group: "{{ resource_group }}" 178 | state: absent 179 | register: output 180 | 181 | - assert: 182 | that: 183 | - not output.changed 184 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_securitygroup/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group2 3 | destructive 4 | azure_rm_securitygroup_facts 5 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_securitygroup/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_servicebus/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group4 3 | destructive 4 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_servicebus/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_servicebus/tasks/main.yml: -------------------------------------------------------------------------------- 1 | - name: Prepare random number 2 | set_fact: 3 | rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}" 4 | run_once: yes 5 | 6 | - name: Create a namespace 7 | azure_rm_servicebus: 8 | name: "ns{{ rpfx }}" 9 | resource_group: "{{ resource_group }}" 10 | register: namespace 11 | 12 | - assert: 13 | that: 14 | - namespace.id 15 | - namespace.changed 16 | 17 | - name: Create a namespace (idempontent) 18 | azure_rm_servicebus: 19 | name: "ns{{ rpfx }}" 20 | resource_group: "{{ resource_group }}" 21 | register: namespace 22 | 23 | - assert: 24 | that: 25 | - not namespace.changed 26 | 27 | - name: Create a queue 28 | azure_rm_servicebusqueue: 29 | name: "queue{{ rpfx }}" 30 | namespace: "ns{{ rpfx }}" 31 | resource_group: "{{ resource_group }}" 32 | register: queue 33 | 34 | - assert: 35 | that: 36 | - queue.id 37 | - queue.changed 38 | 39 | - name: Create a topic (check mode) 40 | azure_rm_servicebustopic: 41 | name: "topic{{ rpfx }}" 42 | resource_group: "{{ resource_group }}" 43 | namespace: "ns{{ rpfx }}" 44 | duplicate_detection_time_in_seconds: 600 45 | check_mode: yes 46 | register: output 47 | 48 | - assert: 49 | that: 50 | - output.changed 51 | 52 | - name: Create a topic 53 | azure_rm_servicebustopic: 54 | name: "topic{{ rpfx }}" 55 | resource_group: "{{ resource_group }}" 56 | namespace: "ns{{ rpfx }}" 57 | duplicate_detection_time_in_seconds: 600 58 | register: output 59 | 60 | - assert: 61 | that: 62 | - output.changed 63 | - output.id 64 | - "'subscription_count' not in output" 65 | 66 | - name: Create a topic (idempontent) 67 | azure_rm_servicebustopic: 68 | name: "topic{{ rpfx }}" 69 | resource_group: "{{ resource_group }}" 70 | namespace: "ns{{ rpfx }}" 71 | duplicate_detection_time_in_seconds: 600 72 | register: output 73 | 74 | - assert: 75 | that: 76 | - not output.changed 77 | 78 | - name: Create test policy 79 | azure_rm_servicebussaspolicy: 80 | name: testpolicy 81 | resource_group: "{{ resource_group }}" 82 | namespace: "ns{{ rpfx }}" 83 | topic: "topic{{ rpfx }}" 84 | rights: manage 85 | 86 | - name: Create a subscription 87 | azure_rm_servicebustopicsubscription: 88 | name: "subs{{ rpfx }}" 89 | resource_group: "{{ resource_group }}" 90 | namespace: "ns{{ rpfx }}" 91 | topic: "topic{{ rpfx }}" 92 | register: subs 93 | 94 | - assert: 95 | that: 96 | - subs.id 97 | - subs.changed 98 | 99 | - name: Retrive topic 100 | azure_rm_servicebus_facts: 101 | type: topic 102 | name: "topic{{ rpfx }}" 103 | resource_group: "{{ resource_group }}" 104 | namespace: "ns{{ rpfx }}" 105 | show_sas_policies: yes 106 | register: facts 107 | 108 | - assert: 109 | that: 110 | - "facts.servicebuses | length == 1" 111 | - facts.servicebuses[0].id == output.id 112 | - facts.servicebuses[0].subscription_count == 1 113 | - facts.servicebuses[0].sas_policies.testpolicy 114 | - facts.servicebuses[0].sas_policies.testpolicy.rights == 'manage' 115 | 116 | - name: Delete subscription 117 | azure_rm_servicebustopicsubscription: 118 | name: "subs{{ rpfx }}" 119 | resource_group: "{{ resource_group }}" 120 | namespace: "ns{{ rpfx }}" 121 | topic: "topic{{ rpfx }}" 122 | state: absent 123 | 124 | - name: Retrive topic 125 | azure_rm_servicebus_facts: 126 | type: topic 127 | name: "topic{{ rpfx }}" 128 | resource_group: "{{ resource_group }}" 129 | namespace: "ns{{ rpfx }}" 130 | show_sas_policies: yes 131 | register: facts 132 | 133 | - assert: 134 | that: 135 | - facts.servicebuses[0].subscription_count == 0 136 | - "facts.servicebuses | length == 1" 137 | 138 | - name: Delete topic 139 | azure_rm_servicebustopic: 140 | name: "topic{{ rpfx }}" 141 | resource_group: "{{ resource_group }}" 142 | namespace: "ns{{ rpfx }}" 143 | state: absent 144 | 145 | - name: Retrive topic 146 | azure_rm_servicebus_facts: 147 | name: "topic{{ rpfx }}" 148 | type: topic 149 | resource_group: "{{ resource_group }}" 150 | namespace: "ns{{ rpfx }}" 151 | show_sas_policies: yes 152 | register: facts 153 | 154 | - assert: 155 | that: 156 | - "facts.servicebuses | length == 0" 157 | 158 | - name: Delete queue 159 | azure_rm_servicebusqueue: 160 | name: "queue{{ rpfx }}" 161 | resource_group: "{{ resource_group }}" 162 | namespace: "ns{{ rpfx }}" 163 | state: absent 164 | 165 | - name: Delete namespace 166 | azure_rm_servicebus: 167 | name: "ns{{ rpfx }}" 168 | resource_group: "{{ resource_group }}" 169 | state: absent -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_sqlserver/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | destructive 3 | shippable/azure/group9 4 | azure_rm_sqlserver_facts 5 | azure_rm_sqldatabase 6 | azure_rm_sqldatabase_facts 7 | azure_rm_sqlfirewallrule 8 | azure_rm_sqlfirewallrule_facts 9 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_sqlserver/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_storageaccount/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group2 3 | destructive 4 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_storageaccount/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_storageaccount/tasks/main.yml: -------------------------------------------------------------------------------- 1 | - name: Create storage account name 2 | set_fact: 3 | storage_account: "{{ resource_group | hash('md5') | truncate(24, True, '') }}" 4 | 5 | - name: Test invalid account name 6 | azure_rm_storageaccount: 7 | resource_group: "{{ resource_group }}" 8 | name: "invalid_char$" 9 | register: invalid_name 10 | ignore_errors: yes 11 | 12 | - name: Assert task failed 13 | assert: { that: "invalid_name['failed'] == True" } 14 | 15 | - name: Delete storage account 16 | azure_rm_storageaccount: 17 | resource_group: "{{ resource_group }}" 18 | name: "{{ storage_account }}" 19 | state: absent 20 | force_delete_nonempty: True 21 | 22 | - name: Create new storage account 23 | azure_rm_storageaccount: 24 | resource_group: "{{ resource_group }}" 25 | name: "{{ storage_account }}" 26 | account_type: Standard_LRS 27 | append_tags: no 28 | blob_cors: 29 | - allowed_origins: 30 | - http://www.example.com/ 31 | allowed_methods: 32 | - GET 33 | - POST 34 | allowed_headers: 35 | - x-ms-meta-data* 36 | - x-ms-meta-target* 37 | - x-ms-meta-abc 38 | exposed_headers: 39 | - x-ms-meta-* 40 | max_age_in_seconds: 200 41 | tags: 42 | test: test 43 | galaxy: galaxy 44 | register: output 45 | 46 | - name: Assert status succeeded and results include an Id value 47 | assert: 48 | that: 49 | - output.changed 50 | - output.state.id is defined 51 | - output.state.blob_cors | length == 1 52 | 53 | - name: Create new storage account (idempotence) 54 | azure_rm_storageaccount: 55 | resource_group: "{{ resource_group }}" 56 | name: "{{ storage_account }}" 57 | account_type: Standard_LRS 58 | append_tags: no 59 | blob_cors: 60 | - allowed_origins: 61 | - http://www.example.com/ 62 | allowed_methods: 63 | - GET 64 | - POST 65 | allowed_headers: 66 | - x-ms-meta-data* 67 | - x-ms-meta-target* 68 | - x-ms-meta-abc 69 | exposed_headers: 70 | - x-ms-meta-* 71 | max_age_in_seconds: 200 72 | tags: 73 | test: test 74 | galaxy: galaxy 75 | register: output 76 | 77 | - assert: 78 | that: 79 | - not output.changed 80 | 81 | - name: Gather facts by tags 82 | azure_rm_storageaccount_facts: 83 | resource_group: "{{ resource_group }}" 84 | tags: 85 | - test 86 | - galaxy 87 | 88 | - assert: 89 | that: azure_storageaccounts | length >= 1 90 | 91 | - name: Change account type 92 | azure_rm_storageaccount: 93 | resource_group: "{{ resource_group }}" 94 | name: "{{ storage_account }}" 95 | account_type: Premium_LRS 96 | register: change_account 97 | ignore_errors: yes 98 | 99 | - name: Assert account type change failed 100 | assert: { that: "change_account['failed'] == True" } 101 | 102 | - name: Change account type and add custom domain 103 | azure_rm_storageaccount: 104 | resource_group: "{{ resource_group }}" 105 | name: "{{ storage_account }}" 106 | account_type: Standard_GRS 107 | custom_domain: { name: ansible.com, use_sub_domain: no } 108 | register: change_account 109 | ignore_errors: yes 110 | 111 | - name: Assert CNAME failure 112 | assert: { that: "'custom domain name could not be verified' in change_account['msg']" } 113 | 114 | - name: Update account tags 115 | azure_rm_storageaccount: 116 | resource_group: "{{ resource_group }}" 117 | name: "{{ storage_account }}" 118 | append_tags: no 119 | tags: 120 | testing: testing 121 | delete: never 122 | register: output 123 | 124 | - assert: 125 | that: 126 | - "output.state.tags | length == 2" 127 | - "output.state.tags.testing == 'testing'" 128 | - "output.state.tags.delete == 'never'" 129 | 130 | - name: Gather facts 131 | azure_rm_storageaccount_facts: 132 | resource_group: "{{ resource_group }}" 133 | name: "{{ storage_account }}" 134 | show_connection_string: True 135 | show_blob_cors: True 136 | 137 | - assert: 138 | that: 139 | - "azure_storageaccounts| length == 1" 140 | - "storageaccounts | length == 1" 141 | - not storageaccounts[0].custom_domain 142 | - storageaccounts[0].account_type == "Standard_GRS" 143 | - storageaccounts[0].primary_endpoints.blob.connectionstring 144 | - storageaccounts[0].blob_cors 145 | 146 | - name: Gather facts 147 | azure_rm_storageaccount_facts: 148 | resource_group: "{{ resource_group }}" 149 | 150 | - assert: 151 | that: 152 | - "azure_storageaccounts | length > 0" 153 | 154 | - name: Delete acccount 155 | azure_rm_storageaccount: 156 | resource_group: "{{ resource_group }}" 157 | name: "{{ storage_account }}" 158 | state: absent 159 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_storageblob/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group2 3 | destructive 4 | unstable 5 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_storageblob/files/Ratings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure_preview_modules/f3bcca65d4c2bb528faf1e7f4fbb7cc3846a8b95/tests/integration/targets/azure_rm_storageblob/files/Ratings.png -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_storageblob/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_storageblob/tasks/main.yml: -------------------------------------------------------------------------------- 1 | - name: Create storage account name 2 | set_fact: 3 | storage_account: "{{ resource_group | hash('md5') | truncate(24, True, '') }}" 4 | 5 | - name: Create storage account 6 | azure_rm_storageaccount: 7 | resource_group: "{{ resource_group }}" 8 | name: "{{ storage_account }}" 9 | account_type: Standard_LRS 10 | 11 | - name: Create container 12 | azure_rm_storageblob: 13 | resource_group: "{{ resource_group }}" 14 | account_name: "{{ storage_account }}" 15 | container_name: my-blobs 16 | 17 | - name: Force upload blob 18 | azure_rm_storageblob: 19 | resource_group: "{{ resource_group }}" 20 | account_name: "{{ storage_account }}" 21 | container_name: my-blobs 22 | blob: 'Ratings.png' 23 | src: './targets/azure_rm_storageblob/files/Ratings.png' 24 | content_type: image/png 25 | tags: 26 | val1: foo 27 | val2: bar 28 | force: yes 29 | 30 | - name: storage blob seems to have some timing issues 31 | wait_for: 32 | delay: 10 33 | 34 | - name: Upload blob idempotence 35 | azure_rm_storageblob: 36 | resource_group: "{{ resource_group }}" 37 | account_name: "{{ storage_account }}" 38 | container_name: my-blobs 39 | blob: 'Ratings.png' 40 | src: './targets/azure_rm_storageblob/files/Ratings.png' 41 | content_type: image/png 42 | tags: 43 | val1: foo 44 | val2: bar 45 | register: upload_facts 46 | 47 | - assert: 48 | that: "not upload_facts.changed" 49 | 50 | - name: Download file idempotence 51 | azure_rm_storageblob: 52 | resource_group: "{{ resource_group }}" 53 | account_name: "{{ storage_account }}" 54 | container_name: my-blobs 55 | blob: 'Ratings.png' 56 | dest: './targets/azure_rm_storageblob/files/Ratings.png' 57 | register: download_results 58 | 59 | - assert: 60 | that: not download_results.changed 61 | 62 | - file: path="/tmp/Ratings.png" state=absent 63 | 64 | - name: Download file 65 | azure_rm_storageblob: 66 | resource_group: "{{ resource_group }}" 67 | account_name: "{{ storage_account }}" 68 | container_name: my-blobs 69 | blob: 'Ratings.png' 70 | dest: '/tmp/Ratings.png' 71 | register: download_results 72 | 73 | - assert: 74 | that: "download_results.changed" 75 | 76 | - find: paths='/tmp' patterns="Ratings.png" 77 | register: find_results 78 | 79 | - assert: { that: "find_results['matched'] == 1" } 80 | 81 | - name: Do not delete container that has blobs 82 | azure_rm_storageblob: 83 | resource_group: "{{ resource_group }}" 84 | account_name: "{{ storage_account }}" 85 | container_name: my-blobs 86 | state: absent 87 | register: output 88 | 89 | - assert: 90 | that: "not output.changed" 91 | 92 | - name: Delete blob object 93 | azure_rm_storageblob: 94 | resource_group: "{{ resource_group }}" 95 | account_name: "{{ storage_account }}" 96 | container_name: my-blobs 97 | blob: "Ratings.png" 98 | state: absent 99 | register: output 100 | 101 | - assert: 102 | that: "output.changed" 103 | 104 | - name: Delete container 105 | azure_rm_storageblob: 106 | resource_group: "{{ resource_group }}" 107 | account_name: "{{ storage_account }}" 108 | container_name: my-blobs 109 | state: absent 110 | register: output 111 | 112 | - assert: 113 | that: "output.changed" 114 | 115 | - name: Delete storage account 116 | azure_rm_storageaccount: 117 | resource_group: "{{ resource_group }}" 118 | name: "{{ storage_account }}" 119 | state: absent 120 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_subnet/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group2 3 | destructive 4 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_subnet/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_subnet/tasks/main.yml: -------------------------------------------------------------------------------- 1 | - name: Create virtual network 2 | azure_rm_virtualnetwork: 3 | name: My_Virtual_Network 4 | address_prefixes_cidr: 5 | - 10.1.0.0/16 6 | - 172.100.0.0/16 7 | dns_servers: 8 | - 127.0.0.1 9 | - 127.0.0.3 10 | tags: 11 | testing: testing 12 | delete: on-exit 13 | resource_group: "{{ resource_group }}" 14 | 15 | - name: Create route table 16 | azure_rm_routetable: 17 | name: routetableforsubnet 18 | resource_group: "{{ resource_group }}" 19 | register: route_table 20 | 21 | - name: Remove subnet 22 | azure_rm_subnet: 23 | state: absent 24 | name: foobar 25 | virtual_network_name: My_Virtual_Network 26 | resource_group: "{{ resource_group }}" 27 | 28 | - name: Catch invalid cidr 29 | azure_rm_subnet: 30 | name: foobar 31 | virtual_network_name: My_Virtual_Network 32 | resource_group: "{{ resource_group }}" 33 | address_prefix_cidr: "10.1.0/24" 34 | register: output 35 | ignore_errors: yes 36 | 37 | - assert: 38 | that: output.failed 39 | 40 | - name: Add the subnet back 41 | azure_rm_subnet: 42 | name: foobar 43 | virtual_network_name: My_Virtual_Network 44 | resource_group: "{{ resource_group }}" 45 | address_prefix_cidr: "10.1.0.0/24" 46 | register: output 47 | 48 | - assert: 49 | that: output.changed 50 | 51 | - name: Add the subnet back (idempontent) 52 | azure_rm_subnet: 53 | name: foobar 54 | virtual_network_name: My_Virtual_Network 55 | resource_group: "{{ resource_group }}" 56 | register: output 57 | 58 | - assert: 59 | that: not output.changed 60 | 61 | - name: Create network security group 62 | azure_rm_securitygroup: 63 | name: secgroupfoo 64 | resource_group: "{{ resource_group }}" 65 | tags: 66 | testing: testing 67 | 68 | - name: Update the subnet 69 | azure_rm_subnet: 70 | name: foobar 71 | virtual_network_name: My_Virtual_Network 72 | resource_group: "{{ resource_group }}" 73 | address_prefix_cidr: "10.1.0.0/16" 74 | security_group: secgroupfoo 75 | service_endpoints: 76 | - service: Microsoft.Sql 77 | locations: 78 | - eastus 79 | - westus 80 | 81 | - name: Should be idempotent 82 | azure_rm_subnet: 83 | name: foobar 84 | virtual_network_name: My_Virtual_Network 85 | resource_group: "{{ resource_group }}" 86 | address_prefix_cidr: "10.1.0.0/16" 87 | service_endpoints: 88 | - service: Microsoft.Sql 89 | locations: 90 | - eastus 91 | - westus 92 | register: output 93 | 94 | - assert: 95 | that: not output.changed 96 | 97 | - name: Create network security group in another resource group 98 | azure_rm_securitygroup: 99 | name: secgroupfoo 100 | resource_group: "{{ resource_group_secondary }}" 101 | register: nsg 102 | 103 | - name: Update the subnet 104 | azure_rm_subnet: 105 | name: foobar 106 | virtual_network_name: My_Virtual_Network 107 | resource_group: "{{ resource_group }}" 108 | address_prefix_cidr: "10.1.0.0/16" 109 | route_table: "{{ route_table.id }}" 110 | security_group: 111 | name: secgroupfoo 112 | resource_group: "{{ resource_group_secondary }}" 113 | register: output 114 | 115 | - assert: 116 | that: 117 | - output.changed 118 | - output.state.network_security_group.id == nsg.state.id 119 | 120 | - name: Update the subnet (idempotent) 121 | azure_rm_subnet: 122 | name: foobar 123 | virtual_network_name: My_Virtual_Network 124 | resource_group: "{{ resource_group }}" 125 | address_prefix_cidr: "10.1.0.0/16" 126 | security_group: "{{ nsg.state.id }}" 127 | register: output 128 | 129 | - assert: 130 | that: not output.changed 131 | 132 | - name: Get subnet facts 133 | azure_rm_subnet_facts: 134 | name: foobar 135 | virtual_network_name: My_Virtual_Network 136 | resource_group: "{{ resource_group }}" 137 | register: output 138 | 139 | - debug: 140 | var: output 141 | - name: Assert that facts are returned 142 | assert: 143 | that: 144 | - output.changed == False 145 | - output.subnets[0]['id'] != None 146 | - output.subnets[0]['resource_group'] != None 147 | - output.subnets[0]['virtual_network_name'] != None 148 | - output.subnets[0]['name'] != None 149 | - output.subnets[0]['address_prefix_cidr'] != None 150 | - output.subnets[0]['route_table'] != None 151 | - output.subnets[0]['security_group'] != None 152 | - output.subnets[0]['provisioning_state'] != None 153 | 154 | - name: Remove subnet 155 | azure_rm_subnet: 156 | state: absent 157 | name: foobar 158 | virtual_network_name: My_Virtual_Network 159 | resource_group: "{{ resource_group }}" 160 | 161 | - name: Remove subnet (idempotent) 162 | azure_rm_subnet: 163 | state: absent 164 | name: foobar 165 | virtual_network_name: My_Virtual_Network 166 | resource_group: "{{ resource_group }}" 167 | register: output 168 | 169 | - assert: 170 | that: not output.changed 171 | 172 | - name: Remove security group 173 | azure_rm_securitygroup: 174 | resource_group: "{{ resource_group }}" 175 | name: secgroupfoo 176 | state: absent 177 | 178 | - name: Remove virtual network 179 | azure_rm_virtualnetwork: 180 | name: My_Virtual_Network 181 | resource_group: "{{ resource_group }}" 182 | state: absent 183 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_trafficmanagerprofile/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group6 3 | destructive 4 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_trafficmanagerprofile/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_virtualmachine/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group7 3 | destructive 4 | azure_rm_virtualmachine_facts 5 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_virtualmachine/inventory.yml: -------------------------------------------------------------------------------- 1 | all: 2 | hosts: 3 | azure_test_invalid: 4 | azure_test_public_ip: 5 | network: 10.42.0.0/24 6 | subnet: 10.42.0.0/28 7 | 8 | azure_test_no_public_ip: 9 | network: 10.42.1.0/24 10 | subnet: 10.42.1.0/28 11 | 12 | azure_test_deallocate: 13 | network: 10.42.2.0/24 14 | subnet: 10.42.2.0/28 15 | 16 | azure_test_minimal: 17 | network: 10.42.3.0/24 18 | subnet: 10.42.3.0/28 19 | 20 | azure_test_dual_nic: 21 | network: 10.42.4.0/24 22 | subnet: 10.42.4.0/28 23 | secondary_network: 10.42.5.0/24 24 | secondary_subnet: 10.42.5.0/28 25 | nic_list: 26 | - name: "{{ 'int' ~ uid_short ~ '-1' }}" 27 | resource_group: "{{ resource_group_secondary }}" 28 | - name: "{{ 'int' ~ uid_short ~ '-2' }}" 29 | resource_group: "{{ resource_group_secondary }}" 30 | 31 | vars: 32 | ansible_connection: local 33 | ansible_python_interpreter: "{{ ansible_playbook_python }}" 34 | 35 | uid: "{{ (resource_group ~ inventory_hostname) | hash('md5') | truncate(18, True, '') }}" 36 | uid_short: "{{ (resource_group ~ inventory_hostname) | hash('md5') | truncate(10, True, '') }}" 37 | 38 | storage_account: "{{ 'stor' ~ uid }}" 39 | availability_set: "{{ 'avbs' ~ uid_short }}" 40 | vm_name: "{{ 'vm' ~ uid_short }}" 41 | network_name: "{{ 'vnet' ~ uid_short }}" 42 | subnet_name: "{{ 'snet' ~ uid_short }}" 43 | security_group: "{{ 'sg' ~ uid_short }}" 44 | public_ip_name: "{{ 'ip' ~ uid_short }}" 45 | interface_name: "{{ 'int' ~ uid_short }}" 46 | 47 | ssh_keys: 48 | - path: '/home/chouseknecht/.ssh/authorized_keys' 49 | key_data: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC1igsIlcmTa/yfsJnTtnrEX7PP/a01gwbXcig6JOKyrUmJB8E6c/wtZwP115VSyDRTO6TEL/sBFUpkSw01zM8ydNATErh8meBlAlbnDq5NLhDXnMizgG0VNn0iLc/WplFTqkefsHXa8NtIxAtyEVIj/fKbK3XfBOdEpE3+MJYNtGlWyaod28W+5qmQPZDQys+YnE4OjSwN7D3g85/7dtLFvDH+lEC4ooJOaxVFr9VSMXUIkaRF6oI+R1Zu803LFSCTb4BfFOYOHPuQ/rEMP0KuUzggvP+TEBY14PEA2FoHOn+oRsT0ZR2+loGRaxSVqCQKaEHbNbkm+6Rllx2NQRO0BJxCSKRU1iifInLPxmSc4gvsHCKMAWy/tGkmKHPWIfN8hvwyDMK5MNBp/SJ1pVx4xuFDQjVWNbll0yk2+72uJgtFHHwEPK9QsOz45gX85vS3yhYCKrscS/W9h2l36SWwQXuGy4fXotE7esPsvNGAzBndHX1O8RMPg47qJXz059RyoGforoa9TnzIs3hIv+ts7ESx3OEq3HNk0FJ+wDka7IM7WQpGrVToJ0vfDy9Q46nw54vv5Zc/u4OZF3F5twHmyf3rLYKXRDuCvZQKT2iWQKVX6j63bq6orA5hwl22zndxWZNtOwtq8Sd0Ns0K/Fo/ggYDDGBtr68DwhA+MrxrHw== chouseknecht@ansible.com" 50 | 51 | image: 52 | offer: CentOS 53 | publisher: OpenLogic 54 | sku: '7.1' 55 | version: latest 56 | 57 | image_paid: 58 | publisher: cognosys 59 | offer: ubuntu-14-04-lts 60 | sku: hardened-ubuntu-14-04 61 | version: latest 62 | 63 | plan_paid: 64 | name: hardened-ubuntu-14-04 65 | product: ubuntu-14-04-lts 66 | publisher: cognosys 67 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_virtualmachine/main.yml: -------------------------------------------------------------------------------- 1 | - name: Run Azurue VM tests in parallel 2 | hosts: all 3 | gather_facts: no 4 | strategy: free 5 | tasks: 6 | - name: Include tasks based on inventory hostname 7 | include_tasks: tasks/{{ inventory_hostname }}.yml 8 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_virtualmachine/runme.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -eux 4 | 5 | ansible-playbook -i inventory.yml main.yml "$@" 6 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_deallocate.yml: -------------------------------------------------------------------------------- 1 | - include_tasks: setup.yml 2 | 3 | - name: Create minimal VM with defaults 4 | azure_rm_virtualmachine: 5 | resource_group: "{{ resource_group }}" 6 | name: "{{ vm_name }}" 7 | admin_username: "testuser" 8 | admin_password: "Pass123$$$abx!" 9 | vm_size: Standard_A0 10 | virtual_network: "{{ network_name }}" 11 | image: 12 | offer: UbuntuServer 13 | publisher: Canonical 14 | sku: 16.04-LTS 15 | version: latest 16 | register: vm_output 17 | 18 | - name: Restart the virtual machine 19 | azure_rm_virtualmachine: 20 | resource_group: "{{ resource_group }}" 21 | name: "{{ vm_name }}" 22 | restarted: yes 23 | vm_size: Standard_A0 24 | register: restart_result 25 | 26 | - name: Ensue VM was restarted 27 | assert: 28 | that: 29 | - "azure_vm.powerstate in ['starting', 'running']" 30 | - restart_result is changed 31 | 32 | - name: Deallocate the virtual machine 33 | azure_rm_virtualmachine: 34 | resource_group: "{{ resource_group }}" 35 | name: "{{ vm_name }}" 36 | allocated: no 37 | vm_size: Standard_A0 38 | register: deallocate_result 39 | 40 | - name: Ensure VM was deallocated 41 | assert: 42 | that: 43 | - azure_vm.powerstate == 'deallocated' 44 | - deallocate_result is changed 45 | 46 | - name: Start the virtual machine 47 | azure_rm_virtualmachine: 48 | resource_group: "{{ resource_group }}" 49 | name: "{{ vm_name }}" 50 | vm_size: Standard_A0 51 | register: start_result 52 | 53 | - name: Ensure VM was started 54 | assert: 55 | that: 56 | - "azure_vm.powerstate in ['starting', 'running']" 57 | - start_result is changed 58 | 59 | - name: Delete VM 60 | azure_rm_virtualmachine: 61 | resource_group: "{{ resource_group }}" 62 | name: "{{ vm_name }}" 63 | state: absent 64 | remove_on_absent: all_autocreated 65 | 66 | - name: Destroy subnet 67 | azure_rm_subnet: 68 | resource_group: "{{ resource_group }}" 69 | virtual_network: "{{ network_name }}" 70 | name: "{{ subnet_name }}" 71 | state: absent 72 | 73 | - name: Destroy virtual network 74 | azure_rm_virtualnetwork: 75 | resource_group: "{{ resource_group }}" 76 | name: "{{ network_name }}" 77 | state: absent 78 | 79 | - name: Destroy availability set 80 | azure_rm_availabilityset: 81 | resource_group: "{{ resource_group }}" 82 | name: "{{ availability_set }}" 83 | state: absent 84 | 85 | - name: Destroy storage account 86 | azure_rm_storageaccount: 87 | resource_group: "{{ resource_group }}" 88 | name: "{{ storage_account }}" 89 | force_delete_nonempty: yes 90 | state: absent 91 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_dual_nic.yml: -------------------------------------------------------------------------------- 1 | - include_tasks: setup.yml 2 | 3 | - name: Create virtual network in secondary resource group 4 | azure_rm_virtualnetwork: 5 | resource_group: "{{ resource_group_secondary }}" 6 | name: "{{ network_name ~ '-2' }}" 7 | address_prefixes: "{{ secondary_network }}" 8 | register: create_virt_net_result 9 | 10 | - name: Create subnet in secondary resource group 11 | azure_rm_subnet: 12 | resource_group: "{{ resource_group_secondary }}" 13 | name: "{{ subnet_name ~ '-2' }}" 14 | address_prefix: "{{ secondary_subnet }}" 15 | virtual_network: "{{ network_name ~ '-2' }}" 16 | 17 | - name: Create NICs for dual NIC VM in secondary resource group 18 | azure_rm_networkinterface: 19 | resource_group: "{{ item.resource_group }}" 20 | name: "{{ item.name }}" 21 | virtual_network: "{{ network_name ~ '-2' }}" 22 | subnet: "{{ subnet_name ~ '-2' }}" 23 | loop: "{{ nic_list }}" 24 | 25 | - name: Create virtual machine with two NICs 26 | azure_rm_virtualmachine: 27 | resource_group: "{{ resource_group }}" # Should this be resource_group_secondary? 28 | name: "{{ vm_name }}" 29 | vm_size: Standard_A0 30 | storage_account: "{{ storage_account }}" 31 | storage_container: "{{ vm_name }}" 32 | storage_blob: "{{ vm_name }}.vhd" 33 | admin_username: adminuser 34 | admin_password: Password123! 35 | short_hostname: testvm 36 | os_type: Linux 37 | os_disk_size_gb: 64 38 | os_disk_name: testosdiskxx 39 | network_interfaces: "{{ nic_list }}" 40 | availability_set: "{{ availability_set }}" 41 | image: 42 | offer: UbuntuServer 43 | publisher: Canonical 44 | sku: 16.04-LTS 45 | version: latest 46 | tags: 47 | abc: def 48 | 49 | - name: Ensure VM was created properly 50 | assert: 51 | that: 52 | - azure_vm.properties.availabilitySet.id 53 | - azure_vm.properties.storageProfile.osDisk.name == 'testosdiskxx' 54 | 55 | - name: Retrieve VM facts (filtering by name) 56 | azure_rm_virtualmachine_facts: 57 | resource_group: "{{ resource_group }}" # Should this be resource_group_secondary? 58 | name: "{{ vm_name }}" 59 | register: vm_facts_results 60 | 61 | - name: Ensure facts module returned the second VM 62 | assert: 63 | that: 64 | - vm_facts_results.vms | length == 1 65 | - vm_facts_results.vms[0].name == "{{ vm_name }}" 66 | - vm_facts_results.vms[0].location 67 | - vm_facts_results.vms[0].admin_username == 'adminuser' 68 | - vm_facts_results.vms[0].resource_group == "{{ resource_group }}" 69 | - vm_facts_results.vms[0].power_state != None 70 | 71 | - name: Retrieve facts by tags 72 | azure_rm_virtualmachine_facts: 73 | tags: 74 | - abc:def 75 | register: facts_by_tags_results 76 | 77 | - name: Assert that facts module returned the second VM 78 | assert: 79 | that: 80 | - facts_by_tags_results.vms | length >= 1 81 | 82 | - name: Should be idempotent with a dual NICs 83 | azure_rm_virtualmachine: 84 | resource_group: "{{ resource_group }}" # Should this be resource_group_secondary? 85 | name: "{{ vm_name }}" 86 | vm_size: Standard_A0 87 | storage_account: "{{ storage_account }}" 88 | storage_container: "{{ vm_name }}" 89 | storage_blob: "{{ vm_name }}.vhd" 90 | admin_username: adminuser 91 | admin_password: Password123! 92 | short_hostname: testvm 93 | os_type: Linux 94 | os_disk_size_gb: 64 95 | network_interfaces: "{{ nic_list }}" 96 | availability_set: "{{ availability_set }}" 97 | image: 98 | offer: UbuntuServer 99 | publisher: Canonical 100 | sku: 16.04-LTS 101 | version: latest 102 | register: dual_nics_result 103 | 104 | - name: Ensure nothing changed 105 | assert: 106 | that: dual_nics_result is not changed 107 | 108 | - name: Generalize VM 109 | azure_rm_virtualmachine: 110 | resource_group: "{{ resource_group }}" # Should this be resource_group_secondary? 111 | name: "{{ vm_name }}" 112 | generalized: yes 113 | 114 | - name: Gather facts and check if machine is generalized 115 | azure_rm_virtualmachine_facts: 116 | resource_group: "{{ resource_group }}" # Should this be resource_group_secondary? 117 | name: "{{ vm_name }}" 118 | register: generalized_output 119 | 120 | - name: Ensure power state is generalized 121 | assert: 122 | that: generalized_output.vms[0].power_state == 'generalized' 123 | 124 | - name: Delete dual NIC VM 125 | azure_rm_virtualmachine: 126 | resource_group: "{{ resource_group }}" # Should this be resource_group_secondary? 127 | name: "{{ vm_name }}" 128 | state: absent 129 | vm_size: Standard_A0 130 | async: 5000 131 | poll: 0 132 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_invalid.yml: -------------------------------------------------------------------------------- 1 | # TODO: Until we have a module to create/delete images this is the best tests I can do 2 | - name: Assert error thrown with invalid image dict 3 | azure_rm_virtualmachine: 4 | resource_group: "{{ resource_group }}" 5 | name: "{{ vm_name }}" 6 | image: 7 | offer: UbuntuServer 8 | register: fail_invalid_image_dict 9 | failed_when: 'fail_invalid_image_dict.msg != "parameter error: expecting image to contain [publisher, offer, sku, version], [name, resource_group] or [id]"' 10 | 11 | - name: Assert error thrown with invalid image type 12 | azure_rm_virtualmachine: 13 | resource_group: "{{ resource_group }}" 14 | name: "{{ vm_name }}" 15 | image: 16 | - testing 17 | register: fail_invalid_image_type 18 | failed_when: 'fail_invalid_image_type.msg != "parameter error: expecting image to be a string or dict not list"' 19 | 20 | - name: Assert error finding missing custom image 21 | azure_rm_virtualmachine: 22 | resource_group: "{{ resource_group }}" 23 | name: "{{ vm_name }}" 24 | image: invalid-image 25 | register: fail_missing_custom_image 26 | failed_when: fail_missing_custom_image.msg != "Error could not find image with name invalid-image" 27 | 28 | - name: Assert error finding missing custom image (dict style) 29 | azure_rm_virtualmachine: 30 | resource_group: "{{ resource_group }}" 31 | name: "{{ vm_name }}" 32 | image: 33 | name: invalid-image 34 | register: fail_missing_custom_image_dict 35 | failed_when: fail_missing_custom_image_dict.msg != "Error could not find image with name invalid-image" 36 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_minimal.yml: -------------------------------------------------------------------------------- 1 | - include_tasks: setup.yml 2 | 3 | # # Tests possible when CI user acccount setup with required authority 4 | # - name: Create virtual machine with image and plan which requires acceptance of terms 5 | # azure_rm_virtualmachine: 6 | # resource_group: "{{ resource_group }}" 7 | # name: testvm009 8 | # vm_size: Standard_A0 9 | # storage_account: "{{ storage_account }}" 10 | # storage_container: testvm001 11 | # storage_blob: testvm003.vhd 12 | # admin_username: adminuser 13 | # admin_password: Password123! 14 | # short_hostname: testvm 15 | # os_type: Linux 16 | # availability_set: "{{ availability_set }}" 17 | # image: "{{ image_paid }}" 18 | # plan_paid: "{{ plan_paid }}" 19 | # register: create_image_plan_result 20 | 21 | # - assert: 22 | # that: 23 | # - create_image_plan_result is changed 24 | # - create_image_plan_result.ansible_facts.azure_vm.properties.storageProfile.imageReference.publisher == image_paid.publisher 25 | 26 | # - name: Should be idempotent with image and plan which requires acceptance of terms 27 | # azure_rm_virtualmachine: 28 | # resource_group: "{{ resource_group }}" 29 | # name: testvm009 30 | # vm_size: Standard_A0 31 | # storage_account: "{{ storage_account }}" 32 | # storage_container: testvm001 33 | # storage_blob: testvm003.vhd 34 | # admin_username: adminuser 35 | # admin_password: Password123! 36 | # short_hostname: testvm 37 | # os_type: Linux 38 | # availability_set: "{{ availability_set }}" 39 | # image: "{{ image_paid }}" 40 | # plan_paid: "{{ plan_paid }}" 41 | # register: create_image_plan_again_result 42 | 43 | # - assert: 44 | # that: create_image_plan_again is not changed 45 | 46 | - name: Create minimal VM with defaults 47 | azure_rm_virtualmachine: 48 | resource_group: "{{ resource_group }}" 49 | name: "{{ vm_name }}" 50 | admin_username: "testuser" 51 | admin_password: "Pass123$$$abx!" 52 | vm_size: Standard_B1ms 53 | virtual_network: "{{ network_name }}" 54 | image: 55 | offer: UbuntuServer 56 | publisher: Canonical 57 | sku: 16.04-LTS 58 | version: latest 59 | register: vm_output 60 | 61 | - name: Delete VM 62 | azure_rm_virtualmachine: 63 | resource_group: "{{ resource_group }}" 64 | name: "{{ vm_name }}" 65 | remove_on_absent: all_autocreated 66 | state: absent 67 | 68 | - name: Query auto created NIC 69 | azure_rm_networkinterface_facts: 70 | resource_group: "{{ resource_group }}" 71 | name: "{{ vm_name }}01" 72 | register: nic_result 73 | 74 | - name: Query auto created security group 75 | azure_rm_securitygroup_facts: 76 | resource_group: "{{ resource_group }}" 77 | name: "{{ vm_name }}01" 78 | register: nsg_result 79 | 80 | - name: Query auto created public IP 81 | azure_rm_publicipaddress_facts: 82 | resource_group: "{{ resource_group }}" 83 | name: "{{ vm_name }}01" 84 | register: pip_result 85 | 86 | - name: Assert that autocreated resources were deleted 87 | assert: 88 | that: 89 | # what about the default storage group? 90 | - nic_result.ansible_facts.azure_networkinterfaces | length == 0 91 | - nsg_result.ansible_facts.azure_securitygroups | length == 0 92 | - pip_result.ansible_facts.azure_publicipaddresses | length == 0 93 | 94 | - name: Destroy subnet 95 | azure_rm_subnet: 96 | resource_group: "{{ resource_group }}" 97 | virtual_network: "{{ network_name }}" 98 | name: "{{ subnet_name }}" 99 | state: absent 100 | 101 | - name: Destroy virtual network 102 | azure_rm_virtualnetwork: 103 | resource_group: "{{ resource_group }}" 104 | name: "{{ network_name }}" 105 | state: absent 106 | 107 | - name: Destroy availability set 108 | azure_rm_availabilityset: 109 | resource_group: "{{ resource_group }}" 110 | name: "{{ availability_set }}" 111 | state: absent 112 | 113 | - name: Destroy storage account 114 | azure_rm_storageaccount: 115 | resource_group: "{{ resource_group }}" 116 | name: "{{ storage_account }}" 117 | force_delete_nonempty: yes 118 | state: absent 119 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_virtualmachine/tasks/azure_test_no_public_ip.yml: -------------------------------------------------------------------------------- 1 | - include_tasks: setup.yml 2 | 3 | - name: Create virtual machine without public ip address and with boot diagnostics enabled 4 | azure_rm_virtualmachine: 5 | resource_group: "{{ resource_group }}" 6 | name: "{{ vm_name }}" 7 | vm_size: Standard_A0 8 | admin_username: adminuser 9 | admin_password: Password123! 10 | short_hostname: testvm 11 | os_type: Linux 12 | public_ip_allocation_method: Disabled 13 | storage_account_name: "{{ storage_account }}" 14 | availability_set: "{{ availability_set }}" 15 | virtual_network: "{{ network_name }}" 16 | boot_diagnostics: 17 | enabled: yes 18 | image: 19 | offer: UbuntuServer 20 | publisher: Canonical 21 | sku: 16.04-LTS 22 | version: latest 23 | register: create_vm_public_result 24 | 25 | - name: Ensure VM was created properly 26 | assert: 27 | that: 28 | - azure_vm.properties.diagnosticsProfile.bootDiagnostics.enabled 29 | - azure_vm.properties.diagnosticsProfile.bootDiagnostics.storageUri is defined 30 | - azure_vm.properties.instanceView.bootDiagnostics.consoleScreenshotBlobUri is defined 31 | - azure_vm.properties.instanceView.bootDiagnostics.serialConsoleLogBlobUri is defined 32 | - not 'publicIPAddress' in create_vm_public_result.ansible_facts.azure_vm.properties.networkProfile.networkInterfaces[0].properties.ipConfigurations[0].properties 33 | 34 | - name: Delete VM with no public ip 35 | azure_rm_virtualmachine: 36 | resource_group: "{{ resource_group }}" 37 | name: "{{ vm_name }}" 38 | state: absent 39 | remove_on_absent: all_autocreated 40 | async: 5000 41 | poll: 0 42 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_virtualmachine/tasks/setup.yml: -------------------------------------------------------------------------------- 1 | - debug: 2 | msg: "UID is {{ uid_short }}" 3 | 4 | - name: SETUP | Create storage account 5 | azure_rm_storageaccount: 6 | resource_group: "{{ resource_group }}" 7 | name: "{{ storage_account }}" 8 | account_type: Standard_LRS 9 | 10 | - name: SETUP | Create availability set 11 | azure_rm_availabilityset: 12 | name: "{{ availability_set }}" 13 | resource_group: "{{ resource_group }}" 14 | 15 | - name: SETUP | Create virtual network 16 | azure_rm_virtualnetwork: 17 | resource_group: "{{ resource_group }}" 18 | name: "{{ network_name }}" 19 | address_prefixes: "{{ network }}" 20 | 21 | - name: SETUP | Create subnet 22 | azure_rm_subnet: 23 | resource_group: "{{ resource_group }}" 24 | name: "{{ subnet_name }}" 25 | address_prefix: "{{ subnet }}" 26 | virtual_network: "{{ network_name }}" 27 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_virtualmachineextension/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group5 3 | destructive 4 | azure_rm_virtualmachineextension_facts 5 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_virtualmachineextension/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_virtualmachineimage_facts/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group3 3 | shippable/azure/smoketest 4 | destructive 5 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_virtualmachineimage_facts/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_virtualmachineimage_facts/tasks/main.yml: -------------------------------------------------------------------------------- 1 | - name: set location 2 | set_fact: 3 | location: eastus 4 | 5 | - name: Get facts for a specific image 6 | azure_rm_virtualmachineimage_facts: 7 | location: "{{ location }}" 8 | publisher: OpenLogic 9 | offer: CentOS 10 | sku: '7.3' 11 | version: '7.3.20170707' 12 | register: output 13 | 14 | - assert: 15 | that: azure_vmimages | length == 1 16 | 17 | - name: List available versions 18 | azure_rm_virtualmachineimage_facts: 19 | location: "{{ location }}" 20 | publisher: OpenLogic 21 | offer: CentOS 22 | sku: '7.3' 23 | register: output 24 | 25 | - assert: 26 | that: azure_vmimages | length > 0 27 | 28 | - name: List available offers 29 | azure_rm_virtualmachineimage_facts: 30 | location: "{{ location }}" 31 | publisher: OpenLogic 32 | register: output 33 | 34 | - assert: 35 | that: azure_vmimages | length > 0 36 | 37 | - name: List available publishers 38 | azure_rm_virtualmachineimage_facts: 39 | location: "{{ location }}" 40 | register: output 41 | 42 | - assert: 43 | that: azure_vmimages | length > 0 44 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_virtualmachinescaleset/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group10 3 | destructive 4 | azure_rm_virtualmachinescaleset_facts 5 | azure_rm_virtualmachinescalesetinstance_facts 6 | azure_rm_virtualmachinescalesetextension 7 | azure_rm_virtualmachinescalesetextension_facts 8 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_virtualmachinescaleset/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_virtualnetwork/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group2 3 | destructive 4 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_virtualnetwork/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_virtualnetwork/tasks/main.yml: -------------------------------------------------------------------------------- 1 | - name: Prepare random number 2 | set_fact: 3 | vnetname: "vnet{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}" 4 | 5 | - name: Delete virtual network, if it exists 6 | azure_rm_virtualnetwork: 7 | name: "{{ vnetname }}" 8 | resource_group: "{{ resource_group }}" 9 | state: absent 10 | 11 | - name: Create virtual network 12 | azure_rm_virtualnetwork: 13 | name: "{{ vnetname }}" 14 | address_prefixes_cidr: 15 | - 10.1.0.0/16 16 | - 172.100.0.0/16 17 | tags: 18 | testing: testing 19 | delete: on-exit 20 | resource_group: "{{ resource_group }}" 21 | 22 | - name: Create virtual network 23 | azure_rm_virtualnetwork: 24 | name: "{{ vnetname }}" 25 | address_prefixes_cidr: 26 | - 10.1.0.0/16 27 | - 172.100.0.0/16 28 | dns_servers: 29 | - 127.0.0.1 30 | - 127.0.0.3 31 | tags: 32 | testing: testing 33 | delete: on-exit 34 | resource_group: "{{ resource_group }}" 35 | register: output 36 | 37 | - assert: 38 | that: 39 | - "output.state.address_prefixes | length == 2" 40 | - "output.state.dns_servers | length == 2" 41 | - "output.state.tags.delete == 'on-exit'" 42 | - "output.state.tags | length == 2" 43 | 44 | - name: Attach a subnet 45 | azure_rm_subnet: 46 | resource_group: "{{ resource_group }}" 47 | name: "{{ vnetname }}" 48 | virtual_network_name: "{{ vnetname }}" 49 | address_prefix_cidr: "10.1.0.0/24" 50 | 51 | - name: Gather facts by name, tags 52 | azure_rm_virtualnetwork_facts: 53 | resource_group: "{{ resource_group }}" 54 | name: "{{ vnetname }}" 55 | tags: 56 | - testing 57 | register: facts 58 | 59 | - assert: 60 | that: 61 | - "azure_virtualnetworks | length == 1" 62 | - "facts.virtualnetworks | length == 1" 63 | - "facts.virtualnetworks[0].dns_servers | length == 2" 64 | - "facts.virtualnetworks[0].address_prefixes | length == 2" 65 | - "facts.virtualnetworks[0].subnets | length == 1" 66 | 67 | - name: Gather facts by resource group, tags 68 | azure_rm_virtualnetwork_facts: 69 | resource_group: "{{ resource_group }}" 70 | tags: 71 | - testing 72 | 73 | - assert: 74 | that: "azure_virtualnetworks | length >= 1" 75 | 76 | - name: Gather facts by tags 77 | azure_rm_virtualnetwork_facts: 78 | tags: 79 | - testing 80 | 81 | - assert: 82 | that: "azure_virtualnetworks | length >= 1" 83 | 84 | - name: Should be idempotent 85 | azure_rm_virtualnetwork: 86 | name: "{{ vnetname }}" 87 | address_prefixes_cidr: 88 | - 10.1.0.0/16 89 | - 172.100.0.0/16 90 | dns_servers: 91 | - 127.0.0.1 92 | - 127.0.0.3 93 | tags: 94 | testing: testing 95 | delete: on-exit 96 | resource_group: "{{ resource_group }}" 97 | register: output 98 | 99 | - assert: 100 | that: not output.changed 101 | 102 | - name: Update tags 103 | azure_rm_virtualnetwork: 104 | name: "{{ vnetname }}" 105 | tags: 106 | testing: 'no' 107 | delete: never 108 | foo: bar 109 | resource_group: "{{ resource_group }}" 110 | register: output 111 | 112 | - assert: 113 | that: output.state.tags | length == 3 114 | 115 | - name: Purge tags 116 | azure_rm_virtualnetwork: 117 | name: "{{ vnetname }}" 118 | append_tags: no 119 | tags: 120 | testing: 'always' 121 | resource_group: "{{ resource_group }}" 122 | register: output 123 | 124 | - assert: 125 | that: 126 | - output.state.tags | length == 1 127 | - output.state.tags.testing == 'always' 128 | 129 | - name: Should require address_prefixes_cidr when purge_address_prefixes 130 | azure_rm_virtualnetwork: 131 | name: "{{ vnetname }}" 132 | purge_address_prefixes: true 133 | resource_group: "{{ resource_group }}" 134 | register: output 135 | ignore_errors: yes 136 | 137 | - assert: 138 | that: output.failed 139 | 140 | - name: Purge address prefixes 141 | azure_rm_virtualnetwork: 142 | name: "{{ vnetname }}" 143 | address_prefixes_cidr: 10.1.0.0/16 144 | purge_address_prefixes: true 145 | resource_group: "{{ resource_group }}" 146 | register: output 147 | 148 | - assert: 149 | that: 150 | - output.state.address_prefixes | length == 1 151 | - output.state.address_prefixes[0] == '10.1.0.0/16' 152 | - output.state.dns_servers | length == 2 153 | - output.state.dns_servers[0] == '127.0.0.1' 154 | 155 | - name: Purge DNS servers 156 | azure_rm_virtualnetwork: 157 | name: "{{ vnetname }}" 158 | purge_dns_servers: true 159 | resource_group: "{{ resource_group }}" 160 | register: output 161 | 162 | - assert: 163 | that: output.state['dns_servers'] is undefined 164 | 165 | - name: Gather facts 166 | azure_rm_virtualnetwork_facts: 167 | resource_group: "{{ resource_group }}" 168 | name: "{{ vnetname }}" 169 | register: facts 170 | 171 | - assert: 172 | that: 173 | - azure_virtualnetworks | length == 1 174 | - facts.virtualnetworks | length == 1 175 | - "facts.virtualnetworks[0].subnets | length == 1" 176 | 177 | - name: Delete virtual network 178 | azure_rm_virtualnetwork: 179 | name: "{{ vnetname }}" 180 | resource_group: "{{ resource_group }}" 181 | state: absent 182 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_virtualnetworkgateway/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group2 3 | destructive 4 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_virtualnetworkgateway/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_virtualnetworkgateway/tasks/main.yml: -------------------------------------------------------------------------------- 1 | # FIXME: needs minimal tests (check mode?) that can run quickly, VNG creation takes > 20min 2 | 3 | - name: Prepare random number 4 | set_fact: 5 | vnetname: "vnet{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}" 6 | vngname: "vng{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}" 7 | 8 | - name: Create virtual network gateway without bgp settings (check mode) 9 | check_mode: yes 10 | azure_rm_virtualnetworkgateway: 11 | resource_group: "{{ resource_group }}" 12 | name: "{{ vngname }}" 13 | ip_configurations: 14 | - name: testipconfig 15 | private_ip_allocation_method: Dynamic 16 | public_ip_address_name: testPublicIP 17 | virtual_network: "{{ vnetname }}" 18 | tags: 19 | common: "xyz" 20 | register: output 21 | 22 | - assert: 23 | that: output.changed 24 | 25 | - name: long-running virtualnetworkgateway tests [run with `--tags long_run,untagged` to enable] 26 | tags: [long_run, never] 27 | block: 28 | - name: Create virtual network 29 | azure_rm_virtualnetwork: 30 | resource_group: "{{ resource_group }}" 31 | name: "{{ vnetname }}" 32 | address_prefixes: "10.0.0.0/16" 33 | 34 | - name: Add subnet 35 | azure_rm_subnet: 36 | resource_group: "{{ resource_group }}" 37 | name: GatewaySubnet 38 | address_prefix: "10.0.2.0/24" 39 | virtual_network: "{{ vnetname }}" 40 | 41 | - name: Create public IP address 42 | azure_rm_publicipaddress: 43 | resource_group: "{{ resource_group }}" 44 | allocation_method: Dynamic 45 | name: testPublicIP 46 | 47 | - name: Create virtual network gateway without bgp settings 48 | azure_rm_virtualnetworkgateway: 49 | resource_group: "{{ resource_group }}" 50 | name: "{{ vngname }}" 51 | ip_configurations: 52 | - name: testipconfig 53 | private_ip_allocation_method: Dynamic 54 | public_ip_address_name: testPublicIP 55 | virtual_network: "{{ vnetname }}" 56 | tags: 57 | common: "xyz" 58 | register: output 59 | 60 | - assert: 61 | that: output.changed 62 | 63 | - name: Create virtual network gateway without bgp settings 64 | azure_rm_virtualnetworkgateway: 65 | resource_group: "{{ resource_group }}" 66 | name: "{{ vngname }}" 67 | ip_configurations: 68 | - name: testipconfig 69 | private_ip_allocation_method: Dynamic 70 | public_ip_address_name: testPublicIP 71 | virtual_network: "{{ vnetname }}" 72 | tags: 73 | common: "xyz" 74 | register: output 75 | 76 | - assert: 77 | that: output.changed 78 | 79 | - name: Create virtual network gateway without bgp settings - idempotent 80 | azure_rm_virtualnetworkgateway: 81 | resource_group: "{{ resource_group }}" 82 | name: "{{ vngname }}" 83 | ip_configurations: 84 | - name: testipconfig 85 | private_ip_allocation_method: Dynamic 86 | public_ip_address_name: testPublicIP 87 | virtual_network: "{{ vnetname }}" 88 | tags: 89 | common: "xyz" 90 | register: output 91 | 92 | - assert: 93 | that: not output.changed 94 | 95 | - name: Update virtual network gateway 96 | azure_rm_virtualnetworkgateway: 97 | resource_group: "{{ resource_group }}" 98 | name: "{{ vngname }}" 99 | ip_configurations: 100 | - name: testipconfig 101 | private_ip_allocation_method: Dynamic 102 | public_ip_address_name: testPublicIP 103 | virtual_network: "{{ vnetname }}" 104 | tags: 105 | common: "mno" 106 | register: output 107 | - assert: 108 | that: output.changed 109 | 110 | - name: Delete virtual network gateway 111 | azure_rm_virtualnetworkgateway: 112 | resource_group: "{{ resource_group }}" 113 | name: "{{ vngname }}" 114 | state: absent 115 | register: output 116 | - assert: 117 | that: output.changed 118 | 119 | - name: Delete virtual network gateway - idempotent 120 | azure_rm_virtualnetworkgateway: 121 | resource_group: "{{ resource_group }}" 122 | name: "{{ vngname }}" 123 | state: absent 124 | register: output 125 | - assert: 126 | that: not output.changed 127 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_virtualnetworkpeering/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group2 3 | destructive 4 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_virtualnetworkpeering/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_virtualnetworkpeering/tasks/main.yml: -------------------------------------------------------------------------------- 1 | - name: Prepare random number 2 | set_fact: 3 | vnetname1: "vnet1{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}" 4 | vnetname2: "vnet2{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}" 5 | peering_name: "peering1{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 100 | random }}" 6 | 7 | - name: Create first virtual network 8 | azure_rm_virtualnetwork: 9 | name: "{{ vnetname1 }}" 10 | address_prefixes_cidr: 11 | - 10.1.0.0/16 12 | tags: 13 | testing: testing 14 | delete: on-exit 15 | resource_group: "{{ resource_group }}" 16 | register: vnet1 17 | 18 | - name: Create second virtual network 19 | azure_rm_virtualnetwork: 20 | name: "{{ vnetname2 }}" 21 | address_prefixes_cidr: 22 | - 10.2.0.0/24 23 | resource_group: "{{ resource_group_secondary }}" 24 | register: vnet2 25 | 26 | - assert: 27 | that: 28 | - vnet1.changed 29 | - vnet2.changed 30 | 31 | - name: Create virtual network peering (check mode) 32 | azure_rm_virtualnetworkpeering: 33 | resource_group: "{{ resource_group }}" 34 | name: "{{ peering_name }}" 35 | virtual_network: "{{ vnetname1 }}" 36 | remote_virtual_network: 37 | resource_group: "{{ resource_group_secondary }}" 38 | name: "{{ vnetname2 }}" 39 | allow_virtual_network_access: false 40 | allow_forwarded_traffic: true 41 | check_mode: yes 42 | register: output 43 | 44 | - assert: 45 | that: output.changed 46 | 47 | - name: Create virtual network peering 48 | azure_rm_virtualnetworkpeering: 49 | resource_group: "{{ resource_group }}" 50 | name: "{{ peering_name }}" 51 | virtual_network: "{{ vnetname1 }}" 52 | remote_virtual_network: 53 | resource_group: "{{ resource_group_secondary }}" 54 | name: "{{ vnetname2 }}" 55 | allow_virtual_network_access: false 56 | allow_forwarded_traffic: true 57 | register: output 58 | 59 | - assert: 60 | that: output.changed 61 | 62 | - name: Update virtual network peering (idempotent) 63 | azure_rm_virtualnetworkpeering: 64 | resource_group: "{{ resource_group }}" 65 | name: "{{ peering_name }}" 66 | virtual_network: "{{ vnetname1 }}" 67 | remote_virtual_network: 68 | resource_group: "{{ resource_group_secondary }}" 69 | name: "{{ vnetname2 }}" 70 | allow_virtual_network_access: false 71 | allow_forwarded_traffic: true 72 | register: output 73 | 74 | - assert: 75 | that: not output.changed 76 | 77 | - name: Update virtual network peering 78 | azure_rm_virtualnetworkpeering: 79 | resource_group: "{{ resource_group }}" 80 | name: "{{ peering_name }}" 81 | virtual_network: "{{ vnetname1 }}" 82 | remote_virtual_network: 83 | resource_group: "{{ resource_group_secondary }}" 84 | name: "{{ vnetname2 }}" 85 | allow_virtual_network_access: true 86 | allow_forwarded_traffic: false 87 | register: output 88 | 89 | - assert: 90 | that: output.changed 91 | 92 | - name: Get facts 93 | azure_rm_virtualnetworkpeering_facts: 94 | resource_group: "{{ resource_group }}" 95 | name: "{{ peering_name }}" 96 | virtual_network: "{{ vnetname1 }}" 97 | register: facts 98 | 99 | - name: Assert Facts 100 | assert: 101 | that: 102 | - facts['vnetpeerings'] | length == 1 103 | - facts['vnetpeerings'][0]['id'] 104 | - facts['vnetpeerings'][0]['peering_state'] 105 | - facts['vnetpeerings'][0]['remote_virtual_network'] 106 | - facts['vnetpeerings'][0]['provisioning_state'] 107 | 108 | - name: Delete virtual network peering 109 | azure_rm_virtualnetworkpeering: 110 | resource_group: "{{ resource_group }}" 111 | name: "{{ peering_name }}" 112 | virtual_network: "{{ vnetname1 }}" 113 | state: absent 114 | register: output 115 | 116 | - name: Delete first virtual network 117 | azure_rm_virtualnetwork: 118 | name: "{{ vnetname1 }}" 119 | resource_group: "{{ resource_group }}" 120 | state: absent 121 | 122 | - name: Delete virtual network 123 | azure_rm_virtualnetwork: 124 | name: "{{ vnetname2 }}" 125 | resource_group: "{{ resource_group_secondary }}" 126 | state: absent -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_webapp/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group3 3 | destructive 4 | azure_rm_webapp_facts 5 | azure_rm_webappslot 6 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_webapp/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_workspace/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group4 3 | destructive 4 | azure_rm_workspace 5 | azure_rm_workspace_facts 6 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_workspace/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_workspace/tasks/main.yml: -------------------------------------------------------------------------------- 1 | - name: Prepare random number 2 | set_fact: 3 | name: "workspace{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}" 4 | 5 | - name: Create workspace (check mode) 6 | azure_rm_loganalyticsworkspace: 7 | name: "{{ name }}" 8 | resource_group: "{{ resource_group }}" 9 | retention_in_days: 40 10 | check_mode: yes 11 | register: output 12 | 13 | - assert: 14 | that: 15 | - output.changed 16 | 17 | - name: Get workspace 18 | azure_rm_loganalyticsworkspace_facts: 19 | name: "{{ name }}" 20 | resource_group: "{{ resource_group }}" 21 | register: facts 22 | 23 | - assert: 24 | that: 25 | - facts.workspaces | length == 0 26 | 27 | - name: Create workspace 28 | azure_rm_loganalyticsworkspace: 29 | name: "{{ name }}" 30 | resource_group: "{{ resource_group }}" 31 | retention_in_days: 40 32 | register: output 33 | 34 | - assert: 35 | that: 36 | - output.retention_in_days == 40 37 | - output.changed 38 | - output.intelligence_packs 39 | 40 | - name: Create workspace (idempontent) 41 | azure_rm_loganalyticsworkspace: 42 | name: "{{ name }}" 43 | resource_group: "{{ resource_group }}" 44 | retention_in_days: 40 45 | register: output 46 | 47 | - assert: 48 | that: 49 | - not output.changed 50 | 51 | - name: Get workspace 52 | azure_rm_loganalyticsworkspace_facts: 53 | name: "{{ name }}" 54 | resource_group: "{{ resource_group }}" 55 | register: facts 56 | 57 | - assert: 58 | that: 59 | - facts.workspaces | length == 1 60 | - facts.workspaces[0].id == output.id 61 | 62 | - set_fact: 63 | pack: "{{ pack | default({}) | combine({output.intelligence_packs[0].name: not output.intelligence_packs[0].enabled}) }}" 64 | 65 | - name: Update intelligence pack 66 | azure_rm_loganalyticsworkspace: 67 | name: "{{ name }}" 68 | resource_group: "{{ resource_group }}" 69 | intelligence_packs: "{{ pack }}" 70 | register: intelligence 71 | 72 | - assert: 73 | that: 74 | - intelligence.intelligence_packs[0].enabled != output.intelligence_packs[0].enabled 75 | 76 | - name: Remove workspace (check mode) 77 | azure_rm_loganalyticsworkspace: 78 | name: "{{ name }}" 79 | resource_group: "{{ resource_group }}" 80 | state: absent 81 | check_mode: yes 82 | register: output 83 | 84 | - assert: 85 | that: 86 | - output.changed 87 | 88 | - name: Get workspace 89 | azure_rm_loganalyticsworkspace_facts: 90 | name: "{{ name }}" 91 | resource_group: "{{ resource_group }}" 92 | register: facts 93 | 94 | - assert: 95 | that: 96 | - facts.workspaces | length == 1 97 | 98 | - name: Remove workspace 99 | azure_rm_loganalyticsworkspace: 100 | name: "{{ name }}" 101 | resource_group: "{{ resource_group }}" 102 | state: absent 103 | register: output 104 | 105 | - assert: 106 | that: 107 | - output.changed 108 | 109 | - name: Get workspace 110 | azure_rm_loganalyticsworkspace_facts: 111 | name: "{{ name }}" 112 | resource_group: "{{ resource_group }}" 113 | register: facts 114 | 115 | - assert: 116 | that: 117 | - facts.workspaces | length == 0 118 | 119 | - name: Remove workspace (idempontent) 120 | azure_rm_loganalyticsworkspace: 121 | name: "{{ name }}" 122 | resource_group: "{{ resource_group }}" 123 | state: absent 124 | register: output 125 | 126 | - assert: 127 | that: 128 | - not output.changed 129 | --------------------------------------------------------------------------------