4 All secrets are stored inside encrypted ansible vault files which live in
5 `host_vars`, `group_vars` or inside the `secrets` directory.
6 Access to the vault files is controlled via GPG keys. Anybody who uses this
7 ansible repository needs to have a GPG key.
13 You can use the following command to generate a new GPG key:
17 - select "RSA and RSA" as kind (should be option: 1)
18 - set keysize to: 4096
19 - set key expiration to: 2y
20 - set Real name and eMail address
21 - set a passphrase for the key (please use a strong passphrase!!!)
24 This command prints the fingerprint and other information about the newly
25 generated key. In the line starting with pub you can find the key ID. This
26 ID can be used to uniquely identify your key. Here is a sample output:
29 pub rsa4096/0x1234567812345678 2017-01-01 [SC] [expires: 2019-01-01]
30 Key fingerprint = 1234 5678 1234 5678 1234 5678 1234 5678 1234 5678
31 uid [ unknown] Firstname Lastname <lastname@example.com>
32 sub rsa4096/0x8765432187654321 2017-01-01 [E] [expires: 2019-01-01]
35 The key ID is the hexadecimal number next to ```rsa4096/``` in the line
36 starting with ```pub``` (not ```sub```). In this case the key ID is: ```0x1234567812345678```
38 In order to add your key to the list of keys which can read the ansible vault
39 you first need to export the public part of your key using the following
43 # gpg2 --armor --export "<your key id>" > mykey.asc
48 Adding a key to the Vault
49 -------------------------
51 Everybody who currently has access to the vault can add keys using the
55 # gpg/add-keys.sh mykey.asc
58 This will add the new key to the keyring stored inside the repository and
59 re-encrypt the secret to unlock the vault for all keys inside the keyring.
63 Removing a key from the Vault
64 -----------------------------
66 Everybody who currently has access to the vault can remove keys using the
70 # gpg/remove-keys.sh "<key-id>"
73 This will remove the key from the keyring stored inside the repository and
74 re-encrypt the secret to unlock the vault for all remaining keys inside the
77 You can find out the key ID using the command:
83 Here is an example output:
86 pub rsa4096/0x1234567812345678 2017-01-01 [SC] [expires: 2019-01-01]
87 Key fingerprint = 1234 5678 1234 5678 1234 5678 1234 5678 1234 5678
88 uid [ unknown] Firstname Lastname <lastname@example.com>
89 sub rsa4096/0x8765432187654321 2017-01-01 [E] [expires: 2019-01-01]
92 The key ID is the hexadecimal number next to ```rsa4096/``` in the line
93 starting with ```pub``` (not ```sub```). In this case the key ID is: ```0x1234567812345678```
97 Working with Vault files
98 ------------------------
102 # ansible-vault create host_vars/foo/vault.yml
104 This will open up an editor which allows you to add variables. Once you
105 store and close the file the content is automatically encrypted.
109 # ansible-vault edit group_vars/foo/vault.yml
111 This will open up an editor which allows you to add/remove/change variables.
112 Once you store and close the file the content is automatically encrypted.
114 * show the contents of a vault file:
116 # ansible-vault view secrets/foo.vault.yml
118 This will automatically decrypt the file and print it's contents.