项目作者: RiotKit

项目描述 :
Ansible: TCPlay secured storage
高级语言: Shell
项目地址: git://github.com/RiotKit/ansible-partial-disk-encryption-role.git


Secure Storage

Encrypts the data with a TrueCrypt AES 256 hidden volume, and exposes a HTTP endpoint for having a possibility
to enter the passphrase when the server will go down.

Protect your server against hosting providers. Even if they would mount your storage it will be encrypted.
Its much more difficult to get into your data when its encrypted, but REMEMBER, it’s not impossible!

  1. ansible-galaxy install blackandred.server_secure_storage

Mounting and unmounting from shell

To mount/unmount a volume from shell there are prepared easy to use scripts.

  1. # please replace "storage" with the name you placed in "enc_mount_name" variable (see configuration reference)
  2. # mounting
  3. /usr/local/bin/tcmount-storage.sh 'your-secret-here'
  4. # unmounting
  5. /usr/local/bin/tcunmount-storage.sh

Mounting by a HTTP call

You can mount the storage using an HTTP call, so also you can easily automate the process using some healthchecks.

  1. curl -v http://your-host:8015/deploy/volume_mount?enc_token=YOUR-PASSWORD-THERE&token=YOUR-DEPLOYER-TOKEN-HERE

Legend:

  • enc_token: Its a volume password or secret password (depends on which volume you want to mount)
  • token: Thin-Deployer token, configurable in deployer_token (see: configuration reference)

Notes:

  • IT IS HIGHLY RECOMMENDED TO HIDE DEPLOYER SERVICE BEHIND A SSL GATEWAY

Configuration reference

  1. roles:
  2. - role: blackandred.server_secure_storage
  3. tags: decrypt
  4. vars:
  5. enc_file: /.do-not-delete # path, where all of the data will be stored
  6. enc_file_size: 10000M # examples: 256M, 20G, 500G
  7. enc_mount_name: storage # mount name, should be a-z, lower case, without special letters
  8. enc_file_filesystem: ext4 # any filesystem supported by mkfs (and supported by the operating system)
  9. enc_filesystem_create_if_not_exists: true
  10. # passwords, change them, NOTE: You can keep them secure in an Ansible Vault
  11. # by default the hidden volume is mounted during deployment time
  12. # but normally you can choose over the HTTP endpoint or via SHELL which volume you want to mount
  13. # by choosing one of defined passwords just
  14. enc_passphrase: "test123"
  15. enc_hidden_volume_passphrase: "hidden123"
  16. enc_hidden_volume_size: "9950M"
  17. # tcplay settings
  18. hashing_algorithm: whirlpool
  19. encryption_algorithm: AES-256-XTS
  20. # Mounting webhook
  21. # ================
  22. # Allows to expose a HTTP endpoint, so you could
  23. # invoke that endpoint to put the passphrase to mount the volume
  24. # eg. after server crash. So the password will not be stored on the server
  25. # and how you will secure it is your concern.
  26. #
  27. deployer_token: "" # set a token to enable
  28. slack_or_mattermost_webhook_url: "" # put a slack/mattermost webhook URL to enable notifications
  29. systemd_service_name: "volume-deployer"
  30. deployer_listen: "0.0.0.0"
  31. deployer_listen_port: "8015"

Hooks PRE/POST

Before encryption (detaching the volume) you can execute your code to eg. shutdown services,
and after decryption you can bring them up back.

Example:

  1. hook_pre_mount: ""
  2. hook_post_mount: >
  3. set -x;
  4. mkdir -p /mnt/storage/project /mnt/storage/docker /project /var/lib/docker;
  5. mount -o bind /mnt/storage/project /project || exit 1;
  6. mount -o bind /mnt/storage/docker /var/lib/docker || exit 1;
  7. mount --bind /var/lib/docker/plugins /var/lib/docker/plugins || true;
  8. mount --make-private /var/lib/docker/plugins || true;
  9. if [[ -f /etc/systemd/system/project.service ]]; then
  10. sudo systemctl restart docker;
  11. sleep 5;
  12. sudo systemctl restart project;
  13. fi;
  14. hook_pre_unmount: >
  15. if [[ -f /etc/systemd/system/project.service ]]; then
  16. sudo systemctl disable docker;
  17. sudo systemctl disable project;
  18. sudo systemctl stop project;
  19. sudo systemctl stop docker;
  20. fi;
  21. umount /var/lib/docker/plugins || true;
  22. umount /project || true;
  23. umount /var/lib/docker || true;
  24. hook_post_unmount: ""