NOTE: The issue described in this post was fixed!!! (ansible 2.5.2 and Azure CLI 2.0.34)#

Last week I tried to run this simple Ansible playbook in Azure Cloud Shell:

 1# resource_group.yml
 2# Create test resource group in west europe
 3- name: Create a Resource Group
 4  hosts: localhost
 5  connection: local
 6  gather_facts: no
 7  tasks:
 8    - name: Create Resource Group
 9      azure_rm_resourcegroup:
10        location: westeurope
11        name: test
12        state: present

The first attempt to run the playbook with:

1ansible-playbook resource_group.yml -vvv

failed with the following message: No module named ‘packaging’

So I ran:

1pip install --user packaging

But this time when I tried to run the playbook I got a message telling me to upgrade the Azure module for Ansible. Again the first attempt didn’t go well so I forced the upgrade:

1pip install ansible[azure] --upgrade --force --user

Problem solved!!! Runing the following command did create the resource group:

1ansible-playbook resource_group.yml -vvv

Hope it helps!