在ansible节点中新建/home/student/ansible/hwreport.empty的文件,文件内容为
hostname: inventoryhostname
mem: memory_in_MB
bios: BIOS_version
sda: disk_sda_size
创建一个名为 /home/student/ansible/hwreport.yml的 playbook,它将在所有受管节点上生成含有以 下信息的输出文件 /root/hwreport.txt:
输出文件中的每一行含有一个 key=value 对。
您的 playbook 应当:
从 ansible节点中复制hwreport.empty文件到每台受控主机,并将它保存为/root/hwreport.txt使用正确的值修改 /root/hwreport.txt
然后将/home/student/ansible/hwreport.yml这个playbook进行加密,加密的密码保存在/home/student/ansible/pass文件中,密码为abcdefg
执行该playbook,实现需求
# 创建hwreport.empty
[student@ansible ~/ansible]$cat hwreport.empty
hostname:inventoryhostname
mem:memory_in_MB
bios:BIOS_version
sda:disk_sda_size
# 创建hwreport.yml
[student@ansible ~/ansible]$ansible-vault view hwreport.yml
Vault password:
---
- name: exercise2
hosts: all
tasks:
- name: copy hwrep