5 # Copyright:: 2011, OpenStreetMap Foundation
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # https://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
20 include_recipe "apache"
21 include_recipe "geoipupdate"
22 include_recipe "mysql"
24 passwords = data_bag_item("piwik", "passwords")
29 package "php-mbstring"
35 apache_module "expires"
36 apache_module "php7.2"
37 apache_module "rewrite"
39 version = node[:piwik][:version]
41 directory "/opt/piwik-#{version}" do
47 remote_file "#{Chef::Config[:file_cache_path]}/piwik-#{version}.zip" do
48 source "https://builds.matomo.org/piwik-#{version}.zip"
49 not_if { ::File.exist?("/opt/piwik-#{version}/piwik") }
52 execute "unzip-piwik-#{version}" do
53 command "unzip -q #{Chef::Config[:file_cache_path]}/piwik-#{version}.zip"
54 cwd "/opt/piwik-#{version}"
57 not_if { ::File.exist?("/opt/piwik-#{version}/piwik") }
60 execute "/opt/piwik-#{version}/piwik/piwik.js" do
61 command "gzip -k -9 /opt/piwik-#{version}/piwik/piwik.js"
62 cwd "/opt/piwik-#{version}"
65 not_if { ::File.exist?("/opt/piwik-#{version}/piwik/piwik.js.gz") }
68 directory "/opt/piwik-#{version}/piwik/config" do
74 template "/opt/piwik-#{version}/piwik/config/config.ini.php" do
79 variables :passwords => passwords,
80 :directory => "/opt/piwik-#{version}/piwik",
81 :plugins => node[:piwik][:plugins]
84 directory "/opt/piwik-#{version}/piwik/tmp" do
90 link "/opt/piwik-#{version}/piwik/misc/GeoLite2-ASN.mmdb" do
91 to "/usr/share/GeoIP/GeoLite2-ASN.mmdb"
94 link "/opt/piwik-#{version}/piwik/misc/GeoLite2-City.mmdb" do
95 to "/usr/share/GeoIP/GeoLite2-City.mmdb"
98 link "/opt/piwik-#{version}/piwik/misc/GeoLite2-Country.mmdb" do
99 to "/usr/share/GeoIP/GeoLite2-Country.mmdb"
102 link "/srv/piwik.openstreetmap.org" do
103 to "/opt/piwik-#{version}/piwik"
104 notifies :restart, "service[apache2]"
107 mysql_user "piwik@localhost" do
108 password passwords["database"]
111 mysql_database "piwik" do
112 permissions "piwik@localhost" => :all
115 ssl_certificate "piwik.openstreetmap.org" do
116 domains ["piwik.openstreetmap.org", "piwik.osm.org"]
117 notifies :reload, "service[apache2]"
120 apache_site "piwik.openstreetmap.org" do
121 template "apache.erb"
124 template "/etc/cron.d/piwiki" do