创建一个 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