2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ansible-vaultでパスワードが入ったファイルを暗号・復号化する

Posted at

チーム内でパスワードを共有するのに便利。
特別なサーバなどは不要

$ brew install ansible

$ ansible-vault --version
ansible-vault [core 2.12.4]
...

# 秘密鍵を作る。これは git commit しない。 DM などでメンバーに共有する
$ echo 'PASSWORD' > .vault_pass    

# こういう内緒のファイルがあるとします
$ cat .env
DB_PASSWORD=abc12345
MY_SECRET=xzy99999


# 暗号化して、ファイル名を .env.encypted にする
$ ansible-vault encrypt --vault-password-file .vault_pass --output .env.encrypted  .env
Encryption successful

# 暗号化されました。これを git commit します。
$ cat .env.encrypted
$ANSIBLE_VAULT;1.1;AES256
66653666616531346330353435313635666233643333313164636265623031393135393964376164
3738653164376435653235636131343336396632623365360a326331643963333636316230653236
33333535376463303032663766356538626361376339643463656132386361646131333531353932
6633356337363833380a313530353561393936383666383135626164363736356135646136653464
61396235376661646235393665616234623834653634616331303265313737616563363732306636
6364613230353266303333613237393537313661666632636131


# 他のチームメンバーは、.env.eyncyprted を git clone したら 複合します
$ ansible-vault decrypt --vault-password-file .vault_pass --output .env .env.encrypted
Decryption successful

# 複合されました
$ cat .env
DB_PASSWORD=abc12345
MY_SECRET=xzy99999
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?