• RHCE-ansible第二次实验,通过ansible远程yum安装


    目录

    一、实验内容

    二、配置过程

    1、查看配置文件优先级

    2、不改变/etc/ansible/ansible.cfg,重新创建一个配置文件

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

    4、查看能否访问成功

    5、 查看servera的/etc/yum.repos.d/下有无yum源

    6、配置yum源

    7、在servera上查看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 签名

    二、配置过程

    1、查看配置文件优先级

    1. [root@workstation ~]# ansible --version
    2. ansible [core 2.12.7]
    3.   config file = /etc/ansible/ansible.cfg

    2、不改变/etc/ansible/ansible.cfg,重新创建一个配置文件

    1. [root@workstation ~]# vim ansible.cfg
    2. [defaults]
    3. inventory=~/inventory

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

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

    4、查看能否访问成功

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

    5、 查看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

    6、配置yum源

    1. [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'
    2. servera | CHANGED => {
    3.     "ansible_facts": {
    4.         "discovered_interpreter_python": "/usr/libexec/platform-python"
    5.     },
    6.     "changed": true,
    7.     "repo": "RH294_Stream",
    8.     "state": "present"
    9. }
    10. [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'
    11. servera | CHANGED => {
    12.     "ansible_facts": {
    13.         "discovered_interpreter_python": "/usr/libexec/platform-python"
    14.     },
    15.     "changed": true,
    16.     "repo": "RH294_Base",
    17.     "state": "present"
    18. }

    7、在servera上查看yum源

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

    三、装包测试

    1. [root@servera ~]# yum install httpd -y
    2. Repository RH294_Stream is listed more than once in the configuration
    3. RH294 stream software 32 MB/s | 5.3 MB 00:00
    4. RH294 base software 43 MB/s | 2.2 MB 00:00
    5. Last metadata expiration check: 0:00:01 ago on Fri 09 Sep 2022 08:53:55 PM CST.
    6. Dependencies resolved.
    7. =======================================================================
    8. Package Arch Version Repository Size
    9. =======================================================================
    10. Installing:
    11. httpd x86_64 2.4.37-10.module+el8+2764+7127e69e
    12. RH294_Stream 1.4 M
    13. Installing dependencies:
    14. apr x86_64 1.6.3-9.el8 RH294_Stream 125 k
    15. apr-util x86_64 1.6.1-6.el8 RH294_Stream 105 k
    16. httpd-filesystem noarch 2.4.37-10.module+el8+2764+7127e69e
    17. RH294_Stream 34 k
    18. httpd-tools x86_64 2.4.37-10.module+el8+2764+7127e69e
    19. RH294_Stream 101 k
    20. mod_http2 x86_64 1.11.3-1.module+el8+2443+605475b7
    21. RH294_Stream 156 k
    22. redhat-logos-httpd noarch 80.7-1.el8 RH294_Base 25 k
    23. Installing weak dependencies:
    24. apr-util-bdb x86_64 1.6.1-6.el8 RH294_Stream 25 k
    25. apr-util-openssl x86_64 1.6.1-6.el8 RH294_Stream 27 k
    26. Enabling module streams:
    27. httpd 2.4
    28. Complete!
    29. [root@servera ~]# rpm -qa | grep httpd
    30. httpd-tools-2.4.37-10.module+el8+2764+7127e69e.x86_64
    31. httpd-2.4.37-10.module+el8+2764+7127e69e.x86_64
    32. redhat-logos-httpd-80.7-1.el8.noarch
    33. httpd-filesystem-2.4.37-10.module+el8+2764+7127e69e.noarch

    至此,实验完美成功-。-!

  • 相关阅读:
    什么是时钟树综合?
    Java发送(QQ)邮箱、验证码发送
    虹科方案 | 虹科ATTO加速虚拟存储管理
    优化函数和损失函数的区别与联系
    中职计算机应用专业(大数据方向)建设实践
    8.2模拟赛总结
    JVM 虚拟机
    前端学习记录~2023.8.19~JavaScript重难点实例精讲~第7章 ES6(2)
    公考求的是稳定,搞IT求的是高薪,鱼和熊掌能否兼得?
    设计模式:命令模式
  • 原文地址:https://blog.csdn.net/weixin_46966890/article/details/126843318