From 8ec107389c929759806f3e13762bde4378f0494c Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Mon, 21 Mar 2022 08:38:24 +0000 Subject: [PATCH] Allow piwik to use LOAD DATA INFILE for improved performance --- cookbooks/mysql/recipes/default.rb | 12 ++++++++++++ cookbooks/mysql/templates/default/apparmor.erb | 4 ++++ cookbooks/piwik/attributes/default.rb | 2 ++ cookbooks/piwik/recipes/default.rb | 6 ++++++ 4 files changed, 24 insertions(+) create mode 100644 cookbooks/mysql/templates/default/apparmor.erb diff --git a/cookbooks/mysql/recipes/default.rb b/cookbooks/mysql/recipes/default.rb index d0d7b1679..00334af00 100644 --- a/cookbooks/mysql/recipes/default.rb +++ b/cookbooks/mysql/recipes/default.rb @@ -36,6 +36,18 @@ template "/etc/mysql/mysql.conf.d/zzz-chef.cnf" do notifies :restart, "service[mysql]" end +service "apparmor" do + action :nothing +end + +template "/etc/apparmor.d/local/usr.sbin.mysqld" do + source "apparmor.erb" + owner "root" + group "root" + mode "644" + notifies :restart, "service[apparmor]" +end + package "libdbd-mysql-perl" package "libcache-cache-perl" diff --git a/cookbooks/mysql/templates/default/apparmor.erb b/cookbooks/mysql/templates/default/apparmor.erb new file mode 100644 index 000000000..1a0f6574b --- /dev/null +++ b/cookbooks/mysql/templates/default/apparmor.erb @@ -0,0 +1,4 @@ +# DO NOT EDIT - This file is being maintained by Chef +<% if node[:mysql][:settings][:mysqld][:secure_file_priv] -%> +<%= node[:mysql][:settings][:mysqld][:secure_file_priv] %>/* rw, +<% end -%> diff --git a/cookbooks/piwik/attributes/default.rb b/cookbooks/piwik/attributes/default.rb index 5597d454c..2470bddcc 100644 --- a/cookbooks/piwik/attributes/default.rb +++ b/cookbooks/piwik/attributes/default.rb @@ -12,3 +12,5 @@ default[:piwik][:plugins] = %w[ VisitFrequency VisitorInterest VisitsSummary VisitTime WebsiteMeasurable Widgetize ] + +default[:mysql][:settings][:mysqld][:secure_file_priv] = "/opt/piwik-#{node[:piwik][:version]}/piwik/tmp/assets" diff --git a/cookbooks/piwik/recipes/default.rb b/cookbooks/piwik/recipes/default.rb index 997048308..b2a27737a 100644 --- a/cookbooks/piwik/recipes/default.rb +++ b/cookbooks/piwik/recipes/default.rb @@ -88,6 +88,12 @@ directory "/opt/piwik-#{version}/piwik/tmp" do 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 "/usr/share/GeoIP/GeoLite2-ASN.mmdb" end -- 2.39.5