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"
23 include_recipe "php::fpm"
25 passwords = data_bag_item("piwik", "passwords")
38 apache_module "expires"
39 apache_module "rewrite"
41 version = node[:piwik][:version]
43 directory "/opt/piwik-#{version}" do
49 remote_file "#{Chef::Config[:file_cache_path]}/piwik-#{version}.zip" do
50 source "https://builds.matomo.org/piwik-#{version}.zip"
51 not_if { ::File.exist?("/opt/piwik-#{version}/piwik") }
54 execute "unzip-piwik-#{version}" do
55 command "unzip -q #{Chef::Config[:file_cache_path]}/piwik-#{version}.zip"
56 cwd "/opt/piwik-#{version}"
59 not_if { ::File.exist?("/opt/piwik-#{version}/piwik") }
62 execute "/opt/piwik-#{version}/piwik/piwik.js" do
63 command "gzip -k -9 /opt/piwik-#{version}/piwik/piwik.js"
64 cwd "/opt/piwik-#{version}"
67 not_if { ::File.exist?("/opt/piwik-#{version}/piwik/piwik.js.gz") }
70 directory "/opt/piwik-#{version}/piwik/config" do
76 template "/opt/piwik-#{version}/piwik/config/config.ini.php" do
81 variables :passwords => passwords,
82 :directory => "/opt/piwik-#{version}/piwik",
83 :plugins => node[:piwik][:plugins]
86 directory "/opt/piwik-#{version}/piwik/tmp" do
92 link "/opt/piwik-#{version}/piwik/misc/GeoLite2-ASN.mmdb" do
93 to "/usr/share/GeoIP/GeoLite2-ASN.mmdb"
96 link "/opt/piwik-#{version}/piwik/misc/GeoLite2-City.mmdb" do
97 to "/usr/share/GeoIP/GeoLite2-City.mmdb"
100 link "/opt/piwik-#{version}/piwik/misc/GeoLite2-Country.mmdb" do
101 to "/usr/share/GeoIP/GeoLite2-Country.mmdb"
104 link "/srv/piwik.openstreetmap.org" do
105 to "/opt/piwik-#{version}/piwik"
106 notifies :restart, "service[php#{node[:php][:version]}-fpm]"
109 mysql_user "piwik@localhost" do
110 password passwords["database"]
113 mysql_database "piwik" do
114 permissions "piwik@localhost" => :all
117 ssl_certificate "piwik.openstreetmap.org" do
118 domains ["piwik.openstreetmap.org", "piwik.osm.org"]
119 notifies :reload, "service[apache2]"
122 php_fpm "piwik.openstreetmap.org" do
126 apache_site "piwik.openstreetmap.org" do
127 template "apache.erb"
133 command "/usr/bin/php /srv/piwik.openstreetmap.org/console core:archive --quiet --url=https://piwik.openstreetmap.org/"