目录
一、本地仓库
问题:
当你刚装好rhel8环境,却发现啥也干不了,下载也不行,如:
[root@control ~]# yum install vim* -y
Updating Subscription Management repositories.
Unable to read consumer identityThis system is not registered with an entitlement server. You can use subscription-manager to register.
Error: There are no enabled repositories in "/etc/yum.repos.d", "/etc/yum/repos.d", "/etc/distro.repos.d".
解决:
1.创建一个仓库:
在/etc/yum.repos.d下:
[root@control yum.repos.d]# vim base.repo
内容:
[BaseOS]
name=BaseOS
baseurl=/mnt/BaseOS
gpgcheck=0
enabled=1
[AppStream]
name=AppStream
baseurl=/mnt/AppStream
gpgcheck=0
enabled=1
2.挂载:
确保这个镜像是开启的我这里的是8.5的镜像
挂载:
[root@control yum.repos.d]# mount /dev/sr0 /mnt/
mount: /mnt: WARNING: device write-protected, mounted read-only.
[root@control yum.repos.d]# mount -a
测试:
[root@control yum.repos.d]# yum install vim -y
Updating Subscription Management repositories.
Unable to read consumer identityThis system is not registered with an entitlement server. You can use subscription-manager to register.
BaseOS 137 MB/s | 2.4 MB 00:00
AppStream 165 MB/s | 7.2 MB 00:00
Last metadata expiration check: 0:00:01 ago on Wed 02 Aug 2023 02:19:43 AM PDT.
Package vim-enhanced-2:8.0.1763-16.el8.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
3.或者直接使用阿里云的源
虽然是centos的,但是rhel也能用
[AppStream1]
name=AppStream
baseurl=https://mirrors.aliyun.com/centos/8-stream/AppStream/x86_64/os/
gpgcheck=0
[Base0s1]
name=BaseOS
baseurl=https://mirrors.aliyun.com/centos/8-stream/BaseOS/x86_64/os/
gpgcheck=0
二.配置ansible仓库
在/etc/yum.repos.d下创建:
[root@control yum.repos.d]# vim ansible.repo
[ansible]
name=ansible
baseurl=http://47.108.86.156/rhel8/ansible29/ansible-2.9-for-rhel-8-x86_64-rpms/
gpgcheck=0
1.下载:
[root@control yum.repos.d]# yum install ansible -y
Updating Subscription Management repositories.
Unable to read consumer identityThis system is not registered with an entitlement server. You can use subscription-manager to register.
ansible 1.7 MB/s | 837 kB 00:00
Dependencies resolved.
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
ansible noarch 2.9.11-1.el8ae ansible 17 M
Installing dependencies:
python3-babel noarch 2.5.1-7.el8 AppStream 4.8 M
python3-cffi x86_64 1.11.5-5.el8 BaseOS 238 k
python3-cryptography x86_64 3.2.1-5.el8 BaseOS 559 k
python3-jinja2 noarch 2.10.1-3.el8 AppStream 538 k
python3-markupsafe x86_64 0.23-19.el8 AppStream 39 k
python3-pycparser noarch 2.14-14.el8 BaseOS 109 k
sshpass x86_64 1.06-3.el8ae ansible 27 k
Installing weak dependencies:
python3-jmespath noarch 0.9.0-11.el8 AppStream 45 kTransaction Summary
================================================================================
Install 9 PackagesTotal size: 23 M
Total download size: 17 M
Installed size: 123 M
Downloading Packages:
(1/2): sshpass-1.06-3.el8ae.x86_64.rpm 143 kB/s | 27 kB 00:00
[MIRROR] ansible-2.9.11-1.el8ae.noarch.rpm: Curl error (28): Timeout was reached for http://47.108.86.156/rhel8/ansible29/ansible-2.9-for-rhel-8-x86_64-rpms/Packages/a/ansible-2.9.11-1.el8ae.noarch.rpm [Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds]
(2/2): ansible-2.9.11-1.el8ae.noarch.rpm 239 kB/s | 17 MB 01:12
--------------------------------------------------------------------------------
Total 240 kB/s | 17 MB 01:12
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : python3-markupsafe-0.23-19.el8.x86_64 1/9
Installing : python3-jmespath-0.9.0-11.el8.noarch 2/9
Installing : python3-babel-2.5.1-7.el8.noarch 3/9
Installing : python3-jinja2-2.10.1-3.el8.noarch 4/9
Installing : python3-pycparser-2.14-14.el8.noarch 5/9
Installing : python3-cffi-1.11.5-5.el8.x86_64 6/9
Installing : python3-cryptography-3.2.1-5.el8.x86_64 7/9
Installing : sshpass-1.06-3.el8ae.x86_64 8/9
Installing : ansible-2.9.11-1.el8ae.noarch 9/9
Running scriptlet: ansible-2.9.11-1.el8ae.noarch 9/9
Verifying : sshpass-1.06-3.el8ae.x86_64 1/9
Verifying : ansible-2.9.11-1.el8ae.noarch 2/9
Verifying : python3-cffi-1.11.5-5.el8.x86_64 3/9
Verifying : python3-cryptography-3.2.1-5.el8.x86_64 4/9
Verifying : python3-pycparser-2.14-14.el8.noarch 5/9
Verifying : python3-babel-2.5.1-7.el8.noarch 6/9
Verifying : python3-jinja2-2.10.1-3.el8.noarch 7/9
Verifying : python3-jmespath-0.9.0-11.el8.noarch 8/9
Verifying : python3-markupsafe-0.23-19.el8.x86_64 9/9
Installed products updated.Installed:
ansible-2.9.11-1.el8ae.noarch python3-babel-2.5.1-7.el8.noarch
python3-cffi-1.11.5-5.el8.x86_64 python3-cryptography-3.2.1-5.el8.x86_64
python3-jinja2-2.10.1-3.el8.noarch python3-jmespath-0.9.0-11.el8.noarch
python3-markupsafe-0.23-19.el8.x86_64 python3-pycparser-2.14-14.el8.noarch
sshpass-1.06-3.el8ae.x86_64Complete!
2.检查
[root@control yum.repos.d]# ansible --version
ansible 2.9.11
config file = /etc/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.6/site-packages/ansible
executable location = /usr/bin/ansible
python version = 3.6.8 (default, Sep 9 2021, 07:49:02) [GCC 8.5.0 20210514 (Red Hat 8.5.0-3)]