From: Tom Hughes Date: Tue, 13 Dec 2022 22:50:24 +0000 (+0000) Subject: Manage postgresql for osqa X-Git-Url: https://git.openstreetmap.org./chef.git/commitdiff_plain/a4439134f9270af6953869d8fc4fa0b863b8e09a?hp=d6154d2b144942123a2c5f7fe862a21f5ea4f692 Manage postgresql for osqa --- diff --git a/cookbooks/osqa/attributes/default.rb b/cookbooks/osqa/attributes/default.rb index cc3243ffc..573227013 100644 --- a/cookbooks/osqa/attributes/default.rb +++ b/cookbooks/osqa/attributes/default.rb @@ -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 diff --git a/cookbooks/osqa/metadata.rb b/cookbooks/osqa/metadata.rb index 932a04697..6f47c773c 100644 --- a/cookbooks/osqa/metadata.rb +++ b/cookbooks/osqa/metadata.rb @@ -9,5 +9,6 @@ supports "ubuntu" depends "accounts" depends "apache" depends "memcached" +depends "postgresql" depends "python" depends "tools" diff --git a/cookbooks/osqa/recipes/default.rb b/cookbooks/osqa/recipes/default.rb index 2c924332f..4cbd677a6 100644 --- a/cookbooks/osqa/recipes/default.rb +++ b/cookbooks/osqa/recipes/default.rb @@ -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]"