From 8330f0181539491affd1c6b9ea6f55b5408a3655 Mon Sep 17 00:00:00 2001 From: Rich Schumacher Date: Thu, 23 Jul 2015 13:40:21 -0400 Subject: [PATCH] Properly set FD_LIMIT in sysv init when installing from package on Debian The default['cassandra']['limits']['nofile'] attribute is not used when installing from a package on Debian/Ubuntu. This change uses Chef's FileEdit utility to replace the existing value with the value specified in the attribute. --- Vagrantfile | 8 +++----- recipes/datastax.rb | 11 +++++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index c30b1ba3..0678f988 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -71,15 +71,13 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.provision :chef_solo do |chef| chef.json = { - mysql: { - server_root_password: 'rootpass', - server_debian_password: 'debpass', - server_repl_password: 'replpass' + cassandra: { + cluster_name: 'vagrant-test' } } chef.run_list = [ - "recipe[cassandra::default]" + "recipe[cassandra-dse::default]" ] end end diff --git a/recipes/datastax.rb b/recipes/datastax.rb index 330fc033..740338c4 100644 --- a/recipes/datastax.rb +++ b/recipes/datastax.rb @@ -90,6 +90,7 @@ options '--force-yes -o Dpkg::Options::="--force-confold"' # giving C* some time to start up notifies :run, 'ruby_block[sleep30s]', :immediately + notifies :run, 'ruby_block[set_fd_limit]', :immediately notifies :run, 'execute[set_cluster_name]', :immediately end @@ -100,6 +101,16 @@ action :nothing end + ruby_block "set_fd_limit" do + block do + file = Chef::Util::FileEdit.new("/etc/init.d/#{node['cassandra']['service_name']}") + file.search_file_replace_line(/^FD_LIMIT=.*$/, "FD_LIMIT=#{node['cassandra']['limits']['nofile']}") + file.write_file + end + notifies :restart, 'service[cassandra]', :delayed + action :nothing + end + execute 'set_cluster_name' do command "/usr/bin/cqlsh -e \"update system.local set cluster_name='#{node['cassandra']['cluster_name']}' where key='local';\"; /usr/bin/nodetool flush;" notifies :restart, 'service[cassandra]', :delayed