• RHCE --- ansible配置yum源


    目录

    一、执行ansible配置文件的优先级

    二、创建ansible.cfg文件

    三、在主机列表配置文件下写入主机

    四、查看是否可以访问到servera主机

    五、确保 /etc/yum.repos.d/ 下没有yum源

    六、配置yum源

    七、在servera上查看yum源

    八、通过yum装包测试


    配置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文件

    1. [root@workstation ~]# vim ansible.cfg
    2. [defaults]
    3. inventory=~/inventory //指定主机列表配置文件

    三、在主机列表配置文件下写入主机

    1. [root@workstation ~]# vim inventory
    2. servera
    3. serverb
    4. serverc
    5. serverd

    四、查看是否可以访问到servera主机

    1. [root@workstation ~]# ansible servera --list-hosts
    2. hosts (1):
    3. servera

    五、确保 /etc/yum.repos.d/ 下没有yum源

    1. [root@servera ~]# cd /etc/yum.repos.d/
    2. [root@servera yum.repos.d]# ll
    3. total 8
    4. -rw-r--r--. 1 root root 358 Apr 4 2019 redhat.repo
    5. -rw-r--r--. 1 root root 365 May 22 2019 rhel_dvd.repo //修改其后缀
    6. [root@servera yum.repos.d]# mv rhel_dvd.repo{,.bak}
    7. [root@servera yum.repos.d]# ll
    8. total 8
    9. -rw-r--r--. 1 root root 358 Apr 4 2019 redhat.repo
    10. -rw-r--r--. 1 root root 365 May 22 2019 rhel_dvd.repo.bak

    六、配置yum源

    1. [root@workstation ~]# ansible servera -m yum_repository -a
    2. 'name=RH294_Stream //仓库ID
    3. description="RH294 stream software" //仓库中的name
    4. baseurl=http://content.example.com/rhel8.0/x86_64/dvd/AppStream
    5. gpgcheck=no //包验证
    6. file=base'
    7. [root@workstation ~]# ansible servera -m yum_repository -a
    8. 'name=RH294_Base
    9. description="RH294 base software"
    10. baseurl=http://content.example.com/rhel8.0/x86_64/dvd/BaseOS
    11. gpgcheck=no
    12. file=base'

    七、在servera上查看yum源

    1. [root@servera yum.repos.d]# vim base.repo
    2. [RH294_Stream]
    3. baseurl = http://content.example.com/rhel8.0/x86_64/dvd/AppStream
    4. gpgcheck = 0
    5. name = RH294 stream software
    6. [RH294_Base]
    7. baseurl = http://content.example.com/rhel8.0/x86_64/dvd/BaseOS
    8. gpgcheck = 0
    9. name = RH294 base software

    八、通过yum装包测试

    1. [root@servera ~]# yum install httpd -y
    2. RH294 base software 1.9 MB/s | 2.2 MB 00:01
    3. RH294 stream software 47 MB/s | 5.3 MB 00:00
    4. Dependencies resolved.
    5. ========================================================================
    6. Installed:
    7. httpd-2.4.37-10.module+el8+2764+7127e69e.x86_64
    8. apr-util-bdb-1.6.1-6.el8.x86_64
    9. apr-util-openssl-1.6.1-6.el8.x86_64
    10. redhat-logos-httpd-80.7-1.el8.noarch
    11. apr-1.6.3-9.el8.x86_64
    12. apr-util-1.6.1-6.el8.x86_64
    13. httpd-filesystem-2.4.37-10.module+el8+2764+7127e69e.noarch
    14. httpd-tools-2.4.37-10.module+el8+2764+7127e69e.x86_64
    15. mod_http2-1.11.3-1.module+el8+2443+605475b7.x86_64
    16. Complete!
    17. [root@servera ~]# rpm -qa | grep httpd
    18. httpd-tools-2.4.37-10.module+el8+2764+7127e69e.x86_64
    19. httpd-2.4.37-10.module+el8+2764+7127e69e.x86_64
    20. httpd-filesystem-2.4.37-10.module+el8+2764+7127e69e.noarch
    21. redhat-logos-httpd-80.7-1.el8.noarch

  • 相关阅读:
    开发知识点-python-Tornado框架
    猿创征文 | Spring框架【管理对象(IOC详解)】
    零数科技 CEO 林乐受邀出席亿欧“元碳局”,探讨元宇宙文旅破局之道
    深度学习计算 - 延后初始化&自定义层
    解决JeecgBoot修改默认主题不生效问题
    activiti会签
    (2022版)一套教程搞定k8s安装到实战 | Kubernetes基础
    智慧公厕:提升城市形象,为市民带来极致体验
    「项目管理」甘特图制定项目计划的方法
    【pytorch08】拼接与拆分
  • 原文地址:https://blog.csdn.net/weixin_58299245/article/details/126756177