目录
2、不改变/etc/ansible/ansible.cfg,重新创建一个配置文件
5、 查看servera的/etc/yum.repos.d/下有无yum源
配置yum源仓库文件通过多种方式实现
仓库1 :
Name: RH294_Base
Description: RH294 base software
Base urt: file:///mnt/BaseOS
不需要验证钦件包 GPG 签名
启用此软件仓库
仓库 2:
Name: RH294_Stream
Description : RH294 stream software
Base url:file:///mnt/AppStream
不需要验证软件包 GPG 签名
- [root@workstation ~]# ansible --version
-
- ansible [core 2.12.7]
-
- config file = /etc/ansible/ansible.cfg
- [root@workstation ~]# vim ansible.cfg
-
- [defaults]
- inventory=~/inventory
- [root@workstation ~]# vim inventory
-
- servera
- serverb
- serverc
- serverd
- [root@workstation ~]# ansible servera --list-hosts
- hosts (1):
- servera
- [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
- [root@workstation ~]# ansible servera -m yum_repository -a 'name=RH294_Stream description="RH294 stream software" baseurl=http://content.example.com/rhel8.0/x86_64/dvd/AppStream gpgcheck=no file=base'
- servera | CHANGED => {
- "ansible_facts": {
- "discovered_interpreter_python": "/usr/libexec/platform-python"
- },
- "changed": true,
- "repo": "RH294_Stream",
- "state": "present"
- }
-
- [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 | CHANGED => {
- "ansible_facts": {
- "discovered_interpreter_python": "/usr/libexec/platform-python"
- },
- "changed": true,
- "repo": "RH294_Base",
- "state": "present"
- }
- [root@servera ~]# cd /etc/yum.repos.d/
- [root@servera yum.repos.d]# cat 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
- [root@servera ~]# yum install httpd -y
- Repository RH294_Stream is listed more than once in the configuration
- RH294 stream software 32 MB/s | 5.3 MB 00:00
- RH294 base software 43 MB/s | 2.2 MB 00:00
- Last metadata expiration check: 0:00:01 ago on Fri 09 Sep 2022 08:53:55 PM CST.
- Dependencies resolved.
- =======================================================================
- Package Arch Version Repository Size
- =======================================================================
- Installing:
- httpd x86_64 2.4.37-10.module+el8+2764+7127e69e
- RH294_Stream 1.4 M
- Installing dependencies:
- apr x86_64 1.6.3-9.el8 RH294_Stream 125 k
- apr-util x86_64 1.6.1-6.el8 RH294_Stream 105 k
- httpd-filesystem noarch 2.4.37-10.module+el8+2764+7127e69e
- RH294_Stream 34 k
- httpd-tools x86_64 2.4.37-10.module+el8+2764+7127e69e
- RH294_Stream 101 k
- mod_http2 x86_64 1.11.3-1.module+el8+2443+605475b7
- RH294_Stream 156 k
- redhat-logos-httpd noarch 80.7-1.el8 RH294_Base 25 k
- Installing weak dependencies:
- apr-util-bdb x86_64 1.6.1-6.el8 RH294_Stream 25 k
- apr-util-openssl x86_64 1.6.1-6.el8 RH294_Stream 27 k
- Enabling module streams:
- httpd 2.4
- 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
- redhat-logos-httpd-80.7-1.el8.noarch
- httpd-filesystem-2.4.37-10.module+el8+2764+7127e69e.noarch
至此,实验完美成功-。-!