Download:
child 18:464f9dec4e2f
parent 16:d66aad29c59c
17:5a3522b5fd5c
Anton Shestakov <av6@dwimlabs.net>, Mon, 27 Jun 2016 16:30:20 +0800
prefix all role variables

9 файлов изменено, 42 вставок(+), 42 удалений(-) [+]
roles/hgweb/handlers/main.yml file | annotate | diff | comparison | revisions
roles/hgweb/tasks/appinstall.yml file | annotate | diff | comparison | revisions
roles/hgweb/tasks/main.yml file | annotate | diff | comparison | revisions
roles/hgweb/templates/etc/nginx/sites-available/hgweb file | annotate | diff | comparison | revisions
roles/hgweb/templates/etc/supervisor/conf.d/hgweb.conf file | annotate | diff | comparison | revisions
roles/hgweb/templates/gunicorn.conf file | annotate | diff | comparison | revisions
roles/hgweb/templates/hgweb.conf file | annotate | diff | comparison | revisions
roles/hgweb/templates/hgweb.py file | annotate | diff | comparison | revisions
roles/hgweb/vars/main.yml file | annotate | diff | comparison | revisions
--- a/roles/hgweb/handlers/main.yml Sun Jun 26 17:43:00 2016 +0000
+++ b/roles/hgweb/handlers/main.yml Mon Jun 27 16:30:20 2016 +0800
@@ -1,8 +1,8 @@
---
- name: make local
- command: make --directory /home/{{ user }}/hg/ local
+ command: make --directory /home/{{ hgweb_user }}/hg/ local
become: yes
- become_user: '{{ user }}'
+ become_user: '{{ hgweb_user }}'
- name: restart hgweb
supervisorctl: name=hgweb state=restarted
--- a/roles/hgweb/tasks/appinstall.yml Sun Jun 26 17:43:00 2016 +0000
+++ b/roles/hgweb/tasks/appinstall.yml Mon Jun 27 16:30:20 2016 +0800
@@ -1,28 +1,28 @@
---
- name: Ensure required directories exist
- file: path=/home/{{ user }}/{{ item }}/ state=directory
+ file: path=/home/{{ hgweb_user }}/{{ item }}/ state=directory
with_items:
- hgwebfiles
- repos
- name: Add .hgrc
- copy: src=.hgrc dest=/home/{{ user }}/.hgrc
+ copy: src=.hgrc dest=/home/{{ hgweb_user }}/.hgrc
-- name: Pull Mercurial {{ mercurial_rev }}
- hg: repo={{ mercurial_url }} dest=/home/{{ user }}/hg/ revision={{ mercurial_rev }}
+- name: Pull Mercurial {{ hgweb_mercurial_rev }}
+ hg: repo={{ hgweb_mercurial_url }} dest=/home/{{ hgweb_user }}/hg/ revision={{ hgweb_mercurial_rev }}
notify:
- make local
- restart hgweb
tags: [inert]
-- name: Pull Evolve {{ evolve_rev }}
- hg: repo={{ evolve_url }} dest=/home/{{ user }}/evolve/ revision={{ evolve_rev }}
+- name: Pull Evolve {{ hgweb_evolve_rev }}
+ hg: repo={{ hgweb_evolve_url }} dest=/home/{{ hgweb_user }}/evolve/ revision={{ hgweb_evolve_rev }}
notify:
- restart hgweb
tags: [inert]
- name: Add config files
- template: src={{ item }} dest=/home/{{ user }}/hgwebfiles/{{ item }}
+ template: src={{ item }} dest=/home/{{ hgweb_user }}/hgwebfiles/{{ item }}
with_items:
- hgweb.py
- hgweb.conf
@@ -31,10 +31,10 @@
- restart hgweb
- name: Copy requirements.txt
- copy: src=requirements.txt dest=/home/{{ user }}/hgwebfiles/requirements.txt
+ copy: src=requirements.txt dest=/home/{{ hgweb_user }}/hgwebfiles/requirements.txt
- name: Set up venv for gunicorn
- pip: requirements=/home/{{ user }}/hgwebfiles/requirements.txt state=latest virtualenv=/home/{{ user }}/hgwebfiles/venv/
+ pip: requirements=/home/{{ hgweb_user }}/hgwebfiles/requirements.txt state=latest virtualenv=/home/{{ hgweb_user }}/hgwebfiles/venv/
notify:
- restart hgweb
...
--- a/roles/hgweb/tasks/main.yml Sun Jun 26 17:43:00 2016 +0000
+++ b/roles/hgweb/tasks/main.yml Mon Jun 27 16:30:20 2016 +0800
@@ -1,6 +1,6 @@
---
- name: Create user
- user: name={{ user }}
+ user: name={{ hgweb_user }}
- name: Install packages
apt: pkg={{ item }} state=present
@@ -18,20 +18,20 @@
- include: appinstall.yml
become: yes
- become_user: '{{ user }}'
+ become_user: '{{ hgweb_user }}'
- name: Add supervisor app
template: src=etc/supervisor/conf.d/hgweb.conf dest=/etc/supervisor/conf.d/hgweb.conf
notify:
- reload supervisor
-- name: Add {{ subdomain }}.{{ hostname }} Nginx site
- template: src=etc/nginx/sites-available/hgweb dest=/etc/nginx/sites-available/{{ subdomain }}.{{ hostname }}
+- name: Add {{ hgweb_subdomain }}.{{ hostname }} Nginx site
+ template: src=etc/nginx/sites-available/hgweb dest=/etc/nginx/sites-available/{{ hgweb_subdomain }}.{{ hostname }}
notify:
- restart nginx
-- name: Enable {{ subdomain }}.{{ hostname }} Nginx site
- file: src=/etc/nginx/sites-available/{{ subdomain }}.{{ hostname }} dest=/etc/nginx/sites-enabled/50{{ subdomain }}.{{ hostname }} state=link
+- name: Enable {{ hgweb_subdomain }}.{{ hostname }} Nginx site
+ file: src=/etc/nginx/sites-available/{{ hgweb_subdomain }}.{{ hostname }} dest=/etc/nginx/sites-enabled/50{{ hgweb_subdomain }}.{{ hostname }} state=link
notify:
- restart nginx
...
--- a/roles/hgweb/templates/etc/nginx/sites-available/hgweb Sun Jun 26 17:43:00 2016 +0000
+++ b/roles/hgweb/templates/etc/nginx/sites-available/hgweb Mon Jun 27 16:30:20 2016 +0800
@@ -1,17 +1,17 @@
upstream hgweb {
- server unix:/home/{{ user }}/hgwebfiles/socket fail_timeout=0;
+ server unix:/home/{{ hgweb_user }}/hgwebfiles/socket fail_timeout=0;
}
server {
- server_name {{ subdomain }}.{{ hostname }};
+ server_name {{ hgweb_subdomain }}.{{ hostname }};
listen 80;
listen [::]:80;
- access_log /var/log/nginx/{{ subdomain }}.{{ hostname }}.access.log;
- error_log /var/log/nginx/{{ subdomain }}.{{ hostname }}.error.log;
+ access_log /var/log/nginx/{{ hgweb_subdomain }}.{{ hostname }}.access.log;
+ error_log /var/log/nginx/{{ hgweb_subdomain }}.{{ hostname }}.error.log;
- root /home/{{ user }}/hg/mercurial/templates/;
+ root /home/{{ hgweb_user }}/hg/mercurial/templates/;
location / {
proxy_pass http://hgweb;
--- a/roles/hgweb/templates/etc/supervisor/conf.d/hgweb.conf Sun Jun 26 17:43:00 2016 +0000
+++ b/roles/hgweb/templates/etc/supervisor/conf.d/hgweb.conf Mon Jun 27 16:30:20 2016 +0800
@@ -1,5 +1,5 @@
[program:hgweb]
-command = /home/{{ user }}/hgwebfiles/venv/bin/gunicorn --config=/home/{{ user }}/hgwebfiles/gunicorn.conf hgweb:application
-directory = /home/{{ user }}/hgwebfiles/
-user = {{ user }}
+command = /home/{{ hgweb_user }}/hgwebfiles/venv/bin/gunicorn --config=/home/{{ hgweb_user }}/hgwebfiles/gunicorn.conf hgweb:application
+directory = /home/{{ hgweb_user }}/hgwebfiles/
+user = {{ hgweb_user }}
stopsignal = INT
--- a/roles/hgweb/templates/gunicorn.conf Sun Jun 26 17:43:00 2016 +0000
+++ b/roles/hgweb/templates/gunicorn.conf Mon Jun 27 16:30:20 2016 +0800
@@ -1,5 +1,5 @@
-bind = 'unix:/home/{{ user }}/hgwebfiles/socket'
-workers = {{ workers }}
+bind = 'unix:/home/{{ hgweb_user }}/hgwebfiles/socket'
+workers = {{ hgweb_workers }}
worker_class = 'eventlet'
accesslog = '-'
errorlog = '-'
--- a/roles/hgweb/templates/hgweb.conf Sun Jun 26 17:43:00 2016 +0000
+++ b/roles/hgweb/templates/hgweb.conf Mon Jun 27 16:30:20 2016 +0800
@@ -1,14 +1,14 @@
[paths]
-/ = /home/{{ user }}/repos/*
+/ = /home/{{ hgweb_user }}/repos/*
[extensions]
highlight =
-simple4server = /home/{{ user }}/evolve/hgext/simple4server.py
+simple4server = /home/{{ hgweb_user }}/evolve/hgext/simple4server.py
[web]
-baseurl = http://{{ subdomain }}.{{ hostname }}/
-logourl = http://{{ subdomain }}.{{ hostname }}/
-contact = {{ contact }}
+baseurl = http://{{ hgweb_subdomain }}.{{ hostname }}/
+logourl = http://{{ hgweb_subdomain }}.{{ hostname }}/
+contact = {{ hgweb_contact }}
staticurl = /static
pygments_style = tango
highlightfiles = size('<100k')
--- a/roles/hgweb/templates/hgweb.py Sun Jun 26 17:43:00 2016 +0000
+++ b/roles/hgweb/templates/hgweb.py Mon Jun 27 16:30:20 2016 +0800
@@ -1,9 +1,9 @@
# Path to repo or hgweb config to serve (see 'hg help hgweb')
-config = "/home/{{ user }}/hgwebfiles/hgweb.conf"
+config = "/home/{{ hgweb_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/")
+import sys; sys.path.insert(0, "/home/{{ hgweb_user }}/hg/")
# Uncomment to send python tracebacks to the browser if an error occurs:
#import cgitb; cgitb.enable()
--- a/roles/hgweb/vars/main.yml Sun Jun 26 17:43:00 2016 +0000
+++ b/roles/hgweb/vars/main.yml Mon Jun 27 16:30:20 2016 +0800
@@ -1,10 +1,10 @@
---
-contact: 'Me Myself <me@mydomain>'
-subdomain: hg
-user: hguser
-mercurial_url: https://selenic.com/hg
-mercurial_rev: stable
-evolve_url: https://www.mercurial-scm.org/repo/evolve
-evolve_rev: stable
-workers: 1
+hgweb_contact: 'Me Myself <me@mydomain>'
+hgweb_subdomain: hg
+hgweb_user: hguser
+hgweb_mercurial_url: https://selenic.com/hg
+hgweb_mercurial_rev: stable
+hgweb_evolve_url: https://www.mercurial-scm.org/repo/evolve
+hgweb_evolve_rev: stable
+hgweb_workers: 1
...