Create a Microsoft Azure Resource Group With Ansible

Following our past blog posts about Microsoft Azure and Ansible today we will learn how to create an Azure Resource Group with Ansible.

Before you start, it is recommended you create a credentials file for Microsoft Azure if you are using a Linux or macOS machine. If you prefer not to create a creds file, you can use the az login command to log in to Azure and auth before running the playbook.


If you have Ansible installed and configured, you can use the following playbook to create an empty resource group on Microsoft Azure. In my case, I have named the resource group WSL, and I am creating it in the West US region.

- name: Create a resource group
  hosts: localhost
  connection: local
  gather_facts: no
    - name: Create a resource group
        name: WSL
        location: westus
          Environment: PROD

To run the playbook, use the follwoing command.

ansible-playbook resource-group.yml -vvv

If you like this post, make sure you visit our ansible category page.

Success! You're on the list.