X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/867a767ee96c65b89179c9d53f8c7805173f3fa3..f65e6e5bdfdab789a385847963b9c1ffa799a6e3:/cookbooks/nominatim/recipes/default.rb?ds=sidebyside diff --git a/cookbooks/nominatim/recipes/default.rb b/cookbooks/nominatim/recipes/default.rb index 0a9172b4b..b5496a652 100644 --- a/cookbooks/nominatim/recipes/default.rb +++ b/cookbooks/nominatim/recipes/default.rb @@ -102,7 +102,7 @@ directory "#{basedir}/tablespaces" do mode "700" end -# Note: tablespaces must be exactly in the same location on each +# NOTE: tablespaces must be exactly in the same location on each # Nominatim instance when replication is in use. Therefore # use symlinks to canonical directory locations. node[:nominatim][:tablespaces].each do |name, location| @@ -174,6 +174,7 @@ package %w[ source_directory = "#{basedir}/nominatim" build_directory = "#{basedir}/bin" +ui_directory = "#{basedir}/ui" directory build_directory do owner "nominatim" @@ -226,6 +227,21 @@ template "#{build_directory}/settings/local.php" do :log_file => "#{node[:nominatim][:logdir]}/query.log" end +git ui_directory do + action :sync + repository node[:nominatim][:ui_repository] + revision node[:nominatim][:ui_revision] + user "nominatim" + group "nominatim" +end + +template "#{ui_directory}/dist/config.js" do + source "ui-config.js.erb" + owner "nominatim" + group "nominatim" + mode "664" +end + if node[:nominatim][:flatnode_file] directory File.dirname(node[:nominatim][:flatnode_file]) do recursive true @@ -354,7 +370,7 @@ directory "#{basedir}/etc" do mode "775" end -%w[user_agent referrer email].each do |name| +%w[user_agent referrer email generic].each do |name| file "#{basedir}/etc/nginx_blocked_#{name}.conf" do action :create_if_missing owner "nominatim" @@ -364,7 +380,7 @@ end end node[:nominatim][:fpm_pools].each do |name, data| - php_fpm name.to_s do + php_fpm name do port data[:port] pm data[:pm] pm_max_children data[:max_children] @@ -372,6 +388,7 @@ node[:nominatim][:fpm_pools].each do |name, data| pm_min_spare_servers 10 pm_max_spare_servers 20 pm_max_requests 10000 + prometheus_port data[:prometheus_port] end end @@ -396,12 +413,15 @@ nginx_site "default" do action [:delete] end +frontends = search(:node, "recipes:web\\:\\:frontend").sort_by(&:name) + nginx_site "nominatim" do template "nginx.erb" directory build_directory variables :pools => node[:nominatim][:fpm_pools], - :frontends => search(:node, "recipes:web\\:\\:frontend"), - :confdir => "#{basedir}/etc" + :frontends => frontends, + :confdir => "#{basedir}/etc", + :ui_directory => ui_directory end template "/etc/logrotate.d/nginx" do @@ -437,9 +457,12 @@ end include_recipe "fail2ban" +frontend_addresses = frontends.collect { |f| f.ipaddresses(:role => :external) } + fail2ban_jail "nominatim_limit_req" do filter "nginx-limit-req" logpath "#{node[:nominatim][:logdir]}/nominatim.openstreetmap.org-error.log" ports [80, 443] maxretry 5 + ignoreips frontend_addresses.flatten.sort end