安装 RHEL 系统角色软件包,并创建符合以下条件的 playbook
任务要求
编写 /home/student/ansible/timesync.yml
在所有受管节点上运行
使用 timesync 角色
配置该角色,以使用当前有效的 NTP 提供商
配置该角色,以使用时间服务器 classroom.example.com
配置该角色,以启用 iburst 参数
完成步骤
- 先切到root安装rhel角色包rhel-system-roles
- 也可以sudo
-
[root@workstation ~]# dnf -y install rhel-system-roles [root@workstation ~]# su - student
- 装完了记得切换回student用户
- 创建目录并拷贝角色模板到考试目录
-
[student@workstation ansible]$ mkdir roles [student@workstation ansible]$ cp -r /usr/share/ansible/roles/rhel-system-roles.timesync/ /home/sutdent/ansible/roles/timesync
注意:拷贝的时候使用-r参数拷贝目录下所有文件及文件夹,但不能使用-a参数,否则权限就乱了
-
[student@workstation ansible]$ vim timesync.yml --- - name: set time sync hosts: all vars: timesync_ntp_servers: - hostname: classroom.example.com iburst: yes roles: - timesync [student@workstation ansible]$ ansible-playbook timesync.yml
还有一种情况是使用selinux系统角色,配置该角色,开启所有受控节点的selinux,套路是一样的
进入系统角色目录,找到题中要求的系统角色
拷贝到题中要求的指定目录,并改名
[student@workstation ansible]$ vim selinux.yml --- - name: set selinux hosts: all vars: selinux_policy: targeted selinux_state: enforcing roles: - role: selinux become: ture [student@workstation ansible]$ ansible-playbook timesync.yml