forked from blackberry/saturnring
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sachin Agarwal
committed
Feb 24, 2015
1 parent
5a85ef0
commit 88f735f
Showing
13 changed files
with
351 additions
and
99 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
86 changes: 0 additions & 86 deletions
86
deployments/vagrant/saturnring_postbootup_as_vagrant_user.sh
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
#Name of Saturnring cluster | ||
CLUSTERNAME=saturndevcluster | ||
#Django secret key | ||
#Its a bad idea to use sqllite in production, because the locking mechanism doesnt work so when there are multiple requests to Saturnring things | ||
#wont work quite well. Use Postgres or MariaDB or Oracle instead. | ||
DATABASE_TYPE=sqlite | ||
DATABASE_NAME=saturntestdb.sqlite | ||
#N/A for non-SQLLite DB | ||
DATABASE_DIR=/home/vagrant/sqlitedbdir | ||
#N/A for SQLlite DB | ||
DATABASE_HOST=dbhost | ||
#Only applicable for POstgres | ||
DATABASE_PORT=5432 | ||
#Only applicable for POstgres | ||
DATABASE_USER=postgres | ||
#Only applicable for POstgres,N/A for sqlite | ||
DATABASE_PASSWORD=postgres | ||
DJANGOSECRETKEY=pleasechangemeinproduction | ||
#User account on saturnringserver | ||
LDAP_ENABLED=0 | ||
LDAP_LDAP_URI=ldap://ldapserver.url | ||
LDAP_USER_DN="=OU=Users,OU=Ring,OU=ouname,DC=ad0,DC=dcname" | ||
LDAP_STAFF_GROUP="CN=Cloud Customers,OU-Security Groups, DC=ad0,DC=dcname" | ||
LDAP_BIND_USER_DN="ldapreadaccount,CN=Users,DC=ad0,DC=dcname" | ||
LDAP_BIND_USER_PW=sup3rs3cur3 | ||
NUMWORKERS=3 | ||
SATURNWKDIR=/nfsmount/saturnring | ||
SATURNRINGHOST=192.168.61.20 | ||
SATURNRINGAPACHEPORT=80 | ||
INSTALLUSER=vagrant | ||
SATURNRINGPASSWORD=changeme | ||
[email protected] |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,30 +13,33 @@ | |
#See the License for the specific language governing permissions and | ||
#limitations under the License. | ||
|
||
source ./envvars.sh | ||
source /vagrant/envvars.sh | ||
|
||
apt-get update | ||
apt-get install -y apache2 python-dev python-pip redis-server git python-virtualenv sqlite3 libsqlite3-dev supervisor libapache2-mod-wsgi curl libsasl2-dev libldap2-dev | ||
|
||
mkdir -p $SATURNWKDIR/saturnringlog | ||
chown $USER:$USER $SATURNWKDIR/saturnringlog | ||
chown $INSTALLUSER:$INSTALLUSER $SATURNWKDIR/saturnringlog | ||
|
||
|
||
mkdir -p /var/www/saturnring | ||
chown -R $USER:$USER /var/www | ||
chown -R $INSTALLUSER:$INSTALLUSER /var/www | ||
|
||
mkdir -p $DATABASE_DIR | ||
chown $INSTALLUSER:$INSTALLUSER $DATABASE_DIR | ||
|
||
sudo -u $USER -H bash -c "cd /$USER; ./saturnring_postbootup_as_$USER_user.sh" | ||
sudo -u $INSTALLUSER -H bash -c "cd /vagrant; ./saturnring_postbootup_as_"$INSTALLUSER"_user.sh" | ||
|
||
cd /home/$USER/saturnring/ssddj | ||
cd /home/$INSTALLUSER/saturnring/ssddj | ||
rm /etc/supervisor/conf.d/saturnworker.conf | ||
for ii in `seq 1 $NUMWORKERS`; | ||
do | ||
cat <<EOF >> /etc/supervisor/conf.d/saturnworker.conf | ||
[program:django-rqworker-$ii] | ||
command=/home/$USER/saturnring/misc/rqworker.sh queue$ii | ||
user=$USER | ||
stdout_logfile=$SATURNWKDIR/saturnringlog/rqworker-$ii.log | ||
redirect_stderr=true | ||
[program:django-rqworker-$ii] | ||
command=/home/$INSTALLUSER/saturnring/misc/rqworker.sh queue$ii | ||
user=$INSTALLUSER | ||
stdout_logfile=$SATURNWKDIR/saturnringlog/rqworker-$ii.log | ||
redirect_stderr=true | ||
EOF | ||
done | ||
|
@@ -50,8 +53,8 @@ cat <<EOF > /etc/apache2/sites-available/saturnring.conf | |
ServerAdmin [email protected] | ||
ServerName $SATURNRINGHOST | ||
WSGIScriptAlias / /var/www/saturnring/index.wsgi | ||
WSGIDaemonProcess $USER user=$USER | ||
WSGIProcessGroup $USER | ||
WSGIDaemonProcess $INSTALLUSER user=$INSTALLUSER | ||
WSGIProcessGroup $INSTALLUSER | ||
WSGIPassAuthorization On | ||
Alias /static/ /var/www/saturnring/static/ | ||
<Location "/static/"> | ||
|
@@ -67,6 +70,7 @@ EOF | |
|
||
ln -s /etc/apache2/sites-available/saturnring.conf /etc/apache2/sites-enabled/saturnring.conf | ||
|
||
#chown -R www-data:www-data $DATABASE_DIR | ||
service apache2 restart | ||
|
||
service supervisor stop | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
#!/bin/bash | ||
source /mnt/context.sh | ||
|
||
#Copyright 2014 Blackberry Limited | ||
# | ||
#Licensed under the Apache License, Version 2.0 (the "License"); | ||
#you may not use this file except in compliance with the License. | ||
#You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
#Unless required by applicable law or agreed to in writing, software | ||
#distributed under the License is distributed on an "AS IS" BASIS, | ||
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
#See the License for the specific language governing permissions and | ||
#limitations under the License. | ||
|
||
source /etc/profile | ||
whoami | ||
|
||
mkdir -p /home/local/saturnring | ||
cp /mnt/saturnringsoftware.tar.gz /home/local/saturnring | ||
cd /home/local/saturnring/ | ||
tar -xvzf saturnringsoftware.tar.gz | ||
|
||
if [ ! -d "/home/local/saturnring/saturnenv" ]; then | ||
virtualenv saturnenv | ||
fi | ||
source /home/local/saturnring/saturnenv/bin/activate | ||
mkdir -p /home/local/temp | ||
cp /mnt/pippackages.tar.gz /home/local/temp | ||
cd /home/local/temp | ||
tar -xvzf /home/local/temp/pippackages.tar.gz | ||
pip install --no-index --find-links /home/local/temp/python-pip-packages/ -r /home/local/temp/python-pip-packages/requirements.txt | ||
|
||
cat <<EOF > /home/local/saturnring/ssddj/saturn.ini | ||
[saturnring] | ||
#Cluster name: This is used as the stats Excel XLS filename | ||
clustername=$CLUSTERNAME | ||
#This is where the Saturnring picks up scripts to install on the saturnnode for things like creating/deleting iSCSI targets | ||
bashscripts=globalstatemanager/bashscripts/ | ||
#The user needs to copy the corresponding public key to the saturn node's user (specified in the [saturnnode] section using e.g. ssh-copy-id | ||
privatekeyfile=/nfsmount/saturnring/saturnringconfig/saturnkey | ||
#This is where saturnring keeps the latest iscsi config file | ||
iscsiconfigdir=/nfsmount/saturnring/saturnringconfig/ | ||
#Django secret key (CHANGE in production) | ||
django_secret_key=$DJANGO_SECRET_KEY | ||
#Logging path | ||
logpath=/nfsmount/saturnring/saturnringlog | ||
#Number of queues | ||
#If you change this number then please adjust the /etc/supervisor/conf.d/saturnring.conf by adding or deleting queue entries out there | ||
numqueues=5 | ||
[database] | ||
dbtype=$DATABASE_TYPE | ||
dbname=$DATABASE_NAME | ||
dbhost=$DATABASE_HOST | ||
dbport=$DATABASE_PORT | ||
dbuser=$DATABASE_USER | ||
dbpassword=$DATABASE_PASSWORD | ||
[saturnnode] | ||
user=local | ||
#Location on the saturnnode where the scripts are installed. | ||
install_location=/home/local/saturn/ | ||
bashpath=/bin/bash | ||
pythonpath=/usr/bin/python | ||
[activedirectory] | ||
enabled=$LDAP_ENABLED | ||
ldap_uri=$LDAP_LDAP_URI | ||
user_dn=$LDAP_USER_DN | ||
staff_group=$LDAP_STAFF_GROUP | ||
bind_user_dn=$LDAP_BIND_USER_DN | ||
bind_user_pw=$LDAP_BIND_USER_PW | ||
[tests] | ||
saturnringip=$HOSTNAME | ||
saturnringport=80 | ||
#saturniscsiserver=172.19.157.201 | ||
EOF | ||
|
||
cd /home/local/saturnring/ssddj | ||
python manage.py syncdb --noinput | ||
python manage.py convert_to_south ssdfrontend | ||
python manage.py schemamigration ssdfrontend --auto | ||
python manage.py migrate | ||
echo "from django.contrib.auth.models import User; User.objects.create_superuser('admin', '[email protected]', 'changeme')" | python manage.py shell | ||
|
||
cat <<EOF > /home/local/saturnring/redisqconf/rqworker.sh | ||
#!/bin/bash | ||
source /home/local/saturnring/saturnenv/bin/activate | ||
python /home/local/saturnring/ssddj/manage.py rqworker default | ||
EOF | ||
|
||
cat <<EOF > /var/www/saturnring/index.wsgi | ||
import os | ||
import sys | ||
import site | ||
# Add the site-packages of the chosen virtualenv to work with | ||
site.addsitedir('/home/local/saturnring/saturnenv/local/lib/python2.7/site-packages') | ||
# Add the app's directory to the PYTHONPATH | ||
sys.path.append('/home/local/saturnring/ssddj') | ||
sys.path.append('/home/local/saturnring/ssddj/ssddj') | ||
os.environ['DJANGO_SETTINGS_MODULE'] = 'ssddj.settings' | ||
# Activate your virtual env | ||
activate_env=os.path.expanduser("/home/local/saturnring/saturnenv/bin/activate_this.py") | ||
execfile(activate_env, dict(__file__=activate_env)) | ||
import django.core.handlers.wsgi | ||
application = django.core.handlers.wsgi.WSGIHandler() | ||
EOF | ||
python manage.py collectstatic --noinput | ||
|
||
|
||
#This little bit uses cron to keep updating stats within the applicationa | ||
#Moved this over to root because local cron is not allowed in the image | ||
#if [ ! -f mycron ];then | ||
# crontab -l > mycron | ||
# #echo new cron into cron file | ||
# echo "* * * * * curl -X GET http://$HOSTNAME/api/stateupdate/" >> mycron | ||
# #install new cron file | ||
# crontab mycron | ||
#fi | ||
|
Oops, something went wrong.