Recently, Microsoft announced several key improvements to the developer experience when using Ansible on Azure, including Ansible in Azure Cloud Shell and Ansible extension in Visual Studio Code. Today, I’d to share with you new Azure content that is available in Ansible 2.5.
In total, 13 new Azure modules are now included in the 2.5 release of Ansible. These new modules focus on provisioning the following Azure services, including container and database scenarios:

  • Image
  • Container Instance
  • Container Registry
  • SQL server and database
  • MySQL server and database
  • PostgreSQL server and database
  • Key Vault

You can find sample Ansible playbooks that utilize the new modules here: https://github.com/Azure-Samples/ansible-playbooks.
If you’re saying, this is great, but is there any way to get more Ansible content, I have good news for you… We’re using Ansible Galaxy to deliver the latest bug fixes and new modules ahead of the next Ansible release. Check Ansible Galaxy for the latest fixes and module previews – Azure Preview Module role.
We encourage everyone try it out and file bug or feature request in github to help us improve them before upstreaming. And, please aware that API may change according to bug or feature requests.
To install the playbook role, only one command is needed, as follows:

$ ansible-galaxy install Azure.azure_preview_modules

Then, download the sample playbooks and try AppGatewayCreate.yml, which will call a new module named azure_rm_appgw available in azure_preview_module to create an application gateway on Azure.
Note: If you don’t use environment variables to export service principal credentials, please open “AppGatewayCreate.yml” and add your subscription ID for the variable of “azure_subscription_id”. As for how to configure your environment for Ansible on Azure, refer to guide_azure

$ git clone https://github.com/Azure-Samples/ansible-playbooks.git
$ cd ansible-playbooks
$ ansible-playbook AppGatewayCreate.yml

After minutes, you will get the following output. Some new modules request the latest Azure Python SDK.
Note: If you met any error, like some package is not found, you can upgrade your Azure Python SDK by running below command.

$ pip install -r ~/.ansible/roles/Azure.azure_preview_modules/files/requirements-azure.txt

or

$ sudo pip install -r ~/.ansible/roles/Azure.azure_preview_modules/files/requirements-azure.txt

Congratulations! You’ve successfully created your application gateway through the Ansible playbook role for Azure. If you go to the portal, you will see the your application gateway there.
BTW, you can also use Ansible extension to accelerate your Ansible playbook development and test in Visual Studio Code.
Questions? Let us know in the comments.