離線環境下安裝ansible,藉助有網環境下pip工具

環境

  • 有網的機器(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下載依賴環境到指定路徑
  • 將下載的包壓縮上傳到離線環境
  • 在離線環境準備同有網機器的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

離線機器環境

一、安裝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
相關文章
相關標籤/搜索