# Ansible Dynamic Inventory for Azure

**URL:** <https://forum.ansible.com/t/ansible-dynamic-inventory-for-azure/29757>\
**Category:** Ansible Project\
**Tags:** azure\
**Created:** [February 24, 2019, 7:29am UTC](https://forum.ansible.com/t/ansible-dynamic-inventory-for-azure/29757 "2019-02-24T07:29:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ameya\_Agashe](https://avatars.discourse-cdn.com/v4/letter/a/54ee81/32.png) [@Ameya\_Agashe](https://forum.ansible.com/u/Ameya_Agashe)\
**Post date:** [February 24, 2019, 7:29am UTC](https://forum.ansible.com/t/ansible-dynamic-inventory-for-azure/29757/1 "2019-02-24T07:29:02Z")

</div>

Hi Guys,

I am trying to play around with Ansible dynamic inventory to get software installed/perform configuration management.

I have executed instructions as given by Microsoft here: [https://docs.microsoft.com/en-us/azure/ansible/ansible-manage-azure-dynamic-inventories](https://docs.microsoft.com/en-us/azure/ansible/ansible-manage-azure-dynamic-inventories)

Commands from my VM are here:

az group create --resource-group ansible-inventory-test-rg --location eastus  
az vm create --resource-group ansible-inventory-test-rg --name ansible-inventory-test-vm1 --image UbuntuLTS --generate-ssh-keys  
az vm create --resource-group ansible-inventory-test-rg --name ansible-inventory-test-vm2 --image UbuntuLTS --generate-ssh-keys  
az account show  
az resource tag --tags nginx --id /subscriptions//resourceGroups/ansible-inventory-test-rg/providers/Microsoft.Compute/virtualMachines/ansible-inventory-test-vm1  
wget [https://raw.githubusercontent.com/ansible/ansible/devel/contrib/inventory/azure\_rm.py](https://raw.githubusercontent.com/ansible/ansible/devel/contrib/inventory/azure_rm.py)  
chmod +x azure\_rm.py  
ansible -i azure\_rm.py ansible-inventory-test-rg -m ping

However, it errors out as below:

[WARNING]: \* Failed to parse /media/sf\_C\_DRIVE/OnlyOnMyPC/ansible.rhel75.master/azure\_rm.py with script plugin: Inventory script  
(/media/sf\_C\_DRIVE/OnlyOnMyPC/ansible.rhel75.master/azure\_rm.py) had an execution error: /usr/lib/python2.7/site-packages/requests/ **init**.py:91:  
RequestsDependencyWarning: urllib3 (1.24.1) or chardet (2.2.1) doesn’t match a supported version! RequestsDependencyWarning) ‘Cloud’ object has no attribute ‘find’

[WARNING]: \* Failed to parse /media/sf\_C\_DRIVE/OnlyOnMyPC/ansible.rhel75.master/azure\_rm.py with ini plugin:  
/media/sf\_C\_DRIVE/OnlyOnMyPC/ansible.rhel75.master/azure\_rm.py:22: Error parsing host definition ‘’‘’': No closing quotation

[WARNING]: Unable to parse /media/sf\_C\_DRIVE/OnlyOnMyPC/ansible.rhel75.master/azure\_rm.py as an inventory source

[WARNING]: No inventory was parsed, only implicit localhost is available

[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match ‘all’

[WARNING]: Could not match supplied host pattern, ignoring: ansible-inventory-test-rg

I am unable to understand what is the missing link here as I have executed as it is documented from Microsoft site, am I missing here anything?

Also how that Python script would know which subscription, which resource group and which VM’s it has to apply a particular playbook?

Kind Regards,  
Ameya Agashe

---

<div class="post-metadata">

**Author:** ![dan\_linder](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dan_linder/32/3833_2.png) [@dan\_linder](https://forum.ansible.com/u/dan_linder)\
**Post date:** [February 24, 2019, 7:19pm UTC](https://forum.ansible.com/t/ansible-dynamic-inventory-for-azure/29757/2 "2019-02-24T19:19:13Z")

</div>

When you run the **azure\_rm.py** by itself, does it produce a proper inventory file of those new machines? What is the output when you run it from the command line with the

```auto
**--list** option?

```

I’d say this is the root of the problem:  
**RequestsDependencyWarning: urllib3 (1.24.1) or chardet (2.2.1) doesn’t match a supported version**  
…but I don’t have a solution since that is more dependent on the system you ran the commands on.

Dan
