一、构建学习环境:
student用户在控制节点(workstation)上安装并配置 Ansible, 要求如下 :
1、安装所需的软件包
2、创建静态inventory文件/home/student/ansible/inventory,要求如下:
servera属于dev主机组
serverb属于test和balancers主机组
serverc和serverd属于prod主机组
prod主机组属于webservers主机组
3、创建ansible配置文件/home/student/ansible/ansible.cfg,要求如下:
使用/home/student/ansible/inventory清单文件
角色存放在/home/student/ansible/roles/ 目录
二、创建一个 shell 脚本名为 adhoc.sh 用以运行 ad-hoc 命令 。为每个受控节点配罝 yum仓库。要求如下:
仓库1 :
Name: RH294_Base
Description: RH294 base software
Base url: 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
Base url: http://content.example.com/rhel8.0/x86_64/dvd/AppStream
需要验证软件包 GPG 签名
GPG key 在: /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
启用此软件仓库
一、搭建环境
1、vnet1添加IP
测试连通性
2、设置课程
清除课程:[kiosk@foundation0 ~]$ rht-clearcourse 0
设置课程:[kiosk@foundation0 ~]$ rht-setcourse rh294
3、启动环境
启用classroom(仅一次):[kiosk@foundation0 ~]$ rht-vmctl start classroom
启用其他服务器:[kiosk@foundation0 ~]$ rht-vmctl start all
查看状态:[kiosk@foundation0 ~]$ rht-vmctl status all
重置环境:[kiosk@foundation0 ~]$ rht-vmctl reset servera
[kiosk@foundation0 ~]$ rht-vmctl fullreset servera
连接到workstation
二、ansible配置
1、安装ansible
sudo yum install ansible
2、创建清单文件
[student@workstation ~]$ mkdir /home/student/ansible
[student@workstation ~]$ vim /home/student/ansible/inventory
3、配置文件
vim /home/student/ansible/ansible.cfg
验证
1、ansible-inventory --graph
2、ansible all -m ping
三、脚本运行ad-hoc配置yum仓库
vim ad-hoc.sh
[student@workstation ansible]$ chmod +x adhoc.sh
[student@workstation ansible]$ ./adhoc.sh
验证