Ansible Dynamic Inventory for Azure

28 views
Skip to first unread message

ameya agashe

unread,
Feb 24, 2019, 2:29:26 AM2/24/19
to ansible...@googlegroups.com
Hi Guys,

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


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/<Subscription ID>/resourceGroups/ansible-inventory-test-rg/providers/Microsoft.Compute/virtualMachines/ansible-inventory-test-vm1
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

d...@linder.org

unread,
Feb 24, 2019, 2:19:13 PM2/24/19
to Ansible Project
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
--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
Reply all
Reply to author
Forward
0 new messages