rhce考试模拟环境准备:
cat /etc/rht 确认当前是否为294环境,真实考试有5台被管理节点,借助bastion当做第5台。
将考试所需的文件放到这个目录,/content/courses/rh294/rhel8.0/materials目录,虚拟机看br0网卡信息ifconfig br0
rht-vmctl fullreset all 初始化后做题(重置后sudo免密要重新做,重置后所有做的东西都被清空的)
真正考试时,是要求使用一个普通用户来做题,该用户已做好ssh免密和sudo免密。做题环境ssh免密做好了,但要自己配置sudo免密。
在6台机子给student用户做sudo免密,先在物理机以root身份登录到worktation,vim /etc/sudoers.d/student
%wheel ALL= NOPASSWD: ALL
后将此文件拷贝到其它机子上,scp /etc/sudoers.d/student root@bastion:/etc/sudoers.d/
环境准备好后用student做题,在物理机以student登录到worktation做题。
考试说明:
1、安装和配置 Ansible
[student@workstation ~]$ sudo yum install ansible -y
[student@workstation ~]$ mkdir ansible
[student@workstation ansible]$ mkdir roles
vim inventory
[dev]
servera.lab.example.com
[test]
serverb.lab.example.com
[prod]
serverc.lab.example.com
serverd.lab.example.com
[balancers]
bastion.lab.example.com
[webservers:children]
prod
[prod]也可写成,server[c:d].lab.example.com
也可用短主机名,
[dev]
servera
[test]
serverb
[prod]
server[c:d]
[balancers]
bastion
[webservers:children]
prod
先从默认配置文件把提权部分复制出来,vim /etc/ansible/ansible.cfg,搜索/pri找到并复制下面内容
[privilege_escalation]
#become=True
#become_method=sudo
#become_user=root
#become_ask_pass=False
vim ansible.cfg
[defaults]
inventory=/home/student/ansible/inventory
remote_user=student
roles_path=/home/student/ansible/roles
[privilege_escalation]
become=True
become_method=sudo
become_user=root
become_ask_pass=False
[student@workstation ansible]$ ansible --version
[student@workstation ansible]$ ansible all --list-hosts
2、创建和运行 Ansible 临时命令