]> git.openstreetmap.org Git - chef.git/commitdiff
Add tests for db cookbook
authorTom Hughes <tom@compton.nu>
Sun, 23 Feb 2020 22:12:00 +0000 (22:12 +0000)
committerTom Hughes <tom@compton.nu>
Sun, 23 Feb 2020 22:45:24 +0000 (22:45 +0000)
12 files changed:
.github/workflows/test-kitchen.yml
.kitchen.yml
cookbooks/db/attributes/default.rb [new file with mode: 0644]
cookbooks/db/metadata.rb
cookbooks/db/recipes/base.rb
roles/db-master.rb
roles/db-slave.rb
roles/db.rb
roles/eddie.rb
roles/karm.rb
roles/katla.rb
test/data_bags/db/wal-secrets.json [new file with mode: 0644]

index 6646f28d09a0d2f8794f7af9d4da1dedd39a07b9..086850543af6254278d6af20ca00dbf4e1626dee 100644 (file)
@@ -18,6 +18,10 @@ jobs:
           - blogs
           - civicrm
           - clamav
+          - db-backup
+          - db-base
+          - db-master
+          - db-slave
           - devices
           - dhcpd
           - dmca
index babf141079bbaa68715c2412549b935821162cc8..c136565f1255241d5804b6d16e5be5d1aa2c4f01 100644 (file)
@@ -54,6 +54,18 @@ suites:
   - name: clamav
     run_list:
       - recipe[clamav::default]
+  - name: db-backup
+    run_list:
+      - recipe[db::backup]
+  - name: db-base
+    run_list:
+      - recipe[db::base]
+  - name: db-master
+    run_list:
+      - recipe[db::master]
+  - name: db-slave
+    run_list:
+      - recipe[db::slave]
   - name: devices
     run_list:
       - recipe[devices::default]
diff --git a/cookbooks/db/attributes/default.rb b/cookbooks/db/attributes/default.rb
new file mode 100644 (file)
index 0000000..1b674e3
--- /dev/null
@@ -0,0 +1,3 @@
+default[:db][:cluster] = "9.5/main"
+
+default[:postgresql][:versions] |= ["9.5"]
index 092949cb0ca4642268e88b68c4f0e94636c4f80d..aadfe47dbab448723064f2f3ad42022e6004dfb5 100644 (file)
@@ -6,7 +6,8 @@ description       "Installs and configures database servers"
 
 version           "1.0.0"
 supports          "ubuntu"
-depends           "postgresql"
-depends           "web"
+depends           "accounts"
 depends           "git"
+depends           "postgresql"
 depends           "python"
+depends           "web"
index ee9d0089f65f13ce799b411def26b481414a9c0a..f92a6ea0bf02e6d19e6d08673194636b334373bc 100644 (file)
 # limitations under the License.
 #
 
-include_recipe "postgresql"
+include_recipe "accounts"
 include_recipe "git"
+include_recipe "postgresql"
 include_recipe "python"
 
 passwords = data_bag_item("db", "passwords")
 wal_secrets = data_bag_item("db", "wal-secrets")
 
+ruby_version = node[:passenger][:ruby_version]
+db_version = node[:db][:cluster].split("/").first
+pg_config = "/usr/lib/postgresql/#{db_version}/bin/pg_config"
+function_directory = "/srv/www.openstreetmap.org/rails/db/functions/#{db_version}"
+
 postgresql_munin "openstreetmap" do
   cluster node[:db][:cluster]
   database "openstreetmap"
@@ -35,7 +41,7 @@ directory "/srv/www.openstreetmap.org" do
 end
 
 rails_port "www.openstreetmap.org" do
-  ruby "2.5"
+  ruby ruby_version
   directory "/srv/www.openstreetmap.org/rails"
   user "rails"
   group "rails"
@@ -48,10 +54,6 @@ rails_port "www.openstreetmap.org" do
   gpx_dir "/store/rails/gpx"
 end
 
-db_version = node[:db][:cluster].split("/").first
-pg_config = "/usr/lib/postgresql/#{db_version}/bin/pg_config"
-function_directory = "/srv/www.openstreetmap.org/rails/db/functions/#{db_version}"
-
 directory function_directory do
   owner "rails"
   group "rails"
@@ -60,7 +62,7 @@ end
 
 execute function_directory do
   action :nothing
-  command "make PG_CONFIG=#{pg_config} DESTDIR=#{function_directory}"
+  command "make BUNDLE=bundle#{ruby_version} PG_CONFIG=#{pg_config} DESTDIR=#{function_directory}"
   cwd "/srv/www.openstreetmap.org/rails/db/functions"
   user "rails"
   group "rails"
index 3bfdbd7ca2fbccb9025176e1d3d82ea982f371de..19f9d55d95bf2f3732dac5a06b6a79f32e9bcefe 100644 (file)
@@ -3,7 +3,6 @@ description "Role applied to all the master database server"
 
 default_attributes(
   :postgresql => {
-    :versions => ["9.5"],
     :settings => {
       :defaults => {
         :wal_level => "hot_standby",
index 5b5c09b33fe85424d079bcb8200d1d09b07d1619..30c4a79bf1c62619a929c466fb353da737da0351 100644 (file)
@@ -3,7 +3,6 @@ description "Role applied to all slave database servers"
 
 default_attributes(
   :postgresql => {
-    :versions => ["9.5"],
     :settings => {
       :defaults => {
         :hot_standby => "on",
index bb13e00c5d543b5332c0c5d64257e992fff52aed..c4bd4cfa4ecbcab4c5f6c864af500495782b0537 100644 (file)
@@ -39,7 +39,6 @@ default_attributes(
     "/store/rails" => { :host => "ironbelly", :path => "/store/rails" }
   },
   :postgresql => {
-    :versions => ["9.5"],
     :settings => {
       :defaults => {
         :listen_addresses => "*",
index c96483527f78d3f410c5119c466e243601b4d853..0dbe9dd0a7e9fec6dc0aebe123773674868b6ac1 100644 (file)
@@ -2,9 +2,6 @@ name "eddie"
 description "Master role applied to eddie"
 
 default_attributes(
-  :db => {
-    :cluster => "9.5/main"
-  },
   :networking => {
     :interfaces => {
       :internal_ipv4 => {
index a8f6b9e29eb94a1e38b55f06c55b4f1dfd33ea60..ab1470756d895e9cfacf0b444d8ae6ec4e43eb8e 100644 (file)
@@ -2,9 +2,6 @@ name "karm"
 description "Master role applied to karm"
 
 default_attributes(
-  :db => {
-    :cluster => "9.5/main"
-  },
   :networking => {
     :interfaces => {
       :internal_ipv4 => {
index 6f5376f0889cb28dd8dc043e609255d07098900b..6143cf533a3e1565a6e25b779d8a432e22ec89c9 100644 (file)
@@ -2,9 +2,6 @@ name "katla"
 description "Master role applied to katla"
 
 default_attributes(
-  :db => {
-    :cluster => "9.5/main"
-  },
   :devices => {
     :store_slow => {
       :comment => "RAID array mounted on /store/arrays/slow",
diff --git a/test/data_bags/db/wal-secrets.json b/test/data_bags/db/wal-secrets.json
new file mode 100644 (file)
index 0000000..6f558f2
--- /dev/null
@@ -0,0 +1,4 @@
+{
+  "id": "wal-secrets",
+  "s3_key": "s3-key"
+}