Browse Source

Moar vagrant.

master
Nick Sergeant 7 years ago
parent
commit
1950cb7d94
7 changed files with 62 additions and 33 deletions
  1. +35
    -8
      Makefile
  2. +0
    -3
      README.md
  3. +11
    -11
      salt/application/init.sls
  4. +4
    -4
      salt/application/snipt.nginx.conf
  5. +10
    -0
      salt/nginx/init.sls
  6. +2
    -1
      settings.py
  7. +0
    -6
      settings_local.py-template

+ 35
- 8
Makefile View File

@@ -1,6 +1,6 @@
pm = /var/www/.virtualenvs/snipt/bin/python /var/www/snipt/manage.py
ssh-server-deploy = ssh deploy@snipt.net
ssh-server-root = ssh root@snipt.net
ssh-server-deploy = ssh deploy@69.164.221.98 -p 55555
ssh-server-root = ssh root@69.164.221.98
ssh-vagrant = ssh vagrant@localhost -p 2222 -i ~/.vagrant.d/insecure_private_key

assets:
@@ -72,16 +72,22 @@ db:
@sudo -u postgres bash -c 'createdb snipt -O snipt'

deploy:
@$(ssh-server) 'cd /var/www/snipt; git pull;'
@$(ssh-server) 'cd /var/www/snipt; make assets;'
@$(ssh-server) '$(pm) migrate'
@$(ssh-server) 'sudo supervisorctl restart snipt'
@$(ssh-server-deploy) 'cd /var/www/snipt; git pull;'
@$(ssh-server-deploy) 'cd /var/www/snipt; make assets;'
@$(ssh-server-deploy) '$(pm) migrate'
@$(ssh-server-deploy) 'sudo supervisorctl restart snipt'

deploy-heroku:
@git push heroku

server-settings:
@scp -q -P 2222 -i ~/.vagrant.d/insecure_private_key -r settings_local_server.py vagrant@localhost:settings_local.py
salt-server:
@scp -q -P 55555 -r ./salt/ deploy@69.164.221.98:salt
@scp -q -P 55555 -r ./pillar/ deploy@69.164.221.98:pillar
@$(ssh-server-deploy) 'sudo rm -rf /srv'
@$(ssh-server-deploy) 'sudo mkdir /srv'
@$(ssh-server-deploy) 'sudo mv ~/salt /srv/salt'
@$(ssh-server-deploy) 'sudo mv ~/pillar /srv/pillar'
@$(ssh-server-deploy) 'sudo salt-call --local state.highstate'

salt-vagrant:
@scp -q -P 2222 -i ~/.vagrant.d/insecure_private_key -r ./salt/ vagrant@localhost:salt
@@ -92,6 +98,27 @@ salt-vagrant:
@$(ssh-vagrant) 'sudo mv ~/pillar /srv/pillar'
@$(ssh-vagrant) 'sudo salt-call --local state.highstate'

server:
@$(ssh-server-root) 'sudo apt-get update'
@$(ssh-server-root) 'sudo apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade'
@$(ssh-server-root) 'sudo apt-get install -y software-properties-common python-software-properties'
@$(ssh-server-root) 'sudo add-apt-repository -y ppa:saltstack/salt'
@$(ssh-server-root) 'sudo apt-get update'
@$(ssh-server-root) 'sudo apt-get install -y salt-minion'
@scp -q -r ./salt/ root@69.164.221.98:salt
@scp -q -r ./pillar/ root@69.164.221.98:pillar
@$(ssh-server-root) 'sudo rm -rf /srv'
@$(ssh-server-root) 'sudo mkdir /srv'
@$(ssh-server-root) 'sudo mv ~/salt /srv/salt'
@$(ssh-server-root) 'sudo mv ~/pillar /srv/pillar'
@$(ssh-server-root) 'sudo salt-call --local state.highstate'
@scp -q -P 55555 settings_local_server.py deploy@69.164.221.98:/var/www/snipt/settings_local.py
@$(ssh-server-deploy) 'cd /var/www/snipt; make db;'
@$(ssh-server-deploy) '$(pm) syncdb;'
@$(ssh-server-deploy) '$(pm) migrate;'
@$(ssh-server-deploy) '$(pm) backfill_api_keys'
@$(ssh-server-deploy) '$(pm) rebuild_index --noinput'

vagrant:
@vagrant up --provider=vmware_fusion
@$(ssh-vagrant) 'sudo apt-get update'


+ 0
- 3
README.md View File

@@ -26,9 +26,6 @@ Install [Vagrant](https://www.vagrantup.com/) and either [VirtualBox](https://ww
2. `heroku create`
3. `heroku addons:add heroku-postgresql:hobby-dev`
4. `heroku addons:add searchbox`
5. `heroku config:add AWS_ACCESS_KEY_ID=`
6. `heroku config:add AWS_SECRET_ACCESS_KEY=`
7. `heroku config:add AWS_STORAGE_BUCKET_NAME=`
8. `heroku config:add DEBUG=False`
9. `heroku config:add INTERCOM_SECRET_KEY=`
9. `heroku config:add POSTMARK_API_KEY=`


+ 11
- 11
salt/application/init.sls View File

@@ -21,17 +21,6 @@ virtualenvwrapper:
- require:
- group: deploy

/var/www/.virtualenvs/snipt:
file.directory:
- user: {{ pillar.deploy_user }}
- group: deploy
- mode: 775
- require:
- group: deploy
virtualenv.managed:
- system_site_packages: False
- requirements: /var/www/snipt/requirements.txt

{% if pillar.env_name != 'vagrant' %}

/var/www/snipt:
@@ -49,6 +38,17 @@ virtualenvwrapper:

{% endif %}

/var/www/.virtualenvs/snipt:
file.directory:
- user: {{ pillar.deploy_user }}
- group: deploy
- mode: 775
- require:
- group: deploy
virtualenv.managed:
- system_site_packages: False
- requirements: /var/www/snipt/requirements.txt

/home/{{ pillar.deploy_user }}/tmp:
file.absent



+ 4
- 4
salt/application/snipt.nginx.conf View File

@@ -22,8 +22,8 @@ upstream backend_snipt {
server_name www.{{ pillar.hostname }};

ssl on;
ssl_certificate /etc/certs/2013-dnsimple/{{ pillar.hostname }}.crt;
ssl_certificate_key /etc/certs/2013-dnsimple/{{ pillar.hostname }}.key;
ssl_certificate /etc/certs/{{ pillar.hostname }}.crt;
ssl_certificate_key /etc/certs/{{ pillar.hostname }}.key;

rewrite ^(.*) https://{{ pillar.hostname }}$1 permanent;
}
@@ -32,8 +32,8 @@ upstream backend_snipt {
server_name {{ pillar.hostname }} *.{{ pillar.hostname }};

ssl on;
ssl_certificate /etc/certs/2013-dnsimple/{{ pillar.hostname }}.crt;
ssl_certificate_key /etc/certs/2013-dnsimple/{{ pillar.hostname }}.key;
ssl_certificate /etc/certs/{{ pillar.hostname }}.crt;
ssl_certificate_key /etc/certs/{{ pillar.hostname }}.key;

location ~* /favicon.ico {
root /var/www/snipt/static/img/;


+ 10
- 0
salt/nginx/init.sls View File

@@ -20,6 +20,16 @@ nginx:
- require:
- pkg: nginx

{% if pillar.env_name != 'vagrant' %}

/etc/certs:
file.directory:
- mode: 644
- require:
- pkg: nginx

{% endif %}

/etc/nginx/nginx.conf:
file.managed:
- source: salt://nginx/nginx.conf


+ 2
- 1
settings.py View File

@@ -57,8 +57,9 @@ SESSION_COOKIE_SECURE = True if 'USE_SSL' in os.environ else False
SITE_ID = 1
STATICFILES_DIRS = (os.path.join(BASE_PATH, 'media'),)
STATICFILES_FINDERS = ('django.contrib.staticfiles.finders.FileSystemFinder','django.contrib.staticfiles.finders.AppDirectoriesFinder',)
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage'
STATIC_ROOT = os.path.join(BASE_PATH, 'static')
STATIC_URL = 'https://snipt.s3.amazonaws.com/'
STATIC_URL = '/static/'
TASTYPIE_CANNED_ERROR = "There was an error with your request. The site developers have a record of this error, please email api@snipt.net and we'll help you out."
TEMPLATE_DIRS = (os.path.join(PROJECT_PATH, 'templates'),)
TEMPLATE_DEBUG = DEBUG


+ 0
- 6
settings_local.py-template View File

@@ -1,17 +1,11 @@
AWS_ACCESS_KEY_ID = ''
AWS_SECRET_ACCESS_KEY = ''
AWS_STORAGE_BUCKET_NAME = ''
CSRF_COOKIE_SECURE = False
DEBUG = True
INTERCOM_SECRET_KEY = ''
POSTMARK_API_KEY = ''
RAVEN_CONFIG = { 'dsn': '' }
S3_URL = 'https://%s.s3.amazonaws.com/' % AWS_STORAGE_BUCKET_NAME
SECRET_KEY = 'changeme'
SESSION_COOKIE_SECURE = False
SSLIFY_DISABLE = True
STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
STATIC_URL = '/static/'
STRIPE_SECRET_KEY = ''
USE_HTTPS = False



Loading…
Cancel
Save