首先,我们找一个和生产环境系统一样的版本在本地做个虚拟机,然后本地配置一下yum源,从公网拉取rpm包,然后把本地下载的rpm传到生产的服务器上,在生产的服务器上安装即可,看一下下面的演示,先看第一个演示,安装ansible。
我这里使用的是麒麟系统,因为都是x86_64的,所以我这边就直接安装了。
[root@kylin ~]# yum install --downloadonly --downloaddir=/opt/ansible ansible Kylin Linux Advanced Server 10 - Os 11 kB/s | 3.8 kB 00:00 Dependencies resolved. ========================================================================================================================================== Package Architecture Version Repository Size ========================================================================================================================================== Installing: ansible noarch 2.8.8-1.p01.ky10 ks10-adv-updates 15 M Installing dependencies: libsodium x86_64 1.0.16-7.ky10 ks10-adv-os 146 k python3-asn1crypto noarch 0.24.0-8.ky10 ks10-adv-os 180 k python3-babel noarch 2.7.0-1.ky10 ks10-adv-os 5.9 M python3-bcrypt x86_64 3.1.4-7.ky10 ks10-adv-os 39 k python3-markupsafe x86_64 1.0-3.ky10 ks10-adv-os 28 k python3-ply noarch 3.9-9.ky10 ks10-adv-os 88 k python3-pyasn1 noarch 0.3.7-8.ky10 ks10-adv-os 215 k python3-pycparser noarch 2.19-1.ky10 ks10-adv-os 150 k python3-pynacl x86_64 1.2.1-4.ky10 ks10-adv-os 77 k python3-pyyaml x86_64 5.1.2-1.ky10 ks10-adv-os 187 k sshpass x86_64 1.06-8.ky10 ks10-adv-os 24 k python3-cffi x86_64 1.14.1-1.ky10 ks10-adv-updates 237 k python3-cryptography x86_64 3.3.1-5.ky10 ks10-adv-updates 402 k python3-jinja2 noarch 2.11.2-7.p01.ky10 ks10-adv-updates 224 k python3-paramiko noarch 2.11.0-2.ky10 ks10-adv-updates 300 k Transaction Summary ========================================================================================================================================== Install 16 Packages Total download size: 23 M Installed size: 114 M YUM will only download packages for the transaction. Is this ok [y/N]: y Downloading Packages: (1/16): libsodium-1.0.16-7.ky10.x86_64.rpm 383 kB/s | 146 kB 00:00 (2/16): python3-bcrypt-3.1.4-7.ky10.x86_64.rpm 254 kB/s | 39 kB 00:00 (3/16): python3-markupsafe-1.0-3.ky10.x86_64.rpm 248 kB/s | 28 kB 00:00 (4/16): python3-asn1crypto-0.24.0-8.ky10.noarch.rpm 251 kB/s | 180 kB 00:00 (5/16): python3-babel-2.7.0-1.ky10.noarch.rpm 7.2 MB/s | 5.9 MB 00:00 (6/16): python3-ply-3.9-9.ky10.noarch.rpm 481 kB/s | 88 kB 00:00 (7/16): python3-pyasn1-0.3.7-8.ky10.noarch.rpm 1.1 MB/s | 215 kB 00:00 (8/16): python3-pycparser-2.19-1.ky10.noarch.rpm 927 kB/s | 150 kB 00:00 (9/16): python3-pynacl-1.2.1-4.ky10.x86_64.rpm 506 kB/s | 77 kB 00:00 (10/16): python3-pyyaml-5.1.2-1.ky10.x86_64.rpm 1.2 MB/s | 187 kB 00:00 (11/16): sshpass-1.06-8.ky10.x86_64.rpm 242 kB/s | 24 kB 00:00 (12/16): python3-cffi-1.14.1-1.ky10.x86_64.rpm 1.3 MB/s | 237 kB 00:00 (13/16): python3-cryptography-3.3.1-5.ky10.x86_64.rpm 2.1 MB/s | 402 kB 00:00 (14/16): python3-jinja2-2.11.2-7.p01.ky10.noarch.rpm 983 kB/s | 224 kB 00:00 (15/16): python3-paramiko-2.11.0-2.ky10.noarch.rpm 1.1 MB/s | 300 kB 00:00 (16/16): ansible-2.8.8-1.p01.ky10.noarch.rpm 15 MB/s | 15 MB 00:00 ------------------------------------------------------------------------------------------------------------------------------------------ Total 12 MB/s | 23 MB 00:01 Complete! The downloaded packages were saved in cache until the next successful transaction. You can remove cached packages by executing 'yum clean packages'. [root@kylin ~]# ls /opt/ansible/ ansible-2.8.8-1.p01.ky10.noarch.rpm python3-cryptography-3.3.1-5.ky10.x86_64.rpm python3-pycparser-2.19-1.ky10.noarch.rpm libsodium-1.0.16-7.ky10.x86_64.rpm python3-jinja2-2.11.2-7.p01.ky10.noarch.rpm python3-pynacl-1.2.1-4.ky10.x86_64.rpm python3-asn1crypto-0.24.0-8.ky10.noarch.rpm python3-markupsafe-1.0-3.ky10.x86_64.rpm python3-pyyaml-5.1.2-1.ky10.x86_64.rpm python3-babel-2.7.0-1.ky10.noarch.rpm python3-paramiko-2.11.0-2.ky10.noarch.rpm sshpass-1.06-8.ky10.x86_64.rpm python3-bcrypt-3.1.4-7.ky10.x86_64.rpm python3-ply-3.9-9.ky10.noarch.rpm python3-cffi-1.14.1-1.ky10.x86_64.rpm python3-pyasn1-0.3.7-8.ky10.noarch.rpm [root@kylin ~]# yumdownloader ansible --resolve --destdir=/opt/ansibl1 Last metadata expiration check: 0:00:21 ago on Thu 05 Dec 2024 09:17:33 AM CST. (1/16): python3-asn1crypto-0.24.0-8.ky10.noarch.rpm 461 kB/s | 180 kB 00:00 (2/16): libsodium-1.0.16-7.ky10.x86_64.rpm 349 kB/s | 146 kB 00:00 (3/16): python3-bcrypt-3.1.4-7.ky10.x86_64.rpm 419 kB/s | 39 kB 00:00 (4/16): python3-markupsafe-1.0-3.ky10.x86_64.rpm 252 kB/s | 28 kB 00:00 (5/16): python3-ply-3.9-9.ky10.noarch.rpm 490 kB/s | 88 kB 00:00 (6/16): python3-pyasn1-0.3.7-8.ky10.noarch.rpm 969 kB/s | 215 kB 00:00 (7/16): python3-babel-2.7.0-1.ky10.noarch.rpm 7.7 MB/s | 5.9 MB 00:00 (8/16): python3-pycparser-2.19-1.ky10.noarch.rpm 616 kB/s | 150 kB 00:00 (9/16): python3-pynacl-1.2.1-4.ky10.x86_64.rpm 390 kB/s | 77 kB 00:00 (10/16): python3-pyyaml-5.1.2-1.ky10.x86_64.rpm 926 kB/s | 187 kB 00:00 (11/16): sshpass-1.06-8.ky10.x86_64.rpm 288 kB/s | 24 kB 00:00 (12/16): python3-cffi-1.14.1-1.ky10.x86_64.rpm 1.4 MB/s | 237 kB 00:00 (13/16): python3-cryptography-3.3.1-5.ky10.x86_64.rpm 2.0 MB/s | 402 kB 00:00 (14/16): python3-jinja2-2.11.2-7.p01.ky10.noarch.rpm 1.3 MB/s | 224 kB 00:00 (15/16): python3-paramiko-2.11.0-2.ky10.noarch.rpm 1.5 MB/s | 300 kB 00:00 (16/16): ansible-2.8.8-1.p01.ky10.noarch.rpm 17 MB/s | 15 MB 00:00 [root@kylin ~]# ls /opt/ansibl1/ ansible-2.8.8-1.p01.ky10.noarch.rpm python3-cryptography-3.3.1-5.ky10.x86_64.rpm python3-pycparser-2.19-1.ky10.noarch.rpm libsodium-1.0.16-7.ky10.x86_64.rpm python3-jinja2-2.11.2-7.p01.ky10.noarch.rpm python3-pynacl-1.2.1-4.ky10.x86_64.rpm python3-asn1crypto-0.24.0-8.ky10.noarch.rpm python3-markupsafe-1.0-3.ky10.x86_64.rpm python3-pyyaml-5.1.2-1.ky10.x86_64.rpm python3-babel-2.7.0-1.ky10.noarch.rpm python3-paramiko-2.11.0-2.ky10.noarch.rpm sshpass-1.06-8.ky10.x86_64.rpm python3-bcrypt-3.1.4-7.ky10.x86_64.rpm python3-ply-3.9-9.ky10.noarch.rpm python3-cffi-1.14.1-1.ky10.x86_64.rpm python3-pyasn1-0.3.7-8.ky10.noarch.rpm
这里演示中使用了两个命令分别是,当然,如果安装必须把下载的依赖包上传到生产环境之后才可以安装的。
yumdownloader ansible --resolve --destdir=/opt/ansibl1 yum install --downloadonly --downloaddir=/opt/ansible ansible
两者的区别相同点都是下载依赖包,并不安装,但是yum install --downloadonly --downloaddir=/opt/ansible ansible
在安装时直接使用
yum install /opt/ansible*.rpm
安装完成后/opt/ansible
下的rpm包都会自动删除,如果使用yumdownloader ansible --resolve --destdir=/opt/ansibl1
下载的依赖包,可以当做yum源使用。把下载好的包传到生产环境,需要配置一下啊yum源
[root@prod-kylin ~]# cat >/etc/yum.repos.d/ansible.repo<<eof > [ansible] > name=ansible > baseurl=file:///opt/ansibl1 > gpgcheck=0 > enabled=1 > eof [root@prod-kylin ~]# createrepo /opt/ansibl1 Directory walk started Directory walk done - 11 packages Temporary output repo path: /opt/ansibl1/.repodata/ Preparing sqlite DBs Pool started (with 5 workers) Pool finished [root@prod-kylin ~]# yum clean all 16 files removed [root@prod-kylin ~]# yum repolist repo id repo name ansible ansible kylin_arm.repo
配置好yum源后,直接使用yum安装即可yum install ansible -y
,安装后,下载的rpm包还会继续存在不会自动删除
您可以选择一种方式赞助本站
支付宝扫一扫赞助
微信钱包扫描赞助
赏