CE第二次作业

创建一个 shell 脚本名为 adhoc.sh 用以运行 ad-hoc 命令 . 为每个受控节点配罝 yum仓库.

要求如下:

仓库1 :

Name: RH294_Base

Description: RH294 base software

Baseurl: http://content.example.com/rhel8.0/x86_64/dvd/BaseOS

需要验证钦件包 GPG 签名

GPG key 在: /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

启用此软件仓库

-仓库 2:

Name: RH294_Stream

Description : RH294 stream software

Baseurl: http://content.example.com/rhel8.0/x86_64/dvd/AppStream

需要验证软件包 GPG 签名

GPG key 在: /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

启用此软件仓库

配置思路:

1.配置yum源应该用什么模块

#ansible-doc -l | grep yum

yum Manages packa...

yum_repository Add or remove...

2.查看yum_repository模块的使用帮助

yum_repository:

name: epel

description: EPEL YUM repo

baseurl: https://download.fedoraproject.org/pub/epel/$releasever/$ba>

gpgcheck: no

编辑shell脚本

ansible dev -m yum_repository \

>  -a 'name="RH294_Base" \

> description="RH294 base software" \

> baseurl=http://content.example.com/rhel8.0/x86_64/dvd/BaseOS \

> gpgcheck=yes \

>  gpgkey=/etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release \

>  enabled=yes'

servera | CHANGED => {

    "ansible_facts": {

        "discovered_interpreter_python": "/usr/libexec/platform-python"

    },

    "changed": true,

    "repo": "RH294_Base",

    "state": "present"

}

执行脚本

 [grep@bastion ansible]$ chmod +x adhoc.sh

 [grep@bastion ansible]$ ./adhoc.sh

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值