Merge branch 'sysctl_definition' into 'master'
Sysctl definition Moved all sysctl related changes to a definition. Creating a separate file for our own sysctl configuration. Link that file into `/etc/sysctl.d` which is loaded at system startup. Allows editing sysctl values and it reloads the configuration after editing. Confirmed working on `CentOS release 6.5 (Final)`. Fixes #662 Fixes #700 Hopefully fixes #788 See merge request !470
This commit is contained in:
commit
5481024558
|
@ -0,0 +1,61 @@
|
|||
#
|
||||
# Copyright:: Copyright (c) 2015 GitLab B.V.
|
||||
# License:: Apache License, Version 2.0
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
define :sysctl, value: nil do
|
||||
param = params[:name]
|
||||
value = params[:value]
|
||||
|
||||
directory "/etc/sysctl.d" do
|
||||
mode "0755"
|
||||
recursive true
|
||||
end
|
||||
|
||||
file "/opt/gitlab/embedded/etc/90-omnibus-gitlab.conf" do
|
||||
action :create_if_missing
|
||||
manage_symlink_source true
|
||||
end
|
||||
|
||||
ruby_block "maintain sysctl config" do
|
||||
block do
|
||||
fe = Chef::Util::FileEdit.new("/opt/gitlab/embedded/etc/90-omnibus-gitlab.conf")
|
||||
fe.search_file_replace_line(/^#{param} = /,"#{param} = #{value}")
|
||||
fe.insert_line_if_no_match(/^#{param} = /,"#{param} = #{value}")
|
||||
fe.write_file
|
||||
if fe.file_edited?
|
||||
resources(execute: "sysctl").run_action(:run, :immediately)
|
||||
end
|
||||
end
|
||||
not_if "sysctl -n #{param} | grep -q -x #{value}"
|
||||
end
|
||||
|
||||
link "/opt/gitlab/embedded/etc/90-omnibus-gitlab.conf" do
|
||||
to "/etc/sysctl.d/90-omnibus-gitlab.conf"
|
||||
end
|
||||
|
||||
["/etc/sysctl.d/90-postgresql.conf", "/etc/sysctl.d/90-unicorn.conf"].each do |conf|
|
||||
file conf do
|
||||
action :delete
|
||||
only_if { File.exists?(conf) }
|
||||
end
|
||||
end
|
||||
# Load the settings right away
|
||||
execute "sysctl" do
|
||||
command "cat /etc/sysctl.conf /etc/sysctl.d/*.conf | sysctl -e -p -"
|
||||
action :nothing
|
||||
end
|
||||
end
|
||||
|
|
@ -65,35 +65,12 @@ PATH=#{node['gitlab']['postgresql']['user_path']}
|
|||
EOH
|
||||
end
|
||||
|
||||
if File.directory?("/etc/sysctl.d") && File.exists?("/etc/init.d/procps")
|
||||
# smells like ubuntu...
|
||||
service "procps" do
|
||||
action :nothing
|
||||
end
|
||||
sysctl "kernel.shmmax" do
|
||||
value node['gitlab']['postgresql']['shmmax']
|
||||
end
|
||||
|
||||
template "/etc/sysctl.d/90-postgresql.conf" do
|
||||
source "90-postgresql.conf.sysctl.erb"
|
||||
owner "root"
|
||||
mode "0644"
|
||||
variables(node['gitlab']['postgresql'].to_hash)
|
||||
notifies :start, 'service[procps]', :immediately
|
||||
end
|
||||
else
|
||||
# hope this works...
|
||||
execute "sysctl" do
|
||||
command "/sbin/sysctl -p /etc/sysctl.conf"
|
||||
action :nothing
|
||||
end
|
||||
|
||||
bash "add shm settings" do
|
||||
user "root"
|
||||
code <<-EOF
|
||||
echo 'kernel.shmmax = #{node['gitlab']['postgresql']['shmmax']}' >> /etc/sysctl.conf
|
||||
echo 'kernel.shmall = #{node['gitlab']['postgresql']['shmall']}' >> /etc/sysctl.conf
|
||||
EOF
|
||||
notifies :run, 'execute[sysctl]', :immediately
|
||||
not_if "egrep '^kernel.shmmax = ' /etc/sysctl.conf"
|
||||
end
|
||||
sysctl "kernel.shmall" do
|
||||
value node['gitlab']['postgresql']['shmall']
|
||||
end
|
||||
|
||||
execute "/opt/gitlab/embedded/bin/initdb -D #{postgresql_data_dir} -E UTF8" do
|
||||
|
|
|
@ -22,32 +22,7 @@ unicorn_service 'unicorn' do
|
|||
user account_helper.gitlab_user
|
||||
end
|
||||
|
||||
if File.directory?("/etc/sysctl.d") && File.exists?("/etc/init.d/procps")
|
||||
# smells like ubuntu...
|
||||
service "procps" do
|
||||
action :nothing
|
||||
end
|
||||
|
||||
template "/etc/sysctl.d/90-unicorn.conf" do
|
||||
source "90-unicorn.conf.sysctl.erb"
|
||||
owner "root"
|
||||
mode "0644"
|
||||
variables(node['gitlab']['unicorn'].to_hash)
|
||||
notifies :start, 'service[procps]', :immediately
|
||||
end
|
||||
else
|
||||
# hope this works...
|
||||
execute "sysctl" do
|
||||
command "/sbin/sysctl -p /etc/sysctl.conf"
|
||||
action :nothing
|
||||
end
|
||||
|
||||
bash "add somaxconn settings" do
|
||||
user "root"
|
||||
code <<-EOF
|
||||
echo 'net.core.somaxconn = #{node['gitlab']['unicorn']['somaxconn']}' >> /etc/sysctl.conf
|
||||
EOF
|
||||
notifies :run, 'execute[sysctl]', :immediately
|
||||
not_if "egrep '^net.core.somaxconn = ' /etc/sysctl.conf"
|
||||
end
|
||||
sysctl "net.core.somaxconn" do
|
||||
value node['gitlab']['unicorn']['somaxconn']
|
||||
end
|
||||
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
# This file is managed by gitlab-ctl. Manual changes will be
|
||||
# erased! To change the contents below, edit /etc/gitlab/gitlab.rb
|
||||
# and run `sudo gitlab-ctl reconfigure`.
|
||||
#
|
||||
# gitlab postgresql kernel shm tweaks
|
||||
#
|
||||
kernel.shmmax = <%= node['gitlab']['postgresql']['shmmax'] %>
|
||||
kernel.shmall = <%= node['gitlab']['postgresql']['shmall'] %>
|
|
@ -1,8 +0,0 @@
|
|||
# This file is managed by gitlab-ctl. Manual changes will be
|
||||
# erased! To change the contents below, edit /etc/gitlab/gitlab.rb
|
||||
# and run `sudo gitlab-ctl reconfigure`.
|
||||
#
|
||||
# gitlab somaxconn kernel tweak for unicorn
|
||||
#
|
||||
# make sure this value is equal or higher then unicorn backlog_socket
|
||||
net.core.somaxconn = <%= node['gitlab']['unicorn']['somaxconn'] %>
|
Loading…
Reference in New Issue