1
0
mirror of https://github.com/bigchaindb/bigchaindb.git synced 2024-06-30 13:42:00 +02:00

Refactored install_rethinkdb() into separate functions

This commit is contained in:
troymc 2016-07-18 11:57:42 +02:00
parent 9a93f498a5
commit 013aa60e70
2 changed files with 51 additions and 21 deletions

View File

@ -96,8 +96,12 @@ fab install_base_software
if [ "$WHAT_TO_DEPLOY" == "servers" ]; then if [ "$WHAT_TO_DEPLOY" == "servers" ]; then
# (Re)create the RethinkDB configuration file conf/rethinkdb.conf # (Re)create the RethinkDB configuration file conf/rethinkdb.conf
python create_rethinkdb_conf.py python create_rethinkdb_conf.py
# Rollout storage backend (RethinkDB) and start it # Rollout RethinkDB and start it
fab prep_rethinkdb_storage
fab install_rethinkdb fab install_rethinkdb
fab configure_rethinkdb
fab delete_rethinkdb_data
fab start_rethinkdb
fi fi
# Rollout BigchainDB (but don't start it yet) # Rollout BigchainDB (but don't start it yet)

View File

@ -68,11 +68,11 @@ def install_base_software():
sudo('pip3 install --upgrade pip wheel setuptools') sudo('pip3 install --upgrade pip wheel setuptools')
# Install RethinkDB # Prepare RethinkDB storage
@task @task
@parallel @parallel
def install_rethinkdb(): def prep_rethinkdb_storage():
"""Installation of RethinkDB""" """Prepare RethinkDB storage"""
with settings(warn_only=True): with settings(warn_only=True):
# preparing filesystem # preparing filesystem
sudo("mkdir -p /data") sudo("mkdir -p /data")
@ -88,25 +88,51 @@ def install_rethinkdb():
sudo("rm -rf /etc/fstab") sudo("rm -rf /etc/fstab")
sudo("echo 'LABEL=cloudimg-rootfs / ext4 defaults,discard 0 0' >> /etc/fstab") sudo("echo 'LABEL=cloudimg-rootfs / ext4 defaults,discard 0 0' >> /etc/fstab")
sudo("echo '/dev/xvdb /data ext4 defaults,noatime 0 0' >> /etc/fstab") sudo("echo '/dev/xvdb /data ext4 defaults,noatime 0 0' >> /etc/fstab")
# activate deadline scheduler # activate deadline scheduler (I/O scheduler)
with settings(sudo_user='root'): with settings(sudo_user='root'):
sudo("echo deadline > /sys/block/xvdb/queue/scheduler") sudo("echo deadline > /sys/block/xvdb/queue/scheduler")
# install rethinkdb
sudo("echo 'deb http://download.rethinkdb.com/apt trusty main' | sudo tee /etc/apt/sources.list.d/rethinkdb.list")
sudo("wget -qO- http://download.rethinkdb.com/apt/pubkey.gpg | sudo apt-key add -") # Install RethinkDB
sudo("apt-get update") @task
sudo("apt-get -y install rethinkdb") @parallel
# change fs to user def install_rethinkdb():
sudo('chown -R rethinkdb:rethinkdb /data') """Install RethinkDB"""
# copy config file to target system sudo("echo 'deb http://download.rethinkdb.com/apt trusty main' | sudo tee /etc/apt/sources.list.d/rethinkdb.list")
put('conf/rethinkdb.conf', sudo("wget -qO- http://download.rethinkdb.com/apt/pubkey.gpg | sudo apt-key add -")
'/etc/rethinkdb/instances.d/instance1.conf', sudo("apt-get update")
mode=0600, sudo("apt-get -y install rethinkdb")
use_sudo=True) # Change owner:group of the RethinkDB data directory to rethinkdb:rethinkdb
# initialize data-dir sudo('chown -R rethinkdb:rethinkdb /data')
sudo('rm -rf /data/*')
# finally restart instance
sudo('/etc/init.d/rethinkdb restart') # Configure RethinkDB
@task
@parallel
def configure_rethinkdb():
"""Copy the RethinkDB config file to the remote host"""
put('conf/rethinkdb.conf',
'/etc/rethinkdb/instances.d/instance1.conf',
mode=0600,
use_sudo=True)
# Delete RethinkDB data
@task
@parallel
def delete_rethinkdb_data():
"""Delete the contents of the RethinkDB /data directory
but not the directory itself.
"""
sudo('rm -rf /data/*')
# Start RethinkDB
@task
@parallel
def start_rethinkdb():
"""Start RethinkDB"""
sudo('/etc/init.d/rethinkdb restart')
# Install BigchainDB from PyPI # Install BigchainDB from PyPI