@@ -4,39 +4,122 @@ Secure Storage
44Encrypts the data with a TrueCrypt AES 256 hidden volume, and exposes a HTTP endpoint for having a possibility
55to enter the passphrase when the server will go down.
66
7+ Protect your server against hosting providers. Even if they would mount your storage it will be encrypted.
8+ Its much more difficult to get into your data when its encrypted, but REMEMBER, it's not impossible!
9+
710``` bash
811ansible-galaxy install blackandred.server_secure_storage
912```
1013
14+ Mounting and unmounting from shell
15+ ----------------------------------
16+
17+ To mount/unmount a volume from shell there are prepared easy to use scripts.
18+
19+ ``` bash
20+ # please replace "storage" with the name you placed in "enc_mount_name" variable (see configuration reference)
21+
22+ # mounting
23+ /usr/local/bin/tcmount-storage.sh ' your-secret-here'
24+
25+ # unmounting
26+ /usr/local/bin/tcunmount-storage.sh
27+ ```
28+
29+ Mounting by a HTTP call
30+ -----------------------
31+
32+ You can mount the storage using an HTTP call, so also you can easily automate the process using some healthchecks.
33+
34+ ``` bash
35+ curl -v http://your-host:8015/deploy/volume_mount? enc_token=YOUR-PASSWORD-THERE& token=YOUR-DEPLOYER-TOKEN-HERE
36+ ```
37+
38+ Legend:
39+ - enc_token: Its a volume password or secret password (depends on which volume you want to mount)
40+ - token: Thin-Deployer token, configurable in ` deployer_token ` (see: configuration reference)
41+
42+ Notes:
43+ - IT IS HIGHLY RECOMMENDED TO HIDE DEPLOYER SERVICE BEHIND A SSL GATEWAY
44+
1145Configuration reference
1246-----------------------
1347
1448``` yamlex
15- enc_file: /.do-not-delete # path, where all of the data will be stored
16- enc_file_size: 400M # examples: 256M, 20G, 500G
17- enc_mount_name: storage # mount name, should be a-z, lower case, without special letters
18- enc_file_filesystem: ext4 # any filesystem supported by mkfs (and supported by the operating system)
19- enc_filesystem_create_if_not_exists: true
20-
21- # passwords, change them
22- enc_passphrase: "test123"
23- enc_hidden_volume_passphrase: "hidden123"
24- enc_hidden_volume_size: "390M"
25-
26- # tcplay settings
27- hashing_algorithm: whirlpool
28- encryption_algorithm: AES-256-XTS
29-
30- # Mounting webhook
31- # ================
32- # Allows to expose a HTTP endpoint, so you could
33- # invoke that endpoint to put the passphrase to mount the volume
34- # eg. after server crash. So the password will not be stored on the server
35- # and how you will secure it is your concern.
36- #
37- deployer_token: "" # set a token to enable
38- slack_or_mattermost_webhook_url: "" # put a slack/mattermost webhook URL to enable notifications
39- systemd_service_name: "volume-deployer"
40- deployer_listen: "0.0.0.0"
41- deployer_listen_port: "8015"
49+ roles:
50+ - role: blackandred.server_secure_storage
51+ tags: decrypt
52+ vars:
53+ enc_file: /.do-not-delete # path, where all of the data will be stored
54+ enc_file_size: 10000M # examples: 256M, 20G, 500G
55+ enc_mount_name: storage # mount name, should be a-z, lower case, without special letters
56+ enc_file_filesystem: ext4 # any filesystem supported by mkfs (and supported by the operating system)
57+ enc_filesystem_create_if_not_exists: true
58+
59+ # passwords, change them, NOTE: You can keep them secure in an Ansible Vault
60+ # by default the hidden volume is mounted during deployment time
61+ # but normally you can choose over the HTTP endpoint or via SHELL which volume you want to mount
62+ # by choosing one of defined passwords just
63+ enc_passphrase: "test123"
64+ enc_hidden_volume_passphrase: "hidden123"
65+ enc_hidden_volume_size: "9950M"
66+
67+ # tcplay settings
68+ hashing_algorithm: whirlpool
69+ encryption_algorithm: AES-256-XTS
70+
71+ # Mounting webhook
72+ # ================
73+ # Allows to expose a HTTP endpoint, so you could
74+ # invoke that endpoint to put the passphrase to mount the volume
75+ # eg. after server crash. So the password will not be stored on the server
76+ # and how you will secure it is your concern.
77+ #
78+ deployer_token: "" # set a token to enable
79+ slack_or_mattermost_webhook_url: "" # put a slack/mattermost webhook URL to enable notifications
80+ systemd_service_name: "volume-deployer"
81+ deployer_listen: "0.0.0.0"
82+ deployer_listen_port: "8015"
83+ ```
84+
85+ Hooks PRE/POST
86+ --------------
87+
88+ Before encryption (detaching the volume) you can execute your code to eg. shutdown services,
89+ and after decryption you can bring them up back.
90+
91+ Example:
92+
93+ ``` yamlex
94+ hook_pre_mount: ""
95+
96+ hook_post_mount: >
97+ set -x;
98+
99+ mkdir -p /mnt/storage/project /mnt/storage/docker /project /var/lib/docker;
100+ mount -o bind /mnt/storage/project /project || exit 1;
101+ mount -o bind /mnt/storage/docker /var/lib/docker || exit 1;
102+ mount --bind /var/lib/docker/plugins /var/lib/docker/plugins || true;
103+ mount --make-private /var/lib/docker/plugins || true;
104+
105+ if [[ -f /etc/systemd/system/project.service ]]; then
106+ sudo systemctl restart docker;
107+ sleep 5;
108+ sudo systemctl restart project;
109+ fi;
110+
111+ hook_pre_unmount: >
112+ if [[ -f /etc/systemd/system/project.service ]]; then
113+ sudo systemctl disable docker;
114+ sudo systemctl disable project;
115+
116+ sudo systemctl stop project;
117+ sudo systemctl stop docker;
118+ fi;
119+
120+ umount /var/lib/docker/plugins || true;
121+ umount /project || true;
122+ umount /var/lib/docker || true;
123+
124+ hook_post_unmount: ""
42125```
0 commit comments