建立加密檔案

  1. create 建立加密檔 vfile.yml,輸入密碼後進入 vi 編輯檔案。
    [deyu1@kvm19 ansible]$ ansible-vault create vfile.yml
    New Vault password: 
    Confirm New Vault password:
    
  2. 查看加密檔 vfile.yml,是一串亂數,必須使用 ansible-vault view 輸入密碼才能看到檔案內容。
    [deyu1@kvm19 ansible]$ cat vfile.yml
    $ANSIBLE_VAULT;1.1;AES256
    36663533343866343164623761376664666237383235373666313939636363323631613435636439
    3535336461663666623163346665363432633366343364340a663235316132366431346135326637
    35343837333061336262393239613861383435666233336563643164643236356262613462323630
    3666363538626466610a613062353862303164616563393934666563633063353130393963343832
    61323731336563663439363436613030316263323865656161303930326634346664
    
    [deyu1@kvm19 ansible]$ ansible-vault view vfile.yml
    Vault password:
    vfile.yml vault test
    
  3. edit 輸入密碼後,才可以編輯加密檔 vfile.yml。
    [deyu1@kvm19 ansible]$ ansible-vault edit vfile.yml
    Vault password:
    
  4. 再查看加密檔 vfile.yml,是一串亂數,但與之前的內容不一樣,一樣要使用 ansible-vault view 輸入密碼才能查看檔案內容。
    [deyu1@kvm19 ansible]$ cat vfile.yml
    $ANSIBLE_VAULT;1.1;AES256
    30646565386333306437616161313261396165386238633033323534373433366266653831623366
    3335636132616161643439306430343661386563326166610a346538363039613439373738316530
    37383337383062386134663632633064393465663362633834633838393565373436636332313961
    6537316264323030320a656233316538343861396565623838396566623664346563383962373837
    38633063303836386432663166383739316234373866343534653630383830383237
    
    [deyu1@kvm19 ansible]$ ansible-vault view vfile.yml
    Vault password:
    vfile.yml vault test
    1111