Reputation: 643
I have Centos 7.3 with ansible version 2.3.
Ansible 2.3.0.0
config file = ../ansible.cfg
configured module search path = Default w/o overrides
python version = 2.7.5 (default, Nov 6 2016, 00:28:07) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)]
I need to run ansible playbooks in Azure VM's.
I get the following error when I run
fatal: [52.170.201.24]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Shared connection to 52.170.201.24 closed.\r\n",
"module_stdout": "\r\nTraceback (most recent call last):\r\n File \"/tmp/ansible_k2CnFR/ansible_module_azure_rm_virtualmachine.py\", line 445, in <module>\r\n
from ansible.module_utils.azure_rm_common import *\r\n
File \"/tmp/ansible_k2CnFR/ansible_modlib.zip/ansible/module_utils/azure_rm_common.py\", line 29, in <module>\r\nImportError: No module named packaging.version\r\n", "msg": "MODULE FAILURE", "rc": 0}
Tried installing setuptools as indicated in several sites
sudo pip install setuptools
Requirement already satisfied: setuptools in /root/.local/lib/python2.7/site-packages
Requirement already satisfied: six>=1.6.0 in /root/.local/lib/python2.7/site-packages (from setuptools)
Requirement already satisfied: appdirs>=1.4.0 in /root/.local/lib/python2.7/site-packages (from setuptools)
Requirement already satisfied: packaging>=16.8 in /root/.local/lib/python2.7/site-packages (from setuptools)
Requirement already satisfied: pyparsing in /root/.local/lib/python2.7/site-packages (from packaging>=16.8->setuptools
Tried upgrading pip as mentioned in several sites and got it to the latest version
pip -V
pip 9.0.1 from /usr/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg (python 2.7)
which pip
/usr/bin/pip
$ which pip3
/usr/local/bin/pip3
$ which python
/usr/bin/python
UPDATE:
52.170.201.24 is the IP Address of the Azure Virtual machine which is part of the inventory hosts.
I'm actually trying to power on an Azure Virtual machine with this ansible code in my ansible control machine
- name: Power On Docker repo if Azure
azure_rm_virtualmachine:
resource_group: HpsaPoc
name: DockerRepo
started: yes
when: "{{cloud_provider}}" == 'azure'
I can't wrap my head around this python/pip configurations, I had tried installing python 3.5 and pip3 but didn't help, so deleted it as I didn't know how to uninstall it. Please help.
Upvotes: 6
Views: 8179
Reputation: 169
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
Upvotes: 2
Reputation: 68269
Seems like you try to execute azure_rm_virtualmachine
from remote host, not from your Ansible control host.
Try:
- name: Power On Docker repo if Azure
azure_rm_virtualmachine:
resource_group: HpsaPoc
name: DockerRepo
started: yes
when: cloud_provider == 'azure'
delegate_to: localhost
Upvotes: 3