--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/roles/hgweb/files/.hgrc Sat Feb 20 15:57:54 2016 +0800
+selenic.com = f0:40:cc:b9:46:62:b6:69:48:c5:1a:65:d0:34:35:22:b6:e0:1b:87
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/roles/hgweb/files/requirements.txt Sat Feb 20 15:57:54 2016 +0800
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/roles/hgweb/handlers/main.yml Sat Feb 20 15:57:54 2016 +0800
+ command: make --directory /home/{{ user }}/hg/ local
+ become_user: '{{ user }}'
+ supervisorctl: name=hgweb state=restarted
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/roles/hgweb/tasks/appinstall.yml Sat Feb 20 15:57:54 2016 +0800
+- name: Ensure required directories exist
+ file: path=/home/{{ user }}/{{ item }}/ state=directory
+ copy: src=.hgrc dest=/home/{{ user }}/.hgrc
+- name: Pull Mercurial {{ mercurial_rev }}
+ hg: repo={{ mercurial_url }} dest=/home/{{ user }}/hg/ revision={{ mercurial_rev }}
+- name: Pull Evolve {{ evolve_rev }}
+ hg: repo={{ evolve_url }} dest=/home/{{ user }}/evolve/ revision={{ evolve_rev }}
+- name: Add config files
+ template: src={{ item }} dest=/home/{{ user }}/hgwebfiles/{{ item }}
+- name: Copy requirements.txt
+ copy: src=requirements.txt dest=/home/{{ user }}/hgwebfiles/requirements.txt
+- name: Set up venv for gunicorn
+ pip: requirements=/home/{{ user }}/hgwebfiles/requirements.txt state=latest virtualenv=/home/{{ user }}/hgwebfiles/venv/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/roles/hgweb/tasks/main.yml Sat Feb 20 15:57:54 2016 +0800
+- name: Install packages
+ apt: pkg={{ item }} state=present
+ tags: [packages, inert]
+- name: Install virtualenv
+ apt: pkg=virtualenv state=present
+ when: ansible_distribution_release == 'jessie'
+ tags: [packages, inert]
+- include: appinstall.yml
+ become_user: '{{ user }}'
+- name: Add supervisor app
+ template: src=etc/supervisor/conf.d/hgweb.conf dest=/etc/supervisor/conf.d/hgweb.conf
+- name: Add {{ subdomain }}.{{ hostname }} Nginx site
+ template: src=etc/nginx/sites-available/hgweb dest=/etc/nginx/sites-available/{{ subdomain }}.{{ hostname }}
+- name: Enable {{ subdomain }}.{{ hostname }} Nginx site
+ file: src=/etc/nginx/sites-available/{{ subdomain }}.{{ hostname }} dest=/etc/nginx/sites-enabled/50{{ subdomain }}.{{ hostname }} state=link
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/roles/hgweb/templates/etc/nginx/sites-available/hgweb Sat Feb 20 15:57:54 2016 +0800
+ server unix:/home/{{ user }}/hgwebfiles/socket fail_timeout=0;
+ server_name {{ subdomain }}.{{ hostname }};
+ access_log /var/log/nginx/{{ subdomain }}.{{ hostname }}.access.log;
+ error_log /var/log/nginx/{{ subdomain }}.{{ hostname }}.error.log;
+ root /home/{{ user }}/hg/mercurial/templates/;
+ proxy_pass http://hgweb;
+ proxy_set_header Host $host;
+ proxy_set_header X-Scheme $scheme;
+ proxy_set_header X-Forwarded-Proto $scheme;
+ proxy_set_header X-Real-Ip $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ gzip_types text/plain text/css application/javascript text/javascript;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/roles/hgweb/templates/etc/supervisor/conf.d/hgweb.conf Sat Feb 20 15:57:54 2016 +0800
+command = /home/{{ user }}/hgwebfiles/venv/bin/gunicorn --config=/home/{{ user }}/hgwebfiles/gunicorn.conf hgweb:application
+directory = /home/{{ user }}/hgwebfiles/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/roles/hgweb/templates/gunicorn.conf Sat Feb 20 15:57:54 2016 +0800
+bind = 'unix:/home/{{ user }}/hgwebfiles/socket'
+worker_class = 'eventlet'
+timeout = 30 # set to bigger values for serving bigger repos
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/roles/hgweb/templates/hgweb.conf Sat Feb 20 15:57:54 2016 +0800
+/ = /home/{{ user }}/repos/*
+simple4server = /home/{{ user }}/evolve/hgext/simple4server.py
+baseurl = http://{{ subdomain }}.{{ hostname }}/
+logourl = http://{{ subdomain }}.{{ hostname }}/
+highlightfiles = size('<100k')
+highlightonlymatchfilename = True
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/roles/hgweb/templates/hgweb.py Sat Feb 20 15:57:54 2016 +0800
+# Path to repo or hgweb config to serve (see 'hg help hgweb')
+config = "/home/{{ user }}/hgwebfiles/hgweb.conf"
+# Uncomment and adjust if Mercurial is not installed system-wide
+# (consult "installed modules" path from 'hg debuginstall'):
+import sys; sys.path.insert(0, "/home/{{ user }}/hg/")
+# Uncomment to send python tracebacks to the browser if an error occurs:
+#import cgitb; cgitb.enable()
+# enable demandloading to reduce startup time
+from mercurial import demandimport; demandimport.enable()
+from mercurial.hgweb import hgweb
+application = hgweb(config)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/roles/hgweb/vars/main.yml Sat Feb 20 15:57:54 2016 +0800
+contact: 'Me Myself <me@mydomain>'
+mercurial_url: https://selenic.com/hg
+evolve_url: http://42.netv6.net/evolve-main