创建和运行Ansible临时命令

请按照下方所述 , 创建一个名为 /home/student/ansible/adhoc.sh shell 脚本 , 该脚本将使用 Ansible
时命令在各个受管节点上安装 yum 存储库 :
存储库 1:
存储库的名称为 rh294_BASE
描述为 rh294 base software
基础 URL http://content.example.com/rhel8.4/x86_64/dvd/BaseOS
GPG 签名检查为启用状态
GPG 密钥 URL http://content.example.com/rhel8.4/x86_64/dvd/RPM-GPG-KEY-redhat-releas
e
存储库为开启状态
存储库 2:
存储库的名称为 rh294_STREAM
描述为 rh294 stream software
基础 URL http://content.example.com/rhel8.4/x86_64/dvd/AppStream
签名检查为启用状态
GPG 密钥 URL http://content.example.com/rhel8.4/x86_64/dvd/RPM-GPG-KEY-redhat-releas
e
存储库为开启状态
[student@workstation ansible] $ for i in server{a..d} bastion; do ssh root@ $i
"rm -rf /etc/yum.repos.d/*" ; done
[student@workstation ansible] $ vim adhoc.sh
#!/bin/bash
ansible all -m yum_repository -a "name=rh294_BASE description='rh294 base
software' file=rhel_dvd
baseurl = http://content.example.com/rhel8.4/x86_64/dvd/BaseOS gpgcheck = yes
gpgkey = http://content.example.com/rhel8.4/x86_64/dvd/RPM-GPG-KEY
redhatrelease enabled = yes "
ansible all -m yum_repository -a "name=rh294_STREAM description='rh294
stream software' file=rhel_dvd
baseurl = http://content.example.com/rhel8.4/x86_64/dvd/AppStream
gpgcheck = yes gpgkey = http://content.example.com/rhel8.4/x86_64/dvd/RPM
GPGKEY-redhat-release enabled = yes "
[student@workstation ansible] $ chmod a + x adhoc.sh
[student@workstation ansible] $ ./adhoc.sh
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值