Skip to content

Commit a37dc35

Browse files
committed
Add a Fabric task to mount encrypted MongoDB drive
This task first checks whether the drive is already mounted. If it doesn't do this check, it will remove stop MongoDB and remove all the data from the encrypted drive. Mounting the encrypted drive asks for a passphrase through Fabric, which just works.
1 parent e16816f commit a37dc35

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

mongo.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,3 +211,16 @@ def safe_reboot():
211211
abort("Cluster has not recovered")
212212

213213
execute(vm.reboot, hosts=[env['host_string']])
214+
215+
216+
@task
217+
def mount_licensify_encrypted_drive():
218+
with settings(ok_ret_codes=[0, 1]):
219+
result = run('grep /var/lib/mongodb /proc/mounts')
220+
if result.return_code == 0:
221+
exit('/var/lib/mongodb is already mounted on this host.')
222+
with settings(warn_only=True):
223+
sudo('service mongodb stop')
224+
sudo('rm -rf /var/lib/mongodb/*')
225+
sudo('mount /var/lib/mongodb')
226+
sudo('service mongodb start')

0 commit comments

Comments
 (0)