Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync fb_limits with upstream #258

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions cookbooks/fb_limits/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@
# limitations under the License.
#

# Allow locking 1/1024th of total system memory
total_system_memory_kbytes = node['memory']['total'].to_i
memlock_limit_kbytes = total_system_memory_kbytes / 1024
default['fb_limits']['*'] = {
'memlock' => {
'soft' => memlock_limit_kbytes,
'hard' => memlock_limit_kbytes,
},
}

default['fb_limits']['root'] = {
'nofile' => {
'hard' => '65535',
Expand Down
1 change: 0 additions & 1 deletion cookbooks/fb_limits/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
license 'Apache-2.0'
description 'Installs/Configures /etc/security/limits.conf'
source_url 'https://github.com/facebook/chef-cookbooks/'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.0.1'
supports 'centos'
supports 'debian'
Expand Down
23 changes: 15 additions & 8 deletions cookbooks/fb_limits/recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,22 @@

template '/etc/security/limits.conf' do
source 'limits.conf.erb'
owner 'root'
group 'root'
owner node.root_user
group node.root_group
mode '0644'
end

# We want to manage all limits config via /etc/security/limits.conf so
# clean out limits.d
directory '/etc/security/limits.d' do
only_if { Dir.exists?('/etc/security/limits.d') }
action :delete
recursive true
# We want to manage all limits config via /etc/security/limits.conf, so clean
# out limits.d/*.conf. Instead of deleting the directory, just overwrite the
# files with a comment indicating they were disabled by Chef. This is important
# so that upgrading or reinstalling an RPM that ships one such config file will
# not end up creating the file back again.
Dir.glob '/etc/security/limits.d/*.conf' do |i|
file "overwrite #{i} in /etc/security/limits.d" do
path i
content "# Disabled by Chef\n"
owner node.root_user
group node.root_group
mode '0644'
end
end