4
votes

I am using a CentOS 7.2 and trying to provision a VM in azure through Ansible using the module "azure_rm_virtualmachine" and getting the error as "No module named packaging.version" Below is my error

Traceback (most recent call last): File "/tmp/ansible_7aeFMQ/ansible_module_azure_rm_virtualmachine.py", line 445, in from ansible.module_utils.azure_rm_common import * File "/tmp/ansible_7aeFMQ/ansible_modlib.zip/ansible/module_utils/azure_rm_common.py", line 29, in ImportError: No module named packaging.version

fatal: [localhost]: FAILED! => { "changed": false, "failed": true, "module_stderr": "Traceback (most recent call last):\n File \"/tmp/ansible_7aeFMQ/ansible_module_azure_rm_virtualmachine.py\", line 445, in \n from ansible.module_utils.azure_rm_common import *\n File \"/tmp/ansible_7aeFMQ/ansible_modlib.zip/ansible/module_utils/azure_rm_common.py\", line 29, in \nImportError: No module named packaging.version\n", "module_stdout": "", "msg": "MODULE FAILURE", "rc": 0 }

Below is my playbook and I am using a ansible version 2.3.0.0 and python version of 2.7.5 and pip 9.0.1

  • name: Provision new VM in azure hosts: localhost connection: local

    tasks:

    • name: Create VM azure_rm_virtualmachine: resource_group: xyz name: ScriptVM vm_size: Standard_D1 admin_username: xxxx admin_password: xxxx image: offer: CentOS publisher: Rogue Wave Software sku: '7.2' version: latest

I am running the playbook from the ansible host and I tried to create a resource group through ansible but I get the same error as "No module named packaging.version" .

2
Did you search anything on "No module named packaging.version"?Konstantin Suvorov
yes I have searched for "No module named packaging.version" , there was a similar issue but resolution was to run the run the playbook with delegate access to local .. where I have tried that as well .. but the issue still remains the same .Dhinesh
The issue is resolved .. I just installed Packaging library through pip and that resolved .. Thanks @Konstantin for the immediate response .Dhinesh

2 Answers

5
votes

The above error is occurred due to your environment doesn't have packaging module.

To solve this issue by installing packaging module.

pip install packaging

The above command will install packaging module of 16.8 version

0
votes

You may try this, it solved for me
sudo pip install -U pip setuptools

FYI: My ENVs are Ubuntu 16.04.2 LTS on Windows Subsystem for Linux (Windows 10 bash) Python 2.7.12 pip 9.0.1 ansible 2.3.1.0 azure-cli (2.0.12)