aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--provision.yml4
-rw-r--r--roles/gitolite/defaults/main.yml3
-rw-r--r--roles/gitolite/tasks/main.yml49
-rw-r--r--roles/gitolite/templates/gitconfig.j23
-rw-r--r--roles/gitolite/templates/gitolite.rc.j2179
5 files changed, 238 insertions, 0 deletions
diff --git a/provision.yml b/provision.yml
index e7b6602..a5bd229 100644
--- a/provision.yml
+++ b/provision.yml
@@ -29,6 +29,10 @@
29 29
30 - role: fail2ban 30 - role: fail2ban
31 31
32 - role: gitolite
33 vars:
34 admin_pubkey: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJRy2xTx1XiYIsphsrJyZtQ3qguTFxwIfHOY+v7/j7yB martin@michalec.dev"
35
32 - role: acme_client 36 - role: acme_client
33 vars: 37 vars:
34 setup: true 38 setup: true
diff --git a/roles/gitolite/defaults/main.yml b/roles/gitolite/defaults/main.yml
new file mode 100644
index 0000000..a818ae7
--- /dev/null
+++ b/roles/gitolite/defaults/main.yml
@@ -0,0 +1,3 @@
1---
2user: "git"
3home: "/var/lib/{{ user }}"
diff --git a/roles/gitolite/tasks/main.yml b/roles/gitolite/tasks/main.yml
new file mode 100644
index 0000000..fa4b435
--- /dev/null
+++ b/roles/gitolite/tasks/main.yml
@@ -0,0 +1,49 @@
1---
2- block:
3 - name: Ensure gitolite package is installed
4 community.general.apk:
5 name:
6 - gitolite
7 state: present
8
9 - name: Create gitolite system user ({{ user }})
10 ansible.builtin.user:
11 name: "{{ user }}"
12 home: "{{ home }}"
13 shell: /bin/sh
14 create_home: true
15 system: true
16
17 - name: Deploy admin SSH public key
18 ansible.builtin.copy:
19 content: "{{ admin_pubkey }}\n"
20 dest: "{{ home }}/admin.pub"
21 owner: "{{ user }}"
22 group: "{{ user }}"
23 mode: '0444'
24
25 - name: Initialize gitolite setup for {{ user }}
26 ansible.builtin.command:
27 cmd: "gitolite setup -pk {{ home }}/admin.pub"
28 creates: "{{ home }}/.gitolite"
29 become: true
30 become_user: "{{ user }}"
31
32 - name: Deploy .gitolite.rc
33 ansible.builtin.template:
34 src: "gitolite.rc.j2"
35 dest: "{{ home }}/.gitolite.rc"
36 owner: "{{ user }}"
37 group: "{{ user }}"
38 mode: '0444'
39
40 - name: Deploy .gitconfig
41 ansible.builtin.template:
42 src: "gitconfig.j2"
43 dest: "{{ home }}/.gitconfig"
44 owner: "{{ user }}"
45 group: "{{ user }}"
46 mode: '0444'
47
48 tags:
49 - gitolite
diff --git a/roles/gitolite/templates/gitconfig.j2 b/roles/gitolite/templates/gitconfig.j2
new file mode 100644
index 0000000..ab5a8df
--- /dev/null
+++ b/roles/gitolite/templates/gitconfig.j2
@@ -0,0 +1,3 @@
1# {{ ansible_managed }}
2[init]
3 defaultBranch = master
diff --git a/roles/gitolite/templates/gitolite.rc.j2 b/roles/gitolite/templates/gitolite.rc.j2
new file mode 100644
index 0000000..e34f72b
--- /dev/null
+++ b/roles/gitolite/templates/gitolite.rc.j2
@@ -0,0 +1,179 @@
1# -*- Perl -*-
2# {{ ansible_managed }}
3
4%RC = (
5 UMASK => 0077,
6 GIT_CONFIG_KEYS => 'cgit\..*',
7 LOG_EXTRA => 1,
8 # logging options
9 # 1. leave this section as is for 'normal' gitolite logging (default)
10 # 2. uncomment this line to log ONLY to syslog:
11 # LOG_DEST => 'syslog',
12 # 3. uncomment this line to log to syslog and the normal gitolite log:
13 # LOG_DEST => 'syslog,normal',
14 # 4. prefixing "repo-log," to any of the above will **also** log just the
15 # update records to "gl-log" in the bare repo directory:
16 LOG_DEST => 'repo-log,normal',
17 # LOG_DEST => 'repo-log,syslog',
18 # LOG_DEST => 'repo-log,syslog,normal',
19 # syslog 'facility': defaults to 'local0', uncomment if needed. For example:
20 # LOG_FACILITY => 'local4',
21
22 # roles. add more roles (like MANAGER, TESTER, ...) here.
23 # WARNING: if you make changes to this hash, you MUST run 'gitolite
24 # compile' afterward, and possibly also 'gitolite trigger POST_COMPILE'
25 ROLES => {
26 READERS => 1,
27 WRITERS => 1,
28 },
29
30 # enable caching (currently only Redis). PLEASE RTFM BEFORE USING!!!
31 # CACHE => 'Redis',
32
33 # ------------------------------------------------------------------
34
35 # rc variables used by various features
36
37 # the 'info' command prints this as additional info, if it is set
38 SITE_INFO => 'Please see https://git.cosmos.party for more help',
39
40 # the CpuTime feature uses these
41 # display user, system, and elapsed times to user after each git operation
42 # DISPLAY_CPU_TIME => 1,
43 # display a warning if total CPU times (u, s, cu, cs) crosses this limit
44 # CPU_TIME_WARN_LIMIT => 0.1,
45
46 # the Mirroring feature needs this
47 # HOSTNAME => "foo",
48
49 # TTL for redis cache; PLEASE SEE DOCUMENTATION BEFORE UNCOMMENTING!
50 # CACHE_TTL => 600,
51
52 # ------------------------------------------------------------------
53
54 # suggested locations for site-local gitolite code (see cust.html)
55
56 # this one is managed directly on the server
57 LOCAL_CODE => "$ENV{HOME}/local",
58
59 # or you can use this, which lets you put everything in a subdirectory
60 # called "local" in your gitolite-admin repo. For a SECURITY WARNING
61 # on this, see http://gitolite.com/gitolite/non-core.html#using-the-gitolite-admin-repo-to-manage-non-core-code
62 # LOCAL_CODE => "$rc{GL_ADMIN_BASE}/local",
63
64 # ------------------------------------------------------------------
65
66 # List of commands and features to enable
67
68 ENABLE => [
69
70 # COMMANDS
71
72 # These are the commands enabled by default
73 'help',
74 'desc',
75 'info',
76 'perms',
77 'writable',
78
79 # Uncomment or add new commands here.
80 'create',
81 'fork',
82 'mirror',
83 'readme',
84 # 'sskm',
85 'D',
86 'config',
87 'creator',
88 'access',
89 'motd',
90 'option',
91
92 # These FEATURES are enabled by default.
93
94 # essential (unless you're using smart-http mode)
95 'ssh-authkeys',
96
97 # creates git-config entries from gitolite.conf file entries like 'config foo.bar = baz'
98 'git-config',
99
100 # creates git-daemon-export-ok files; if you don't use git-daemon, comment this out
101 'daemon',
102
103 # These FEATURES are disabled by default; uncomment to enable. If you
104 # need to add new ones, ask on the mailing list :-)
105
106 # user-visible behaviour
107
108 # prevent wild repos auto-create on fetch/clone
109 'no-create-on-read',
110 # no auto-create at all (don't forget to enable the 'create' command!)
111 # 'no-auto-create',
112
113 # access a repo by another (possibly legacy) name
114 'Alias',
115
116 # give some users direct shell access. See documentation in
117 # sts.html for details on the following two choices.
118 # "Shell $ENV{HOME}/.gitolite.shell-users",
119 # 'Shell alice bob',
120
121 # set default roles from lines like 'option default.roles-1 = ...', etc.
122 # 'set-default-roles',
123
124 # show more detailed messages on deny
125 'expand-deny-messages',
126
127 # show a message of the day
128 # 'Motd',
129
130 # system admin stuff
131
132 # enable mirroring (don't forget to set the HOSTNAME too!)
133 'Mirroring',
134
135 # allow people to submit pub files with more than one key in them
136 # 'ssh-authkeys-split',
137
138 # selective read control hack
139 # 'partial-copy',
140
141 # manage local, gitolite-controlled, copies of read-only upstream repos
142 # 'upstream',
143
144 # updates 'description' file instead of 'gitweb.description' config item
145 'cgit',
146
147 # allow repo-specific hooks to be added
148 'repo-specific-hooks',
149
150 # performance, logging, monitoring...
151
152 # be nice
153 'renice 10',
154
155 # log CPU times (user, system, cumulative user, cumulative system)
156 # 'CpuTime',
157
158 # syntactic_sugar for gitolite.conf and included files
159
160 # allow backslash-escaped continuation lines in gitolite.conf
161 # 'continuation-lines',
162
163 # create implicit user groups from directory names in keydir/
164 # 'keysubdirs-as-groups',
165
166 # allow simple line-oriented macros
167 # 'macros',
168
169 # Kindergarten mode
170
171 # disallow various things that sensible people shouldn't be doing anyway
172 # 'Kindergarten',
173 ],
174
175);
176
177# ------------------------------------------------------------------------------
178# per perl rules, this should be the last line in such a file:
1791;