├── .gitignore ├── .travis.yml ├── README.md ├── SECURITY.md ├── files ├── requirements-azure.txt └── sha.json ├── 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_acs.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_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_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_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_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 ├── meta └── main.yml ├── module_utils └── azure_rm_common.py ├── tasks └── main.yml └── tests ├── integration ├── 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_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_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 └── utils ├── create_resource_group.yml └── delete_resource_group.yml /.gitignore: -------------------------------------------------------------------------------- 1 | .idea -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: '2.7' 3 | 4 | env: 5 | global: 6 | - ANSIBLE_VERSION=latest 7 | 8 | branches: 9 | only: 10 | - master 11 | - /^\d+\.\d+(\.\d+)?(-\S*)?$/ 12 | 13 | install: 14 | - if [ "$ANSIBLE_VERSION" == "latest" ]; then pip install ansible[azure]; else pip 15 | install ansible[azure]==$ANSIBLE_VERSION; fi 16 | - "{ echo '[defaults]'; echo 'roles_path = ../'; echo 'lookup_plugins = ./tests/integration/targets/azure_rm_keyvaultkey/lookup_plugins'; } >> ansible.cfg" 17 | - ansible --version 18 | - pip install -I -r ./files/requirements-azure.txt 19 | - pip freeze 20 | - git remote set-branches --add origin master 21 | - git fetch 22 | 23 | script: 24 | - echo 'send notifiication' 25 | 26 | notifications: 27 | webhooks: https://galaxy.ansible.com/api/v1/notifications/ 28 | 29 | 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | azure.azure_modules 2 | ========= 3 | 4 | This role includes the latest changes and bug fixes for Azure modules from the `devel` branch of [Ansible repository](https://github.com/ansible/ansible). If you cannot wait for Ansible's next release, installing this role is a good choice. 5 | 6 | Prerequisite 7 | ------------ 8 | 9 | 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). 10 | 11 | 12 | Installation 13 | ------------ 14 | 15 | 1. Install the role. 16 | 17 | ``` bash 18 | $ ansible-galaxy install azure.azure_modules 19 | ``` 20 | 21 | 2. Upgrade Azure Python SDKs required by new Azure modules. 22 | 23 | ``` bash 24 | $ pip install -r ~/.ansible/roles/azure.azure_modules/files/requirements-azure.txt 25 | ``` 26 | 27 |     or 28 | 29 | ``` bash 30 | $ sudo pip install -r ~/.ansible/roles/azure.azure_modules/files/requirements-azure.txt 31 | ``` 32 | 33 | Several reasons for installing Python SDKs are listed here. 34 | 35 | - A 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. The corresponding SDK for this new resource needs to be installed. 36 | 37 | - Newer versions of SDKs may introduce breaking API change. One specific working version should be installed here. 38 | 39 | 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. 40 | 41 | 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 the above command, please read below part carefully to double check the installation location. 42 | 43 | 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. 44 | 45 | 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 a user folder and the latter is a system folder. 46 | 47 | One way to figure out the correct `site-packages` path is to check the details of existing packages, say `azure-mgmt-storage` by running the command below: 48 | 49 | ``` bash 50 | $ pip show azure-mgmt-storage 51 | ``` 52 | 53 | You can get the output like below. 54 | 55 | ``` bash 56 | your-user-name@ansible:~$ pip show azure-mgmt-storage 57 | Name: azure-mgmt-storage 58 | Version: 1.5.0 59 | Summary: Microsoft Azure Storage Management Client Library for Python 60 | Home-page: https://github.com/Azure/azure-sdk-for-python 61 | Author: Microsoft Corporation 62 | Author-email: azpysdkhelp@microsoft.com 63 | License: MIT License 64 | Location: /home//.local/lib/python2.7/site-packages 65 | Requires: azure-common, azure-mgmt-nspkg, msrestazure 66 | ``` 67 | 68 | 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. 69 | 70 | Role Variables 71 | -------------- 72 | 73 | No. 74 | 75 | Dependencies 76 | ------------ 77 | 78 | No dependencies on other roles. 79 | 80 | Example Playbook 81 | ---------------- 82 | 83 | - hosts: localhost 84 | roles: 85 | - { role: azure.azure_modules } 86 | tasks: 87 | - name: create storage account 88 | azure_rm_storageaccount: 89 | resource_group: resourcegroupname 90 | name: storagename 91 | account_type: Standard_LRS 92 | 93 | License 94 | ------- 95 | MIT 96 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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==4.4.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==2.3.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.1 31 | msrestazure==0.5.0 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 | -------------------------------------------------------------------------------- /files/sha.json: -------------------------------------------------------------------------------- 1 | { 2 | "lib/ansible/module_utils/azure_rm_common.py": "52a665e224a82b09cb26436d29a753dc8f7facad", 3 | "lib/ansible/modules/cloud/azure": "dfc023209fc7460c449b2e97feb1b5e6d79d1491", 4 | "packaging/requirements/requirements-azure.txt": "68fa03138c719377b754dc1bbd083529297d38b3", 5 | "test/integration/targets": "ff53ca76b83d151fb05ba0c69def6089dc893135" 6 | } -------------------------------------------------------------------------------- /library/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/azure_modules/9b18d4c6e1f68c1cb4e474ff7510d81f49b38413/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 | #!/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_aks_info 18 | 19 | version_added: "2.9" 20 | 21 | short_description: Get Azure Kubernetes Service facts 22 | 23 | description: 24 | - Get facts for a specific Azure Kubernetes Service or all Azure Kubernetes Services. 25 | 26 | options: 27 | name: 28 | description: 29 | - Limit results to a specific resource group. 30 | resource_group: 31 | description: 32 | - The resource group to search for the desired Azure Kubernetes Service 33 | tags: 34 | description: 35 | - Limit results by providing a list of tags. Format tags as 'key' or 'key:value'. 36 | show_kubeconfig: 37 | description: 38 | - Show kubeconfig of the AKS cluster. 39 | - Note the operation will cost more network overhead, not recommended when listing AKS. 40 | version_added: "2.8" 41 | choices: 42 | - user 43 | - admin 44 | 45 | extends_documentation_fragment: 46 | - azure 47 | 48 | author: 49 | - Yuwei Zhou (@yuwzho) 50 | ''' 51 | 52 | EXAMPLES = ''' 53 | - name: Get facts for one Azure Kubernetes Service 54 | azure_rm_aks_info: 55 | name: Testing 56 | resource_group: myResourceGroup 57 | 58 | - name: Get facts for all Azure Kubernetes Services 59 | azure_rm_aks_info: 60 | 61 | - name: Get facts by tags 62 | azure_rm_aks_info: 63 | tags: 64 | - testing 65 | ''' 66 | 67 | RETURN = ''' 68 | azure_aks: 69 | description: List of Azure Kubernetes Service dicts. 70 | returned: always 71 | type: list 72 | ''' 73 | 74 | from ansible.module_utils.azure_rm_common import AzureRMModuleBase 75 | 76 | try: 77 | from msrestazure.azure_exceptions import CloudError 78 | from azure.common import AzureHttpError 79 | except Exception: 80 | # handled in azure_rm_common 81 | pass 82 | 83 | AZURE_OBJECT_CLASS = 'managedClusters' 84 | 85 | 86 | class AzureRMManagedClusterInfo(AzureRMModuleBase): 87 | """Utility class to get Azure Kubernetes Service facts""" 88 | 89 | def __init__(self): 90 | 91 | self.module_args = dict( 92 | name=dict(type='str'), 93 | resource_group=dict(type='str'), 94 | tags=dict(type='list'), 95 | show_kubeconfig=dict(type='str', choices=['user', 'admin']), 96 | ) 97 | 98 | self.results = dict( 99 | changed=False, 100 | aks=[], 101 | available_versions=[] 102 | ) 103 | 104 | self.name = None 105 | self.resource_group = None 106 | self.tags = None 107 | self.show_kubeconfig = None 108 | 109 | super(AzureRMManagedClusterInfo, self).__init__( 110 | derived_arg_spec=self.module_args, 111 | supports_tags=False, 112 | facts_module=True 113 | ) 114 | 115 | def exec_module(self, **kwargs): 116 | 117 | is_old_facts = self.module._name == 'azure_rm_aks_facts' 118 | if is_old_facts: 119 | self.module.deprecate("The 'azure_rm_aks_facts' module has been renamed to 'azure_rm_aks_info'", version='2.13') 120 | 121 | for key in self.module_args: 122 | setattr(self, key, kwargs[key]) 123 | 124 | self.results['aks'] = ( 125 | self.get_item() if self.name 126 | else self.list_items() 127 | ) 128 | 129 | return self.results 130 | 131 | def get_item(self): 132 | """Get a single Azure Kubernetes Service""" 133 | 134 | self.log('Get properties for {0}'.format(self.name)) 135 | 136 | item = None 137 | result = [] 138 | 139 | try: 140 | item = self.managedcluster_client.managed_clusters.get(self.resource_group, self.name) 141 | except CloudError: 142 | pass 143 | 144 | if item and self.has_tags(item.tags, self.tags): 145 | result = [self.serialize_obj(item, AZURE_OBJECT_CLASS)] 146 | if self.show_kubeconfig: 147 | result[0]['kube_config'] = self.get_aks_kubeconfig(self.resource_group, self.name) 148 | 149 | return result 150 | 151 | def list_items(self): 152 | """Get all Azure Kubernetes Services""" 153 | 154 | self.log('List all Azure Kubernetes Services') 155 | 156 | try: 157 | response = self.managedcluster_client.managed_clusters.list(self.resource_group) 158 | except AzureHttpError as exc: 159 | self.fail('Failed to list all items - {0}'.format(str(exc))) 160 | 161 | results = [] 162 | for item in response: 163 | if self.has_tags(item.tags, self.tags): 164 | item_dict = self.serialize_obj(item, AZURE_OBJECT_CLASS) 165 | if self.show_kubeconfig: 166 | item_dict['kube_config'] = self.get_aks_kubeconfig(self.resource_group, item.name) 167 | results.append(item_dict) 168 | 169 | return results 170 | 171 | def get_aks_kubeconfig(self, resource_group, name): 172 | ''' 173 | Gets kubeconfig for the specified AKS instance. 174 | 175 | :return: AKS instance kubeconfig 176 | ''' 177 | if not self.show_kubeconfig: 178 | return '' 179 | role_name = 'cluster{0}'.format(str.capitalize(self.show_kubeconfig)) 180 | access_profile = self.managedcluster_client.managed_clusters.get_access_profile(resource_group, name, role_name) 181 | return access_profile.kube_config.decode('utf-8') 182 | 183 | 184 | def main(): 185 | """Main module execution code path""" 186 | 187 | AzureRMManagedClusterInfo() 188 | 189 | 190 | if __name__ == '__main__': 191 | main() 192 | -------------------------------------------------------------------------------- /library/_azure_rm_aksversion_facts.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_facts.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 | -------------------------------------------------------------------------------- /library/azure_rm_aks_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_aks_info 18 | 19 | version_added: "2.9" 20 | 21 | short_description: Get Azure Kubernetes Service facts 22 | 23 | description: 24 | - Get facts for a specific Azure Kubernetes Service or all Azure Kubernetes Services. 25 | 26 | options: 27 | name: 28 | description: 29 | - Limit results to a specific resource group. 30 | resource_group: 31 | description: 32 | - The resource group to search for the desired Azure Kubernetes Service 33 | tags: 34 | description: 35 | - Limit results by providing a list of tags. Format tags as 'key' or 'key:value'. 36 | show_kubeconfig: 37 | description: 38 | - Show kubeconfig of the AKS cluster. 39 | - Note the operation will cost more network overhead, not recommended when listing AKS. 40 | version_added: "2.8" 41 | choices: 42 | - user 43 | - admin 44 | 45 | extends_documentation_fragment: 46 | - azure 47 | 48 | author: 49 | - Yuwei Zhou (@yuwzho) 50 | ''' 51 | 52 | EXAMPLES = ''' 53 | - name: Get facts for one Azure Kubernetes Service 54 | azure_rm_aks_info: 55 | name: Testing 56 | resource_group: myResourceGroup 57 | 58 | - name: Get facts for all Azure Kubernetes Services 59 | azure_rm_aks_info: 60 | 61 | - name: Get facts by tags 62 | azure_rm_aks_info: 63 | tags: 64 | - testing 65 | ''' 66 | 67 | RETURN = ''' 68 | azure_aks: 69 | description: List of Azure Kubernetes Service dicts. 70 | returned: always 71 | type: list 72 | ''' 73 | 74 | from ansible.module_utils.azure_rm_common import AzureRMModuleBase 75 | 76 | try: 77 | from msrestazure.azure_exceptions import CloudError 78 | from azure.common import AzureHttpError 79 | except Exception: 80 | # handled in azure_rm_common 81 | pass 82 | 83 | AZURE_OBJECT_CLASS = 'managedClusters' 84 | 85 | 86 | class AzureRMManagedClusterInfo(AzureRMModuleBase): 87 | """Utility class to get Azure Kubernetes Service facts""" 88 | 89 | def __init__(self): 90 | 91 | self.module_args = dict( 92 | name=dict(type='str'), 93 | resource_group=dict(type='str'), 94 | tags=dict(type='list'), 95 | show_kubeconfig=dict(type='str', choices=['user', 'admin']), 96 | ) 97 | 98 | self.results = dict( 99 | changed=False, 100 | aks=[], 101 | available_versions=[] 102 | ) 103 | 104 | self.name = None 105 | self.resource_group = None 106 | self.tags = None 107 | self.show_kubeconfig = None 108 | 109 | super(AzureRMManagedClusterInfo, self).__init__( 110 | derived_arg_spec=self.module_args, 111 | supports_tags=False, 112 | facts_module=True 113 | ) 114 | 115 | def exec_module(self, **kwargs): 116 | 117 | is_old_facts = self.module._name == 'azure_rm_aks_facts' 118 | if is_old_facts: 119 | self.module.deprecate("The 'azure_rm_aks_facts' module has been renamed to 'azure_rm_aks_info'", version='2.13') 120 | 121 | for key in self.module_args: 122 | setattr(self, key, kwargs[key]) 123 | 124 | self.results['aks'] = ( 125 | self.get_item() if self.name 126 | else self.list_items() 127 | ) 128 | 129 | return self.results 130 | 131 | def get_item(self): 132 | """Get a single Azure Kubernetes Service""" 133 | 134 | self.log('Get properties for {0}'.format(self.name)) 135 | 136 | item = None 137 | result = [] 138 | 139 | try: 140 | item = self.managedcluster_client.managed_clusters.get(self.resource_group, self.name) 141 | except CloudError: 142 | pass 143 | 144 | if item and self.has_tags(item.tags, self.tags): 145 | result = [self.serialize_obj(item, AZURE_OBJECT_CLASS)] 146 | if self.show_kubeconfig: 147 | result[0]['kube_config'] = self.get_aks_kubeconfig(self.resource_group, self.name) 148 | 149 | return result 150 | 151 | def list_items(self): 152 | """Get all Azure Kubernetes Services""" 153 | 154 | self.log('List all Azure Kubernetes Services') 155 | 156 | try: 157 | response = self.managedcluster_client.managed_clusters.list(self.resource_group) 158 | except AzureHttpError as exc: 159 | self.fail('Failed to list all items - {0}'.format(str(exc))) 160 | 161 | results = [] 162 | for item in response: 163 | if self.has_tags(item.tags, self.tags): 164 | item_dict = self.serialize_obj(item, AZURE_OBJECT_CLASS) 165 | if self.show_kubeconfig: 166 | item_dict['kube_config'] = self.get_aks_kubeconfig(self.resource_group, item.name) 167 | results.append(item_dict) 168 | 169 | return results 170 | 171 | def get_aks_kubeconfig(self, resource_group, name): 172 | ''' 173 | Gets kubeconfig for the specified AKS instance. 174 | 175 | :return: AKS instance kubeconfig 176 | ''' 177 | if not self.show_kubeconfig: 178 | return '' 179 | role_name = 'cluster{0}'.format(str.capitalize(self.show_kubeconfig)) 180 | access_profile = self.managedcluster_client.managed_clusters.get_access_profile(resource_group, name, role_name) 181 | return access_profile.kube_config.decode('utf-8') 182 | 183 | 184 | def main(): 185 | """Main module execution code path""" 186 | 187 | AzureRMManagedClusterInfo() 188 | 189 | 190 | if __name__ == '__main__': 191 | main() 192 | -------------------------------------------------------------------------------- /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_automationaccount.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # 3 | # Copyright (c) 2017 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 | 16 | DOCUMENTATION = ''' 17 | --- 18 | module: azure_rm_automationaccount 19 | version_added: "2.9" 20 | short_description: Manage Azure Automation account 21 | description: 22 | - Create, delete an Azure Automation account. 23 | options: 24 | resource_group: 25 | description: 26 | - Name of resource group. 27 | type: str 28 | required: true 29 | name: 30 | description: 31 | - Name of the automation account. 32 | type: str 33 | required: true 34 | state: 35 | description: 36 | - State of the automation account. Use C(present) to create or update a automation account and C(absent) to delete an automation account. 37 | type: str 38 | default: present 39 | choices: 40 | - absent 41 | - present 42 | location: 43 | description: 44 | - Location of the resource. 45 | - If not specified, use resource group location. 46 | type: str 47 | 48 | extends_documentation_fragment: 49 | - azure 50 | - azure_tags 51 | 52 | author: 53 | - Yuwei Zhou (@yuwzho) 54 | 55 | ''' 56 | 57 | EXAMPLES = ''' 58 | - name: Create an automation account 59 | azure_rm_automationaccount: 60 | name: Testing 61 | resource_group: myResourceGroup 62 | 63 | - name: Create an automation account 64 | azure_rm_automationaccount: 65 | name: Testing 66 | resource_group: myResourceGroup 67 | location: eastus 68 | ''' 69 | 70 | RETURN = ''' 71 | id: 72 | description: 73 | - Automation account resource ID. 74 | type: str 75 | returned: success 76 | sample: "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myResourceGroup/providers/Microsoft.Automation/automationAccounts/Testing" 77 | ''' # NOQA 78 | 79 | from ansible.module_utils.azure_rm_common import AzureRMModuleBase 80 | 81 | 82 | class AzureRMAutomationAccount(AzureRMModuleBase): 83 | 84 | def __init__(self): 85 | 86 | self.module_arg_spec = dict( 87 | resource_group=dict(type='str', required=True), 88 | name=dict(type='str', required=True), 89 | state=dict(type='str', default='present', choices=['present', 'absent']), 90 | location=dict(type='str') 91 | ) 92 | 93 | self.results = dict( 94 | changed=False, 95 | id=None 96 | ) 97 | 98 | self.resource_group = None 99 | self.name = None 100 | self.state = None 101 | self.location = None 102 | 103 | super(AzureRMAutomationAccount, self).__init__(self.module_arg_spec, supports_check_mode=True) 104 | 105 | def exec_module(self, **kwargs): 106 | 107 | for key in list(self.module_arg_spec.keys()) + ['tags']: 108 | setattr(self, key, kwargs[key]) 109 | 110 | account = self.get_account() 111 | changed = False 112 | if self.state == 'present': 113 | if not account: 114 | if not self.location: 115 | resource_group = self.get_resource_group(self.resource_group) 116 | self.location = resource_group.location 117 | param = self.automation_models.AutomationAccountCreateOrUpdateParameters( 118 | location=self.location, 119 | sku=self.automation_models.Sku(name='Basic'), 120 | tags=self.tags 121 | ) 122 | changed = True 123 | if not self.check_mode: 124 | account = self.create_or_update(param) 125 | elif self.tags: 126 | update_tags, tags = self.update_tags(account.tags) 127 | if update_tags: 128 | changed = True 129 | param = self.automation_models.AutomationAccountUpdateParameters( 130 | tags=tags 131 | ) 132 | changed = True 133 | if not self.check_mode: 134 | self.update_account_tags(param) 135 | if account: 136 | self.results['id'] = account.id 137 | elif account: 138 | changed = True 139 | if not self.check_mode: 140 | self.delete_account() 141 | self.results['changed'] = changed 142 | return self.results 143 | 144 | def get_account(self): 145 | try: 146 | return self.automation_client.automation_account.get(self.resource_group, self.name) 147 | except self.automation_models.ErrorResponseException: 148 | pass 149 | 150 | def create_or_update(self, param): 151 | try: 152 | return self.automation_client.automation_account.create_or_update(self.resource_group, self.name, param) 153 | except self.automation_models.ErrorResponseException as exc: 154 | self.fail('Error when creating automation account {0}: {1}'.format(self.name, exc.message)) 155 | 156 | def update_account_tags(self, param): 157 | try: 158 | return self.automation_client.automation_account.update(self.resource_group, self.name, param) 159 | except self.automation_models.ErrorResponseException as exc: 160 | self.fail('Error when updating automation account {0}: {1}'.format(self.name, exc.message)) 161 | 162 | def delete_account(self): 163 | try: 164 | return self.automation_client.automation_account.delete(self.resource_group, self.name) 165 | except self.automation_models.ErrorResponseException as exc: 166 | self.fail('Error when deleting automation account {0}: {1}'.format(self.name, exc.message)) 167 | 168 | 169 | def main(): 170 | AzureRMAutomationAccount() 171 | 172 | 173 | if __name__ == '__main__': 174 | main() 175 | -------------------------------------------------------------------------------- /library/azure_rm_iothubconsumergroup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # 3 | # Copyright (c) 2019 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 | 16 | DOCUMENTATION = ''' 17 | --- 18 | module: azure_rm_iothubconsumergroup 19 | version_added: "2.9" 20 | short_description: Manage Azure IoT hub 21 | description: 22 | - Create, delete an Azure IoT hub. 23 | options: 24 | resource_group: 25 | description: 26 | - Name of resource group. 27 | type: str 28 | required: true 29 | hub: 30 | description: 31 | - Name of the IoT hub. 32 | type: str 33 | required: true 34 | state: 35 | description: 36 | - State of the IoT hub. Use C(present) to create or update an IoT hub and C(absent) to delete an IoT hub. 37 | type: str 38 | default: present 39 | choices: 40 | - absent 41 | - present 42 | event_hub: 43 | description: 44 | - Event hub endpoint name. 45 | type: str 46 | default: events 47 | name: 48 | description: 49 | - Name of the consumer group. 50 | type: str 51 | extends_documentation_fragment: 52 | - azure 53 | - azure_tags 54 | 55 | author: 56 | - Yuwei Zhou (@yuwzho) 57 | 58 | ''' 59 | 60 | EXAMPLES = ''' 61 | - name: Create an IoT hub consumer group 62 | azure_rm_iothubconsumergroup: 63 | name: test 64 | resource_group: myResourceGroup 65 | hub: Testing 66 | ''' 67 | 68 | RETURN = ''' 69 | id: 70 | description: 71 | - Resource ID of the consumer group. 72 | returned: success 73 | type: str 74 | sample: "/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourceGroups/myResourceGroup 75 | /providers/Microsoft.Devices/IotHubs/Testing/events/ConsumerGroups/%24Default" 76 | name: 77 | description: 78 | - Name of the consumer group. 79 | sample: Testing 80 | returned: success 81 | type: str 82 | ''' # NOQA 83 | 84 | from ansible.module_utils.azure_rm_common import AzureRMModuleBase, format_resource_id 85 | from ansible.module_utils.common.dict_transformations import _snake_to_camel, _camel_to_snake 86 | import re 87 | 88 | try: 89 | from msrestazure.tools import parse_resource_id 90 | from msrestazure.azure_exceptions import CloudError 91 | except ImportError: 92 | # This is handled in azure_rm_common 93 | pass 94 | 95 | 96 | class AzureRMIoTHubConsumerGroup(AzureRMModuleBase): 97 | 98 | def __init__(self): 99 | 100 | self.module_arg_spec = dict( 101 | resource_group=dict(type='str', required=True), 102 | name=dict(type='str', required=True), 103 | state=dict(type='str', default='present', choices=['present', 'absent']), 104 | hub=dict(type='str', required=True), 105 | event_hub=dict(type='str', default='events') 106 | ) 107 | 108 | self.results = dict( 109 | changed=False, 110 | id=None 111 | ) 112 | 113 | self.resource_group = None 114 | self.name = None 115 | self.state = None 116 | self.hub = None 117 | self.event_hub = None 118 | 119 | super(AzureRMIoTHubConsumerGroup, self).__init__(self.module_arg_spec, supports_check_mode=True) 120 | 121 | def exec_module(self, **kwargs): 122 | 123 | for key in self.module_arg_spec.keys(): 124 | setattr(self, key, kwargs[key]) 125 | 126 | changed = False 127 | cg = self.get_cg() 128 | if not cg and self.state == 'present': 129 | changed = True 130 | if not self.check_mode: 131 | cg = self.create_cg() 132 | elif cg and self.state == 'absent': 133 | changed = True 134 | cg = None 135 | if not self.check_mode: 136 | self.delete_cg() 137 | self.results = dict( 138 | id=cg.id, 139 | name=cg.name 140 | ) if cg else dict() 141 | self.results['changed'] = changed 142 | return self.results 143 | 144 | def get_cg(self): 145 | try: 146 | return self.IoThub_client.iot_hub_resource.get_event_hub_consumer_group(self.resource_group, self.hub, self.event_hub, self.name) 147 | except Exception: 148 | pass 149 | return None 150 | 151 | def create_cg(self): 152 | try: 153 | return self.IoThub_client.iot_hub_resource.create_event_hub_consumer_group(self.resource_group, self.hub, self.event_hub, self.name) 154 | except Exception as exc: 155 | self.fail('Error when creating the consumer group {0} for IoT Hub {1} event hub {2}: {3}'.format(self.name, self.hub, self.event_hub, str(exc))) 156 | 157 | def delete_cg(self): 158 | try: 159 | return self.IoThub_client.iot_hub_resource.delete_event_hub_consumer_group(self.resource_group, self.hub, self.event_hub, self.name) 160 | except Exception as exc: 161 | self.fail('Error when deleting the consumer group {0} for IoT Hub {1} event hub {2}: {3}'.format(self.name, self.hub, self.event_hub, str(exc))) 162 | 163 | 164 | def main(): 165 | AzureRMIoTHubConsumerGroup() 166 | 167 | 168 | if __name__ == '__main__': 169 | main() 170 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # 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 is undefined 7 | - debug: 8 | msg: 9 | - "Your Ansible version is lower than 2.5.0" 10 | - "You may need to perform additional steps to install this roles:" 11 | - " sudo pip install -r {{ role_path }}/files/requirements-azure.txt" 12 | - "or" 13 | - " pip install --user -r {{ role_path }}/files/requirements-azure.txt" 14 | - "depending on your ansible setup." 15 | when: ansible_version.full < "2.5.0" 16 | -------------------------------------------------------------------------------- /tests/integration/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | roles: 4 | - { role: azure_modules } 5 | tasks: 6 | - debug: 7 | msg: "{{resource_group}} {{test}}" 8 | 9 | - include_tasks: "{{test}}" -------------------------------------------------------------------------------- /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_info: 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_autoscale/tasks/main.yml: -------------------------------------------------------------------------------- 1 | - name: Prepare random number 2 | set_fact: 3 | rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}" 4 | name: "scale{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}" 5 | run_once: yes 6 | 7 | - name: Create virtual network 8 | azure_rm_virtualnetwork: 9 | resource_group: "{{ resource_group }}" 10 | name: testVnet 11 | address_prefixes: "10.0.0.0/16" 12 | 13 | - name: Add subnet 14 | azure_rm_subnet: 15 | resource_group: "{{ resource_group }}" 16 | name: testSubnet 17 | address_prefix: "10.0.1.0/24" 18 | virtual_network: testVnet 19 | 20 | - name: Create VMSS 21 | azure_rm_virtualmachinescaleset: 22 | resource_group: "{{ resource_group }}" 23 | name: testVMSS{{ rpfx }} 24 | vm_size: Standard_DS1_v2 25 | admin_username: testuser 26 | ssh_password_enabled: true 27 | admin_password: "Password1234!" 28 | capacity: 2 29 | virtual_network_name: testVnet 30 | subnet_name: testSubnet 31 | upgrade_policy: Manual 32 | tier: Standard 33 | managed_disk_type: Standard_LRS 34 | os_disk_caching: ReadWrite 35 | image: 36 | offer: CoreOS 37 | publisher: CoreOS 38 | sku: Stable 39 | version: latest 40 | data_disks: 41 | - lun: 0 42 | disk_size_gb: 64 43 | caching: ReadWrite 44 | managed_disk_type: Standard_LRS 45 | register: vmss 46 | 47 | - name: create auto scaling (check mode) 48 | azure_rm_autoscale: 49 | resource_group: "{{ resource_group }}" 50 | name: "{{ name }}" 51 | target: "{{ vmss.ansible_facts.azure_vmss.id }}" 52 | enabled: true 53 | profiles: 54 | - count: '1' 55 | recurrence_days: 56 | - Monday 57 | name: Auto created scale condition 58 | recurrence_timezone: China Standard Time 59 | recurrence_mins: 60 | - '0' 61 | min_count: '1' 62 | max_count: '1' 63 | recurrence_frequency: Week 64 | recurrence_hours: 65 | - '18' 66 | check_mode: yes 67 | register: output 68 | 69 | - assert: 70 | that: 71 | - output.changed 72 | 73 | - name: create auto scaling 74 | azure_rm_autoscale: 75 | resource_group: "{{ resource_group }}" 76 | name: "{{ name }}" 77 | target: 78 | name: "testVMSS{{ rpfx }}" 79 | types: "virtualMachineScaleSets" 80 | namespace: "Microsoft.Compute" 81 | enabled: true 82 | profiles: 83 | - count: '1' 84 | recurrence_days: 85 | - Monday 86 | name: Auto created scale condition 87 | recurrence_timezone: China Standard Time 88 | recurrence_mins: 89 | - '0' 90 | min_count: '1' 91 | max_count: '1' 92 | recurrence_frequency: Week 93 | recurrence_hours: 94 | - '18' 95 | register: output 96 | 97 | - assert: 98 | that: 99 | - output.changed 100 | - output.id 101 | 102 | - name: create auto scaling (idemponent) 103 | azure_rm_autoscale: 104 | resource_group: "{{ resource_group }}" 105 | name: "{{ name }}" 106 | target: "{{ vmss.ansible_facts.azure_vmss.id }}" 107 | enabled: true 108 | profiles: 109 | - count: '1' 110 | recurrence_days: 111 | - Monday 112 | name: Auto created scale condition 113 | recurrence_timezone: China Standard Time 114 | recurrence_mins: 115 | - '0' 116 | min_count: '1' 117 | max_count: '1' 118 | recurrence_frequency: Week 119 | recurrence_hours: 120 | - '18' 121 | register: output 122 | 123 | - assert: 124 | that: 125 | - not output.changed 126 | - output.id 127 | 128 | - name: update auto scaling 129 | azure_rm_autoscale: 130 | resource_group: "{{ resource_group }}" 131 | name: "{{ name }}" 132 | target: "{{ vmss.ansible_facts.azure_vmss.id }}" 133 | enabled: true 134 | profiles: 135 | - count: '1' 136 | recurrence_days: 137 | - Monday 138 | name: Auto created scale condition 0 139 | rules: 140 | - time_aggregation: Average 141 | time_window: 10 142 | direction: Increase 143 | metric_name: Percentage CPU 144 | metric_resource_uri: "{{ vmss.ansible_facts.azure_vmss.id }}" 145 | value: '1' 146 | threshold: 70 147 | cooldown: 5 148 | time_grain: 1 149 | statistic: Average 150 | operator: GreaterThan 151 | type: ChangeCount 152 | max_count: '1' 153 | recurrence_mins: 154 | - '0' 155 | min_count: '1' 156 | recurrence_timezone: China Standard Time 157 | recurrence_frequency: Week 158 | recurrence_hours: 159 | - '6' 160 | register: output 161 | 162 | - assert: 163 | that: 164 | - output.changed 165 | - output.profiles[0].rules[0].metric_resource_uri == vmss.ansible_facts.azure_vmss.id 166 | 167 | - name: delete auto scaling (check mode) 168 | azure_rm_autoscale: 169 | resource_group: "{{ resource_group }}" 170 | name: "{{ name }}" 171 | state: absent 172 | check_mode: yes 173 | register: output 174 | 175 | - assert: 176 | that: 177 | - output.changed 178 | 179 | - name: delete auto scaling 180 | azure_rm_autoscale: 181 | resource_group: "{{ resource_group }}" 182 | name: "{{ name }}" 183 | state: absent 184 | register: output 185 | 186 | - assert: 187 | that: 188 | - output.changed 189 | 190 | - name: delete auto scaling (idemponetent) 191 | azure_rm_autoscale: 192 | resource_group: "{{ resource_group }}" 193 | name: "{{ name }}" 194 | state: absent 195 | register: output 196 | 197 | - assert: 198 | that: 199 | - not output.changed 200 | 201 | - name: Clean VMSS 202 | azure_rm_virtualmachinescaleset: 203 | resource_group: "{{ resource_group }}" 204 | vm_size: Standard_DS1_v2 205 | name: testVMSS{{ rpfx }} 206 | state: absent 207 | 208 | - name: Clean subnet 209 | azure_rm_subnet: 210 | resource_group: "{{ resource_group }}" 211 | name: testSubnet 212 | virtual_network: testVnet 213 | state: absent 214 | 215 | - name: Clean virtual network 216 | azure_rm_virtualnetwork: 217 | resource_group: "{{ resource_group }}" 218 | name: testVnet 219 | state: absent 220 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_availabilityset/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group2 3 | destructive 4 | azure_rm_availalibityset_info 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 | - assert: 112 | that: 113 | - not results.changed 114 | - not results.failed 115 | - results.ansible_info.azure_availabilitysets[0].properties.platformFaultDomainCount == 2 116 | - results.ansible_info.azure_availabilitysets[0].properties.platformUpdateDomainCount == 5 117 | - results.ansible_info.azure_availabilitysets[0].sku == 'Aligned' 118 | 119 | 120 | - name: Delete an availability set 121 | azure_rm_availabilityset: 122 | name: myavailabilityset1 123 | resource_group: "{{ resource_group }}" 124 | state: absent 125 | 126 | - name: Delete an availability set 127 | azure_rm_availabilityset: 128 | name: myavailabilityset2 129 | resource_group: "{{ resource_group }}" 130 | state: absent 131 | 132 | - name: Delete an availability set 133 | azure_rm_availabilityset: 134 | name: myavailabilityset3 135 | resource_group: "{{ resource_group }}" 136 | state: absent 137 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_azurefirewall/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group4 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_info 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_info 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_info 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_info: 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_info: 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_info 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_info: 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: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | destructive 3 | shippable/azure/group2 4 | azure_rm_devtestlab_facts 5 | azure_rm_devtestlabarmtemplate 6 | azure_rm_devtestlabartifact 7 | azure_rm_devtestlabartifactsource_facts 8 | azure_rm_devtestlabartifactsource 9 | azure_rm_devtestlabcustomimage 10 | azure_rm_devtestlabpolicy 11 | azure_rm_devtestlabschedule 12 | azure_rm_devtestlabvirtualmachine_facts 13 | azure_rm_devtestlabvirtualmachine_facts 14 | azure_rm_devtestlabvirtualnetwork_facts 15 | azure_rm_devtestlabvirtualnetwork 16 | disabled 17 | 18 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_devtestlab/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_dnszone/aliases: -------------------------------------------------------------------------------- 1 | cloud/azure 2 | shippable/azure/group2 3 | destructive 4 | azure_rm_dnszone_info 5 | azure_rm_dnsrecordset 6 | azure_rm_dnsrecordset_info 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 | - name: assert the facts were retrieved 37 | assert: 38 | that: 39 | - results.ansible_info.azure_functionapps|length == 1 40 | - results.ansible_info.azure_functionapps[0].name == "{{ funcapp_name_basic }}" 41 | 42 | - name: delete basic function app 43 | azure_rm_functionapp: 44 | resource_group: '{{ resource_group }}' 45 | name: "{{ funcapp_name_basic }}" 46 | state: absent 47 | register: output 48 | 49 | - name: assert the function was deleted 50 | assert: 51 | that: output.changed 52 | 53 | - name: create a function with app settings 54 | azure_rm_functionapp: 55 | resource_group: '{{ resource_group }}' 56 | name: "{{ funcapp_name_params }}" 57 | storage_account: "{{ storage_account_name }}" 58 | app_settings: 59 | hello: world 60 | things: more stuff 61 | FUNCTIONS_EXTENSION_VERSION: "~2" 62 | register: output 63 | 64 | - name: assert the function with app settings was created 65 | assert: 66 | that: output.changed 67 | 68 | - name: change app settings 69 | azure_rm_functionapp: 70 | resource_group: '{{ resource_group }}' 71 | name: "{{ funcapp_name_params }}" 72 | storage_account: "{{ storage_account_name }}" 73 | app_settings: 74 | hello: world 75 | things: more stuff 76 | FUNCTIONS_EXTENSION_VERSION: "~2" 77 | another: one 78 | register: output 79 | 80 | - name: assert the function was changed 81 | assert: 82 | that: output.changed 83 | 84 | - name: delete the function app 85 | azure_rm_functionapp: 86 | resource_group: '{{ resource_group }}' 87 | name: "{{ funcapp_name_params }}" 88 | state: absent 89 | register: output 90 | 91 | - name: assert the function was deleted 92 | assert: 93 | that: output.changed 94 | 95 | - name: Create a linux app service plan 96 | azure_rm_appserviceplan: 97 | resource_group: "{{ resource_group }}" 98 | name: "{{ plan_name }}" 99 | sku: S1 100 | is_linux: true 101 | number_of_workers: 1 102 | 103 | - name: "Create azure function app {{ function_app }}" 104 | azure_rm_functionapp: 105 | resource_group: "{{ resource_group }}" 106 | name: "{{ funcapp_name_container }}" 107 | storage_account: "{{ storage_account_name }}" 108 | plan: 109 | resource_group: "{{ resource_group }}" 110 | name: "{{ plan_name }}" 111 | container_settings: 112 | name: httpd 113 | app_settings: 114 | FUNCTIONS_EXTENSION_VERSION: "~2" 115 | register: output 116 | 117 | - name: assert the function was changed 118 | assert: 119 | that: output.changed 120 | 121 | - name: delete the function app 122 | azure_rm_functionapp: 123 | resource_group: '{{ resource_group }}' 124 | name: "{{ funcapp_name_container }}" 125 | state: absent 126 | 127 | - name: delete storage account 128 | azure_rm_storageaccount: 129 | resource_group: '{{ resource_group }}' 130 | name: "{{ storage_account_name }}" 131 | state: absent 132 | -------------------------------------------------------------------------------- /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 | azure_rm_snapshot 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_info 6 | disabled 7 | -------------------------------------------------------------------------------- /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_info 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_info: 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 | disabled # See: https://github.com/ansible/ansible/issues/61852 4 | destructive 5 | -------------------------------------------------------------------------------- /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_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_info 5 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_manageddisk/meta/main.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - setup_azure 3 | -------------------------------------------------------------------------------- /tests/integration/targets/azure_rm_manageddisk/tasks/main.yml: -------------------------------------------------------------------------------- 1 | - name: Prepare random number 2 | set_fact: 3 | rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}" 4 | parameter: {} 5 | run_once: yes 6 | 7 | - name: Clearing (if) previous disks were created 8 | azure_rm_manageddisk: 9 | resource_group: "{{ resource_group }}" 10 | name: "md{{ rpfx }}{{ item }}" 11 | managed_by: '' 12 | state: absent 13 | with_items: 14 | - 1 15 | - 2 16 | - 3 17 | 18 | - name: Test invalid account name (should give error) 19 | azure_rm_manageddisk: 20 | resource_group: "{{ resource_group }}" 21 | name: "invalid_char$" 22 | disk_size_gb: 1 23 | register: output 24 | ignore_errors: yes 25 | check_mode: no 26 | 27 | - name: Assert task failed 28 | assert: { that: "output['failed'] == True" } 29 | 30 | - name: Create managed disk (Check Mode) 31 | azure_rm_manageddisk: 32 | resource_group: "{{ resource_group }}" 33 | name: "md{{ rpfx }}1" 34 | storage_account_type: "Standard_LRS" 35 | disk_size_gb: 1 36 | tags: 37 | testing: testing 38 | delete: never 39 | register: output 40 | check_mode: yes 41 | 42 | - name: Assert status succeeded (Check Mode) 43 | assert: 44 | that: 45 | - output.changed 46 | - output.state 47 | 48 | - name: Create new managed disk succesfully 49 | azure_rm_manageddisk: 50 | resource_group: "{{ resource_group }}" 51 | name: "md{{ rpfx }}1" 52 | storage_account_type: "Standard_LRS" 53 | disk_size_gb: 1 54 | tags: 55 | testing: testing 56 | delete: never 57 | register: output 58 | 59 | - name: Assert status succeeded and results include an Id value 60 | assert: 61 | that: 62 | - output.changed 63 | - output.state.disk_size_gb == 1 64 | - output.state.id is defined 65 | - output.state.os_type == None 66 | - output.state.storage_account_type == "Standard_LRS" 67 | 68 | - name: Copy disk to a new managed disk 69 | azure_rm_manageddisk: 70 | resource_group: "{{ resource_group }}" 71 | name: "md{{ rpfx }}2" 72 | create_option: "copy" 73 | source_uri: "{{ output.state.id }}" 74 | disk_size_gb: 1 75 | register: disk2 76 | 77 | - name: Assert status succeeded and results include an Id value 78 | assert: 79 | that: 80 | - disk2.changed 81 | - disk2.state.id is defined 82 | 83 | - name: Create disk to a new managed disk with zone and os type 84 | azure_rm_manageddisk: 85 | resource_group: "{{ resource_group }}" 86 | name: "md{{ rpfx }}3" 87 | source_uri: "{{ output.state.id }}" 88 | disk_size_gb: 1 89 | zone: "1" 90 | os_type: windows 91 | register: disk3 92 | 93 | - name: Assert status succeeded and results include an Id value 94 | assert: 95 | that: 96 | - disk3.changed 97 | - disk3.state.id is defined 98 | - disk3.state.zone == "1" 99 | - disk3.state.os_type == "windows" 100 | 101 | - name: Change storage account type to an invalid type 102 | azure_rm_manageddisk: 103 | resource_group: "{{ resource_group }}" 104 | name: "md{{ rpfx }}1" 105 | storage_account_type: "PremiumL" 106 | disk_size_gb: 1 107 | register: output 108 | ignore_errors: yes 109 | 110 | - name: Assert storage account type change failed 111 | assert: { that: "output['failed'] == True" } 112 | 113 | - name: Update disk options (os_type, account_type, size, tags) 114 | azure_rm_manageddisk: 115 | resource_group: "{{ resource_group }}" 116 | name: "md{{ rpfx }}1" 117 | disk_size_gb: 2 118 | os_type: linux 119 | storage_account_type: "StandardSSD_LRS" 120 | tags: 121 | galaxy: "no" 122 | delete: never 123 | register: output 124 | 125 | - assert: 126 | that: 127 | - output.changed 128 | - output.state.storage_account_type == "StandardSSD_LRS" 129 | - output.state.disk_size_gb == 2 130 | - "output.state.tags | length == 2" 131 | - "output.state.tags.galaxy == 'no'" 132 | - output.state.os_type == 'linux' 133 | 134 | - name: Gather facts to one specific disk 135 | azure_rm_manageddisk_info: 136 | resource_group: "{{ resource_group }}" 137 | name: "md{{ rpfx }}1" 138 | register: output 139 | 140 | - assert: 141 | that: 142 | - "output.ansible_info.azure_managed_disk | length == 1" 143 | - output.ansible_info.azure_managed_disk[0].storage_account_type == "StandardSSD_LRS" 144 | - output.ansible_info.azure_managed_disk[0].disk_size_gb == 2 145 | - "output.ansible_info.azure_managed_disk[0].os_type == 'linux'" 146 | 147 | - set_fact: 148 | parameter: "{{parameter |combine({item.key: item.value})}}" 149 | when: "{{item.key not in ['id', 'changed'] and item.value != None}}" 150 | with_dict: "{{ output.ansible_info.azure_managed_disk[0] }}" 151 | 152 | - name: Create disk with facts return value 153 | azure_rm_manageddisk: 154 | resource_group: "{{ resource_group }}" 155 | location: "{{ parameter.location }}" 156 | name: "{{ parameter.name }}" 157 | storage_account_type: "{{ parameter.storage_account_type }}" 158 | disk_size_gb: "{{ parameter.disk_size_gb }}" 159 | create_option: "{{ parameter.create_option }}" 160 | tags: "{{ parameter.tags }}" 161 | register: output 162 | 163 | - assert: 164 | that: 165 | - not output.changed 166 | 167 | - name: Delete managed disk (Check Mode) 168 | azure_rm_manageddisk: 169 | resource_group: "{{ resource_group }}" 170 | name: "md{{ rpfx }}1" 171 | state: absent 172 | register: output 173 | check_mode: yes 174 | 175 | - name: Assert status succeeded 176 | assert: 177 | that: 178 | - output.changed 179 | - output.state 180 | 181 | - name: Delete all managed disk 182 | azure_rm_manageddisk: 183 | resource_group: "{{ resource_group }}" 184 | name: "md{{ rpfx }}{{ item }}" 185 | managed_by: '' 186 | state: absent 187 | with_items: 188 | - 1 189 | - 2 190 | - 3 191 | 192 | - name: Delete virtual machine 193 | azure_rm_virtualmachine: 194 | resource_group: "{{ resource_group }}" 195 | name: "tr{{ rpfx }}" 196 | state: absent 197 | vm_size: Standard_DS1_v2 198 | 199 | - name: Delete public ip 200 | azure_rm_publicipaddress: 201 | resource_group: "{{ resource_group }}" 202 | allocation_method: Static 203 | name: "tr{{ rpfx }}" 204 | state: absent 205 | -------------------------------------------------------------------------------- /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_modules/9b18d4c6e1f68c1cb4e474ff7510d81f49b38413/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_info: 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_info: 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_info: 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.networkinterfaces | length == 0 91 | - nsg_result.securitygroups | length == 0 92 | - pip_result.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_virtualmachineextension/tasks/main.yml: -------------------------------------------------------------------------------- 1 | - name: Create Random Storage Account Name 2 | set_fact: 3 | storage_account: "{{ resource_group | hash('md5') | truncate(24, True, '') }}" 4 | 5 | - name: Create virtual network 6 | azure_rm_virtualnetwork: 7 | resource_group: "{{ resource_group }}" 8 | name: testVnet 9 | address_prefixes: "10.0.0.0/16" 10 | 11 | - name: Add subnet 12 | azure_rm_subnet: 13 | resource_group: "{{ resource_group }}" 14 | name: testSubnet 15 | address_prefix: "10.0.1.0/24" 16 | virtual_network: testVnet 17 | 18 | - name: Create public IP address 19 | azure_rm_publicipaddress: 20 | resource_group: "{{ resource_group }}" 21 | allocation_method: Dynamic 22 | name: testPublicIP 23 | 24 | - name: Create Network Security Group that allows SSH 25 | azure_rm_securitygroup: 26 | resource_group: "{{ resource_group }}" 27 | name: testNetworkSecurityGroup 28 | rules: 29 | - name: SSH 30 | protocol: Tcp 31 | destination_port_range: 22 32 | access: Allow 33 | priority: 1001 34 | direction: Inbound 35 | 36 | - name: Create virtual network interface card 37 | azure_rm_networkinterface: 38 | resource_group: "{{ resource_group }}" 39 | name: testNIC 40 | virtual_network: testVnet 41 | subnet: testSubnet 42 | public_ip_name: testPublicIP 43 | security_group_name: testNetworkSecurityGroup 44 | 45 | - name: create a storage account 46 | azure_rm_storageaccount: 47 | resource_group: "{{ resource_group }}" 48 | name: "{{ storage_account }}" 49 | type: Standard_LRS 50 | 51 | - name: Create VM 52 | azure_rm_virtualmachine: 53 | resource_group: "{{ resource_group }}" 54 | name: testVM 55 | vm_size: Standard_DS1_v2 56 | admin_username: testuser 57 | ssh_password_enabled: true 58 | admin_password: "Password1234!" 59 | network_interfaces: testNIC 60 | storage_account_name: "{{ storage_account }}" 61 | storage_container: osdisk 62 | storage_blob: osdisk.vhd 63 | os_disk_caching: ReadWrite 64 | image: 65 | offer: CoreOS 66 | publisher: CoreOS 67 | sku: Stable 68 | version: latest 69 | 70 | - name: Create VM Extension 71 | azure_rm_virtualmachineextension: 72 | resource_group: "{{ resource_group }}" 73 | name: testVMExtension 74 | virtual_machine_name: testVM 75 | publisher: Microsoft.Azure.Extensions 76 | virtual_machine_extension_type: CustomScript 77 | type_handler_version: 2.0 78 | auto_upgrade_minor_version: true 79 | settings: {"commandToExecute": "hostname"} 80 | register: results 81 | 82 | - name: Assert that VM Extension ran 83 | assert: 84 | that: results.changed 85 | 86 | - name: Query extension 87 | azure_rm_virtualmachineextension_facts: 88 | resource_group: "{{ resource_group }}" 89 | name: testVMExtension 90 | virtual_machine_name: testVM 91 | register: results 92 | - name: Assert that facts are returned 93 | assert: 94 | that: 95 | - results.changed == False 96 | - results.extensions[0]['id'] != None 97 | - results.extensions[0]['resource_group'] != None 98 | - results.extensions[0]['virtual_machine_name'] != None 99 | - results.extensions[0]['name'] != None 100 | - results.extensions[0]['location'] != None 101 | - results.extensions[0]['publisher'] != None 102 | - results.extensions[0]['type'] != None 103 | - results.extensions[0]['settings'] != None 104 | - results.extensions[0]['auto_upgrade_minor_version'] != None 105 | - results.extensions[0]['provisioning_state'] != None 106 | 107 | - name: List extensions 108 | azure_rm_virtualmachineextension_facts: 109 | resource_group: "{{ resource_group }}" 110 | virtual_machine_name: testVM 111 | register: results 112 | - name: Assert that facts are returned 113 | assert: 114 | that: 115 | - results.changed == False 116 | - results.extensions[0]['id'] != None 117 | - results.extensions[0]['resource_group'] != None 118 | - results.extensions[0]['virtual_machine_name'] != None 119 | - results.extensions[0]['name'] != None 120 | - results.extensions[0]['location'] != None 121 | - results.extensions[0]['publisher'] != None 122 | - results.extensions[0]['type'] != None 123 | - results.extensions[0]['settings'] != None 124 | - results.extensions[0]['auto_upgrade_minor_version'] != None 125 | - results.extensions[0]['provisioning_state'] != None 126 | 127 | - name: Delete VM Extension 128 | azure_rm_virtualmachineextension: 129 | resource_group: "{{ resource_group }}" 130 | name: testVMExtension 131 | virtual_machine_name: testVM 132 | state: absent 133 | publisher: Microsoft.Azure.Extensions 134 | virtual_machine_extension_type: CustomScript 135 | type_handler_version: 2.0 136 | auto_upgrade_minor_version: true 137 | settings: {"commandToExecute": "hostname"} 138 | register: results 139 | 140 | - name: Assert that VM Extension deleted 141 | assert: 142 | that: results.changed 143 | 144 | - name: Delete VM 145 | azure_rm_virtualmachine: 146 | resource_group: "{{ resource_group }}" 147 | name: testVM 148 | state: absent 149 | remove_on_absent: ['all'] 150 | vm_size: Standard_DS1_v2 151 | admin_username: testuser 152 | network_interfaces: testNIC 153 | storage_container: osdisk 154 | storage_blob: osdisk.vhd 155 | os_disk_caching: ReadWrite 156 | image: 157 | offer: CoreOS 158 | publisher: CoreOS 159 | sku: Stable 160 | version: latest 161 | 162 | - name: Delete a storage account 163 | azure_rm_storageaccount: 164 | resource_group: "{{ resource_group }}" 165 | name: "{{ storage_account }}" 166 | type: Standard_LRS 167 | state: absent 168 | force_delete_nonempty: true 169 | 170 | - name: Delete Network Security Group that allows SSH 171 | azure_rm_securitygroup: 172 | resource_group: "{{ resource_group }}" 173 | name: testNetworkSecurityGroup 174 | state: absent 175 | 176 | - name: Delete virtual network 177 | azure_rm_virtualnetwork: 178 | resource_group: "{{ resource_group }}" 179 | name: testVnet 180 | state: absent 181 | address_prefixes: "10.0.0.0/16" 182 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tests/utils/create_resource_group.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | tasks: 4 | - name: Create a resource group 5 | azure_rm_resourcegroup: 6 | name: "{{ name }}" 7 | location: eastus -------------------------------------------------------------------------------- /tests/utils/delete_resource_group.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | tasks: 4 | - name: Delete a resource group 5 | azure_rm_resourcegroup: 6 | name: "{{ name }}" 7 | state: absent 8 | force: True --------------------------------------------------------------------------------