4.使用 RHEL 系统角色
1. 考题
安装 RHEL 系统角色软件包,并创建符合以下条件的 playbook
- /home/student/ansible/selinux.yml :
- 在所有受管节点上运行
- 使用 selinux 角色
- 配置该角色,配置被管理节点的selinux为enforcing
2. 解题思路
安装rhel-system-roles模块
编辑/home/student/ansible/selinux.yml
使用yum模块
使用ansible-doc yum获取到模块使用方法
使用when实现服务器选择
3. 解题
3.1 安装rhel-system-roles
sudo yum install -y rhel-system-roles
3.2 复制selinux roles模板
cp -r /usr/share/ansible/roles/rhel-system-roles.selinux /home/student/ansible/roles/selinux
3.3 复制selinux配置文件
cp /usr/share/doc/rhel-system-roles/selinux/example-selinux-playbook.yml /home/student/ansible/selinux.yml
3.4 修改selinux.yml文件
sed -i 's/rhel-system-roles/selinux/g' /home/student/ansible/selinux.yml
3.5 执行/home/student/ansible/selinux.yml
ansible-playbook /home/student/ansible/selinux.yml
4. 确认本题是否成功
4.1 确认roles
ansible-galaxy list
没有报错即为正常