added salt scripts back

This commit is contained in:
Matthew 2013-12-02 10:02:53 -06:00
parent 36cf728862
commit 810845441c
15 changed files with 339 additions and 0 deletions

17
Vagrantfile vendored Normal file
View file

@ -0,0 +1,17 @@
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise64"
config.vm.synced_folder "srv/", "/srv/"
config.vm.synced_folder ".", "/home/deploy/realms"
config.vm.provision :salt do |salt|
salt.minion_config = "srv/minion"
salt.run_highstate = true
end
end
Vagrant::Config.run do |config|
config.vm.forward_port 80, 8000
config.vm.forward_port 10000, 10000
config.vm.forward_port 20000, 20000
end

2
srv/minion Normal file
View file

@ -0,0 +1,2 @@
master: localhost
file_client: local

43
srv/salt/common/init.sls Normal file
View file

@ -0,0 +1,43 @@
redis-lea-repo:
pkgrepo.managed:
- name: 'deb http://ppa.launchpad.net/chris-lea/redis-server/ubuntu precise main'
nodejs-lea-repo:
pkgrepo.managed:
- name: 'deb http://ppa.launchpad.net/chris-lea/node.js/ubuntu precise main'
python-redis-lea-repo:
pkgrepo.managed:
- name: 'deb http://ppa.launchpad.net/chris-lea/python-redis/ubuntu precise main'
nginx-stable-repo:
pkgrepo.managed:
- name: 'deb http://ppa.launchpad.net/nginx/stable/ubuntu precise main'
common-pkgs:
pkg.installed:
- pkgs:
- python
- vim
- build-essential
- screen
- htop
- git
- ntp
- libpcre3-dev
- libevent-dev
- iptraf
- python-software-properties
- python-pip
- python-virtualenv
- python-dev
- pkg-config
- curl
- libxml2-dev
- libxslt1-dev
- nodejs
- require:
- pkgrepo.managed: nodejs-lea-repo
- pkgrepo.managed: redis-lea-repo
- pkgrepo.managed: python-redis-lea-repo
- pkgrepo.managed: nginx-stable-repo

15
srv/salt/nginx/init.sls Normal file
View file

@ -0,0 +1,15 @@
nginx:
pkg:
- installed
service.running:
- enable: True
- reload: True
- require:
- pkg: nginx
- watch:
- file: /etc/nginx/conf.d/realms.conf
/etc/nginx/conf.d/realms.conf:
file.managed:
- template: jinja
- source: salt://nginx/nginx.conf

71
srv/salt/nginx/nginx.conf Normal file
View file

@ -0,0 +1,71 @@
{% set root = '/home/deploy/realms/realms' %}
{% set ssl_certificate = False %}
gzip_proxied any;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
upstream web {
fair;
server 127.0.0.1:10000;
}
server {
listen 80;
# Allow file uploads
client_max_body_size 50M;
location ^~ /static/ {
root {{ root }};
expires max;
}
location = /favicon.ico {
rewrite (.*) /static/favicon.ico;
}
location = /robots.txt {
rewrite (.*) /static/robots.txt;
}
location / {
proxy_pass_header Server;
proxy_redirect off;
proxy_buffering off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_set_header Host $http_host;
proxy_pass http://web;
error_page 502 = /maintenance.html;
}
location /maintenance.html {
root {{ root }}/templates/;
add_header Cache-Control private;
expires epoch;
}
}
{% if ssl_certificate %}
server {
listen 443;
ssl on;
ssl_certificate {{ ssl_certificate }};
ssl_certificate_key {{ ssl_certificate_key }};
location ^~ /static/ {
root {{ root }};
expires max;
}
location / {
proxy_pass_header Server;
proxy_redirect off;
proxy_buffering off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_set_header Host $http_host;
proxy_pass http://web;
error_page 502 = /maintenance.html;
}
}
{% endif %}

28
srv/salt/realms/init.sls Normal file
View file

@ -0,0 +1,28 @@
python-dev:
pkg.installed
build-essential:
pkg.installed
python-pip:
pkg.installed
virtualenvwrapper:
pip.installed:
- require:
- pkg: python-pip
bower:
npm.installed:
- require:
- pkg.installed: common-pkgs
realms-repo:
git.latest:
- unless: test -e /vagrant
- name: git@github.com:scragg0x/realms.git
- target: /home/deploy
- rev: master
- user: deploy
- identity: /home/deploy/.ssh/id_rsa

9
srv/salt/redis/init.sls Normal file
View file

@ -0,0 +1,9 @@
redis-server:
pkg:
- installed
service:
- running
- enable: True
- reload: True
- require:
- pkg: redis-server

View file

@ -0,0 +1,41 @@
rethinkdb-repo:
pkgrepo.managed:
- name: 'deb http://ppa.launchpad.net/rethinkdb/ppa/ubuntu precise main'
rethinkdb:
pkg.installed:
- require:
- pkgrepo.managed: rethinkdb-repo
rethinkdb-user:
user.present:
- name: rethinkdb
- shell: /bin/bash
- home: /home/rethinkdb
rethinkdb-pip:
pip:
- name: rethinkdb
- installed
- require:
- pkg: python-pip
- pkg: rethinkdb
- pkg: build-essential
/home/rethinkdb/rdb0:
file.directory:
- user: rethinkdb
- group: rethinkdb
- makedirs: True
/etc/rethinkdb/instances.d/rdb0.conf:
file.managed:
- source: salt://rethinkdb/rdb0.conf
rethinkdb-service:
service.running:
- name: rethinkdb
- enable: True
- reload: True
- watch:
- file.managed: /etc/rethinkdb/instances.d/rdb0.conf

View file

@ -0,0 +1,10 @@
runuser=rethinkdb
rungroup=rethinkdb
pid-file=/home/rethinkdb/rdb0/rethinkdb.pid
directory=/home/rethinkdb/rdb0
bind=all
driver-port=28015
cluster-port=29015
port-offset=0
http-port=20000
cores=2

View file

@ -0,0 +1,17 @@
/etc/supervisord.conf:
file.managed:
- source: salt://supervisor/supervisord.conf
supervisor-pip:
pip:
- name: supervisor
- installed
- require:
- pkg.installed: python-pip
supervisor-run:
cmd.run:
- unless: test -e /tmp/supervisord.pid
- name: /usr/local/bin/supervisord
- require:
- file.managed: /etc/supervisord.conf

View file

@ -0,0 +1,29 @@
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[unix_http_server]
file = /tmp/supervisor.sock
chmod = 0777
[supervisorctl]
serverurl = unix:///tmp/supervisor.sock
[supervisord]
logfile = /tmp/supervisord.log
logfile_maxbytes = 50MB
logfile_backups=10
loglevel = info
pidfile = /tmp/supervisord.pid
nodaemon = false
minfds = 1024
minprocs = 200
umask = 022
user = root
identifier = supervisor
directory = /tmp
nocleanup = true
childlogdir = /tmp
strip_ansi = false
[program:realms]
command=/home/deploy/virtualenvs/realms/bin/python /home/deploy/realms/app.py

10
srv/salt/top.sls Normal file
View file

@ -0,0 +1,10 @@
base:
'*':
- common
- users
- nodejs
- redis
- nginx
- rethinkdb
- realms
- supervisor

View file

@ -0,0 +1,2 @@
source /usr/local/bin/virtualenvwrapper.sh
WORKON_HOME=/home/deploy/virtualenvs

44
srv/salt/users/init.sls Normal file
View file

@ -0,0 +1,44 @@
deploy:
user.present:
- shell: /bin/bash
- home: /home/deploy
- fullname: Deploy
sudo:
pkg:
- installed
/etc/sudoers.d/mysudoers:
file.managed:
- source: salt://users/mysudoers
- mode: 440
- user: root
- group: root
- require:
- pkg: sudo
/home/deploy:
file.directory:
- user: deploy
- group: deploy
/home/deploy/.bash_profile:
file.managed:
- source: salt://users/.bash_profile
- mode: 440
- user: deploy
- group: deploy
- require:
- file.directory: /home/deploy
/home/deploy/.bashrc:
file.copy:
- mode: 440
- user: deploy
- group: deploy
- source: /etc/skel/.bashrc
bashrc-append:
file.append:
- name: /home/deploy/.bashrc
- text: . ~/.bash_profile

1
srv/salt/users/mysudoers Normal file
View file

@ -0,0 +1 @@
deploy ALL=(ALL) NOPASSWD:ALL