-
-
Notifications
You must be signed in to change notification settings - Fork 166
/
Copy pathgitlab.rb.erb
556 lines (449 loc) · 17.1 KB
/
gitlab.rb.erb
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
## THIS CONFIGURATION IS MANAGED BY PUPPET
# for all possible parameters, see:
# https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-config-template/gitlab.rb.template
<%-
# As this template is writing a config file based on some hashes and hashes are not meant to be in a certain order,
# We need to ensure that the order of the keys are always outputed in the same order.
# Otherwise puppet will always update(change) the config file.
def sort_hash_by_key(hash, deep=true, &block)
if hash.kind_of?(Hash)
hash.keys.sort(&block).reduce({}) do |memo, key|
memo[key] = hash[key]
if deep && memo[key].kind_of?(Hash)
memo[key] = sort_hash_by_key(memo[key], true, &block)
end
memo
end
end
end
def numify(obj)
if obj.is_a?(String)
Integer(obj) rescue Float(obj) rescue obj
elsif obj.is_a?(Array)
obj.map { |item| numify(item) }
elsif obj.is_a?(Hash)
sort_hash_by_key(obj.merge(obj) { |_, v| numify(v) })
else
obj
end
end
def decorate(v)
numify(v).inspect
end
-%>
## Url on which GitLab will be reachable.
## For more details on configuring external_url see:
## https://gitlab.com/gitlab-org/omnibus-gitlab/blob/629def0a7a26e7c2326566f0758d4a27857b52a3/README.md#configuring-the-external-url-for-gitlab
external_url '<%= @external_url %>'
<%- if @external_port -%>
external_port '<%= @external_port %>'
<%- end -%>
<%- if @roles -%>
## Roles for multi-instance GitLab
##! The default is to have no roles enabled, which results in GitLab running as an all-in-one instance.
##! Options:
##! redis_sentinel_role redis_master_role redis_slave_role geo_primary_role geo_secondary_role
##! For more deatils on each role, see:
##! https://docs.gitlab.com/omnibus/roles/README.html#roles
roles <%= decorate(@roles) %>
<%- end -%>
<%- if @git_data_dirs -%>
### For setting up different data storing directory
###! Docs: https://docs.gitlab.com/omnibus/settings/configuration.html#storing-git-data-in-an-alternative-directory
###! **If you want to use a single non-default directory to store git data use a
###! path that doesn't contain symlinks.**
git_data_dirs(<%= decorate(@git_data_dirs) %>)
<%- end -%>
<%- if @gitlab_rails -%>
############################
# gitlab.yml configuration #
############################
<%- @gitlab_rails.keys.sort.each do |k| -%>
gitlab_rails['<%= k -%>'] = <%= decorate(@gitlab_rails[k]) %>
<%- end end -%>
<%- if @user -%>
###############
# GitLab user #
###############
## see https://gitlab.com/gitlab-org/omnibus-gitlab/tree/629def0a7a26e7c2326566f0758d4a27857b52a3/README.md#changing-the-name-of-the-git-user-group
## Modify default git user.
<%- @user.keys.sort.each do |k| -%>
user['<%= k -%>'] = <%= decorate(@user[k]) %>
<%- end end -%>
<%- if @unicorn -%>
##################
# GitLab Unicorn #
##################
## Tweak unicorn settings.
<%- @unicorn.keys.sort.each do |k| -%>
unicorn['<%= k -%>'] = <%= decorate(@unicorn[k]) %>
<%- end end -%>
<%- if @sidekiq -%>
##################
# GitLab Sidekiq #
##################
<%- @sidekiq.keys.sort.each do |k| -%>
sidekiq['<%= k -%>'] = <%= decorate(@sidekiq[k]) %>
<%- end end -%>
<%- if @sidekiq_cluster -%>
##########################
# GitLab Sidekiq Cluster #
##########################
<%- @sidekiq_cluster.keys.sort.each do |k| -%>
sidekiq_cluster['<%= k -%>'] = <%= decorate(@sidekiq_cluster[k]) %>
<%- end end -%>
<%- if @shell -%>
################
# gitlab-shell #
################
<%- @shell.keys.sort.each do |k| -%>
gitlab_shell['<%= k -%>'] = <%= decorate(@shell[k]) %>
<%- end end -%>
<%- if @postgresql -%>
#####################
# GitLab PostgreSQL #
#####################
<%- @postgresql.keys.sort.each do |k| -%>
postgresql['<%= k -%>'] = <%= decorate(@postgresql[k]) %>
<%- end end -%>
<%- if @redis -%>
################
# GitLab Redis #
################
## Can be disabled if you are using your own redis instance.
<%- @redis.keys.sort.each do |k| -%>
redis['<%= k -%>'] = <%= decorate(@redis[k]) %>
<%- end end -%>
<%- if @redis_master_role -%>
#######################
# Gitlab Redis Master #
#######################
## see https://docs.gitlab.com/omnibus/settings/redis.html
## see https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-config-template/gitlab.rb.template#L667
redis_master_role['enable'] = true
<%- end -%>
<%- if @redis_slave_role -%>
#######################
# Gitlab Redis Slave #
#######################
## see https://docs.gitlab.com/omnibus/settings/redis.html
## see https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-config-template/gitlab.rb.template#L668
redis_slave_role['enable'] = true
<%- end -%>
<%- if @web_server -%>
#####################
# GitLab Web server #
#####################
## see: https://gitlab.com/gitlab-org/omnibus-gitlab/tree/629def0a7a26e7c2326566f0758d4a27857b52a3/doc/settings/nginx.md#using-a-non-bundled-web-server
## When bundled nginx is disabled we need to add the external webserver user to the GitLab webserver group.
<%- @web_server.keys.sort.each do |k| -%>
web_server['<%= k -%>'] = <%= decorate(@web_server[k]) %>
<%- end end -%>
<%- if @gitlab_git_http_server -%>
##########################
# GitLab Git HTTP server #
##########################
## see: https://about.gitlab.com/2015/08/22/gitlab-7-14-released/
<%- @gitlab_git_http_server.keys.sort.each do |k| -%>
gitlab_git_http_server['<%= k -%>'] = <%= decorate(@gitlab_git_http_server[k]) %>
<%- end end -%>
<%- if @nginx -%>
################
# GitLab Nginx #
################
## see: https://gitlab.com/gitlab-org/omnibus-gitlab/tree/629def0a7a26e7c2326566f0758d4a27857b52a3/doc/settings/nginx.md
<%- @nginx.keys.sort.each do |k| -%>
nginx['<%= k -%>'] = <%= decorate(@nginx[k]) %>
<%- end end -%>
<%- if @gitlab_workhorse -%>
####################
# GitLab Workhorse #
####################
<%- @gitlab_workhorse.keys.sort.each do |k| -%>
gitlab_workhorse['<%= k -%>'] = <%= decorate(@gitlab_workhorse[k]) %>
<%- end end -%>
<%- if @letsencrypt -%>
######################
# GitLab Letsencrypt #
######################
## see: https://docs.gitlab.com/omnibus/settings/ssl.html#let-39-s-encrypt-integration
<%- @letsencrypt.keys.sort.each do |k| -%>
letsencrypt['<%= k -%>'] = <%= decorate(@letsencrypt[k]) %>
<%- end end -%>
<%- if @logging -%>
##################
# GitLab Logging #
##################
## see: https://gitlab.com/gitlab-org/omnibus-gitlab/tree/629def0a7a26e7c2326566f0758d4a27857b52a3/README.md#logs
<%- @logging.keys.sort.each do |k| -%>
logging['<%= k -%>'] = <%= decorate(@logging[k]) %>
<%- end end -%>
<%- if @logrotate -%>
#############
# Logrotate #
#############
## see: https://gitlab.com/gitlab-org/omnibus-gitlab/tree/629def0a7a26e7c2326566f0758d4a27857b52a3/README.md#logrotate
## You can disable built in logrotate feature.
<%- @logrotate.keys.sort.each do |k| -%>
logrotate['<%= k -%>'] = <%= decorate(@logrotate[k]) %>
<%- end end -%>
<%- if @manage_storage_directories -%>
#######################
# Storage directories #
#######################
## Disable managing storage directories
## Set only if the select directories are created manually
## See: http://doc.gitlab.com/omnibus/settings/configuration.html#disable-storage-directories-management
# manage_storage_directories['enable'] = false
<%- @manage_storage_directories.keys.sort.each do |k| -%>
manage_storage_directories['<%= k -%>'] = <%= decorate(@manage_storage_directories[k]) %>
<%- end end -%>
<%- if @git -%>
#######
# Git #
#######
## Advanced setting for configuring git system settings for omnibus-gitlab internal git
## For multiple options under one header use array of comma separated values, eg.
## { "receive" => ["fsckObjects = true"], "alias" => ["st = status", "co = checkout"] }
<%- @git.keys.sort.each do |k| -%>
omnibus_gitconfig['<%= k -%>'] = <%= decorate(@git[k]) %>
<%- end end -%>
<%- if @registry -%>
############################
# registry configuration #
############################
<%- @registry.keys.sort.each do |k| -%>
registry['<%= k -%>'] = <%= decorate(@registry[k]) %>
<%- end end -%>
<%- if @gitlab_ci -%>
#################################
# application.yml configuration #
#################################
<%- @gitlab_ci.keys.sort.each do |k| -%>
gitlab_ci['<%= k -%>'] = <%= decorate(@gitlab_ci[k]) %>
<%- end end -%>
<%- if @ci_unicorn -%>
#####################
# GitLab CI Unicorn #
#####################
## Tweak unicorn settings.
<%- @ci_unicorn.keys.sort.each do |k| -%>
ci_unicorn['<%= k -%>'] = <%= decorate(@ci_unicorn[k]) %>
<%- end end -%>
<%- if @ci_redis -%>
###################
# GitLab CI Redis #
###################
## see https://gitlab.com/gitlab-org/omnibus-gitlab/tree/629def0a7a26e7c2326566f0758d4a27857b52a3/doc/settings/redis.md
## You can turn off bundled redis if you want to use your own redis instanance
<%- @ci_redis.keys.sort.each do |k| -%>
ci_redis['<%= k -%>'] = <%= decorate(@ci_redis[k]) %>
<%- end end -%>
<%- if @prometheus or defined?(@prometheus_monitoring) -%>
##############
# Prometheus #
##############
##! Docs: https://docs.gitlab.com/ce/administration/monitoring/performance/prometheus.html
<%- if defined?(@prometheus_monitoring) -%>prometheus_monitoring['enable'] = <%= @prometheus_monitoring %>
<%- end -%>
<%- if @prometheus %>
<%- @prometheus.keys.sort.each do |k| -%>
prometheus['<%= k -%>'] = <%= decorate(@prometheus[k]) %>
<%- end end end -%>
<%- if @node_exporter -%>
############################
# Prometheus Node Exporter #
############################
##! Docs: https://docs.gitlab.com/ce/administration/monitoring/performance/prometheus.html
<%- @node_exporter.keys.sort.each do |k| -%>
node_exporter['<%= k -%>'] = <%= decorate(@node_exporter[k]) %>
<%- end end -%>
<%- if @redis_exporter -%>
################################################################################
## Prometheus Redis exporter
##! Docs: https://docs.gitlab.com/ce/administration/monitoring/performance/prometheus.html
<%- @redis_exporter.keys.sort.each do |k| -%>
redis_exporter['<%= k -%>'] = <%= decorate(@redis_exporter[k]) %>
<%- end end -%>
<%- if @postgres_exporter -%>
################################################################################
## Postgres exporter
##! Docs: https://docs.gitlab.com/ce/administration/monitoring/performance/prometheus.html
<%- @postgres_exporter.keys.sort.each do |k| -%>
postgres_exporter['<%= k -%>'] = <%= decorate(@postgres_exporter[k]) %>
<%- end end -%>
<%- if @alertmanager -%>
################################################################################
## Alertmanager
##! Docs: https://prometheus.io/docs/alerting/alertmanager/
<%- @alertmanager.keys.sort.each do |k| -%>
alertmanager['<%= k -%>'] = <%= decorate(@alertmanager[k]) %>
<%- end end -%>
<%- if @gitlab_monitor -%>
################################################################################
## Gitlab monitor
##! Docs: https://docs.gitlab.com/ce/administration/monitoring/performance/prometheus.html
<%- @gitlab_monitor.keys.sort.each do |k| -%>
gitlab_monitor['<%= k -%>'] = <%= decorate(@gitlab_monitor[k]) %>
<%- end end -%>
<%- if @gitlab_exporter -%>
################################################################################
## Prometheus Gitlab exporter
##! Docs: https://docs.gitlab.com/ce/administration/monitoring/prometheus/gitlab_exporter.html
<%- @gitlab_exporter.keys.sort.each do |k| -%>
gitlab_exporter['<%= k -%>'] = <%= decorate(@gitlab_exporter[k]) %>
<%- end end -%>
<%- if @high_availability -%>
#####################
# High Availability #
#####################
## see: https://gitlab.com/gitlab-org/omnibus-gitlab/blob/629def0a7a26e7c2326566f0758d4a27857b52a3/README.md#only-start-omnibus-gitlab-services-after-a-given-filesystem-is-mounted
<%- @high_availability.keys.sort.each do |k| -%>
high_availability['<%= k -%>'] = <%= decorate(@high_availability[k]) %>
<%- end end -%>
<%- if @mattermost_external_url -%>
#############################################
# Url on which Mattermost will be reachable #
#############################################
## see http://doc.gitlab.com/omnibus/gitlab-mattermost/
mattermost_external_url '<%= @mattermost_external_url %>'
<%- end -%>
<%- if @mattermost -%>
#####################
# GitLab Mattermost #
#####################
## see: http://doc.gitlab.com/omnibus/gitlab-mattermost/
<%- @mattermost.keys.sort.each do |k| -%>
mattermost['<%= k -%>'] = <%= decorate(@mattermost[k]) %>
<%- end end -%>
<%- if @_real_mattermost_nginx -%>
#####################
# Mattermost NGINX #
#####################
## see: http://doc.gitlab.com/omnibus/gitlab-mattermost/
<%- @_real_mattermost_nginx.keys.sort.each do |k| -%>
mattermost_nginx['<%= k -%>'] = <%= decorate(@_real_mattermost_nginx[k]) %>
<%- end end -%>
<%- if @grafana -%>
##################
# GitLab Grafana #
##################
## see: https://docs.gitlab.com/omnibus/settings/grafana/
<%- @grafana.keys.sort.each do |k| -%>
grafana['<%= k -%>'] = <%= decorate(@grafana[k]) %>
<%- end end -%>
<%- if @pages_external_url -%>
####################
# GitLab Pages
####################
## Define to enable GitLab Pages
pages_external_url '<%= @pages_external_url %>'
<%- end -%>
<%- if @gitlab_pages -%>
<%- @gitlab_pages.keys.sort.each do |k| -%>
gitlab_pages['<%= k -%>'] = <%= decorate(@gitlab_pages[k]) %>
<%- end end -%>
<%- if @_real_pages_nginx -%>
######################
# GitLab Pages NGINX #
######################
## see: http://doc.gitlab.com/ee/pages/administration.html
<%- @_real_pages_nginx.keys.sort.each do |k| -%>
pages_nginx['<%= k -%>'] = <%= decorate(@_real_pages_nginx[k]) %>
<%- end end -%>
<%- if @registry_external_url -%>
############
# Registry #
############
registry_external_url '<%= @registry_external_url %>'
<%- end -%>
<%- if @_real_registry_nginx -%>
##################
# Registry NGINX #
##################
<%- @_real_registry_nginx.keys.sort.each do |k| -%>
registry_nginx['<%= k -%>'] = <%= decorate(@_real_registry_nginx[k]) %>
<%- end end -%>
<%- if @manage_accounts -%>
###################
# Manage Accounts #
###################
## see: https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/settings/configuration.md#disable-user-and-group-account-management
<%- @manage_accounts.keys.sort.each do |k| -%>
manage_accounts['<%= k -%>'] = <%= decorate(@manage_accounts[k]) %>
<%- end end -%>
<%- if @redis_sentinel_role -%>
##################
# Redis Sentinel #
##################
redis_sentinel_role['enable'] = true
<%- end -%>
<%- if @sentinel -%>
###################
# GitLab Sentinel #
###################
## To enable Sentinel and disable all other services in this machine, enable below section.
## https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-config-template/gitlab.rb.template#L1406-1453
<%- @sentinel.keys.sort.each do |k| -%>
sentinel['<%= k -%>'] = <%= decorate(@sentinel[k]) %>
<%- end end -%>
<%- if @gitaly -%>
##########
# Gitaly #
##########
## To configure Gitaly, refer below section
## https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-config-template/gitlab.rb.template#L1352-1363
<%- @gitaly.keys.sort.each do |k| -%>
gitaly['<%= k -%>'] = <%= decorate(@gitaly[k]) %>
<%- end end -%>
<%- if @geo_primary_role -%>
#####################
# Gitlab Geo Primary#
#####################
## To configure Gitlab Geo, refer below section.
## https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-config-template/gitlab.rb.template#L1459
geo_primary_role['enable'] = true
<%- end -%>
<%- if @geo_secondary_role -%>
#######################
# Gitlab Geo Secondary#
#######################
## To configure Gitlab Geo, refer below section.
## https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-config-template/gitlab.rb.template#1463-L1481
geo_secondary_role['enable'] = true
<%- if @geo_secondary -%>
<%- @geo_secondary.keys.sort.each do |k| -%>
geo_secondary['<%= k -%>'] = <%= decorate(@geo_secondary[k]) %>
<%- end end -%>
<%- end -%>
<%- if @geo_postgresql -%>
########################
# Gitlab Geo Postgresql#
########################
## To configure GitLab Geo Secondary Tracking Database (EE only).
<%- @geo_postgresql.keys.sort.each do |k| -%>
geo_postgresql['<%= k -%>'] = <%= decorate(@geo_postgresql[k]) %>
<%- end end -%>
<%- if @pgbouncer -%>
################################################################################
# Pgbouncer (EE only)
# See [GitLab PgBouncer documentation](http://docs.gitlab.com/omnibus/settings/database.html#enabling-pgbouncer-ee-only)
# See the [PgBouncer page](https://pgbouncer.github.io/config.html) for details
################################################################################
<%- @pgbouncer.keys.sort.each do |k| -%>
pgbouncer['<%= k -%>'] = <%= decorate(@pgbouncer[k]) %>
<%- end end -%>
<%- if @repmgr -%>
################################################################################
# repmgr (EE only)
################################################################################
<%- @repmgr.keys.sort.each do |k| -%>
repmgr['<%= k -%>'] = <%= decorate(@repmgr[k]) %>
<%- end end -%>
<%- if @consul -%>
################################################################################
# consul (EEP only)
################################################################################
<%- @consul.keys.sort.each do |k| -%>
consul['<%= k -%>'] = <%= decorate(@consul[k]) %>
<%- end end -%>