[技术干货] 解决Ansible安装依赖问题

[复制链接]
乐维 发表于 2020-3-25 11:31:41 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题
由于每台机器的环境都不尽相同,存在某些机器的yum源太小或者所带软件版本太低或缺失等问题,所以在安装软件时也可能会产生不同的依赖报错。下面我就以安装ansible时自身遇到过的依赖问题解决方法作介绍,只介绍解决依赖部分内容,安装ansible详细过程另请自行百度。
一、 使用ansible --version
1.png

Ansible并未安装完成,存在依赖问题。


附报错内容:
ERROR! Unexpected Exception, this is probably a bug: (cryptography 1.3.1 (/usr/lib64/python2.7/site-packages), Requirement.parse('cryptography>=1.5'))
the full traceback was:

Traceback (most recent call last):
  File "/usr/bin/ansible", line 97, in <module>
    mycli = getattr(__import__("ansible.cli.%s" % sub, fromlist=[myclass]), myclass)
  File "/usr/lib/python2.7/site-packages/ansible/cli/__init__.py", line 38, in <module>
    from ansible.inventory.manager import InventoryManager
  File "/usr/lib/python2.7/site-packages/ansible/inventory/manager.py", line 33, in <module>
    from ansible.plugins.loader import inventory_loader
  File "/usr/lib/python2.7/site-packages/ansible/plugins/loader.py", line 22, in <module>
    from ansible.parsing.utils.yaml import from_yaml
  File "/usr/lib/python2.7/site-packages/ansible/parsing/utils/yaml.py", line 17, in <module>
    from ansible.parsing.yaml.loader import AnsibleLoader
  File "/usr/lib/python2.7/site-packages/ansible/parsing/yaml/loader.py", line 30, in <module>
    from ansible.parsing.yaml.constructor import AnsibleConstructor
  File "/usr/lib/python2.7/site-packages/ansible/parsing/yaml/constructor.py", line 29, in <module>
    from ansible.parsing.vault import VaultLib
  File "/usr/lib/python2.7/site-packages/ansible/parsing/vault/__init__.py", line 45, in <module>
    from cryptography.hazmat.backends import default_backend
  File "/usr/lib64/python2.7/site-packages/cryptography/hazmat/backends/__init__.py", line 7, in <module>
    import pkg_resources
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 3011, in <module>
    parse_requirements(__requires__), Environment()
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 630, in resolve
    raise VersionConflict(dist,req) # XXX put more info here
VersionConflict: (cryptography 1.3.1 (/usr/lib64/python2.7/site-packages), Requirement.parse('cryptography>=1.5'))

估计是cryptography该模块的问题(版本太低)。


1. 安装cryptography前先安装setuptools
2.png
这里Setuptools版本需要大于等于18.5.
3.png


2. 解压安装
4.png
#python setup.py build
#python setup.py install


3. 安装cffi(在安装cryptography之前报错,应该先安装cffi)
[root@zabbix-server cryptography-2.8]# python setup.py install
Download error on https://pypi.python.org/simple/cffi/: [Errno -2] Name or service not known -- Some packages may not be found!
Download error on https://pypi.python.org/simple/: [Errno -2] Name or service not known -- Some packages may not be found!
No local packages or download links found for cffi!=1.11.3,>=1.8
Traceback (most recent call last):
  File "setup.py", line 275, in <module>
    **keywords_with_side_effects(sys.argv)
  File "/usr/lib64/python2.7/distutils/core.py", line 112, in setup
    _setup_distribution = dist = klass(attrs)
  File "build/bdist.linux-x86_64/egg/setuptools/dist.py", line 268, in __init__
  File "build/bdist.linux-x86_64/egg/setuptools/dist.py", line 313, in fetch_build_eggs
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 843, in resolve
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 1088, in best_match
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 1100, in obtain
  File "build/bdist.linux-x86_64/egg/setuptools/dist.py", line 380, in fetch_build_egg
  File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 632, in easy_install

distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse('cffi!=1.11.3,>=1.8')
5.png
安装cffi
l python setup.py build
l python setup.py install
6.png
还是缺包
7.png

又报错(估计还是缺包)
8.png
该图片中报错关于Python.h的,并未找到相应的文件或目录,直接安装python3.4-devel,即可解决
yum install python-devel                #因为我这ansible是用2版本的,所以后面装python-develpython不带数字默认装2版本。

4. 上传cryptography
9.png
解压安装
10.png
#python setup.py build
#python setup.py install

5. 解决问题,成功得到版本信息
11.png

看到这里能够成功获取到ansible的版本信息则说明ansible已经安装成功了。

技术交流欢迎加入Q群:177428068







上一篇:曙光工作站安装centos后实际内存变小
下一篇:Zabbix触发器配置指定生效星期
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝0

帖子135

发布主题
最新发布

乐维社区

微信公众号

版权所有 © 2016-2019 九一乐维丨粤ICP备17007026号-2