經過自制yum源離線安裝 ansible

系統    環境:     Red Hat Enterprise Linux Server release 7.5 (Maipo)python

Python版本:  Python 2.7.5sql

       因爲在工做環境中,常常遇到批量安裝的服務器,不具有鏈接互聯網的條件。同時經過簡單的下載安裝 ansible 源碼安裝,又會遇到各類奇葩問題,推薦使用自制 yum 源方法,而後使用 yum安裝 ansible。bash

1、準備一臺能夠鏈接互聯網的相同版本系統的操做系統(安裝環境同樣),使用yumdownloader工具下載ansible安裝包以及全部依賴包。並以 root 身份安裝 Yumdownloader工具:服務器

# yum  -y install  yum-utils

建立兩個文件夾,用於存放依賴的安裝包python2.7

# mkdir   /root/packages1    /root/packages2

因爲默認的源裏沒有 ansible,須要安裝 fedora epel源:ide

# yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm


下載 ansible 和 全部依賴包工具

# yumdownloader --resolve --destdir /root/packages1   ansible
# yumdownloader --resolve --destdir /root/packages2   createrepo

 

2、將上面下載的全部 rpm 安裝包打包,傳輸到須要批量的任意一臺服務器上,並解壓到指定的文件夾裏面url

# tar  -Jcvf  packages1.tar.xz   packages1
# tar  -Jcvf  packages2.tar.xz   packages2
# tar -Jxvf    packages1.tar.xz   -C  /mnt/
# tar -Jxvf    packages2.tar.xz   -C  /mnt/

 

1.首先建立 安裝createrepo   進入 /mnt/packages2 目錄中操作系統

# rpm -ivh deltarpm-3.6-3.el7.x86_64.rpm
# rpm -ivh python-deltarpm-3.6-3.el7.x86_64.rpm
# rpm -ivh createrepo-0.9.9-28.el7.noarch.rpm

 

2. 而後使用createrepo生成符合要求的yum倉庫,執行:sqlite

# cd  /mnt
# createrepo /packages1
Spawning worker 0 with 25 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete

 

3、配置本地 yum源

把當前存在 yum 作備份,並移走別的目錄

# vi  /etc/yum.repos.d/ansible.repo
[ansibel]
name=my local ansible
baseurl=file:///mnt/packages1
enabled=1
gpgcheck=0

保存退出,而後執行:

# yum clean all
# yum makecache

 

4、使用 yum安裝 ansible

# yum -y install ansible

驗證安裝成功:

# ansible --version
ansible 2.7.4
  config file = /etc/ansible/ansible.cfg  
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']  
  ansible python module location = /usr/lib/python2.7/site-packages/ansible  
  executable location = /usr/bin/ansible  
  python version = 2.7.5 (default, Feb 20 2018, 09:19:12) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]


         備註:因爲以上環境依賴存在差別,僅供參考。

相關文章
相關標籤/搜索