diff --git a/Vagrantfile b/Vagrantfile index 59b8bdf..6e41c95 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -12,6 +12,6 @@ end Vagrant::Config.run do |config| config.vm.forward_port 80, 8000 + config.vm.forward_port 5432, 5432 config.vm.forward_port 10000, 10000 - config.vm.forward_port 20000, 20000 end diff --git a/requirements.txt b/requirements.txt index 29cf14e..6a0299d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -19,4 +19,5 @@ rethinkdb==1.10.0-0 simplejson==3.3.0 sockjs-tornado==1.0.0 supervisor==3.0 +SQLAlchemy==0.8.3 tornado==3.1.1 \ No newline at end of file diff --git a/srv/salt/common/init.sls b/srv/salt/common/init.sls index f4c036a..10df4f6 100644 --- a/srv/salt/common/init.sls +++ b/srv/salt/common/init.sls @@ -1,18 +1,26 @@ redis-lea-repo: pkgrepo.managed: - - name: 'deb http://ppa.launchpad.net/chris-lea/redis-server/ubuntu precise main' + - ppa: chris-lea/redis-server + - required_in: redis-server nodejs-lea-repo: pkgrepo.managed: - - name: 'deb http://ppa.launchpad.net/chris-lea/node.js/ubuntu precise main' + - ppa: chris-lea/node.js python-redis-lea-repo: pkgrepo.managed: - - name: 'deb http://ppa.launchpad.net/chris-lea/python-redis/ubuntu precise main' + - ppa: chris-lea/python-redis nginx-stable-repo: pkgrepo.managed: - - name: 'deb http://ppa.launchpad.net/nginx/stable/ubuntu precise main' + - ppa: nginx/stable + - required_in: nginx + +postgres-repo: + pkgrepo.managed: + - name: deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main + - key_url: https://www.postgresql.org/media/keys/ACCC4CF8.asc + - required_in: postgresql common-pkgs: pkg.installed: @@ -40,4 +48,5 @@ common-pkgs: - pkgrepo.managed: nodejs-lea-repo - pkgrepo.managed: redis-lea-repo - pkgrepo.managed: python-redis-lea-repo - - pkgrepo.managed: nginx-stable-repo \ No newline at end of file + - pkgrepo.managed: nginx-stable-repo + - pkgrepo.managed: postgres-repo \ No newline at end of file diff --git a/srv/salt/postgres/init.sls b/srv/salt/postgres/init.sls new file mode 100644 index 0000000..081a298 --- /dev/null +++ b/srv/salt/postgres/init.sls @@ -0,0 +1,16 @@ +postgresql: + pkg.installed: + - name: postgresql-9.3 + + +createdb: + cmd.run: + - name: createdb -T template1 realms + - user: postgres + - require: + - pkg.installed: postgresql-9.3 + +initdb: + cmd.run: + - name: psql realms < /srv/salt/postgres/init.sql + - user: postgres diff --git a/srv/salt/postgres/init.sql b/srv/salt/postgres/init.sql new file mode 100644 index 0000000..08acf81 --- /dev/null +++ b/srv/salt/postgres/init.sql @@ -0,0 +1,26 @@ +DROP TABLE IF EXISTS users; +CREATE TABLE users ( + id SERIAL, + username VARCHAR(100), + password VARCHAR(255), + email VARCHAR(255), + joined TIMESTAMP +); + +DROP TABLE IF EXISTS sites; +CREATE TABLE sites ( + name VARCHAR(255), + pages INT, + views INT, + created TIMESTAMP +); + +DROP TABLE IF EXISTS pages; +CREATE TABLE pages ( + id VARCHAR(255), -- / + edits INT, + views INT, + author INT, + created TIMESTAMP, + modified TIMESTAMP +); \ No newline at end of file diff --git a/srv/salt/realms/init.sls b/srv/salt/realms/init.sls index 20c7e34..a20be0c 100644 --- a/srv/salt/realms/init.sls +++ b/srv/salt/realms/init.sls @@ -14,6 +14,7 @@ virtualenvwrapper: bower: npm.installed: + - user: root - require: - pkg.installed: common-pkgs @@ -26,3 +27,9 @@ realms-repo: - user: deploy - identity: /home/deploy/.ssh/id_rsa +/home/deploy/virtualenvs/realms: + virtualenv.managed: + - requirements: /home/deploy/realms/requirements.txt + - cwd: /home/deploy/realms + - runas: deploy + diff --git a/srv/salt/top.sls b/srv/salt/top.sls index e051b8f..966a0a9 100644 --- a/srv/salt/top.sls +++ b/srv/salt/top.sls @@ -2,9 +2,8 @@ base: '*': - common - users - - nodejs - redis - nginx - - rethinkdb + - postgres - realms - supervisor \ No newline at end of file diff --git a/srv/salt/users/init.sls b/srv/salt/users/init.sls index 5a463c1..bdca24b 100644 --- a/srv/salt/users/init.sls +++ b/srv/salt/users/init.sls @@ -41,4 +41,6 @@ sudo: bashrc-append: file.append: - name: /home/deploy/.bashrc - - text: . ~/.bash_profile \ No newline at end of file + - text: . ~/.bash_profile + - user: deploy + - group: deploy \ No newline at end of file