]> git.openstreetmap.org Git - chef.git/commitdiff
Merge remote-tracking branch 'github/pull/561'
authorTom Hughes <tom@compton.nu>
Sat, 14 Jan 2023 16:43:39 +0000 (16:43 +0000)
committerTom Hughes <tom@compton.nu>
Sat, 14 Jan 2023 16:43:39 +0000 (16:43 +0000)
20 files changed:
.github/workflows/test-kitchen.yml
.kitchen.yml
cookbooks/apt/recipes/grafana.rb
cookbooks/foundation/recipes/board.rb
cookbooks/foundation/recipes/dwg.rb
cookbooks/foundation/recipes/mwg.rb
cookbooks/foundation/recipes/wiki.rb
cookbooks/mediawiki/resources/extension.rb
cookbooks/mediawiki/resources/site.rb
cookbooks/mediawiki/resources/skin.rb
cookbooks/wiki/recipes/default.rb
cookbooks/wiki/templates/default/mw-ext-JsonConfig.inc.php.erb [new file with mode: 0644]
cookbooks/wiki/templates/default/mw-ext-Kartographer.inc.php.erb [new file with mode: 0644]
cookbooks/wiki/templates/default/mw-ext-MultiMaps.inc.php.erb [deleted file]
test/data_bags/foundation/passwords.json [new file with mode: 0644]
test/integration/foundation-board/serverspec/apache_spec.rb [new file with mode: 0644]
test/integration/foundation-dwg/serverspec/apache_spec.rb [new file with mode: 0644]
test/integration/foundation-mwg/serverspec/apache_spec.rb [new file with mode: 0644]
test/integration/foundation-owg/serverspec/apache_spec.rb [new file with mode: 0644]
test/integration/foundation-wiki/serverspec/apache_spec.rb [new file with mode: 0644]

index 76305aaa2cde46bbe78618c85727a874bad8b7b3..e1ddf7221adbda1f03ebbf97fd3a10cd62dc5314 100644 (file)
@@ -39,6 +39,11 @@ jobs:
           - exim
           - fail2ban
           - forum
+          - foundation-board
+          - foundation-dwg
+          - foundation-mwg
+          - foundation-owg
+          - foundation-wiki
           - ftp
           - geodns
           - geoipupdate
index 830cc04c5fec876a7ace08a9f9918dab986c28f6..47630151624ed9fa3c1c118473741970ccd99c6c 100644 (file)
@@ -127,6 +127,21 @@ suites:
   - name: forum
     run_list:
       - recipe[forum::default]
+  - name: foundation-board
+    run_list:
+      - recipe[foundation::board]
+  - name: foundation-dwg
+    run_list:
+      - recipe[foundation::dwg]
+  - name: foundation-mwg
+    run_list:
+      - recipe[foundation::mwg]
+  - name: foundation-owg
+    run_list:
+      - recipe[foundation::owg]
+  - name: foundation-wiki
+    run_list:
+      - recipe[foundation::wiki]
   - name: ftp
     run_list:
       - recipe[ftp::default]
index 5738c23d495b8d1d7f3590611681b54366a3562a..ef6531c1f669213e5c7f4d7babe37df1f7eda644 100644 (file)
 
 include_recipe "apt"
 
+remote_file "/etc/apt/trusted.gpg.d/grafana.asc" do
+  source "https://packages.grafana.com/gpg.key"
+  owner "root"
+  group "root"
+  mode "644"
+end
+
 apt_repository "grafana" do
   uri "https://packages.grafana.com/enterprise/deb"
   distribution "stable"
   components ["main"]
-  key "https://packages.grafana.com/gpg.key"
 end
index 5d47c0c5198a8b6e0e32cd1841b4da21f55fdfc4..e26570a8f2455922820e38f845599ff290a8f385 100644 (file)
@@ -35,7 +35,7 @@ mediawiki_site "board.osmfoundation.org" do
   email_sender "webmaster@openstreetmap.org"
   email_sender_name "OSMF Board Wiki"
   private_site true
-  version "1.38"
+  version "1.39"
 end
 
 cookbook_file "/srv/board.osmfoundation.org/Wiki.png" do
index 83e8846ba2abbda7972788d7b3f344ab8ff06228..30804082f0172bb6bd3d2a35703a413fd7b3b052 100644 (file)
@@ -35,7 +35,7 @@ mediawiki_site "dwg.osmfoundation.org" do
   email_sender "webmaster@openstreetmap.org"
   email_sender_name "OSMF Board Wiki"
   private_site true
-  version "1.38"
+  version "1.39"
 end
 
 cookbook_file "/srv/dwg.osmfoundation.org/Wiki.png" do
index 90791606dd2da41c27eda0d2564a0629b78c7c1e..21f464074d4dccaefbe48ff80089887f4fc68893 100644 (file)
@@ -35,7 +35,7 @@ mediawiki_site "mwg.osmfoundation.org" do
   email_sender "webmaster@openstreetmap.org"
   email_sender_name "OSMF Board Wiki"
   private_site true
-  version "1.38"
+  version "1.39"
 end
 
 cookbook_file "/srv/mwg.osmfoundation.org/Wiki.png" do
index 9764a0934221370f83ce6aa803a0bdc979492015..8096c3016985c62ee090997a03edb0aec7ea428e 100644 (file)
@@ -42,7 +42,7 @@ mediawiki_site "wiki.osmfoundation.org" do
   email_sender_name "OSMF Wiki"
   private_accounts true
   extra_file_extensions ["mp3"]
-  version "1.38"
+  version "1.39"
 end
 
 mediawiki_skin "osmf" do
index 4e44f18c2ad426fd8d81c810d137e58bebcc7701..6240f6e87d008c1624d5497c6f2da6595499af61 100644 (file)
@@ -84,17 +84,6 @@ action :create do
       mode "664"
     end
   end
-
-  execute "#{extension_directory}/composer.json" do
-    action :nothing
-    command "composer update --no-dev"
-    cwd mediawiki_directory
-    user node[:mediawiki][:user]
-    group node[:mediawiki][:group]
-    environment "COMPOSER_HOME" => site_directory
-    only_if { ::File.exist?("#{extension_directory}/composer.json") }
-    subscribes :run, "git[#{extension_directory}]"
-  end
 end
 
 action :delete do
@@ -131,12 +120,5 @@ action_class do
 end
 
 def after_created
-  if update_site
-    notifies :update, "mediawiki_site[#{site}]"
-  else
-    site_directory = node[:mediawiki][:sites][site][:directory]
-
-    notifies :create, "template[#{site_directory}/w/LocalSettings.php]"
-    notifies :run, "execute[#{site_directory}/w/maintenance/update.php]"
-  end
+  notifies :update, "mediawiki_site[#{site}]" if update_site
 end
index 8be994ee3b1ae9af81f3791698b4755f06c1c4ba..f27c150f574aab13d403ac47ce35c85ce37371ef 100644 (file)
@@ -59,8 +59,6 @@ action :create do
     :version => new_resource.version
   }
 
-  secret_key = persistent_token("mediawiki", new_resource.site, "wgSecretKey")
-
   mysql_user "#{new_resource.database_user}@localhost" do
     password new_resource.database_password
   end
@@ -71,13 +69,6 @@ action :create do
 
   mediawiki_directory = "#{site_directory}/w"
 
-  ruby_block "rename-installer-localsettings" do
-    action :nothing
-    block do
-      ::File.rename("#{mediawiki_directory}/LocalSettings.php", "#{mediawiki_directory}/LocalSettings-install.php")
-    end
-  end
-
   declare_resource :directory, site_directory do
     owner node[:mediawiki][:user]
     group node[:mediawiki][:group]
@@ -97,9 +88,6 @@ action :create do
     depth 1
     user node[:mediawiki][:user]
     group node[:mediawiki][:group]
-    notifies :run, "execute[#{mediawiki_directory}/composer.json]", :immediately
-    notifies :run, "execute[#{mediawiki_directory}/maintenance/install.php]", :immediately
-    notifies :run, "execute[#{mediawiki_directory}/maintenance/update.php]"
   end
 
   template "#{mediawiki_directory}/composer.local.json" do
@@ -111,44 +99,21 @@ action :create do
   end
 
   execute "#{mediawiki_directory}/composer.json" do
-    action :nothing
     command "composer update --no-dev"
     cwd mediawiki_directory
     user node[:mediawiki][:user]
     group node[:mediawiki][:group]
     environment "COMPOSER_HOME" => site_directory
+    not_if { ::File.exist?("#{mediawiki_directory}/composer.lock") }
   end
 
   execute "#{mediawiki_directory}/maintenance/install.php" do
-    action :nothing
     # Use metanamespace as Site Name to ensure correct set namespace
     command "php maintenance/install.php --server '#{name}' --dbtype 'mysql' --dbname '#{new_resource.database_name}' --dbuser '#{new_resource.database_user}' --dbpass '#{new_resource.database_password}' --dbserver 'localhost' --scriptpath /w --pass '#{new_resource.admin_password}' '#{new_resource.metanamespace}' '#{new_resource.admin_user}'"
     cwd mediawiki_directory
     user node[:mediawiki][:user]
     group node[:mediawiki][:group]
-    not_if do
-      ::File.exist?("#{mediawiki_directory}/LocalSettings-install.php")
-    end
-    notifies :run, "ruby_block[rename-installer-localsettings]", :immediately
-  end
-
-  execute "#{mediawiki_directory}/maintenance/update.php" do
-    action :nothing
-    command "php maintenance/update.php --quick"
-    cwd mediawiki_directory
-    user node[:mediawiki][:user]
-    group node[:mediawiki][:group]
-  end
-
-  # Safety catch if git doesn't update but install.php hasn't run
-  ruby_block "catch-installer-localsettings-run" do
-    action :run
-    block do
-    end
-    not_if do
-      ::File.exist?("#{mediawiki_directory}/LocalSettings-install.php")
-    end
-    notifies :run, "execute[#{mediawiki_directory}/maintenance/install.php]", :immediately
+    not_if { ::File.exist?("#{mediawiki_directory}/LocalSettings.php") }
   end
 
   declare_resource :directory, "#{mediawiki_directory}/images" do
@@ -180,23 +145,26 @@ action :create do
               :database_params => database_params,
               :mediawiki => mediawiki_params,
               :secret_key => secret_key
-    notifies :run, "execute[#{mediawiki_directory}/maintenance/update.php]"
   end
 
   service "mediawiki-sitemap@#{new_resource.site}.timer" do
     action [:enable, :start]
+    only_if { ::File.exist?("#{mediawiki_directory}/LocalSettings.php") }
   end
 
   service "mediawiki-jobs@#{new_resource.site}.timer" do
     action [:enable, :start]
+    only_if { ::File.exist?("#{mediawiki_directory}/LocalSettings.php") }
   end
 
   service "mediawiki-email-jobs@#{new_resource.site}.timer" do
     action [:enable, :start]
+    only_if { ::File.exist?("#{mediawiki_directory}/LocalSettings.php") }
   end
 
   service "mediawiki-refresh-links@#{new_resource.site}.timer" do
     action [:enable, :start]
+    only_if { ::File.exist?("#{mediawiki_directory}/LocalSettings.php") }
   end
 
   template "/etc/cron.daily/mediawiki-#{cron_name}-backup" do
@@ -208,12 +176,14 @@ action :create do
     variables :name => new_resource.site,
               :directory => site_directory,
               :database_params => database_params
+    only_if { ::File.exist?("#{mediawiki_directory}/LocalSettings.php") }
   end
 
   # MobileFrontend extension is required by MinervaNeue skin
   mediawiki_extension "MobileFrontend" do
     site new_resource.site
     template "mw-ext-MobileFrontend.inc.php.erb"
+    update_site false
   end
 
   # MobileFrontend extension is required by MinervaNeue skin
@@ -534,6 +504,14 @@ end
 action :update do
   mediawiki_directory = "#{site_directory}/w"
 
+  execute "#{mediawiki_directory}/composer.json" do
+    command "composer update --no-dev"
+    cwd mediawiki_directory
+    user node[:mediawiki][:user]
+    group node[:mediawiki][:group]
+    environment "COMPOSER_HOME" => site_directory
+  end
+
   template "#{mediawiki_directory}/LocalSettings.php" do
     cookbook "mediawiki"
     source "LocalSettings.php.erb"
@@ -543,8 +521,8 @@ action :update do
     variables :name => new_resource.site,
               :directory => mediawiki_directory,
               :database_params => database_params,
-              :mediawiki => mediawiki_params
-    notifies :run, "execute[#{mediawiki_directory}/maintenance/update.php]"
+              :mediawiki => mediawiki_params,
+              :secret_key => secret_key
   end
 
   execute "#{mediawiki_directory}/maintenance/update.php" do
@@ -624,8 +602,13 @@ action_class do
       :private_site => new_resource.private_site
     }
   end
+
+  def secret_key
+    persistent_token("mediawiki", new_resource.site, "wgSecretKey")
+  end
 end
 
 def after_created
+  notifies :update, "mediawiki_site[#{site}]"
   notifies :reload, "service[apache2]" if reload_apache
 end
index 3153fa91a772b37b4e15b682015e782f89f81be6..15ab639464f815380fe87e69be06e4e848d4bfea 100644 (file)
@@ -121,12 +121,5 @@ action_class do
 end
 
 def after_created
-  if update_site
-    notifies :update, "mediawiki_site[#{site}]"
-  else
-    site_directory = node[:mediawiki][:sites][site][:directory]
-
-    notifies :create, "template[#{site_directory}/w/LocalSettings.php]"
-    notifies :run, "execute[#{site_directory}/w/maintenance/update.php]"
-  end
+  notifies :update, "mediawiki_site[#{site}]" if update_site
 end
index 2485932b3df66596bbc52146bf71b789e19da3af..58836b54fd182e58f96048101b139b5695456a9a 100644 (file)
@@ -107,6 +107,19 @@ mediawiki_extension "MultiMaps" do
   template "mw-ext-MultiMaps.inc.php.erb"
   template_cookbook "wiki"
   variables :thunderforest_key => passwords["thunderforest"]
+  action :delete
+end
+
+mediawiki_extension "JsonConfig" do
+  site "wiki.openstreetmap.org"
+  template "mw-ext-JsonConfig.inc.php.erb"
+  template_cookbook "wiki"
+end
+
+mediawiki_extension "Kartographer" do
+  site "wiki.openstreetmap.org"
+  template "mw-ext-Kartographer.inc.php.erb"
+  template_cookbook "wiki"
 end
 
 cookbook_file "/srv/wiki.openstreetmap.org/osm_logo_wiki.png" do
diff --git a/cookbooks/wiki/templates/default/mw-ext-JsonConfig.inc.php.erb b/cookbooks/wiki/templates/default/mw-ext-JsonConfig.inc.php.erb
new file mode 100644 (file)
index 0000000..b3c666b
--- /dev/null
@@ -0,0 +1,6 @@
+<?php
+# DO NOT EDIT - This file is being maintained by Chef
+
+# JsonConfig is a requirement for Kartographer extension
+wfLoadExtension( 'JsonConfig' );
+
diff --git a/cookbooks/wiki/templates/default/mw-ext-Kartographer.inc.php.erb b/cookbooks/wiki/templates/default/mw-ext-Kartographer.inc.php.erb
new file mode 100644 (file)
index 0000000..60cba9a
--- /dev/null
@@ -0,0 +1,8 @@
+<?php
+# DO NOT EDIT - This file is being maintained by Chef
+
+wfLoadExtension( 'Kartographer' );
+$wgKartographerMapServer = 'https://tile.openstreetmap.org';
+$wgKartographerDfltStyle = '';
+$wgKartographerStyles = [];
+
diff --git a/cookbooks/wiki/templates/default/mw-ext-MultiMaps.inc.php.erb b/cookbooks/wiki/templates/default/mw-ext-MultiMaps.inc.php.erb
deleted file mode 100644 (file)
index ddcfb62..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php
-# DO NOT EDIT - This file is being maintained by Chef
-
-require_once "$IP/extensions/MultiMaps/MultiMaps.php";
-
-# Array of String. Array containing all the mapping services that will be made available to the user.
-# First value - default service, which will be used if the service is not in the parameters
-# Values may be a valid name of class based on class BaseMapService or some string and an array if they
-# denote different tiles within a BaseMapService
-$egMultiMaps_MapServices = [
-  'Leaflet',
-  'cyclosm' => [
-    'service' => 'Leaflet',
-    'attribution' => '&copy; <a href="https://osm.org/copyright">OpenStreetMap contributors</a>. Tiles style by <a href="https://www.cyclosm.org/" target="_blank">CyclOSM</a> hosted by <a href="https://openstreetmap.fr/" target="_blank">OpenStreetMap France</a>',
-    'source' => 'https://{s}.tile-cyclosm.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png',
-  ],
-  'cycle' => [
-    'service' => 'Leaflet',
-    'attribution' => '&copy; <a href="https://osm.org/copyright">OpenStreetMap contributors</a>. Tiles courtesy of <a href="https://www.thunderforest.com/" target="_blank">Andy Allan</a>',
-    'source' => 'https://tile.thunderforest.com/cycle/{z}/{x}/{y}.png?apikey=<%= @thunderforest_key %>',
-  ],
-  'transport' => [
-    'service' => 'Leaflet',
-    'attribution' => '&copy; <a href="https://osm.org/copyright">OpenStreetMap contributors</a>. Tiles courtesy of <a href="https://www.thunderforest.com/" target="_blank">Andy Allan</a>',
-    'source' => 'https://tile.thunderforest.com/transport/{z}/{x}/{y}.png?apikey=<%= @thunderforest_key %>',
-  ],
-  'oepnv' => [
-    'service' => 'Leaflet',
-    'attribution' => '&copy; <a href="https://osm.org/copyright">OpenStreetMap contributors</a>. Tiles courtesy of <a href="https://memomaps.de/" target="_blank">MeMoMaps</a>',
-    'source' => 'https://tileserver.memomaps.de/tilegen/{z}/{x}/{y}.png',
-  ],
-  'humanitarian' => [
-    'service' => 'Leaflet',
-    'attribution' => '&copy; <a href="https://osm.org/copyright">OpenStreetMap contributors</a>. Tiles style by <a href="https://www.hotosm.org/" target="_blank">Humanitarian OpenStreetMap team</a> hosted by <a href="https://openstreetmap.fr/" target="_blank">OpenStreetMap France</a>',
-    'source' => 'https://tile.openstreetmap.fr/hot/{z}/{x}/{y}.png'
-  ],
-];
diff --git a/test/data_bags/foundation/passwords.json b/test/data_bags/foundation/passwords.json
new file mode 100644 (file)
index 0000000..b8b93ca
--- /dev/null
@@ -0,0 +1,19 @@
+{
+  "id": "passwords",
+  "wiki": {
+    "database": "database_password",
+    "admin": "admin_password"
+  },
+  "board": {
+    "database": "database_password",
+    "admin": "admin_password"
+  },
+  "dwg": {
+    "database": "database_password",
+    "admin": "admin_password"
+  },
+  "mwg": {
+    "database": "database_password",
+    "admin": "admin_password"
+  }
+}
diff --git a/test/integration/foundation-board/serverspec/apache_spec.rb b/test/integration/foundation-board/serverspec/apache_spec.rb
new file mode 100644 (file)
index 0000000..446d3b9
--- /dev/null
@@ -0,0 +1,21 @@
+require "serverspec"
+
+# Required by serverspec
+set :backend, :exec
+
+describe package("apache2") do
+  it { should be_installed }
+end
+
+describe service("apache2") do
+  it { should be_enabled }
+  it { should be_running }
+end
+
+describe port(80) do
+  it { should be_listening.with("tcp") }
+end
+
+describe port(443) do
+  it { should be_listening.with("tcp") }
+end
diff --git a/test/integration/foundation-dwg/serverspec/apache_spec.rb b/test/integration/foundation-dwg/serverspec/apache_spec.rb
new file mode 100644 (file)
index 0000000..446d3b9
--- /dev/null
@@ -0,0 +1,21 @@
+require "serverspec"
+
+# Required by serverspec
+set :backend, :exec
+
+describe package("apache2") do
+  it { should be_installed }
+end
+
+describe service("apache2") do
+  it { should be_enabled }
+  it { should be_running }
+end
+
+describe port(80) do
+  it { should be_listening.with("tcp") }
+end
+
+describe port(443) do
+  it { should be_listening.with("tcp") }
+end
diff --git a/test/integration/foundation-mwg/serverspec/apache_spec.rb b/test/integration/foundation-mwg/serverspec/apache_spec.rb
new file mode 100644 (file)
index 0000000..446d3b9
--- /dev/null
@@ -0,0 +1,21 @@
+require "serverspec"
+
+# Required by serverspec
+set :backend, :exec
+
+describe package("apache2") do
+  it { should be_installed }
+end
+
+describe service("apache2") do
+  it { should be_enabled }
+  it { should be_running }
+end
+
+describe port(80) do
+  it { should be_listening.with("tcp") }
+end
+
+describe port(443) do
+  it { should be_listening.with("tcp") }
+end
diff --git a/test/integration/foundation-owg/serverspec/apache_spec.rb b/test/integration/foundation-owg/serverspec/apache_spec.rb
new file mode 100644 (file)
index 0000000..446d3b9
--- /dev/null
@@ -0,0 +1,21 @@
+require "serverspec"
+
+# Required by serverspec
+set :backend, :exec
+
+describe package("apache2") do
+  it { should be_installed }
+end
+
+describe service("apache2") do
+  it { should be_enabled }
+  it { should be_running }
+end
+
+describe port(80) do
+  it { should be_listening.with("tcp") }
+end
+
+describe port(443) do
+  it { should be_listening.with("tcp") }
+end
diff --git a/test/integration/foundation-wiki/serverspec/apache_spec.rb b/test/integration/foundation-wiki/serverspec/apache_spec.rb
new file mode 100644 (file)
index 0000000..446d3b9
--- /dev/null
@@ -0,0 +1,21 @@
+require "serverspec"
+
+# Required by serverspec
+set :backend, :exec
+
+describe package("apache2") do
+  it { should be_installed }
+end
+
+describe service("apache2") do
+  it { should be_enabled }
+  it { should be_running }
+end
+
+describe port(80) do
+  it { should be_listening.with("tcp") }
+end
+
+describe port(443) do
+  it { should be_listening.with("tcp") }
+end