Commit be30154cbd22dda9b3ade438ce66ae2da9139362
1 parent
a621a76a
Exists in
master
and in
4 other branches
Add a recipe for the remote-syslog service
Showing
9 changed files
with
100 additions
and
0 deletions
Show diff stats
files/gitlab-cookbooks/gitlab/attributes/default.rb
@@ -258,3 +258,14 @@ default['gitlab']['logging']['svlogd_timeout'] = 24 * 60 * 60 # rotate after 24 | @@ -258,3 +258,14 @@ default['gitlab']['logging']['svlogd_timeout'] = 24 * 60 * 60 # rotate after 24 | ||
258 | default['gitlab']['logging']['svlogd_filter'] = "gzip" # compress logs with gzip | 258 | default['gitlab']['logging']['svlogd_filter'] = "gzip" # compress logs with gzip |
259 | default['gitlab']['logging']['svlogd_udp'] = nil # transmit log messages via UDP | 259 | default['gitlab']['logging']['svlogd_udp'] = nil # transmit log messages via UDP |
260 | default['gitlab']['logging']['svlogd_prefix'] = nil # custom prefix for log messages | 260 | default['gitlab']['logging']['svlogd_prefix'] = nil # custom prefix for log messages |
261 | + | ||
262 | +### | ||
263 | +# Remote syslog | ||
264 | +### | ||
265 | +default['gitlab']['remote-syslog']['enable'] = false | ||
266 | +default['gitlab']['remote-syslog']['ha'] = false | ||
267 | +default['gitlab']['remote-syslog']['dir'] = "/var/opt/gitlab/remote-syslog" | ||
268 | +default['gitlab']['remote-syslog']['log_directory'] = "/var/log/gitlab/remote-syslog" | ||
269 | +default['gitlab']['remote-syslog']['destination_host'] = "localhost" | ||
270 | +default['gitlab']['remote-syslog']['destination_port'] = 514 | ||
271 | +default['gitlab']['remote-syslog']['services'] = %w{redis nginx unicorn gitlab-rails postgresql sidekiq} |
files/gitlab-cookbooks/gitlab/libraries/gitlab.rb
@@ -44,6 +44,7 @@ module Gitlab | @@ -44,6 +44,7 @@ module Gitlab | ||
44 | sidekiq Mash.new | 44 | sidekiq Mash.new |
45 | nginx Mash.new | 45 | nginx Mash.new |
46 | logging Mash.new | 46 | logging Mash.new |
47 | + remote_syslog Mash.new | ||
47 | node nil | 48 | node nil |
48 | external_url nil | 49 | external_url nil |
49 | git_data_dir nil | 50 | git_data_dir nil |
@@ -132,6 +133,7 @@ module Gitlab | @@ -132,6 +133,7 @@ module Gitlab | ||
132 | "sidekiq", | 133 | "sidekiq", |
133 | "nginx", | 134 | "nginx", |
134 | "logging", | 135 | "logging", |
136 | + "remote_syslog", | ||
135 | "postgresql" | 137 | "postgresql" |
136 | ].each do |key| | 138 | ].each do |key| |
137 | rkey = key.gsub('_', '-') | 139 | rkey = key.gsub('_', '-') |
files/gitlab-cookbooks/gitlab/recipes/default.rb
@@ -70,6 +70,7 @@ include_recipe "runit" | @@ -70,6 +70,7 @@ include_recipe "runit" | ||
70 | "unicorn", | 70 | "unicorn", |
71 | "sidekiq", | 71 | "sidekiq", |
72 | "nginx", | 72 | "nginx", |
73 | + "remote-syslog", | ||
73 | "bootstrap", | 74 | "bootstrap", |
74 | ].each do |service| | 75 | ].each do |service| |
75 | if node["gitlab"][service]["enable"] | 76 | if node["gitlab"][service]["enable"] |
@@ -0,0 +1,48 @@ | @@ -0,0 +1,48 @@ | ||
1 | +# | ||
2 | +# Copyright:: Copyright (c) 2014 GitLab B.V. | ||
3 | +# License:: Apache License, Version 2.0 | ||
4 | +# | ||
5 | +# Licensed under the Apache License, Version 2.0 (the "License"); | ||
6 | +# you may not use this file except in compliance with the License. | ||
7 | +# You may obtain a copy of the License at | ||
8 | +# | ||
9 | +# http://www.apache.org/licenses/LICENSE-2.0 | ||
10 | +# | ||
11 | +# Unless required by applicable law or agreed to in writing, software | ||
12 | +# distributed under the License is distributed on an "AS IS" BASIS, | ||
13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
14 | +# See the License for the specific language governing permissions and | ||
15 | +# limitations under the License. | ||
16 | +# | ||
17 | + | ||
18 | +remote_syslog_dir = node['gitlab']['remote-syslog']['dir'] | ||
19 | +remote_syslog_log_dir = node['gitlab']['remote-syslog']['log_directory'] | ||
20 | + | ||
21 | +[ | ||
22 | + remote_syslog_dir, | ||
23 | + remote_syslog_log_dir | ||
24 | +].each do |dir| | ||
25 | + directory dir do | ||
26 | + mode "0700" | ||
27 | + end | ||
28 | +end | ||
29 | + | ||
30 | +template File.join(remote_syslog_dir, "remote_syslog.yml") do | ||
31 | + mode "0644" | ||
32 | + variables(node['gitlab']['remote-syslog'].to_hash) | ||
33 | + notifies :restart, 'service[remote-syslog]' if OmnibusHelper.should_notify?("remote-syslog") | ||
34 | +end | ||
35 | + | ||
36 | +runit_service "remote-syslog" do | ||
37 | + down node['gitlab']['remote-syslog']['ha'] | ||
38 | + options({ | ||
39 | + :log_directory => remote_syslog_log_dir | ||
40 | + }.merge(params)) | ||
41 | + log_options node['gitlab']['logging'].to_hash.merge(node['gitlab']['remote-syslog'].to_hash) | ||
42 | +end | ||
43 | + | ||
44 | +if node['gitlab']['bootstrap']['enable'] | ||
45 | + execute "/opt/gitlab/bin/gitlab-ctl start remote-syslog" do | ||
46 | + retries 20 | ||
47 | + end | ||
48 | +end |
files/gitlab-cookbooks/gitlab/recipes/remote-syslog_disable.rb
0 → 100644
@@ -0,0 +1,20 @@ | @@ -0,0 +1,20 @@ | ||
1 | +# | ||
2 | +# Copyright:: Copyright (c) 2014 GitLab.com | ||
3 | +# License:: Apache License, Version 2.0 | ||
4 | +# | ||
5 | +# Licensed under the Apache License, Version 2.0 (the "License"); | ||
6 | +# you may not use this file except in compliance with the License. | ||
7 | +# You may obtain a copy of the License at | ||
8 | +# | ||
9 | +# http://www.apache.org/licenses/LICENSE-2.0 | ||
10 | +# | ||
11 | +# Unless required by applicable law or agreed to in writing, software | ||
12 | +# distributed under the License is distributed on an "AS IS" BASIS, | ||
13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
14 | +# See the License for the specific language governing permissions and | ||
15 | +# limitations under the License. | ||
16 | +# | ||
17 | + | ||
18 | +runit_service "remote-syslog" do | ||
19 | + action :disable | ||
20 | +end |
files/gitlab-cookbooks/gitlab/templates/default/remote_syslog.yml.erb
0 → 100644
files/gitlab-cookbooks/gitlab/templates/default/sv-remote-syslog-log-config.erb
0 → 100644
files/gitlab-cookbooks/gitlab/templates/default/sv-remote-syslog-log-run.erb
0 → 100644
files/gitlab-cookbooks/gitlab/templates/default/sv-remote-syslog-run.erb
0 → 100644