实验要求:
仓库1 : Name: RH294_Base Description: RH294 base software baseurl: file:///mnt/BaseOS 不需要验证钦件包 GPG 签名 启用此软件仓库
仓库 2: Name: RH294_Stream Description : RH294 stream software baseurl:file:///mnt/AppStream 不需要验证软件包 GPG 签名 yum_repository
分别用blockinfile lineinfile copy三种方式实现
法一:copy
在主控主机中写入仓库内容:
[RH294_Base]
name=RH294 base software
baseurl=file:///mnt/BaseOS
gpgcheck=0
[RH294_Stream]
name=RH294 stream software
baseurl=file:///mnt/AppStream
gpgcheck=0
用copy模块将配置文件拷贝到受控主机中
[root@server ansible]#ansible node2 -m copy -a "src=/etc/yum.repos.d
/rh294.repo dest=/etc/yum.repos.d/rh294.repo"
在受控主机上查看文件内容
法二:lineinfile
主控主机
[root@server ansible]# ansible node2 -m lineinfile -a "path=/home/root/yum
line='[RH294_Base]\nname=RH294 base software\nbaseurl=file:///mnt/BaseOS\ngpgche
ck=0\n[RH294_AppStream]\nname=RH294 appstream
software\nbaseurl=file:///mnt/AppStream\ngpg
check=0\n ' create=yes"
在受控主机上查看文件内容
法三:blockinfile
主控主机中:
[root@server ansible]# ansible node2 -m blockinfile -a "path=/home/root/yum2 block='[RH294_Base]\nname=RH294 base
software\nbaseurl=file:///mnt/BaseOS\ngpgche
ck=0\n[RH294_AppStream]\nname=RH294 appstream
software\nbaseurl=file:///mnt/AppStream\ngpgcheck=0\n' create=yes"
在受控主机上查看文件内容