From 2aee43e01a67d07f0392f230d83f6e5db10f2de7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Mon, 24 Apr 2017 21:27:01 +0100 Subject: [PATCH] Add more configuration options for redis - `REDIS_HOST` can be specified in the secrets - Two new secrets: `REDIS_PASSWD` and `REDIS_DB` --- cof/settings/common.py | 8 ++++++-- cof/settings/secret_example.py | 3 +++ provisioning/bootstrap.sh | 10 +++++----- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/cof/settings/common.py b/cof/settings/common.py index 93b11dae..612d52fc 100644 --- a/cof/settings/common.py +++ b/cof/settings/common.py @@ -22,7 +22,8 @@ except KeyError: # Other secrets try: from .secret import ( - SECRET_KEY, RECAPTCHA_PUBLIC_KEY, RECAPTCHA_PRIVATE_KEY, ADMINS + SECRET_KEY, RECAPTCHA_PUBLIC_KEY, RECAPTCHA_PRIVATE_KEY, ADMINS, + REDIS_PASSWD, REDIS_DB, REDIS_HOST ) except ImportError: raise RuntimeError("Secrets missing") @@ -159,7 +160,10 @@ CHANNEL_LAYERS = { "default": { "BACKEND": "asgi_redis.RedisChannelLayer", "CONFIG": { - "hosts": [(os.environ.get("REDIS_HOST", "localhost"), 6379)], + "hosts": [( + "redis://:{}@{}:6379/{}" + .format(REDIS_PASSWD, REDIS_HOST, REDIS_DB) + )], }, "ROUTING": "cof.routing.channel_routing", } diff --git a/cof/settings/secret_example.py b/cof/settings/secret_example.py index 36a8e932..3dc5de4b 100644 --- a/cof/settings/secret_example.py +++ b/cof/settings/secret_example.py @@ -1,4 +1,7 @@ SECRET_KEY = 'q()(zn4m63i%5cp4)f+ww4-28_w+ly3q9=6imw2ciu&_(5_4ah' RECAPTCHA_PUBLIC_KEY = "DUMMY" RECAPTCHA_PRIVATE_KEY = "DUMMY" +REDIS_PASSWD = "dummy" +REDIS_DB = 0 +REDIS_HOST = "127.0.0.1" ADMINS = None diff --git a/provisioning/bootstrap.sh b/provisioning/bootstrap.sh index c8f73ab6..33ae8308 100644 --- a/provisioning/bootstrap.sh +++ b/provisioning/bootstrap.sh @@ -23,6 +23,9 @@ apt-get install -y mysql-server mysql -uroot -p$DBPASSWD -e "CREATE DATABASE $DBNAME; GRANT ALL PRIVILEGES ON $DBNAME.* TO '$DBUSER'@'localhost' IDENTIFIED BY '$DBPASSWD'" mysql -uroot -p$DBPASSWD -e "GRANT ALL PRIVILEGES ON test_$DBNAME.* TO '$DBUSER'@'localhost'" +# Configuration de redis +echo "requirepass dummy" >> /etc/redis/redis.conf + # Installation et configuration d'Apache apt-get install -y apache2 a2enmod proxy proxy_http proxy_wstunnel headers @@ -36,7 +39,7 @@ chown -R ubuntu:www-data /var/www/static # Mise en place du .bash_profile pour tout configurer lors du `vagrant ssh` cat >> ~ubuntu/.bashrc <