Commit 23e826c4 authored by Kirill Smelkov's avatar Kirill Smelkov

X Switch to jinja2

parent c0025cbc
...@@ -165,7 +165,7 @@ return = redis_ip redis_port ...@@ -165,7 +165,7 @@ return = redis_ip redis_port
# GitLab instance setup # # GitLab instance setup #
############################# #############################
# create gitlab dirs structure # 1. directories
[directory] [directory]
recipe = slapos.cookbook:mkdirectory recipe = slapos.cookbook:mkdirectory
home = ${buildout:directory} home = ${buildout:directory}
...@@ -202,41 +202,50 @@ etc = ${directory:etc}/gitlab-shell ...@@ -202,41 +202,50 @@ etc = ${directory:etc}/gitlab-shell
[gitlab-database.yml] # 2. configuration files
recipe = slapos.recipe.template [gitlab-etc-template]
url = {{ database_yml_in }} recipe = slapos.recipe.template:jinja2
output = ${gitlab:etc}/database.yml extensions = jinja2.ext.do
# FIXME aaa should not be here rendered= ${gitlab:etc}/${:_buildout_section_name_}
aaa = ${request-postgresql:connection-url} mode = 0640
[database.yml]
<= gitlab-etc-template
template= {{ database_yml_in }}
context =
section pgsql postgresql-urlparse
[gitlab.yml] [gitlab.yml]
recipe = slapos.recipe.template <= gitlab-etc-template
url = {{ gitlab_yml_in }} template= {{ gitlab_yml_in }}
output = ${gitlab:etc}/gitlab.yml context =
section gitlab gitlab
section gitlab_backend gitlab-backend
section instance_parameter instance-parameter
[resque.yml] [resque.yml]
recipe = slapos.recipe.template <= gitlab-etc-template
url = {{ resque_yml_in }} template= {{ resque_yml_in }}
output = ${gitlab:etc}/resque.yml context =
# FIXME aaa should not be here section redis request-redis
aaa = ${request-redis:connection-redis_ip}
[smtp_settings.rb] [smtp_settings.rb]
recipe = slapos.recipe.template <= gitlab-etc-template
url = {{ smtp_settings_rb_in }} template= {{ smtp_settings_rb_in }}
output = ${gitlab:etc}/smtp_settings.rb context =
section instance_parameter instance-parameter
# TODO log: logrotate # TODO log: logrotate
# bin/ # 3. bin/
# gitlab-rails # gitlab-rails
# gitlab-rake # gitlab-rake
# ? gitlab-unicorn # gitlab-unicorn
# ? gitlab-sidekiq # gitlab-sidekiq
[gitlab-bin] [gitlab-bin]
recipe = slapos.cookbook:wrapper recipe = slapos.cookbook:wrapper
wrapper-path = ${directory:bin}/${:_buildout_section_name_} wrapper-path = ${directory:bin}/${:_buildout_section_name_}
...@@ -318,13 +327,13 @@ command = ...@@ -318,13 +327,13 @@ command =
# config/ # config/
cd config && cd config &&
ln -s ${gitlab:etc}/unicorn.rb . && ln -s ${gitlab:etc}/unicorn.rb . &&
ln -s ${gitlab.yml:output} gitlab.yml && ln -s ${gitlab.yml:rendered} gitlab.yml &&
ln -s ${gitlab-database.yml:output} database.yml && ln -s ${database.yml:rendered} database.yml &&
ln -s ${resque.yml:output} resque.yml && ln -s ${resque.yml:rendered} resque.yml &&
# config/initializers/ # config/initializers/
cd initializers && cd initializers &&
ln -s ${gitlab:etc}/rack_attack.rb . && ln -s ${gitlab:etc}/rack_attack.rb . &&
ln -s ${smtp_settings.rb:output} smtp_settings.rb && ln -s ${smtp_settings.rb:rendered} smtp_settings.rb &&
# public/ # public/
cd ../../public && cd ../../public &&
rm -rf uploads && rm -rf uploads &&
......
...@@ -17,7 +17,7 @@ default = $${instance-gitlab.cfg:rendered} ...@@ -17,7 +17,7 @@ default = $${instance-gitlab.cfg:rendered}
[instance-gitlab.cfg] [instance-gitlab.cfg]
#<= jinja2-template-base #<= jinja2-template-base
recipe = slapos.recipe.template:jinja2 recipe = slapos.recipe.template:jinja2
mode = 0640 mode = 0644
template= ${instance-gitlab.cfg.in:target} template= ${instance-gitlab.cfg.in:target}
rendered= $${buildout:directory}/instance-gitlab.cfg rendered= $${buildout:directory}/instance-gitlab.cfg
context = context =
......
...@@ -7,10 +7,10 @@ production: ...@@ -7,10 +7,10 @@ production:
adapter: postgresql adapter: postgresql
encoding: unicode encoding: unicode
#database: gitlabhq_production #database: gitlabhq_production
database: ${postgresql-urlparse:path} database: {{ pgsql.path }}
pool: 10 pool: 10
username: '${postgresql-urlparse:username}' username: '{{ pgsql.username }}'
password: '${postgresql-urlparse:password}' password: '{{ pgsql.password }}'
host: ${postgresql-urlparse:host} host: {{ pgsql.host }}
port: ${postgresql-urlparse:port} port: {{ pgsql.port }}
# socket: # socket:
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
# https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-cookbooks/gitlab/templates/default/gitlab.yml.erb # https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-cookbooks/gitlab/templates/default/gitlab.yml.erb
# (last updated for v7.13.0.rc2) # (last updated for v7.13.0.rc2)
{# cfg(name) -> instance_parameter:configuration.<name> #}
{% macro cfg(name) %}{{ instance_parameter[str("configuration." + name)] }}{% endmacro %}
production: &base production: &base
# #
# 1. GitLab app settings # 1. GitLab app settings
...@@ -12,30 +15,30 @@ production: &base ...@@ -12,30 +15,30 @@ production: &base
## GitLab settings ## GitLab settings
gitlab: gitlab:
## Web server settings (note: host is the FQDN, do not include http://) ## Web server settings (note: host is the FQDN, do not include http://)
host: ${gitlab-backend:host} host: {{ gitlab_backend.host }}
port: ${gitlab-backend:port} port: {{ gitlab_backend.port }}
# TODO # TODO
#https: <%= @gitlab_https %> #https: <%= @gitlab_https %>
https: false https: false
# XXX temp workaround for gitlab not building correct url for host being ipv6 addr # XXX temp workaround for gitlab not building correct url for host being ipv6 addr
url: ${gitlab-backend:url} url: {{ gitlab_backend.url }}
user: ${gitlab-backend:user} user: {{ gitlab_backend.user }}
## Email settings ## Email settings
email_enabled: ${instance-parameter:configuration.email_enabled} email_enabled: {{ cfg('email_enabled') }}
email_from: ${instance-parameter:configuration.email_from} email_from: {{ cfg('email_from') }}
email_display_name: ${instance-parameter:configuration.email_display_name} email_display_name: {{ cfg('email_display_name') }}
email_reply_to: ${instance-parameter:configuration.email_reply_to} email_reply_to: {{ cfg('email_reply_to') }}
# Email server smtp settings are in template/smtp_settings.rb.in # Email server smtp settings are in template/smtp_settings.rb.in
## User settings ## User settings
default_can_create_group: ${instance-parameter:configuration.default_can_create_group} default_can_create_group: {{ cfg('default_can_create_group') }}
username_changing_enabled: ${instance-parameter:configuration.username_changing_enabled} username_changing_enabled: {{ cfg('username_changing_enabled') }}
default_theme: ${instance-parameter:configuration.default_theme} default_theme: {{ cfg('default_theme') }}
# TODO # TODO
# restricted_visibility_levels: ... # restricted_visibility_levels: ...
...@@ -43,14 +46,14 @@ production: &base ...@@ -43,14 +46,14 @@ production: &base
## Default project features settings ## Default project features settings
default_projects_features: default_projects_features:
issues: ${instance-parameter:configuration.default_projects_features.issues} issues: {{ cfg('default_projects_features.issues') }}
merge_requests: ${instance-parameter:configuration.default_projects_features.merge_requests} merge_requests: {{ cfg('default_projects_features.merge_requests') }}
wiki: ${instance-parameter:configuration.default_projects_features.wiki} wiki: {{ cfg('default_projects_features.wiki') }}
snippets: ${instance-parameter:configuration.default_projects_features.snippets} snippets: {{ cfg('default_projects_features.snippets') }}
visibility_level: '${instance-parameter:configuration.default_projects_features.visibility_level}' visibility_level: '{{ cfg("default_projects_features.visibility_level") }}'
## Webhook settings ## Webhook settings
webhook_timeout: ${instance-parameter:configuration.webhook_timeout} webhook_timeout: {{ cfg('webhook_timeout') }}
# TODO # TODO
# repository_downloads_path: ... # repository_downloads_path: ...
...@@ -89,8 +92,8 @@ production: &base ...@@ -89,8 +92,8 @@ production: &base
## Backup settings ## Backup settings
backup: backup:
path: ${gitlab:backup} path: {{ gitlab.backup }}
keep_time: ${instance-parameter:configuration.backup_keep_time} keep_time: {{ cfg('backup_keep_time') }}
upload: upload:
# TODO ? # TODO ?
# connection: ... # connection: ...
...@@ -100,10 +103,10 @@ production: &base ...@@ -100,10 +103,10 @@ production: &base
## GitLab Shell settings ## GitLab Shell settings
gitlab_shell: gitlab_shell:
path: ${gitlab-backend:gitlab-shell} path: {{ gitlab_backend['gitlab-shell'] }}
repos_path: ${gitlab:repositories} repos_path: {{ gitlab.repositories }}
hooks_path: ${gitlab-backend:gitlab-shell}/hooks/ hooks_path: {{ gitlab_backend['gitlab-shell'] }}/hooks/
# Git over HTTP is enabled # Git over HTTP is enabled
upload_pack: true upload_pack: true
...@@ -115,9 +118,9 @@ production: &base ...@@ -115,9 +118,9 @@ production: &base
## Git settings ## Git settings
git: git:
bin_path: ${gitlab-backend:git} bin_path: {{ gitlab_backend.git }}
max_size: ${instance-parameter:configuration.git_max_size} max_size: {{ cfg('git_max_size') }}
timeout: ${instance-parameter:configuration.git_timeout} timeout: {{ cfg('git_timeout') }}
# #
......
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
# https://gitlab.com/gitlab-org/gitlab-ce/blob/master/config/resque.yml.example # https://gitlab.com/gitlab-org/gitlab-ce/blob/master/config/resque.yml.example
# https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-cookbooks/gitlab/templates/default/resque.yml.erb # https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-cookbooks/gitlab/templates/default/resque.yml.erb
production: redis://[${request-redis:connection-redis_ip}]:${request-redis:connection-redis_port} production: redis://[{{ redis['connection-redis_ip'] }}]:{{ redis['connection-redis_port'] }}
...@@ -3,17 +3,22 @@ ...@@ -3,17 +3,22 @@
# https://gitlab.com/gitlab-org/gitlab-ce/blob/master/config/initializers/smtp_settings.rb.sample # https://gitlab.com/gitlab-org/gitlab-ce/blob/master/config/initializers/smtp_settings.rb.sample
# https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-cookbooks/gitlab/templates/default/smtp_settings.rb.erb # https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/files/gitlab-cookbooks/gitlab/templates/default/smtp_settings.rb.erb
{# cfg(name) -> instance_parameter:configuration.<name> #}
{# XXX dup -> import from gitlab.yml.in ? #}
{% macro cfg(name) %}{{ instance_parameter[str("configuration." + name)] }}{% endmacro %}
if Rails.env.production? if Rails.env.production?
Gitlab::Application.config.action_mailer.delivery_method = :smtp Gitlab::Application.config.action_mailer.delivery_method = :smtp
ActionMailer::Base.smtp_settings = { ActionMailer::Base.smtp_settings = {
address: "${instance-parameter:configuration.smtp_address}", address: "{{ cfg('smtp_address') }}",
port: ${instance-parameter:configuration.smtp_port}, port: {{ cfg('smtp_port') }},
user_name: "${instance-parameter:configuration.smtp_user_name}", user_name: "{{ cfg('smtp_user_name') }}",
password: "${instance-parameter:configuration.smtp_password}", password: "{{ cfg('smtp_password') }}",
domain: "${instance-parameter:configuration.smtp_domain}", domain: "{{ cfg('smtp_domain') }}",
authentication: :${instance-parameter:configuration.smtp_authentication}, authentication: :{{ cfg('smtp_authentication') }},
enable_starttls_auto: ${instance-parameter:configuration.smtp_enable_starttls_auto}, enable_starttls_auto: {{ cfg('smtp_enable_starttls_auto') }},
openssl_verify_mode: '${instance-parameter:configuration.smtp_openssl_verify_mode}' openssl_verify_mode: '{{ cfg("smtp_openssl_verify_mode") }}'
} }
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment