From 2cbbd3f2b8bed8cf096170137045d9721452745d Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Wed, 30 Mar 2016 21:18:13 +0200 Subject: [PATCH] nominatim: make log dir configurable and move it to ssd on dulcy --- cookbooks/nominatim/attributes/default.rb | 1 + cookbooks/nominatim/recipes/base.rb | 23 +++++++++++++------ .../nominatim/templates/default/ipblocks.erb | 2 +- .../templates/default/logrotate.nominatim.erb | 4 ++-- .../nominatim/templates/default/munin.erb | 2 +- .../nominatim/templates/default/nominatim.erb | 2 +- .../nominatim/templates/default/updater.erb | 2 +- roles/dulcy.rb | 1 + 8 files changed, 24 insertions(+), 13 deletions(-) create mode 100644 cookbooks/nominatim/attributes/default.rb diff --git a/cookbooks/nominatim/attributes/default.rb b/cookbooks/nominatim/attributes/default.rb new file mode 100644 index 000000000..b4a0b0952 --- /dev/null +++ b/cookbooks/nominatim/attributes/default.rb @@ -0,0 +1 @@ +default[:nominatim][:logdir] = "/var/log/nominatim" diff --git a/cookbooks/nominatim/recipes/base.rb b/cookbooks/nominatim/recipes/base.rb index a7c5a9c52..da10a9001 100644 --- a/cookbooks/nominatim/recipes/base.rb +++ b/cookbooks/nominatim/recipes/base.rb @@ -65,10 +65,25 @@ postgresql_munin "nominatim" do database database_name end -directory "/var/log/nominatim" do +directory node[:nominatim][:logdir] do owner "nominatim" group "nominatim" mode 0755 + recursive true +end + +file "#{node[:nominatim][:logdir]}/query.log" do + action :create_if_missing + owner "www-data" + group "adm" + mode 0664 +end + +file "#{node[:nominatim][:logdir]}/update.log" do + action :create_if_missing + owner "nominatim" + group "adm" + mode 0664 end directory "#{home_directory}/status" do @@ -121,12 +136,6 @@ execute "compile_nominatim" do user "nominatim" end -directory "#{source_directory}/log" do - owner "nominatim" - group "nominatim" - mode 0755 -end - template "#{source_directory}/.git/hooks/post-merge" do source "update_source.erb" owner "nominatim" diff --git a/cookbooks/nominatim/templates/default/ipblocks.erb b/cookbooks/nominatim/templates/default/ipblocks.erb index a679563a4..9fb36fef5 100644 --- a/cookbooks/nominatim/templates/default/ipblocks.erb +++ b/cookbooks/nominatim/templates/default/ipblocks.erb @@ -1,4 +1,4 @@ -LOGFILE='/var/log/nominatim/restricted_ips.log' +LOGFILE='<%= node[:nominatim][:logdir] %>/restricted_ips.log' # space-separated list of IPs that are never banned WHITELIST = '' # space-separated list of IPs manually blocked diff --git a/cookbooks/nominatim/templates/default/logrotate.nominatim.erb b/cookbooks/nominatim/templates/default/logrotate.nominatim.erb index 0b853f79f..7097e432d 100644 --- a/cookbooks/nominatim/templates/default/logrotate.nominatim.erb +++ b/cookbooks/nominatim/templates/default/logrotate.nominatim.erb @@ -1,6 +1,6 @@ # DO NOT EDIT - This file is being maintained by Chef -/var/log/nominatim/update.log { +<%= node[:nominatim][:logdir] %>/update.log { weekly missingok rotate 5 @@ -10,7 +10,7 @@ create 640 nominatim adm } -/var/log/nominatim/query.log { +<%= node[:nominatim][:logdir] %>/query.log { weekly missingok rotate 8 diff --git a/cookbooks/nominatim/templates/default/munin.erb b/cookbooks/nominatim/templates/default/munin.erb index 136211ef5..aa6ac2af2 100644 --- a/cookbooks/nominatim/templates/default/munin.erb +++ b/cookbooks/nominatim/templates/default/munin.erb @@ -4,4 +4,4 @@ user www-data env.PGDATABASE <%= node[:nominatim][:database][:dbname] %> env.PGUSER www-data -env.NOMINATIM_QUERYLOG /var/log/nominatim/query.log +env.NOMINATIM_QUERYLOG <%= node[:nominatim][:logdir] %>/query.log diff --git a/cookbooks/nominatim/templates/default/nominatim.erb b/cookbooks/nominatim/templates/default/nominatim.erb index d1c3517e6..6e911223d 100644 --- a/cookbooks/nominatim/templates/default/nominatim.erb +++ b/cookbooks/nominatim/templates/default/nominatim.erb @@ -17,5 +17,5 @@ else @define('CONST_Tablespace_<%= part %>', '<%= name %>'); <% end -%> -@define('CONST_Log_File', '/var/log/nominatim/query.log'); +@define('CONST_Log_File', '<%= node[:nominatim][:logdir] %>/query.log'); @define('CONST_Log_DB', false); diff --git a/cookbooks/nominatim/templates/default/updater.erb b/cookbooks/nominatim/templates/default/updater.erb index aba7f72aa..d8c9666ce 100644 --- a/cookbooks/nominatim/templates/default/updater.erb +++ b/cookbooks/nominatim/templates/default/updater.erb @@ -9,7 +9,7 @@ cd $DIR/.. while [ ! -f "<%= @update_stop_file %>" ] do # Send output to the log (logrotatable) - exec >> /var/log/nominatim/update.log 2>&1 + exec >> <%= node[:nominatim][:logdir] %>/update.log 2>&1 starttime=`date +%s` ./utils/update.php --no-npi --import-osmosis diff --git a/roles/dulcy.rb b/roles/dulcy.rb index e40e04834..eb8d29526 100644 --- a/roles/dulcy.rb +++ b/roles/dulcy.rb @@ -41,6 +41,7 @@ default_attributes( :nominatim => { :enabled => false, :flatnode_file => "/ssd/nominatim/nodes.store", + :logdir => "/ssd/nominatim/log", :database => { :cluster => "9.4/main", :dbname => "nominatim", -- 2.39.5