From 6dc624ab40b613b092d8339d77bb669491bd9281 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Thu, 18 Jun 2015 07:42:47 +0200 Subject: [PATCH 1/1] nominatim: split master and slave recipes Must not do any DB setup on slave. --- .../nominatim/recipes/{default.rb => base.rb} | 32 +---------- cookbooks/nominatim/recipes/master.db | 54 +++++++++++++++++++ cookbooks/nominatim/recipes/slave.db | 31 +++++++++++ roles/nominatim-master.rb | 1 + roles/nominatim.rb | 1 - 5 files changed, 88 insertions(+), 31 deletions(-) rename cookbooks/nominatim/recipes/{default.rb => base.rb} (90%) create mode 100644 cookbooks/nominatim/recipes/master.db create mode 100644 cookbooks/nominatim/recipes/slave.db diff --git a/cookbooks/nominatim/recipes/default.rb b/cookbooks/nominatim/recipes/base.rb similarity index 90% rename from cookbooks/nominatim/recipes/default.rb rename to cookbooks/nominatim/recipes/base.rb index df5f6618f..c754d10d5 100644 --- a/cookbooks/nominatim/recipes/default.rb +++ b/cookbooks/nominatim/recipes/base.rb @@ -1,8 +1,8 @@ # # Cookbook Name:: nominatim -# Recipe:: default +# Recipe:: base # -# Copyright 2012, OpenStreetMap Foundation +# Copyright 2015, OpenStreetMap Foundation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -32,7 +32,6 @@ apache_module "rewrite" apache_module "proxy" apache_module "proxy_fcgi" -passwords = data_bag_item("nominatim", "passwords") home_directory = data_bag_item("accounts", "nominatim")["home"] source_directory = "#{home_directory}/nominatim" email_errors = data_bag_item("accounts", "lonvia")["email"] @@ -70,25 +69,6 @@ node[:nominatim][:fpm_pools].each do |name, data| end end -superusers = %w(tomh lonvia twain nominatim) - -superusers.each do |user| - postgresql_user user do - cluster database_cluster - superuser true - end -end - -postgresql_user "www-data" do - cluster database_cluster -end - -postgresql_user "replication" do - cluster database_cluster - password passwords["replication"] - replication true -end - postgresql_munin "nominatim" do cluster database_cluster database database_name @@ -141,14 +121,6 @@ execute "compile_nominatim" do user "nominatim" end -git source_directory do - action :checkout - repository node[:nominatim][:repository] - enable_submodules true - user "nominatim" - group "nominatim" - notifies :run, "execute[compile_nominatim]" -end directory "#{source_directory}/log" do owner "nominatim" diff --git a/cookbooks/nominatim/recipes/master.db b/cookbooks/nominatim/recipes/master.db new file mode 100644 index 000000000..a63444143 --- /dev/null +++ b/cookbooks/nominatim/recipes/master.db @@ -0,0 +1,54 @@ +# +# Cookbook Name:: nominatim +# Recipe:: master +# +# Copyright 2015, OpenStreetMap Foundation +# +# 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. +# + +include_recipe "nominatim::base" + +passwords = data_bag_item("nominatim", "passwords") +home_directory = data_bag_item("accounts", "nominatim")["home"] + +superusers = %w(tomh lonvia twain nominatim) + +superusers.each do |user| + postgresql_user user do + cluster database_cluster + superuser true + end +end + +postgresql_user "www-data" do + cluster database_cluster +end + +postgresql_user "replication" do + cluster database_cluster + password passwords["replication"] + replication true +end + + +git "#{home_directory}/nominatim" do + action :checkout + repository node[:nominatim][:repository] + enable_submodules true + user "nominatim" + group "nominatim" + notifies :run, "execute[compile_nominatim]" +end + + diff --git a/cookbooks/nominatim/recipes/slave.db b/cookbooks/nominatim/recipes/slave.db new file mode 100644 index 000000000..bcc1b116e --- /dev/null +++ b/cookbooks/nominatim/recipes/slave.db @@ -0,0 +1,31 @@ +# +# Cookbook Name:: nominatim +# Recipe:: slave +# +# Copyright 2015, OpenStreetMap Foundation +# +# 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. +# + +include_recipe "nominatim::base" + +home_directory = data_bag_item("accounts", "nominatim")["home"] + +git "#{home_directory}/nominatim" do + repository node[:nominatim][:repository] + enable_submodules true + user "nominatim" + group "nominatim" + notifies :run, "execute[compile_nominatim]" +end + diff --git a/roles/nominatim-master.rb b/roles/nominatim-master.rb index d787716cc..f910bcb9a 100644 --- a/roles/nominatim-master.rb +++ b/roles/nominatim-master.rb @@ -40,5 +40,6 @@ default_attributes( run_list( "role[nominatim]", + "recipe[nominatim::master]", "recipe[rsyncd]" ) diff --git a/roles/nominatim.rb b/roles/nominatim.rb index e1a2a3ddc..8cfa7fe7a 100644 --- a/roles/nominatim.rb +++ b/roles/nominatim.rb @@ -87,5 +87,4 @@ default_attributes( ) run_list( - "recipe[nominatim]" ) -- 2.39.5