Skip to content

Commit

Permalink
New app; Etherpad, found better way to include nutcracker
Browse files Browse the repository at this point in the history
  • Loading branch information
renoirb committed Jun 8, 2015
1 parent 84866d7 commit 42de996
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 2 deletions.
28 changes: 28 additions & 0 deletions code/etherpad.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{%- set dir = '/srv/webplatform/etherpad' -%}
{%- set salt_master_ip = salt['pillar.get']('infra:hosts_entries:salt') -%}
{%- set upstream_port = salt['pillar.get']('upstream:etherpad:port', 8006) %}

include:
- users.app-user

{{ dir }}:
file.directory:
- user: app-user
- group: www-data
- recurse:
- user
- group

{{ dir }}/docker-compose.yml:
file.managed:
- source: salt://code/files/etherpad/docker-compose.yml.jinja
- template: jinja
- user: app-user
- group: www-data
- mode: 644
- context:
upstream_port: {{ upstream_port }}
salt_master_ip: {{ salt_master_ip }}
- require:
- file: {{ dir }}

20 changes: 20 additions & 0 deletions code/files/etherpad/docker-compose.yml.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## Managed by Salt Stack, please DO NOT TOUCH, or ALL CHANGES WILL be LOST!
## source {{ source }}

# ref:
# - http://docs.docker.com/compose/
# - http://docs.docker.com/compose/yml/

web:
image: webplatform/etherpad

restart: always

ports:
- "{{ upstream_port }}:9001"

dns:
- 10.10.10.41
- 8.8.8.8

# vim: et ts=2 sw=2 ft=yaml:
56 changes: 56 additions & 0 deletions etherpad/files/nginx.frontend.conf.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@

#
# This is the PUBLIC virtual host for etherpad.{{ tld }}
#
# Note that we call another NGINX virtual host, from the internal network,
# without SSL, and with a different name than the publicly exposed.
#
# Intention is that we can have multiple internal upstreams load-balanced
# by this very virtual host.
#
# ===========================================================================
#
# Managed by Salt Stack. Do NOT edit manually!
# source: {{ source }}
#

upstream upstream_etherpad {
keepalive 16;
ip_hash;

{%- for b in upstreams %}
server {{ b }}:{{ upstream_port }};
{%- endfor %}
}

server {
listen 80;
server_name etherpad.{{ tld }};
include common_params;
return 301 https://etherpad.{{ tld }}$request_uri;
}

server {
listen 443 ssl spdy;
server_name etherpad.{{ tld }};

root /var/www/html;
include common_params;
include ssl_params;

ssl on;
ssl_certificate /etc/ssl/webplatform/public_wildcard_201407.pem;
ssl_certificate_key /etc/ssl/webplatform/201407.key;

location / {
proxy_pass http://upstream_etherpad;
include proxy_params;
proxy_intercept_errors on;

# Backend keepalive
# ref: http://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive
proxy_http_version 1.1;
proxy_set_header Connection "";
}
}

31 changes: 31 additions & 0 deletions etherpad/frontend.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{%- set tld = salt['pillar.get']('infra:current:tld', 'webplatform.org') -%}
{%- set upstreams = salt['pillar.get']('upstream:etherpad:nodes', ['127.0.0.1']) -%}
{%- set upstream_port = salt['pillar.get']('upstream:etherpad:port', 8006) %}

include:
- nginx

#
# This is the PUBLIC virtual host for **etherpad** subdomain proxying requests
# to an internal webserver.
#
# ===========================================================================
#

/etc/nginx/sites-available/etherpad:
file.managed:
- source: salt://etherpad/files/nginx.frontend.conf.jinja
- template: jinja
- context:
tld: {{ tld }}
upstreams: {{ upstreams }}
upstream_port: {{ upstream_port }}
- require:
- pkg: nginx

/etc/nginx/sites-enabled/10-etherpad:
file.symlink:
- target: /etc/nginx/sites-available/etherpad
- require:
- file: /etc/nginx/sites-available/etherpad

2 changes: 1 addition & 1 deletion monitor/files/nginx.frontend.conf.jinja
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

#
# This is the PUBLIC virtual host for specs.{{ tld }}
# This is the PUBLIC virtual host for monitor.{{ tld }}
#
# Note that we call another NGINX virtual host, from the internal network,
# without SSL, and with a different name than the publicly exposed.
Expand Down
3 changes: 3 additions & 0 deletions nutcracker/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ include:
- mmonit
- code.packages

# https://launchpad.net/~twemproxy/+archive/ubuntu/stable
# add-apt-repository -y ppa:twemproxy/stable

nutcracker:
pkg.installed:
- skip_verify: True
Expand Down
1 change: 1 addition & 0 deletions roles/docker.sls
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ include:
- code.discuss
- code.status
- code.publican
- code.etherpad

5 changes: 4 additions & 1 deletion top.sls
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,16 @@ base:
'code*':
- gerrit
- rsync
'db*':
'roles:db':
- match: grain
- logwatch
- mysql.server
- rsync
'roles:dbpostgres':
- match: grain
- webplatform.postgres
- postgres
- logwatch
- rsync
'memcache*':
- memcached
Expand Down Expand Up @@ -145,6 +147,7 @@ base:
- piwik.frontend
- monitor.frontend
- discourse.frontend
- etherpad.frontend

# vim: ai filetype=yaml tabstop=2 softtabstop=2 shiftwidth=2

0 comments on commit 42de996

Please sign in to comment.