环境
有网的机器(192.168.19.222):rhe65,python2.7.13,pip9.0.1
离线机器(192.168.19.203):rhe65,python2.6
FTP(192.168.20.25):有已经编译好的python2.7.13的zip包
离线安装思路
- 准备安装包,借助pip下载依赖环境到指定路径
- 将下载的包压缩上传到离线环境
- 在离线环境准备同有网机器的python环境(python2.7.13,pip9.0.1)
- 开始安装
有网机器
#从豆瓣源下载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
离线机器环境
1、安装python2.7.13
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
2、解压缩
unzip /tmp/ansible_packet.zip && cd ansible
3、执行安装命令
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
4、复制配置
#先解压缩压缩包
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