Commit a98e398cfab943e53816cfe8994e472a2c3e6daf

Authored by Marin Jankovski
1 parent c720190f
Exists in master

Add webserver recipe and attributes.

files/gitlab-cookbooks/gitlab/attributes/default.rb
... ... @@ -233,6 +233,14 @@ default['gitlab']['redis']['shell'] = "/bin/nologin"
233 233 default['gitlab']['redis']['home'] = "/var/opt/gitlab/redis"
234 234 default['gitlab']['redis']['port'] = 6379
235 235  
  236 +####
  237 +# Web server
  238 +####
  239 +# Username for the webserver user
  240 +default['gitlab']['webserver']['username'] = 'gitlab-www'
  241 +default['gitlab']['webserver']['group'] = 'gitlab-www'
  242 +default['gitlab']['webserver']['uid'] = nil
  243 +default['gitlab']['webserver']['gid'] = nil
236 244  
237 245 ####
238 246 # Nginx
... ...
files/gitlab-cookbooks/gitlab/recipes/default.rb
... ... @@ -49,6 +49,7 @@ include_recipe "gitlab::users"
49 49 include_recipe "gitlab::gitlab-shell"
50 50 include_recipe "gitlab::gitlab-rails"
51 51 include_recipe "gitlab::selinux"
  52 +include_recipe "gitlab::web_server"
52 53  
53 54 # Create dummy unicorn and sidekiq services to receive notifications, in case
54 55 # the corresponding service recipe is not loaded below.
... ...
files/gitlab-cookbooks/gitlab/recipes/web_server.rb 0 → 100644
... ... @@ -0,0 +1,33 @@
  1 +#
  2 +# Copyright:: Copyright (c) 2012 Opscode, Inc.
  3 +# Copyright:: Copyright (c) 2014 GitLab.com
  4 +# License:: Apache License, Version 2.0
  5 +#
  6 +# Licensed under the Apache License, Version 2.0 (the "License");
  7 +# you may not use this file except in compliance with the License.
  8 +# You may obtain a copy of the License at
  9 +#
  10 +# http://www.apache.org/licenses/LICENSE-2.0
  11 +#
  12 +# Unless required by applicable law or agreed to in writing, software
  13 +# distributed under the License is distributed on an "AS IS" BASIS,
  14 +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15 +# See the License for the specific language governing permissions and
  16 +# limitations under the License.
  17 +#
  18 +
  19 +webserver_username = node['gitlab']['webserver']['username']
  20 +webserver_group = node['gitlab']['webserver']['group']
  21 +
  22 +# Create the group for the GitLab user
  23 +group webserver_group do
  24 + gid node['gitlab']['webserver']['gid']
  25 +end
  26 +
  27 +# Create the webserver user
  28 +user webserver_username do
  29 + shell node['gitlab']['user']['shell']
  30 + uid node['gitlab']['webserver']['uid']
  31 + gid webserver_group
  32 + supports manage_home: false
  33 +end
... ...
files/gitlab-cookbooks/gitlab/templates/default/nginx.conf.erb
... ... @@ -2,7 +2,7 @@
2 2 # erased! To change the contents below, edit /etc/gitlab/gitlab.rb
3 3 # and run `sudo gitlab-ctl reconfigure`.
4 4  
5   -user <%= node['gitlab']['user']['username'] %> <%= node['gitlab']['user']['username']%>;
  5 +user <%= node['gitlab']['user']['username'] %> <%= node['gitlab']['web_server']['username']%>;
6 6 worker_processes <%= @worker_processes %>;
7 7 error_log /var/log/gitlab/nginx/error.log;
8 8 pid /var/opt/gitlab/nginx/nginx.pid;
... ...