blob: 27e05543eef60b9694a8929373e439596971b868 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
- name: Install cgit
apt: pkg={{ item }}
with_items:
- cgit
- highlight
- uwsgi
- name: Configure cgit
copy: src=etc/cgitrc
dest=/etc/cgitrc
owner=root group=root
mode=0644
register: r1
notify:
- Restart uWSGI
- name: Copy /usr/lib/cgit/filters/syntax-highlighting2.sh
copy: src=usr/lib/cgit/filters/syntax-highlighting2.sh
dest=/usr/lib/cgit/filters/syntax-highlighting2.sh
owner=root group=root
mode=0755
register: r2
notify:
- Restart uWSGI
- name: Create a user 'cgit'
user: name=cgit system=yes
home=/var/www
shell=/usr/sbin/nologin
password=!
state=present
register: r3
notify:
- Restart uWSGI
- name: Create /etc/uwsgi/apps-available/{cgit,git-http-backend}.ini
copy: src=etc/uwsgi/apps-available/{{ item }}.ini
dest=/etc/uwsgi/apps-available/{{ item }}.ini
owner=root group=root
mode=0644
register: r4
with_items:
- cgit
- git-http-backend
notify:
- Restart uWSGI
- name: Create /etc/uwsgi/apps-enabled/{cgit,git-http-backend}.ini
file: src=../apps-available/{{ item }}.ini
dest=/etc/uwsgi/apps-enabled/{{ item }}.ini
owner=root group=root
state=link force=yes
register: r5
with_items:
- cgit
- git-http-backend
notify:
- Restart uWSGI
- name: Start uWSGI
service: name=nginx state=started
when: not (r1.changed or r2.changed or r3.changed or r4.changed or r5.changed)
- meta: flush_handlers
- name: Add 'cgit' & 'www-data' to the group 'gitolite'
user: name={{ item }} groups=gitolite append=yes
with_items:
# for the cgit interface
- cgit
# for pulls over HTTP/HTTPS
- www-data
- name: Generate a private key and a X.509 certificate for Nginx
command: genkeypair.sh x509
--pubkey=/etc/nginx/ssl/git.fripost.org.pem
--privkey=/etc/nginx/ssl/git.fripost.org.key
--ou=WWW --cn=git.fripost.org --dns=git.fripost.org
-t rsa -b 4096 -h sha512
register: r1
changed_when: r1.rc == 0
failed_when: r1.rc > 1
notify:
- Restart Nginx
tags:
- genkey
- name: Copy /etc/nginx/sites-available/git
copy: src=etc/nginx/sites-available/git
dest=/etc/nginx/sites-available/git
owner=root group=root
mode=0644
register: r2
notify:
- Restart Nginx
- name: Create /etc/nginx/sites-enabled/git
file: src=../sites-available/git
dest=/etc/nginx/sites-enabled/git
owner=root group=root
state=link force=yes
register: r3
notify:
- Restart Nginx
- name: Start Nginx
service: name=nginx state=started
when: not (r1.changed or r2.changed or r3.changed)
- meta: flush_handlers
- name: Fetch Nginx's X.509 certificate
# Ensure we don't fetch private data
sudo: False
fetch: src=/etc/nginx/ssl/git.fripost.org.pem
dest=certs/public/
fail_on_missing=yes
flat=yes
tags:
- genkey
|