diff --git a/config/base/_vimrc b/config/base/_vimrc new file mode 100644 index 0000000..91470f9 --- /dev/null +++ b/config/base/_vimrc @@ -0,0 +1,7 @@ +:syntax on +:set number +:set textwidth=125 +:set autoindent +:set shiftwidth=4 +:set nobackup +:set nowritebackup diff --git a/config/nginx/rookeries-uwsgi.conf b/config/nginx/rookeries-uwsgi.conf new file mode 100644 index 0000000..a31d22f --- /dev/null +++ b/config/nginx/rookeries-uwsgi.conf @@ -0,0 +1,14 @@ +server { + + server_name localhost; + + location /static/ { + alias /var/www/rookeries/static/; + } + + location / { try_files $uri @yourapplication; } + location @yourapplication { + include uwsgi_params; + uwsgi_pass 127.0.0.1:8001; + } +} \ No newline at end of file diff --git a/config/requirements.txt b/config/requirements.txt new file mode 100644 index 0000000..479a26c --- /dev/null +++ b/config/requirements.txt @@ -0,0 +1,6 @@ +--allow-external mysql-connector-python +--allow-unverified mysql-connector-python + +mysql-connector-python==1.1.6 +uwsgi==2.0 +mailsink==0.0.2 diff --git a/config/rookeries_webapp_config.cfg b/config/rookeries_webapp_config.cfg new file mode 100644 index 0000000..4646799 --- /dev/null +++ b/config/rookeries_webapp_config.cfg @@ -0,0 +1,21 @@ +# Basic environmental +ENVIRONMENTAL_NAME = "Vagrant" +TESTING = False +DEBUG = True + +# Password salts + secrets +PASSWORD_SALT = "secret" +SECRET_KEY = "development" +USER_REGISTRATION_INVITE_KEY = None + +# Database +DATABASE_URI = "mysql+mysqlconnector://rookeries:penguin2013flight@localhost:3306/rookeries?charset=utf8" + +# Mail server configuration +MAIL_SERVER = "localhost" +MAIL_PORT = 25 +MAIL_USERNAME = "admin@rookeri.es" +MAIL_PASSWORD = "password" +MAIL_DEFAULT_SENDER = "admin@rookeri.es" +MAIL_USE_TLS = False +MAIL_USE_SSL = False diff --git a/config/uwsgi/rookeries-uwsgi.ini b/config/uwsgi/rookeries-uwsgi.ini new file mode 100644 index 0000000..db60a2b --- /dev/null +++ b/config/uwsgi/rookeries-uwsgi.ini @@ -0,0 +1,5 @@ +[uwsgi] +socket = :8001 +log = /tmp/rookeries-uwsgi.log +master = true +module = rookeries:app diff --git a/deployment.yaml b/deployment.yaml index e895ca6..2b05c12 100644 --- a/deployment.yaml +++ b/deployment.yaml @@ -1,6 +1,4 @@ --- -- hosts: all - sudo: yes - tasks: - - # TODO Include all necessary deployment playbooks +- include: deployment/rookeries_install.yaml +- include: deployment/email_server.yaml +- include: deployment/uwsgi.yaml diff --git a/deployment/email_server.yaml b/deployment/email_server.yaml index 9264521..45dbcd5 100644 --- a/deployment/email_server.yaml +++ b/deployment/email_server.yaml @@ -4,5 +4,5 @@ tasks: # TODO PIP install mailsink into a virtualenv somewhere - - name: Install fake SMTP server for email development. - pip: name=mailsink use_mirrors=no +# - name: Install fake SMTP server for email development. +# pip: name=mailsink use_mirrors=no diff --git a/pre_deployment.yaml b/pre_deployment.yaml index 34a5555..eb284ff 100644 --- a/pre_deployment.yaml +++ b/pre_deployment.yaml @@ -1,6 +1,6 @@ --- -- hosts: all - sudo: yes - tasks: - - # TODO Include all necessary playbooks +- include: pre_deployment/base_linux.yaml +- include: pre_deployment/python.yaml +- include: pre_deployment/mysql_db.yaml +- include: pre_deployment/nodejs.yaml +- include: pre_deployment/nginx.yaml diff --git a/pre_deployment/base_linux.yaml b/pre_deployment/base_linux.yaml index d53e115..92bffed 100644 --- a/pre_deployment/base_linux.yaml +++ b/pre_deployment/base_linux.yaml @@ -3,10 +3,11 @@ sudo: yes tasks: + - name: Update and upgrade system + apt: update_cache=yes upgrade=full + - name: Install vim - apt: pkg=vim update_cache=yes state=present + apt: pkg=vim state=present - name: Configure vim - copy: src=config/base/_vimrc dest=/home/vagrant/.vimrc - - # TODO Add update of apt cache + any extra repo setup here. + copy: src=../config/base/_vimrc dest=/home/vagrant/.vimrc diff --git a/pre_deployment/mysql_db.yaml b/pre_deployment/mysql_db.yaml index 2169324..9191fe8 100644 --- a/pre_deployment/mysql_db.yaml +++ b/pre_deployment/mysql_db.yaml @@ -1,18 +1,23 @@ --- - hosts: all sudo: yes + vars: + databases: + rookeries: + username: rookeries + password: system_admin tasks: - # Setup MySQL dependencies. - # TODO Extract all variables into an easy to configure file. - - name: Install MySQL 5x server - apt: pkg=mysql-server update_cache=no state=present + - name: Setup MySQL 5 server + Python dependencies + apt: pkg={{ item }} state=present + with_items: + - mysql-server + - python-mysqldb - - name: Install mysqldb is installed. - apt: pkg=python-mysqldb update_cache=no state=present + - name: Setup MySQL databases for rookeries. + mysql_db: name={{ item.key }} state=present + with_dict: databases - - name: Setup MySQL database for rookeries. - mysql_db: name=rookeries state=present - - - name: Setup MySQL database user for rookeries. - mysql_user: name=rookeries password=system_admin priv=rookeries:ALL + - name: Setup MySQL database users for rookeries. + mysql_user: name={{ item.value.username }} password={{ item.value.password }} priv={{ item.key }}:ALL + with_dict: databases diff --git a/pre_deployment/nginx.yaml b/pre_deployment/nginx.yaml index b847fbf..1d6b4d9 100644 --- a/pre_deployment/nginx.yaml +++ b/pre_deployment/nginx.yaml @@ -1,20 +1,20 @@ --- - hosts: all sudo: yes + vars: + rookeries_nginx_conf: rookeries-uwsgi.conf tasks: - # Next setup our webserver. - # TODO Extract variables into a single easy to configure place. - - name: Install nginx - apt: pkg=nginx-full update_cache=yes state=present + - name: Setup nginx webserver + apt: pkg=nginx-full state=present - name: Configure nginx - copy: src=config/nginx/rookeries-uwsgi.conf dest=/etc/nginx/sites-available + copy: src=../config/nginx/{{ rookeries_nginx_conf }} dest=/etc/nginx/sites-available - name: Link the rookeries uwsgi file file: state=link - src=/etc/nginx/sites-available/rookeries-uwsgi.conf - path=/etc/nginx/sites-enabled/rookeries-uwsgi.conf + src=/etc/nginx/sites-available/{{ rookeries_nginx_conf }} + path=/etc/nginx/sites-enabled/{{ rookeries_nginx_conf }} - name: Unlink the default page file: state=absent path=/etc/nginx/sites-enabled/default @@ -22,8 +22,9 @@ - name: Run nginx service command: service nginx restart - - name: Setup webapp deployment folder with the correct permissions - file: path=/var/www state=directory owner=vagrant group=www-data mode=0774 - - - name: Add vagrant user to www-data - user: name=vagrant append=yes groups=www-data + # TODO Verify if still required for pip package deployment +# - name: Setup webapp deployment folder with the correct permissions +# file: path=/var/www state=directory owner=vagrant group=www-data mode=0774 +# +# - name: Add vagrant user to www-data +# user: name=vagrant append=yes groups=www-data diff --git a/pre_deployment/nodejs.yaml b/pre_deployment/nodejs.yaml index cbb1302..3261ea3 100644 --- a/pre_deployment/nodejs.yaml +++ b/pre_deployment/nodejs.yaml @@ -3,4 +3,14 @@ sudo: yes tasks: - # TODO Install nodejs + coffeescript dependencies + - name: Setup nodejs + npm dependencies + apt: pkg={{ item }} state=present + with_items: + - nodejs + - npm + + - name: Setup coffeescript + lessc dependency + npm: name={{ item }} global=yes state=present + with_items: + - coffee-script + - less diff --git a/pre_deployment/python.yaml b/pre_deployment/python.yaml index b6a066b..948c7c4 100644 --- a/pre_deployment/python.yaml +++ b/pre_deployment/python.yaml @@ -3,18 +3,20 @@ sudo: yes tasks: - # Setup Python dependencies. - - name: Python Development - apt: pkg=python-dev update_cache=no state=present - - - name: Bootstrap Python SetupTools - apt: pkg=python-setuptools update_cache=no state=present + - name: Setup Python setuptools dependencies + apt: pkg={{ item }} state=present + with_items: + - python-dev + - python-setuptools - name: Bootstrap PIP using Setuptools - easy_install: pkg=pip state=present + easy_install: name=pip - - name: Install Python virtualenvwrapper - pip: name=virtualenvwrapper use_mirrors=no + - name: Basic Python dependencies + pip: name={{ item }} use_mirrors=no + with_items: + - virtualenv + - virtualenvwrapper - - name: Configure Bash to use virtualenvwrapper + - name: Add virtualenvwrapper to bashrc lineinfile: dest=/home/vagrant/.bashrc line="source virtualenvwrapper.sh"