请按照下方所述
,
创建一个名为
/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