加密Playbook 防止泄露敏感信息
[root@localhost ~]# ansible-vault encrypt hello.yml
New Vault password: #输入密码
Confirm New Vault password: #确定密码
Encryption successful # 成功
试图查看加密文件
[root@localhost ~]# cat hello.yml #显示乱码
$ANSIBLE_VAULT;1.1;AES256 #AES256加密算法
37633935306263363635353231623531633436613163336399999999999999999
3265336264643062633132373230643162346433373235320....
正确的查看加密的Playbook
[root@localhost ~]# ansible-vault view hello.yml
.....
编辑加密的Playbook
[root@localhost ~]# ansible-vault edit hello.yml
修改Playbook密码
[root@localhost ~]# ansible-vault rekey hello.yml
创建加密的Playbook
[root@localhost ~]# ansible-vault create xxx.yml
加密后的Playbook不能直接运行,需要先解密Playbook
[root@localhost ~]# ansible-vault decrypt hello.yml
New Vault password: #输入密码
Confirm New Vault password: #确定密码
Encryption successful # 成功