Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add role for etherpad #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Vagrant.configure(2) do |config|
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.network "forwarded_port", guest: 9002, host: 8000


# Create a private network, which allows host-only access to the machine
# using a specific IP.
Expand Down Expand Up @@ -67,7 +69,7 @@ Vagrant.configure(2) do |config|
ansible.playbook = "playbook.yml"
ansible.host_key_checking = "False"
ansible.inventory_path = "hosts"
ansible.verbose = "v"
ansible.verbose = "vvv"
ansible.limit = "vagrant"
end
end
23 changes: 23 additions & 0 deletions playbook.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
---
- hosts: all
sudo: true
gather_facts: yes

roles:
- andyceo.git
- bennojoy.mysql
- common
- nginx
- erasme.etherpad



vars:
- etherpad_deploy_user : etherpad
- etherpad_port : 9001
- etherpad_log_parent_dir : /var/log
- etherpad_session_key: default
- etherpad_version : master
- etherpad_path: /var/www/html
- etherpad_repos: https://github.com/ether/etherpad-lite.git
- etherpad_database:
name: etherpad
user: etherpad
host: localhost
password: etherpad
- mysql_db: [{name: etherpad}]
- mysql_users: [{name: etherpad, pass: etherpad, priv: "*.*:ALL"}]
9 changes: 9 additions & 0 deletions requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,12 @@

# https://github.com/yatesr/ansible-timezone
- src: yatesr.timezone

# https://github.com/erasme/ansible-etherpad
- src: erasme.etherpad

# https://github.com/bennojoy/mysql
- src: bennojoy.mysql

# https://github.com/andyceo/ansible-role-git
- src: andyceo.git
6 changes: 6 additions & 0 deletions roles/nginx/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- name: restart nginx
service: name=nginx state=restarted

- name: reload nginx
service: name=nginx state=reloaded
22 changes: 22 additions & 0 deletions roles/nginx/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
- name: install NGINX Server.
apt: pkg=nginx state=installed update-cache=yes

- name: copy base nginx configuration.
template: src=nginx.conf.j2 dest=/etc/nginx/nginx.conf
notify: restart nginx

- name: delete default vhost.
action: file path=/etc/nginx/sites-enabled/default state=absent
notify: restart nginx

- name: copy site host configuration.
template: src=site.conf.j2 dest=/etc/nginx/sites-available/{{project_name}}.conf
notify: restart nginx

- name: put host configuration in sites-enabled
file: src=/etc/nginx/sites-available/{{project_name}}.conf dest=/etc/nginx/sites-enabled/{{project_name}} state=link
notify: restart nginx

- name: ensure nginx is running
service: name=nginx state=started
95 changes: 95 additions & 0 deletions roles/nginx/templates/nginx.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
user www-data;
worker_processes 1;
pid /var/run/nginx.pid;

events {
worker_connections 768;
# multi_accept on;
}

http {

##
# Basic Settings
##

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;

# server_names_hash_bucket_size 64;
# server_name_in_redirect off;

include /etc/nginx/mime.types;
default_type application/octet-stream;

##
# Logging Settings
##

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

##
# Gzip Settings
##

gzip on;
gzip_disable "msie6";

# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##

#include /etc/nginx/naxsi_core.rules;

##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##

#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;

##
# Virtual Host Configs
##

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}


#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
50 changes: 50 additions & 0 deletions roles/nginx/templates/site.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
upstream app_server {
server 127.0.0.1:8000;
}

server {
# From WWW to non-WWW, for all domains
server_name "~^www\.(.*)$" ;
return 301 $scheme://$1$request_uri ;
}

# Serve static files and redirect any other request to django wsgi server
server {
listen 80;

server_name {{ domain_name }};
root /var/www/;
access_log /var/log/nginx/{{ domain_name }}.access.log;
error_log /var/log/nginx/{{ domain_name }}.error.log;
client_max_body_size 10M;

gzip on;
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_types application/atom+xml application/javascript application/x-javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-ttf application/xhtml+xml application/xml font/opentype image/svg+xml image/x-icon text/css text/plain text/x-component text/xml;

# expires 30d;
# expires max;
# expires modified +24h;
# expires @24h;
# expires 0;
# expires -1;
# expires epoch;
# add_header Cache-Control private;


# Check if a file exists at /var/www/ for the incoming request.
# If it doesn't proxy to Django wsgi server.
try_files $uri @app_server;

# Setup named location for Django requests and handle proxy details
location @app_server {
add_header Cache-Control "no-cache, must-revalidate, max-age=0";

proxy_pass http://127.0.0.1:8000;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}