RHCE8 练习题:创建密码库

按照下方所述,创建一个Ansible库来存储用户密码:

  • 库名为 /home/student/ansible/locker.yml
  • 库中含有两个变量,名称如下:
    • pw_developer , 值为 Imadev
    • pw_manager , 值为 Imamgr
  • 用于加密和解密该库的密码为 retent
  • 密码存储在文件 /home/student/ansible/secret.txt 中


Answer:

echo retent> /home/student/ansible/secret.txt
vim /home/student/ansible/locker.yml
---
pw_developer: Imadev
pw_Manager: Imangr
ansible-vault encrypt --vault-password-file=/home/student/ansible/secret.txt /home/student/ansible/locker.yml

或者

ansible-vault create --vault-password-file=/home/student/ansible/secret.txt /home/student/ansible/locker.yml
---
pw_developer: Imadev
pw_Manager: Imangr

验证:

ansible-vault view /home/student/nsible/locker.yml
# 使用密码retent解密查看文件