blob: 7b4600d8c48ec1cb11bc085cc397760f32a0452c (
plain) (
blame)
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
122
123
124
|
---
- name: install gitolite
apt:
name:
- git
- gitolite3
- name: prepare storage volume for /srv/git
when: gitolite_storage is defined
vars:
storage_volume: "{{ gitolite_storage | combine({'dest': gitolite_base_path}) }}"
include_role:
name: "storage/{{ gitolite_storage.type }}/volume"
- name: create gitolite instance user
loop: "{{ gitolite_instances | dict2items }}"
loop_control:
label: "{{ item.key }}"
user:
name: "{{ item.value.user | default('git-' + item.key) }}"
home: "{{ gitolite_base_path }}/{{ item.key }}"
shell: /bin/sh
system: yes
state: present
- name: make sure base dir is owned by gitolite user
loop: "{{ gitolite_instances | dict2items }}"
loop_control:
label: "{{ item.key }}"
file:
path: "{{ gitolite_base_path }}/{{ item.key }}"
mode: 0750
owner: "{{ item.value.user | default('git-' + item.key) }}"
group: "{{ item.value.user | default('git-' + item.key) }}"
- name: deploy primary admin key
loop: "{{ gitolite_instances | dict2items }}"
loop_control:
label: "{{ item.key }}"
copy:
content: "{{ item.value.primary_admin_key }}"
dest: "{{ gitolite_base_path }}/{{ item.key }}/primary-admin.pub"
- name: run initial gitolite setup
loop: "{{ gitolite_instances | dict2items }}"
loop_control:
label: "{{ item.key }}"
become: yes
become_method: su
become_user: "{{ item.value.user | default('git-' + item.key) }}"
args:
creates: "{{ gitolite_base_path }}/{{ item.key }}/.gitolite.rc"
chdir: "{{ gitolite_base_path }}/{{ item.key }}"
command: gitolite setup -pk "{{ gitolite_base_path }}/{{ item.key }}/primary-admin.pub"
register: gitolite_instance_initial_setup
- name: remove testing repository
loop: "{{ gitolite_instance_initial_setup.results }}"
loop_control:
label: "{{ item.item.key }}"
when: item is changed
file:
path: "{{ gitolite_base_path }}/{{ item.item.key }}/repositories/testing.git"
state: absent
- name: configure umask
loop: "{{ gitolite_instances | dict2items }}"
loop_control:
label: "{{ item.key }}"
lineinfile:
path: "{{ gitolite_base_path }}/{{ item.key }}/.gitolite.rc"
backrefs: yes
regexp: "^(\\s*UMASK\\s*=>\\s*).*(,.*)$"
line: '\g<1>{{ item.value.umask | default("0077") }}\2'
- name: configure GIT_CONFIG_KEYS to allow gitweb settings
loop: "{{ gitolite_instances | list }}"
lineinfile:
path: "{{ gitolite_base_path }}/{{ item }}/.gitolite.rc"
backrefs: yes
regexp: "^(\\s*GIT_CONFIG_KEYS\\s*=>\\s*').*('.*)$"
line: '\1cgit.*\2'
- name: disable gitweb gitolite command
loop: "{{ gitolite_instances | list }}"
lineinfile:
path: "{{ gitolite_base_path }}/{{ item }}/.gitolite.rc"
backrefs: yes
regexp: "^(\\s*)('gitweb'.*)$"
line: '\1# \2'
- name: enable daemon gitolite command
loop: "{{ gitolite_instances | list }}"
lineinfile:
path: "{{ gitolite_base_path }}/{{ item }}/.gitolite.rc"
backrefs: yes
regexp: "^(\\s*)#?\\s*('daemon'.*)$"
line: '\1\2'
- name: install git-fsck script
template:
src: git-fsck.sh.j2
dest: "{{ gitolite_base_path }}/git-fsck.sh"
mode: 0755
- name: install template systemd unit for git-fsck
template:
src: git-fsck@.service.j2
dest: /etc/systemd/system/git-fsck@.service
- name: install systemd timer unit for git-fsck
loop: "{{ gitolite_instances | list }}"
template:
src: git-fsck-.timer.j2
dest: "/etc/systemd/system/git-fsck-{{ item }}.timer"
- name: start/enable git-fsck systemd timer
loop: "{{ gitolite_instances | list }}"
systemd:
daemon_reload: yes
name: "git-fsck-{{ item }}.timer"
state: started
enabled: yes
|