有网的机器(192.168.19.222):rhe65,python2.7.13,pip9.0.1python
离线机器(192.168.19.203):rhe65,python2.6linux
FTP(192.168.20.25):有已经编译好的python2.7.13的zip包shell
#从豆瓣源下载pip和ansible mkdir -p /opt/ansible pip install --download /opt/ansible -i https://pypi.douban.com/simple ansible pip install --download /opt/ansible -i https://pypi.douban.com/simple pip cd /opt && zip ansible_packet.zip scp ansible_packet.zip 192.168.19.203:/tmp
一、安装python2.7.13python2.7
wget ftp://192.168.20.25/python/python2.7.13-pip.zip unzip python2.7.13-pip.zip && mv python2.7.13 /usr/local/ #用python2.7替换掉2.6 rm -rf /usr/bin/python ln -s /usr/local/python2.7.13/bin/python /usr/bin/ #替换yum里面的python,yum使用的仍是2.6 sed -i 's/python/python2.6/' /usr/bin/yum* #添加环境变量 echo"export PATH=$PATH:/usr/local/python2.7.13/bin/" >> /etc/profile source /etc/profile
二、解压缩ssh
unzip /tmp/ansible_packet.zip && cd ansible
三、执行安装命令测试
pip install MarkupSafe-1.0.tar.gz pip install PyYAML-3.12.tar.gz pip install asn1crypto-0.23.0-py2.py3-none-any.whl pip install pycparser-2.18.tar.gz pip install Jinja2-2.10-py2.py3-none-any.whl #paramiko依赖 pip install cffi-1.11.2-cp27-cp27m-manylinux1_x86_64.whl pip install enum34-1.1.6-py2-none-any.whl pip install idna-2.6-py2.py3-none-any.whl pip install six-1.11.0-py2.py3-none-any.whl pip install ipaddress-1.0.18-py2-none-any.whl pip install cryptography-2.1.3-cp27-cp27m-manylinux1_x86_64.whl #[root@cloudshijinshi ansible]# pip install cryptography-2.1.3-cp27-cp27m-manylinux1_x86_64.whl #Processing ./cryptography-2.1.3-cp27-cp27m-manylinux1_x86_64.whl #Requirement already satisfied: cffi>=1.7; platform_python_implementation != "PyPy" in /usr/local/python2.7.13/lib/python2.7/site-packages (from cryptography==2.1.3) #Requirement already satisfied: enum34; python_version < "3" in /usr/local/python2.7.13/lib/python2.7/site-packages (from cryptography==2.1.3) #Requirement already satisfied: idna>=2.1 in /usr/local/python2.7.13/lib/python2.7/site-packages (from cryptography==2.1.3) #Requirement already satisfied: asn1crypto>=0.21.0 in /usr/local/python2.7.13/lib/python2.7/site-packages (from cryptography==2.1.3) #Requirement already satisfied: six>=1.4.1 in /usr/local/python2.7.13/lib/python2.7/site-packages (from cryptography==2.1.3) #Requirement already satisfied: ipaddress; python_version < "3" in /usr/local/python2.7.13/lib/python2.7/site-packages (from cryptography==2.1.3) #Requirement already satisfied: pycparser in /usr/local/python2.7.13/lib/python2.7/site-packages (from cffi>=1.7; platform_python_implementation != "PyPy"->cryptography==2.1.3) #Installing collected packages: cryptography #Successfully installed cryptography-2.1.3 pip install PyNaCl-1.2.0-cp27-cp27m-manylinux1_x86_64.whl pip install pyasn1-0.4.2-py2.py3-none-any.whl pip install bcrypt-3.1.4-cp27-cp27m-manylinux1_x86_64.whl pip install paramiko-2.4.0-py2.py3-none-any.whl pip install setuptools-38.2.1-py2.py3-none-any.whl ###这个貌似我装了包了一些错误,使用pip list又能够查看到,后面又拿了一台机器装的时候没有装这个,ansible经过测试 pip install ansible-2.4.1.0.tar.gz
四、复制配置ui
#先解压缩压缩包 tar -xvf ansible-2.4.1.0.tar.gz && cd ansible-2.4.1.0 mkdir /etc/ansible cp examples/* /etc/ansible/
#生成密钥,而且拷贝公钥到远程主机 ssh-keygen -t dsa -P "" -f ~/.ssh/id_dsa >/dev/null 2>&1 ssh-copy-id -i /root/.ssh/id_dsa.pub root@192.168.19.222 #在hosts文件里面增长一台主机 echo '192.168.19.222' >> /etc/ansible/hosts #测试命令 ansible 192.168.19.222 -m ping
#使用whl文件先安装pip python pip-9.0.1-py2.py3-none-any.whl/pip install pip-9.0.1-py2.py3-none-any.whl #python2.6的setuptools下载地址 wget https://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c9.tar.gz --no-check-certificate