]> git.openstreetmap.org Git - chef.git/commitdiff
Add infrastructure for using WAL-E
authorTom Hughes <tom@compton.nu>
Tue, 10 Oct 2017 19:43:46 +0000 (20:43 +0100)
committerTom Hughes <tom@compton.nu>
Tue, 10 Oct 2017 19:49:20 +0000 (20:49 +0100)
cookbooks/db/metadata.rb
cookbooks/db/recipes/base.rb
cookbooks/db/templates/default/wal-e.erb [new file with mode: 0644]
cookbooks/python/recipes/default.rb
cookbooks/python/resources/package.rb

index 2a7f0c69498b0cda2c112015b530d5705ff6866a..94c044fad84bb23f7315491645698eb25efb1d8e 100644 (file)
@@ -9,3 +9,4 @@ supports          "ubuntu"
 depends           "postgresql"
 depends           "web"
 depends           "git"
+depends           "python"
index f24e42e93b581540ce7c0d22da2055ff432d8313..92d74f86dcda82fbbb5a5bd5745c16e94cdeb0e2 100644 (file)
 
 include_recipe "postgresql"
 include_recipe "git"
+include_recipe "python"
 
 passwords = data_bag_item("db", "passwords")
+wal_secrets = data_bag_item("db", "wal-secrets")
 
 postgresql_munin "openstreetmap" do
   cluster node[:db][:cluster]
@@ -72,3 +74,21 @@ link "/usr/lib/postgresql/#{db_version}/lib/libpgosm.so" do
   owner "root"
   group "root"
 end
+
+package "lzop"
+
+python_package "wal-e" do
+  python_version "3"
+end
+
+python_package "boto" do
+  python_version "3"
+end
+
+template "/usr/local/bin/openstreetmap-wal-e" do
+  source "wal-e.erb"
+  owner "root"
+  group "postgres"
+  mode 0o750
+  variables :s3_key => wal_secrets["s3_key"]
+end
diff --git a/cookbooks/db/templates/default/wal-e.erb b/cookbooks/db/templates/default/wal-e.erb
new file mode 100644 (file)
index 0000000..93f3144
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+# DO NOT EDIT - This file is being maintained by Chef
+
+export WALE_S3_PREFIX="s3://openstreetmap-wal/"
+export AWS_ACCESS_KEY_ID="AKIAIQX2LTDOBIW4CZUQ"
+export AWS_SECRET_ACCESS_KEY="<%= @s3_key %>"
+export AWS_REGION="eu-west-2"
+
+exec /usr/local/bin/wal-e "$@"
index 14b1e5a87b0d4cdea3a302261c6ca401df74b227..a2eaf1cdbffa1b6935f3e8df85486357aec6238c 100644 (file)
@@ -19,3 +19,6 @@
 
 package "python"
 package "python-pip"
+
+package "python3"
+package "python3-pip"
index 76a6af7ec4a7aad7c64635b98f8ef5f81ab78df4..d6431c87da8714116d29f5e0101b6ac5469a096b 100644 (file)
@@ -21,24 +21,29 @@ default_action :install
 
 property :package_name, :kind_of => String, :name_property => true
 property :version, :kind_of => String
+property :python_version, :kind_of => String
 
 action :install do
   if version.nil?
     execute "pip-install-#{name}" do
-      command "pip install #{new_resource.package_name}"
-      not_if "pip show #{new_resource.package_name}"
+      command "#{pip_command} install #{new_resource.package_name}"
+      not_if "#{pip_command} show #{new_resource.package_name}"
     end
   else
     execute "pip-install-#{name}" do
-      command "pip install #{new_resource.package_name}==#{new_resource.version}"
-      not_if "pip show #{new_resource.package_name} | fgrep -q #{new_resource.version}"
+      command "#{pip_command} install #{new_resource.package_name}==#{new_resource.version}"
+      not_if "#{pip_command} show #{new_resource.package_name} | fgrep -q #{new_resource.version}"
     end
   end
 end
 
 action :remove do
   execute "pip-uninstall-#{name}" do
-    command "pip uninstall #{new_resource.package_name}"
-    only_if "pip show #{new_resource.package_name}"
+    command "#{pip_command} uninstall #{new_resource.package_name}"
+    only_if "#{pip_command} show #{new_resource.package_name}"
   end
 end
+
+def pip_command
+  "pip#{python_version}"
+end