简体   繁体   English

Ansible错误 - 没有名为packaging.version的模块

[英]Ansible error - No module named packaging.version

I have Centos 7.3 with ansible version 2.3. 我有Centos 7.3和ansible版本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. 我需要在Azure VM中运行ansible playbooks。

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 尝试安装几个站点中指示的setuptools

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. 52.170.201.24是Azure虚拟机的IP地址,它是清单主机的一部分。

I'm actually trying to power on an Azure Virtual machine with this ansible code in my ansible control machine 我实际上正在尝试使用我的ansible控制机器中的这个ansible代码启动Azure虚拟机

- 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. 我无法绕过这个python / pip配置,我曾尝试安装python 3.5和pip3但没有帮助,所以删除它,因为我不知道如何卸载它。 Please help. 请帮忙。

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 pip安装包装

The above command will install packaging module of 16.8 version 以上命令将安装16.8版本的打包模块

Seems like you try to execute azure_rm_virtualmachine from remote host, not from your Ansible control host. 您似乎尝试从远程主机执行azure_rm_virtualmachine ,而不是从Ansible控制主机执行。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM