自动化利器 Ansible - 从了解到应用(11)

示例-3加密字符串[root@test01 ansible-test]# ansible-vault encrypt_string "test123456"New Vault password:Confirm New Vault password:!vault |$ANSIBLE_VAULT;1.1;AES256333833363537373464306531653266653934303465393763343963353365306133306437643139623438366538366262316666353962663564666532393333300a333934633664393262653065343864636533616661333638623530613232383763356661653131303936646237613930333431363432656166663630353038380a6661646435653433363730623231356430383634363439383833633036326230Encryption successful[root@test01 ansible-test]#[root@test01 ansible-test]# vim test-encrypt_string.yaml[root@test01 ansible-test]#[root@test01 ansible-test]# cat test-encrypt_string.yaml- hosts: tagather_facts: novars:test_user: "testuser"test_passwd: !vault |$ANSIBLE_VAULT;1.1;AES256333833363537373464306531653266653934303465393763343963353365306133306437643139623438366538366262316666353962663564666532393333300a333934633664393262653065343864636533616661333638623530613232383763356661653131303936646237613930333431363432656166663630353038380a6661646435653433363730623231356430383634363439383833633036326230tasks:- debug:msg: "{{test_user}}"- debug:msg: "{{test_passwd}}"[root@test01 ansible-test]#[root@test01 ansible-test]# ansible-playbook test-encrypt_string.yaml --ask-vault-passVault password: PLAY [ta] *********************************************************************************************************************************************************************************************TASK [debug] ******************************************************************************************************************************************************************************************ok: [172.20.8.247] => {"msg": "testuser"}TASK [debug] ******************************************************************************************************************************************************************************************ok: [172.20.8.247] => {"msg": "test123456"}PLAY RECAP ********************************************************************************************************************************************************************************************172.20.8.247: ok=2changed=0unreachable=0failed=0skipped=0rescued=0ignored=0[root@test01 ansible-test]#示例-4通过密码文件加密字符串[root@test01 ansible-test]# ansible-vault encr【自动化利器 Ansible - 从了解到应用】

推荐阅读