]> git.openstreetmap.org Git - chef.git/commitdiff
Rename piwik to matomo
authorTom Hughes <tom@compton.nu>
Fri, 29 Jul 2022 16:18:43 +0000 (17:18 +0100)
committerTom Hughes <tom@compton.nu>
Fri, 29 Jul 2022 16:39:53 +0000 (17:39 +0100)
15 files changed:
.github/workflows/test-kitchen.yml
.kitchen.yml
cookbooks/matomo/README.md [new file with mode: 0644]
cookbooks/matomo/attributes/default.rb [moved from cookbooks/piwik/attributes/default.rb with 89% similarity]
cookbooks/matomo/metadata.rb [moved from cookbooks/piwik/metadata.rb with 78% similarity]
cookbooks/matomo/recipes/default.rb [new file with mode: 0644]
cookbooks/matomo/templates/default/apache.erb [moved from cookbooks/piwik/templates/default/apache.erb with 55% similarity]
cookbooks/matomo/templates/default/config.erb [moved from cookbooks/piwik/templates/default/config.erb with 92% similarity]
cookbooks/piwik/README.md [deleted file]
cookbooks/piwik/recipes/default.rb [deleted file]
roles/eustace.rb
roles/matomo.rb [moved from roles/piwik.rb with 85% similarity]
test/data_bags/matomo/passwords.json [moved from test/data_bags/piwik/passwords.json with 100% similarity]
test/data_bags/web/matomo.json [moved from test/data_bags/web/piwik.json with 77% similarity]
test/integration/matomo/serverspec/apache_spec.rb [moved from test/integration/piwik/serverspec/apache_spec.rb with 100% similarity]

index 5072dbe24c7bf64e427c76c34868160c7bc16d30..5c622df16ba003f872fc58a35e74c9f6a71bcb9b 100644 (file)
@@ -56,6 +56,7 @@ jobs:
           - logstash-forwarder
           - mail
           - mailman
+          - matomo
           - memcached
           - munin
           - munin-plugins
@@ -75,7 +76,6 @@ jobs:
           - php
           - php-apache
           - php-fpm
-          - piwik
           - planet
           - planet-current
           - planet-dump
index f9ac5d2439696a3db2c5ac299dc1a76c475bfc4c..84a501546457fc32f8534d7e2d63a82c28823be4 100644 (file)
@@ -191,6 +191,9 @@ suites:
   - name: mailman
     run_list:
       - recipe[mailman::default]
+  - name: matomo
+    run_list:
+      - recipe[matomo::default]
   - name: memcached
     run_list:
       - recipe[memcached::default]
@@ -248,9 +251,6 @@ suites:
   - name: php-fpm
     run_list:
       - recipe[php::fpm]
-  - name: piwik
-    run_list:
-      - recipe[piwik::default]
   - name: planet
     run_list:
       - recipe[planet::default]
diff --git a/cookbooks/matomo/README.md b/cookbooks/matomo/README.md
new file mode 100644 (file)
index 0000000..6cb8ee4
--- /dev/null
@@ -0,0 +1,4 @@
+# Matomo Cookbook
+
+This cookbook installs and configures the Matomo server-side software used for
+analytics on openstreetmap.org
similarity index 89%
rename from cookbooks/piwik/attributes/default.rb
rename to cookbooks/matomo/attributes/default.rb
index ff933400e99ff6ddf0db6efeeae5c4f650c4de13..6a9220b02387d47b55c059b748ce427d0916d9a0 100644 (file)
@@ -1,5 +1,5 @@
-default[:piwik][:version] = "4.10.1"
-default[:piwik][:plugins] = {
+default[:matomo][:version] = "4.10.1"
+default[:matomo][:plugins] = {
   "Actions" => nil,
   "Annotations" => nil,
   "API" => nil,
@@ -67,4 +67,4 @@ default[:piwik][:plugins] = {
   "Widgetize" => nil,
 }
 
-default[:mysql][:settings][:mysqld][:secure_file_priv] = "/opt/piwik-#{node[:piwik][:version]}/piwik/tmp/assets"
+default[:mysql][:settings][:mysqld][:secure_file_priv] = "/opt/matomo-#{node[:matomo][:version]}/matomo/tmp/assets"
similarity index 78%
rename from cookbooks/piwik/metadata.rb
rename to cookbooks/matomo/metadata.rb
index 54054e0e071e0e34589ecb8870d64413098ffe56..6160ec17ec4c4f4ac94c5adfdb66f544c7c805d2 100644 (file)
@@ -1,8 +1,8 @@
-name              "piwik"
+name              "matomo"
 maintainer        "OpenStreetMap Administrators"
 maintainer_email  "admins@openstreetmap.org"
 license           "Apache-2.0"
-description       "Installs and configures Piwik"
+description       "Installs and configures Matomo"
 
 version           "1.0.0"
 supports          "ubuntu"
diff --git a/cookbooks/matomo/recipes/default.rb b/cookbooks/matomo/recipes/default.rb
new file mode 100644 (file)
index 0000000..8b79c54
--- /dev/null
@@ -0,0 +1,171 @@
+#
+# Cookbook:: matomo
+# Recipe:: default
+#
+# Copyright:: 2011, OpenStreetMap Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+include_recipe "apache"
+include_recipe "geoipupdate"
+include_recipe "mysql"
+include_recipe "php::fpm"
+
+passwords = data_bag_item("matomo", "passwords")
+
+package %w[
+  php-cli
+  php-curl
+  php-mbstring
+  php-mysql
+  php-gd
+  php-xml
+  php-apcu
+]
+
+apache_module "expires"
+apache_module "rewrite"
+
+version = node[:matomo][:version]
+
+geoip_directory = node[:geoipupdate][:directory]
+
+directory "/opt/matomo-#{version}" do
+  owner "root"
+  group "root"
+  mode "0755"
+end
+
+remote_file "#{Chef::Config[:file_cache_path]}/matomo-#{version}.zip" do
+  source "https://builds.matomo.org/matomo-#{version}.zip"
+  not_if { ::File.exist?("/opt/matomo-#{version}/matomo") }
+end
+
+archive_file "#{Chef::Config[:file_cache_path]}/matomo-#{version}.zip" do
+  destination "/opt/matomo-#{version}"
+  overwrite true
+  owner "root"
+  group "root"
+  not_if { ::File.exist?("/opt/matomo-#{version}/matomo") }
+end
+
+node[:matomo][:plugins].each do |plugin_name, plugin_version|
+  next if plugin_version.nil?
+
+  remote_file "#{Chef::Config[:file_cache_path]}/matomo-#{plugin_name}-#{plugin_version}.zip" do
+    source "https://plugins.matomo.org/api/2.0/plugins/#{plugin_name}/download/#{plugin_version}"
+  end
+
+  archive_file "#{Chef::Config[:file_cache_path]}/matomo-#{plugin_name}-#{plugin_version}.zip" do
+    action :nothing
+    destination "/opt/matomo-#{version}/matomo/plugins"
+    overwrite true
+    owner "root"
+    group "root"
+    subscribes :extract, "remote_file[#{Chef::Config[:file_cache_path]}/matomo-#{plugin_name}-#{plugin_version}.zip]", :immediately
+  end
+end
+
+execute "/opt/matomo-#{version}/matomo/matomo.js" do
+  command "gzip -k -9 /opt/matomo-#{version}/matomo/matomo.js"
+  cwd "/opt/matomo-#{version}"
+  user "root"
+  group "root"
+  not_if { ::File.exist?("/opt/matomo-#{version}/matomo/matomo.js.gz") }
+end
+
+execute "/opt/matomo-#{version}/matomo/piwik.js" do
+  command "gzip -k -9 /opt/matomo-#{version}/matomo/piwik.js"
+  cwd "/opt/matomo-#{version}"
+  user "root"
+  group "root"
+  not_if { ::File.exist?("/opt/matomo-#{version}/matomo/piwik.js.gz") }
+end
+
+directory "/opt/matomo-#{version}/matomo/config" do
+  owner "www-data"
+  group "www-data"
+  mode "0755"
+end
+
+template "/opt/matomo-#{version}/matomo/config/config.ini.php" do
+  source "config.erb"
+  owner "root"
+  group "root"
+  mode "0644"
+  variables :passwords => passwords,
+            :directory => "/opt/matomo-#{version}/matomo",
+            :plugins => node[:matomo][:plugins].keys.sort
+end
+
+directory "/opt/matomo-#{version}/matomo/tmp" do
+  owner "www-data"
+  group "www-data"
+  mode "0755"
+end
+
+directory "/opt/matomo-#{version}/matomo/tmp/assets" do
+  owner "www-data"
+  group "mysql"
+  mode "0750"
+end
+
+link "/opt/matomo-#{version}/matomo/misc/GeoLite2-ASN.mmdb" do
+  to "#{geoip_directory}/GeoLite2-ASN.mmdb"
+end
+
+link "/opt/matomo-#{version}/matomo/misc/GeoLite2-City.mmdb" do
+  to "#{geoip_directory}/GeoLite2-City.mmdb"
+end
+
+link "/opt/matomo-#{version}/matomo/misc/GeoLite2-Country.mmdb" do
+  to "#{geoip_directory}/GeoLite2-Country.mmdb"
+end
+
+link "/srv/matomo.openstreetmap.org" do
+  to "/opt/matomo-#{version}/matomo"
+  notifies :restart, "service[php#{node[:php][:version]}-fpm]"
+end
+
+mysql_user "piwik@localhost" do
+  password passwords["database"]
+end
+
+mysql_database "piwik" do
+  permissions "piwik@localhost" => :all
+end
+
+ssl_certificate "matomo.openstreetmap.org" do
+  domains ["matomo.openstreetmap.org", "matomo.osm.org",
+           "piwik.openstreetmap.org", "piwik.osm.org"]
+  notifies :reload, "service[apache2]"
+end
+
+php_fpm "matomo.openstreetmap.org" do
+  prometheus_port 9253
+end
+
+apache_site "matomo.openstreetmap.org" do
+  template "apache.erb"
+end
+
+cron_d "matomo" do
+  minute "5"
+  user "www-data"
+  command "/usr/bin/php /srv/matomo.openstreetmap.org/console core:archive --quiet --url=https://matomo.openstreetmap.org/"
+end
+
+cron_d "piwik" do
+  action :delete
+end
similarity index 55%
rename from cookbooks/piwik/templates/default/apache.erb
rename to cookbooks/matomo/templates/default/apache.erb
index f1278a31fb921af7021b37ad9a0f56dda8015973..45b8bc0f305aecdc07374791eb91e2fcec4c245e 100644 (file)
@@ -1,20 +1,22 @@
 # DO NOT EDIT - This file is being maintained by Chef
 
 <VirtualHost *:443>
-       ServerName piwik.openstreetmap.org
+       ServerName matomo.openstreetmap.org
+       ServerAlias matomo.osm.org
+       ServerAlias piwik.openstreetmap.org
        ServerAlias piwik.osm.org
        ServerAdmin webmaster@openstreetmap.org
 
        SSLEngine on
-       SSLCertificateFile /etc/ssl/certs/piwik.openstreetmap.org.pem
-       SSLCertificateKeyFile /etc/ssl/private/piwik.openstreetmap.org.key
+       SSLCertificateFile /etc/ssl/certs/matomo.openstreetmap.org.pem
+       SSLCertificateKeyFile /etc/ssl/private/matomo.openstreetmap.org.key
 
-       CustomLog /var/log/apache2/piwik.openstreetmap.org-access.log combined
-       ErrorLog /var/log/apache2/piwik.openstreetmap.org-error.log
+       CustomLog /var/log/apache2/matomo.openstreetmap.org-access.log combined
+       ErrorLog /var/log/apache2/matomo.openstreetmap.org-error.log
 
        Options -Indexes
 
-       DocumentRoot /srv/piwik.openstreetmap.org
+       DocumentRoot /srv/matomo.openstreetmap.org
 
        Redirect 403 /core/
        Redirect 403 /config/
 </VirtualHost>
 
 <VirtualHost *:80>
-       ServerName piwik.openstreetmap.org
+       ServerName matomo.openstreetmap.org
+       ServerAlias matomo.osm.org
+       ServerAlias piwik.openstreetmap.org
        ServerAlias piwik.osm.org
        ServerAdmin webmaster@openstreetmap.org
 
-       CustomLog /var/log/apache2/piwik.openstreetmap.org-access.log combined
-       ErrorLog /var/log/apache2/piwik.openstreetmap.org-error.log
+       CustomLog /var/log/apache2/matomo.openstreetmap.org-access.log combined
+       ErrorLog /var/log/apache2/matomo.openstreetmap.org-error.log
 
        RedirectPermanent /.well-known/acme-challenge/ http://acme.openstreetmap.org/.well-known/acme-challenge/
-       RedirectPermanent / https://piwik.openstreetmap.org/
+       RedirectPermanent / https://matomo.openstreetmap.org/
 </VirtualHost>
 
-<Directory /srv/piwik.openstreetmap.org>
+<Directory /srv/matomo.openstreetmap.org>
        Require all granted
 
        ExpiresActive On
@@ -57,6 +61,6 @@
        </FilesMatch>
 
         <FilesMatch ".+\.ph(ar|p|tml)$">
-                SetHandler "proxy:unix:/run/php/piwik.openstreetmap.org.sock|fcgi://127.0.0.1"
+                SetHandler "proxy:unix:/run/php/matomo.openstreetmap.org.sock|fcgi://127.0.0.1"
         </FilesMatch>
 </Directory>
similarity index 92%
rename from cookbooks/piwik/templates/default/config.erb
rename to cookbooks/matomo/templates/default/config.erb
index 469adeeecdfee911b94b2bc7e32b7163d004a69e..457badc839c343f5545c06e437f7da0cbfd81eba 100644 (file)
@@ -13,11 +13,12 @@ force_ssl = 1
 force_ssl_login = 1
 login_allowlist_apply_to_reporting_api_requests = "0"
 proxy_client_headers[] = "HTTP_X_FORWARDED_FOR"
+trusted_hosts[] = "matomo.openstreetmap.org"
 trusted_hosts[] = "piwik.openstreetmap.org"
 salt = "<%= @passwords['salt'] %>"
 
 [Tracker]
-ignore_visits_cookie_name = "piwik_ignore"
+ignore_visits_cookie_name = "matomo_ignore"
 
 [Plugins]
 <% @plugins.each do |plugin| -%>
diff --git a/cookbooks/piwik/README.md b/cookbooks/piwik/README.md
deleted file mode 100644 (file)
index a968336..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-# Piwik Cookbook
-
-This cookbook installs and configures the Piwiki server-side software used for
-analytics on openstreetmap.org
diff --git a/cookbooks/piwik/recipes/default.rb b/cookbooks/piwik/recipes/default.rb
deleted file mode 100644 (file)
index 483a348..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-#
-# Cookbook:: piwik
-# Recipe:: default
-#
-# Copyright:: 2011, OpenStreetMap Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-include_recipe "apache"
-include_recipe "geoipupdate"
-include_recipe "mysql"
-include_recipe "php::fpm"
-
-passwords = data_bag_item("piwik", "passwords")
-
-package %w[
-  php-cli
-  php-curl
-  php-mbstring
-  php-mysql
-  php-gd
-  php-xml
-  php-apcu
-]
-
-apache_module "expires"
-apache_module "rewrite"
-
-version = node[:piwik][:version]
-
-geoip_directory = node[:geoipupdate][:directory]
-
-directory "/opt/piwik-#{version}" do
-  owner "root"
-  group "root"
-  mode "0755"
-end
-
-remote_file "#{Chef::Config[:file_cache_path]}/piwik-#{version}.zip" do
-  source "https://builds.matomo.org/piwik-#{version}.zip"
-  not_if { ::File.exist?("/opt/piwik-#{version}/piwik") }
-end
-
-archive_file "#{Chef::Config[:file_cache_path]}/piwik-#{version}.zip" do
-  destination "/opt/piwik-#{version}"
-  overwrite true
-  owner "root"
-  group "root"
-  not_if { ::File.exist?("/opt/piwik-#{version}/piwik") }
-end
-
-node[:piwik][:plugins].each do |plugin_name, plugin_version|
-  next if plugin_version.nil?
-
-  remote_file "#{Chef::Config[:file_cache_path]}/piwik-#{plugin_name}-#{plugin_version}.zip" do
-    source "https://plugins.matomo.org/api/2.0/plugins/#{plugin_name}/download/#{plugin_version}"
-  end
-
-  archive_file "#{Chef::Config[:file_cache_path]}/piwik-#{plugin_name}-#{plugin_version}.zip" do
-    action :nothing
-    destination "/opt/piwik-#{version}/piwik/plugins"
-    overwrite true
-    owner "root"
-    group "root"
-    subscribes :extract, "remote_file[#{Chef::Config[:file_cache_path]}/piwik-#{plugin_name}-#{plugin_version}.zip]", :immediately
-  end
-end
-
-execute "/opt/piwik-#{version}/piwik/piwik.js" do
-  command "gzip -k -9 /opt/piwik-#{version}/piwik/piwik.js"
-  cwd "/opt/piwik-#{version}"
-  user "root"
-  group "root"
-  not_if { ::File.exist?("/opt/piwik-#{version}/piwik/piwik.js.gz") }
-end
-
-directory "/opt/piwik-#{version}/piwik/config" do
-  owner "www-data"
-  group "www-data"
-  mode "0755"
-end
-
-template "/opt/piwik-#{version}/piwik/config/config.ini.php" do
-  source "config.erb"
-  owner "root"
-  group "root"
-  mode "0644"
-  variables :passwords => passwords,
-            :directory => "/opt/piwik-#{version}/piwik",
-            :plugins => node[:piwik][:plugins].keys.sort
-end
-
-directory "/opt/piwik-#{version}/piwik/tmp" do
-  owner "www-data"
-  group "www-data"
-  mode "0755"
-end
-
-directory "/opt/piwik-#{version}/piwik/tmp/assets" do
-  owner "www-data"
-  group "mysql"
-  mode "0750"
-end
-
-link "/opt/piwik-#{version}/piwik/misc/GeoLite2-ASN.mmdb" do
-  to "#{geoip_directory}/GeoLite2-ASN.mmdb"
-end
-
-link "/opt/piwik-#{version}/piwik/misc/GeoLite2-City.mmdb" do
-  to "#{geoip_directory}/GeoLite2-City.mmdb"
-end
-
-link "/opt/piwik-#{version}/piwik/misc/GeoLite2-Country.mmdb" do
-  to "#{geoip_directory}/GeoLite2-Country.mmdb"
-end
-
-link "/srv/piwik.openstreetmap.org" do
-  to "/opt/piwik-#{version}/piwik"
-  notifies :restart, "service[php#{node[:php][:version]}-fpm]"
-end
-
-mysql_user "piwik@localhost" do
-  password passwords["database"]
-end
-
-mysql_database "piwik" do
-  permissions "piwik@localhost" => :all
-end
-
-ssl_certificate "piwik.openstreetmap.org" do
-  domains ["piwik.openstreetmap.org", "piwik.osm.org"]
-  notifies :reload, "service[apache2]"
-end
-
-php_fpm "piwik.openstreetmap.org" do
-  prometheus_port 9253
-end
-
-apache_site "piwik.openstreetmap.org" do
-  template "apache.erb"
-end
-
-cron_d "piwik" do
-  minute "5"
-  user "www-data"
-  command "/usr/bin/php /srv/piwik.openstreetmap.org/console core:archive --quiet --url=https://piwik.openstreetmap.org/"
-end
index 4aa2fdd31e80d0399775fc98663a51ac805a869d..bd11cb3458e29d21130cec20543cec04e8df7626 100644 (file)
@@ -23,5 +23,5 @@ default_attributes(
 run_list(
   "role[ucl]",
   "role[hp-dl360-g6]",
-  "role[piwik]"
+  "role[matomo]"
 )
similarity index 85%
rename from roles/piwik.rb
rename to roles/matomo.rb
index 7f161753b54a5a911c8aef718b3fb20225282ce5..ae632f8982bd6dd22ac006a0c53a57a0ae27127b 100644 (file)
@@ -1,5 +1,5 @@
-name "piwik"
-description "Role applied to all Piwik servers"
+name "matomo"
+description "Role applied to all Matomo servers"
 
 default_attributes(
   :apache => {
@@ -24,5 +24,5 @@ default_attributes(
 )
 
 run_list(
-  "recipe[piwik]"
+  "recipe[matomo]"
 )
similarity index 77%
rename from test/data_bags/web/piwik.json
rename to test/data_bags/web/matomo.json
index f9b73748a95ae3ea2e7a8d0273716f8f10a39ccd..0bae1e2673894ffe8f652dd5e65383dacae9570a 100644 (file)
@@ -1,6 +1,6 @@
 {
-  "id": "piwik",
-  "location": "piwik",
+  "id": "matomo",
+  "location": "matomo",
   "site": 100,
   "goals": {
     "signup": 1001,