配置yum源仓库文件通过多种方式实现
仓库1 :
Name: RH294_Base
Description: RH294 base software
Baseurt: file:///mnt/BaseOS
不需要验证软件包 GPG 签名
启用此软件仓库
仓库 2:
Name: RH294_Stream
Description : RH294 stream software
Baseurl:file:///mnt/AppStream
不需要验证软件包 GPG 签名
一、执行ansible配置文件的优先级
1、首先找执行ansible命令的当前目录中,是否有 ansible.cfg文件
./ansible.cfg
2、如果找不到,再找当前用户的家目录下是否有 .ansible.cfg
~/.ansible.cfg
3、如果还找不到,就找 /etc/ansible/ansible.cfg
要检查当前使用的是哪个配置文件
ansible --version 命令中,会显示
…
config file = /etc/ansible/ansible.cfg
二、创建ansible.cfg文件
[root@workstation ~]# vim ansible.cfg
[defaults]
inventory=~/inventory //指定主机列表配置文件
三、在主机列表配置文件下写入主机
[root@workstation ~]# vim inventory
servera
serverb
serverc
serverd
四、查看是否可以访问到servera主机
[root@workstation ~]# ansible servera --list-hosts
hosts (1):
servera
五、确保 /etc/yum.repos.d/ 下没有yum源
[root@servera ~]# cd /etc/yum.repos.d/
[root@servera yum.repos.d]# ll
total 8
-rw-r--r--. 1 root root 358 Apr 4 2019 redhat.repo
-rw-r--r--. 1 root root 365 May 22 2019 rhel_dvd.repo //修改其后缀
[root@servera yum.repos.d]# mv rhel_dvd.repo{,.bak}
[root@servera yum.repos.d]# ll
total 8
-rw-r--r--. 1 root root 358 Apr 4 2019 redhat.repo
-rw-r--r--. 1 root root 365 May 22 2019 rhel_dvd.repo.bak
六、配置yum源
[root@workstation ~]# ansible servera -m yum_repository -a
'name=RH294_Stream //仓库ID
description="RH294 stream software" //仓库中的name
baseurl=http://content.example.com/rhel8.0/x86_64/dvd/AppStream
gpgcheck=no //包验证
file=base'
[root@workstation ~]# ansible servera -m yum_repository -a
'name=RH294_Base
description="RH294 base software"
baseurl=http://content.example.com/rhel8.0/x86_64/dvd/BaseOS
gpgcheck=no
file=base'
七、在servera上查看yum源
[root@servera yum.repos.d]# vim base.repo
[RH294_Stream]
baseurl = http://content.example.com/rhel8.0/x86_64/dvd/AppStream
gpgcheck = 0
name = RH294 stream software
[RH294_Base]
baseurl = http://content.example.com/rhel8.0/x86_64/dvd/BaseOS
gpgcheck = 0
name = RH294 base software
八、通过yum装包测试
[root@servera ~]# yum install httpd -y
RH294 base software 1.9 MB/s | 2.2 MB 00:01
RH294 stream software 47 MB/s | 5.3 MB 00:00
Dependencies resolved.
========================================================================
Installed:
httpd-2.4.37-10.module+el8+2764+7127e69e.x86_64
apr-util-bdb-1.6.1-6.el8.x86_64
apr-util-openssl-1.6.1-6.el8.x86_64
redhat-logos-httpd-80.7-1.el8.noarch
apr-1.6.3-9.el8.x86_64
apr-util-1.6.1-6.el8.x86_64
httpd-filesystem-2.4.37-10.module+el8+2764+7127e69e.noarch
httpd-tools-2.4.37-10.module+el8+2764+7127e69e.x86_64
mod_http2-1.11.3-1.module+el8+2443+605475b7.x86_64
Complete
[root@servera ~]# rpm -qa | grep httpd
httpd-tools-2.4.37-10.module+el8+2764+7127e69e.x86_64
httpd-2.4.37-10.module+el8+2764+7127e69e.x86_64
httpd-filesystem-2.4.37-10.module+el8+2764+7127e69e.noarch
redhat-logos-httpd-80.7-1.el8.noarch