二、Ansible配合virtualenv安装配置
virtuanlenv可以独立出来,不影响其他的程序调用python
2.1、ansible的两种安装模式(centos7)
2.1.1、yum包管理安装
#yum -y install ansible
--但是这种模式的安装会所有的用户都能用,包在python下,如果其他用户也安装了ansible,会形成ansible模块的混乱
2.1.1、git源代码安装(推荐)
#git clone https://github.com/ansible/ansible.git
wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tar.xz [root@10.21.214.221 Python-3.6.5]# tar -xf Python-3.6.5.tar.xz [root@10.21.214.221 Python-3.6.5]# cd Python-3.6.5 [root@10.21.214.221 Python-3.6.5]# ./configure --prefix=/usr/local --with-ensurepip=install --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib" [root@10.21.214.221 Python-3.6.5]# make && make altinstall [root@10.21.214.221 Python-3.6.5]# pip3.6 install virtualenv pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available. Collecting virtualenv Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/virtualenv/ Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/virtualenv/ Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/virtualenv/ Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/virtualenv/ Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/virtualenv/ Could not fetch URL https://pypi.python.org/simple/virtualenv/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.python.org', port=443): Max retries exceeded with url: /simple/virtualenv/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)) - skipping Could not find a version that satisfies the requirement virtualenv (from versions: ) No matching distribution found for virtualenv -----上面的报错是说https加密,本机上没有安装新版本的openssll,导致失败--- ##方法一:通过浏览器下载 https://pypi.python.org/simple/virtualenv/virtualenv-16.0.0-py2.py3-none-any.whl [root@10.21.214.221 Python-3.6.5]# rz rz waiting to receive. zmodem trl+C ȡ 100% 1877 KB 1877 KB/s 00:00:01 0 Errorspy3-none-any.whl... [root@10.21.214.221 Python-3.6.5]# pip3.6 install virtualenv-16.0.0-py2.py3-none-any.whl pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available. Processing ./virtualenv-16.0.0-py2.py3-none-any.whl Installing collected packages: virtualenv Successfully installed virtualenv-16.0.0 ##方法二:安装新的opensll,重新编译python [root@10.21.214.221 Python-3.6.5]# yum install -y openssl openssl-devel [root@10.21.214.221 Python-3.6.5]# ./configure --enable-shared --enable-loadable-sqlite-extensions [root@10.21.214.221 Python-3.6.5]# make && make install ---重新安装,如果报错,根据提示,执行下面的 (.py3-a2.5-env) [deploy@10.21.214.221 .py3-a2.5-env]$ pip3.6 install --upgrade pip
[deploy@tan ~]$ cd /home/deploy/.py3-a2.5-env/ [deploy@tan .py3-a2.5-env]$ git clone https://github.com/ansible/ansible.git [deploy@tan .py3-a2.5-env]$ source bin/activate (.py3-a2.5-env) [deploy@tan .py3-a2.5-env]$ pip3.6 install paramiko PyYAML jinja2 (.py3-a2.5-env) [deploy@10.21.214.221 .py3-a2.5-env]$ cd ansible/ (.py3-a2.5-env) [deploy@10.21.214.221 ansible]$ git checkout stable-2.5 (.py3-a2.5-env) [deploy@10.21.214.221 ansible]$ source ./hacking/env-setup -q (.py3-a2.5-env) [deploy@10.21.214.221 ansible]$ ansible --version
Comments | NOTHING