]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/planet/recipes/replication.rb
Install osmdbt and generate configuration file for it
[chef.git] / cookbooks / planet / recipes / replication.rb
index 2579b511cf3fc8a00bf33de7cbb33100283afa4d..c588de1aee24d4fbf70fbb1684ad78cf91afbadf 100644 (file)
 # limitations under the License.
 #
 
+require "yaml"
+
 include_recipe "accounts"
 include_recipe "osmosis"
 
 db_passwords = data_bag_item("db", "passwords")
 
-package "postgresql-client"
-
-package "ruby"
-package "ruby-dev"
-package "ruby-libxml"
-
-package "make"
-package "gcc"
-package "libpq-dev"
+package %w[
+  postgresql-client
+  ruby
+  ruby-dev
+  ruby-libxml
+  make
+  gcc
+  libpq-dev
+  osmdbt
+]
 
 gem_package "pg"
 
@@ -41,7 +44,7 @@ remote_directory "/opt/flush" do
   mode "755"
   files_owner "root"
   files_group "root"
-  files_mode 0o755
+  files_mode "755"
 end
 
 execute "/opt/flush/Makefile" do
@@ -60,7 +63,7 @@ remote_directory "/usr/local/bin" do
   mode "755"
   files_owner "root"
   files_group "root"
-  files_mode 0o755
+  files_mode "755"
 end
 
 template "/usr/local/bin/users-agreed" do
@@ -84,7 +87,7 @@ remote_directory "/store/planet/users_deleted" do
   mode "755"
   files_owner "root"
   files_group "root"
-  files_mode 0o644
+  files_mode "644"
 end
 
 remote_directory "/store/planet/replication" do
@@ -94,7 +97,7 @@ remote_directory "/store/planet/replication" do
   mode "755"
   files_owner "root"
   files_group "root"
-  files_mode 0o755
+  files_mode "755"
 end
 
 directory "/store/planet/replication/changesets" do
@@ -121,6 +124,25 @@ directory "/store/planet/replication/minute" do
   mode "755"
 end
 
+directory "/store/planet/replication/test" do
+  owner "planet"
+  group "planet"
+  mode "755"
+end
+
+directory "/store/planet/replication/test/minute" do
+  owner "planet"
+  group "planet"
+  mode "755"
+end
+
+systemd_tmpfile "/run/replication" do
+  type "d"
+  owner "planet"
+  group "planet"
+  mode "755"
+end
+
 directory "/etc/replication" do
   owner "root"
   group "root"
@@ -141,6 +163,27 @@ template "/etc/replication/auth.conf" do
   variables :password => db_passwords["planetdiff"]
 end
 
+osmdbt_config = {
+  "database" => {
+    "host" => node[:web][:database_host],
+    "dbname" => "openstreetmap",
+    "user" => "planetdiff",
+    "password" => db_passwords["planetdiff"],
+    "replication_slot" => "osmdbt"
+  },
+  "log_dir" => "/var/lib/replication/minute",
+  "changes_dir" => "/store/planet/replication/test/minute",
+  "tmp_dir" => "/tmp",
+  "run_dir" => "/run/replication"
+}
+
+file "/etc/replication/osmdbt-config.yaml" do
+  user "root"
+  group "planet"
+  mode "640"
+  content YAML.dump(osmdbt_config)
+end
+
 template "/etc/replication/changesets.conf" do
   source "changesets.conf.erb"
   user "root"
@@ -163,6 +206,12 @@ directory "/var/lib/replication" do
   mode "755"
 end
 
+directory "/var/lib/replication/minute" do
+  owner "planet"
+  group "planet"
+  mode "755"
+end
+
 directory "/var/lib/replication/hour" do
   owner "planet"
   group "planet"
@@ -269,38 +318,3 @@ else
     action :delete
   end
 end
-
-# directory "/var/lib/replication/streaming" do
-#   owner "planet"
-#   group "planet"
-#   mode 0o755
-# end
-#
-# directory "/var/log/replication" do
-#   owner "planet"
-#   group "planet"
-#   mode 0o755
-# end
-#
-# ["streaming-replicator", "streaming-server"].each do |name|
-#   template "/etc/init.d/#{name}" do
-#     source "streaming.init.erb"
-#     owner "root"
-#     group "root"
-#     mode 0o755
-#     variables :service => name
-#   end
-#
-#   if node[:planet][:replication] == "enabled"
-#     service name do
-#       action [:enable, :start]
-#       supports :restart => true, :status => true
-#       subscribes :restart, "template[/etc/init.d/#{name}]"
-#     end
-#   else
-#     service name do
-#       action [:disable, :stop]
-#       supports :restart => true, :status => true
-#     end
-#   end
-# end