]> git.openstreetmap.org Git - chef.git/commitdiff
Manage postgresql for osqa
authorTom Hughes <tom@compton.nu>
Tue, 13 Dec 2022 22:50:24 +0000 (22:50 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 13 Dec 2022 22:52:00 +0000 (22:52 +0000)
cookbooks/osqa/attributes/default.rb
cookbooks/osqa/metadata.rb
cookbooks/osqa/recipes/default.rb

index cc3243ffc6ceef22dd0bf31c6f5b142f3e69e9fd..573227013f28978eb6be89582d261212125812dc 100644 (file)
@@ -1,8 +1,11 @@
 default[:osqa][:user] = "osqa"
 default[:osqa][:group] = nil
+default[:osqa][:database_cluster] = "14/main"
 default[:osqa][:database_name] = "osqa"
 default[:osqa][:database_user] = "osqa"
 default[:osqa][:database_password] = ""
 default[:osqa][:sites] = []
 
+default[:postgresql][:versions] |= ["14"]
+
 default[:accounts][:users][:osqa][:status] = :role
index 932a04697bdf149ffdbf33d85e0aa01930c42307..6f47c773c6b08600cbad73860e9d5abbcaa46585 100644 (file)
@@ -9,5 +9,6 @@ supports          "ubuntu"
 depends           "accounts"
 depends           "apache"
 depends           "memcached"
+depends           "postgresql"
 depends           "python"
 depends           "tools"
index 2c924332fe4f19b4185989add22e7d340e77d3ee..4cbd677a658820edf99e4ffbbb3a0914b2d77d50 100644 (file)
@@ -20,6 +20,7 @@
 include_recipe "accounts"
 include_recipe "apache"
 include_recipe "memcached"
+include_recipe "postgresql"
 include_recipe "python"
 include_recipe "tools"
 
@@ -79,11 +80,22 @@ node[:osqa][:sites].each do |site|
   site_user = Etc.getpwuid(site_user).name if site_user.is_a?(Integer)
   site_group = site[:group] || node[:osqa][:group] || Etc.getpwnam(site_user).gid
   site_group = Etc.getgrgid(site_group).name if site_group.is_a?(Integer)
+  database_cluster = site[:database_cluster] || node[:osqa][:database_cluster]
   database_name = site[:database_name] || node[:osqa][:database_name]
   database_user = site[:database_user] || node[:osqa][:database_user]
   database_password = site[:database_user] || node[:osqa][:database_password]
   backup_name = site[:backup]
 
+  postgresql_user database_user do
+    cluster database_cluster
+    password database_password
+  end
+
+  postgresql_database database_name do
+    cluster database_cluster
+    owner database_user
+  end
+
   ssl_certificate site_name do
     domains [site_name] + site_aliases
     notifies :reload, "service[apache2]"