Modernize kosmos-mediawiki

This has been done with the help of `cookstyle` which is very useful to
learn about breaking changes and updates in Chef.

On wiki-1 I managed to update Chef up to 17.10.163. For version 18 I ran
into an issue with the omnibus installer returning a 404

Refs #500
This commit is contained in:
Greg Karekinian 2025-07-09 11:18:14 +02:00
parent 8052c67d23
commit 443910c7a2
3 changed files with 24 additions and 25 deletions

View File

@ -28,6 +28,7 @@
"timezone_iii::debian", "timezone_iii::debian",
"ntp::default", "ntp::default",
"ntp::apparmor", "ntp::apparmor",
"kosmos-base::journald_conf",
"kosmos-base::systemd_emails", "kosmos-base::systemd_emails",
"apt::unattended-upgrades", "apt::unattended-upgrades",
"kosmos-base::firewall", "kosmos-base::firewall",
@ -66,12 +67,13 @@
"cloud": null, "cloud": null,
"chef_packages": { "chef_packages": {
"chef": { "chef": {
"version": "15.13.8", "version": "17.10.163",
"chef_root": "/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/chef-15.13.8/lib" "chef_root": "/opt/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.10.163/lib",
"chef_effortless": null
}, },
"ohai": { "ohai": {
"version": "15.12.0", "version": "17.9.7",
"ohai_root": "/opt/chef/embedded/lib/ruby/gems/2.6.0/gems/ohai-15.12.0/lib/ohai" "ohai_root": "/opt/chef/embedded/lib/ruby/gems/3.0.0/gems/ohai-17.9.7/lib/ohai"
} }
} }
}, },

View File

@ -3,7 +3,6 @@ maintainer 'Kosmos'
maintainer_email 'mail@kosmos.org' maintainer_email 'mail@kosmos.org'
license 'MIT' license 'MIT'
description 'Installs/Configures kosmos-mediawiki' description 'Installs/Configures kosmos-mediawiki'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.3.1' version '0.3.1'
depends "mediawiki" depends "mediawiki"

View File

@ -1,9 +1,9 @@
# #
# Cookbook Name:: kosmos-mediawiki # Cookbook:: kosmos-mediawiki
# Recipe:: default # Recipe:: default.rb
# #
include_recipe 'apt' apt_update
include_recipe 'ark' include_recipe 'ark'
include_recipe 'composer' include_recipe 'composer'
@ -30,14 +30,14 @@ directory "#{node['mediawiki']['webdir']}/skins/common/images" do
owner node['nginx']['user'] owner node['nginx']['user']
group node['nginx']['group'] group node['nginx']['group']
recursive true recursive true
mode 0750 mode "750"
end end
cookbook_file "#{node['mediawiki']['webdir']}/skins/common/images/kosmos.png" do cookbook_file "#{node['mediawiki']['webdir']}/skins/common/images/kosmos.png" do
source 'kosmos.png' source 'kosmos.png'
owner node['nginx']['user'] owner node['nginx']['user']
group node['nginx']['group'] group node['nginx']['group']
mode 0640 mode "640"
end end
directory "#{node['mediawiki']['webdir']}/.well-known/acme-challenge" do directory "#{node['mediawiki']['webdir']}/.well-known/acme-challenge" do
@ -80,14 +80,14 @@ nginx_certbot_site server_name
# Extensions # Extensions
# #
mediawiki_credentials = Chef::EncryptedDataBagItem.load('credentials', 'mediawiki') mediawiki_credentials = data_bag_item('credentials', 'mediawiki')
# #
# MediawikiHubot extension # MediawikiHubot extension
# #
# requires curl extension # requires curl extension
if platform?('ubuntu') && node[:platform_version].to_f < 16.04 if platform?('ubuntu') && node["platform_version"].to_f < 16.04
package "php5-curl" package "php5-curl"
else else
package "php-curl" package "php-curl"
@ -100,7 +100,7 @@ ark "MediawikiHubot" do
action :cherry_pick action :cherry_pick
end end
hubot_credentials = Chef::EncryptedDataBagItem.load('credentials', 'hal8000_xmpp') hubot_credentials = data_bag_item('credentials', 'hal8000_xmpp')
webhook_token = hubot_credentials['webhook_token'] webhook_token = hubot_credentials['webhook_token']
template "#{node['mediawiki']['webdir']}/extensions/MediawikiHubot/DefaultConfig.php" do template "#{node['mediawiki']['webdir']}/extensions/MediawikiHubot/DefaultConfig.php" do
@ -145,7 +145,7 @@ end
ruby_block "configuration" do ruby_block "configuration" do
block do block do
# FIXME This is internal Chef API and should not be used from recipes, as # FIXME: This is internal Chef API and should not be used from recipes, as
# it is unsupported for that # it is unsupported for that
file = Chef::Util::FileEdit.new("#{node['mediawiki']['webdir']}/LocalSettings.php") file = Chef::Util::FileEdit.new("#{node['mediawiki']['webdir']}/LocalSettings.php")
file.search_file_replace_line(%r{\$wgLogo\ =\ \"\$wgResourceBasePath\/resources\/assets\/wiki.png\";}, file.search_file_replace_line(%r{\$wgLogo\ =\ \"\$wgResourceBasePath\/resources\/assets\/wiki.png\";},
@ -247,9 +247,7 @@ end
# #
file "#{node['mediawiki']['webdir']}/composer.local.json" do file "#{node['mediawiki']['webdir']}/composer.local.json" do
requires = { "require": { requires = { "require": { "mediawiki/mermaid": "~1.0" } }.to_json
"mediawiki/mermaid": "~1.0"
}}.to_json
content requires content requires
owner node['nginx']['user'] owner node['nginx']['user']
group node['nginx']['group'] group node['nginx']['group']