Bring piwik installation/upgrade under chef control
authorTom Hughes <tom@compton.nu>
Thu, 23 Oct 2014 21:50:14 +0000 (22:50 +0100)
committerTom Hughes <tom@compton.nu>
Thu, 23 Oct 2014 21:55:43 +0000 (22:55 +0100)
cookbooks/piwik/attributes/default.rb [new file with mode: 0644]
cookbooks/piwik/recipes/default.rb
cookbooks/piwik/templates/default/config.erb [new file with mode: 0644]

diff --git a/cookbooks/piwik/attributes/default.rb b/cookbooks/piwik/attributes/default.rb
new file mode 100644 (file)
index 0000000..23605a6
--- /dev/null
@@ -0,0 +1 @@
+default[:piwik][:version] = "2.8.0"
index 02fb7a860cf3983d13d94cf93c39a433bbf35733..376b96e4f08bb417788e405881446943512a1273 100644 (file)
@@ -35,33 +35,50 @@ package "geoip-database-contrib"
 apache_module "php5"
 apache_module "geoip"
 
-apache_site "piwik.openstreetmap.org" do
-  template "apache.erb"
-end
+version = node[:piwik][:version]
 
-directory "/srv/piwik.openstreetmap.org" do
+directory "/opt/piwik-#{version}" do
   owner "root"
   group "root"
   mode "0755"
 end
 
-directory "/srv/piwik.openstreetmap.org/config" do
-  owner "www-data"
-  group "www-data"
-  mode "0755"
+remote_file "/tmp/piwik-#{version}.zip" do
+  source "http://builds.piwik.org/piwik-#{version}.zip"
+  not_if { File.exist?("/opt/piwik-#{version}/piwik") }
 end
 
-directory "/srv/piwik.openstreetmap.org/tmp" do
+execute "unzip-piwik-#{version}" do
+  command "unzip -q /tmp/piwik-#{version}.zip"
+  cwd "/opt/piwik-#{version}"
+  user "root"
+  group "root"
+  not_if { File.exist?("/opt/piwik-#{version}/piwik") }
+end
+
+directory "/opt/piwik-#{version}/piwik/config" do
   owner "www-data"
   group "www-data"
   mode "0755"
 end
 
-template "/etc/cron.d/piwiki" do
-  source "cron.erb"
+template "/opt/piwik-#{version}/piwik/config/config.ini.php" do
+  source "config.erb"
   owner "root"
   group "root"
   mode "0644"
+  variables :passwords => passwords
+end
+
+directory "/opt/piwik-#{version}/piwik/tmp" do
+  owner "www-data"
+  group "www-data"
+  mode "0755"
+end
+
+link "/srv/piwik.openstreetmap.org" do
+  to "/opt/piwik-#{version}/piwik"
+  notifies :restart, "service[apache2]"
 end
 
 mysql_user "piwik@localhost" do
@@ -71,3 +88,14 @@ end
 mysql_database "piwik" do
   permissions "piwik@localhost" => :all
 end
+
+apache_site "piwik.openstreetmap.org" do
+  template "apache.erb"
+end
+
+template "/etc/cron.d/piwiki" do
+  source "cron.erb"
+  owner "root"
+  group "root"
+  mode "0644"
+end
diff --git a/cookbooks/piwik/templates/default/config.erb b/cookbooks/piwik/templates/default/config.erb
new file mode 100644 (file)
index 0000000..cea82b6
--- /dev/null
@@ -0,0 +1,112 @@
+; <?php exit; ?> DO NOT REMOVE THIS LINE
+; file automatically generated or modified by Piwik; you can manually override the default values in global.ini.php by redefining them in this file.
+[database]
+host = "localhost"
+username = "piwik"
+password = "<%= @passwords['database'] %>"
+dbname = "piwik"
+tables_prefix = "piwik_"
+charset = "utf8"
+
+[General]
+force_ssl_login = 1
+proxy_client_headers[] = "HTTP_X_FORWARDED_FOR"
+trusted_hosts[] = "piwik.openstreetmap.org"
+salt = "<%= @passwords['salt'] %>"
+
+[Plugins]
+Plugins[] = "CorePluginsAdmin"
+Plugins[] = "CoreAdminHome"
+Plugins[] = "CoreHome"
+Plugins[] = "Proxy"
+Plugins[] = "API"
+Plugins[] = "Widgetize"
+Plugins[] = "LanguagesManager"
+Plugins[] = "Actions"
+Plugins[] = "Dashboard"
+Plugins[] = "MultiSites"
+Plugins[] = "UserSettings"
+Plugins[] = "Goals"
+Plugins[] = "SEO"
+Plugins[] = "UserCountry"
+Plugins[] = "VisitsSummary"
+Plugins[] = "VisitFrequency"
+Plugins[] = "VisitTime"
+Plugins[] = "VisitorInterest"
+Plugins[] = "ExampleAPI"
+Plugins[] = "ExamplePlugin"
+Plugins[] = "ExampleRssWidget"
+Plugins[] = "Provider"
+Plugins[] = "Feedback"
+Plugins[] = "Login"
+Plugins[] = "UsersManager"
+Plugins[] = "SitesManager"
+Plugins[] = "Installation"
+Plugins[] = "CoreUpdater"
+Plugins[] = "UserCountryMap"
+Plugins[] = "Live"
+Plugins[] = "CustomVariables"
+Plugins[] = "PrivacyManager"
+Plugins[] = "ImageGraph"
+Plugins[] = "DoNotTrack"
+Plugins[] = "DevicesDetection"
+Plugins[] = "Referrers"
+Plugins[] = "CoreConsole"
+Plugins[] = "CoreVisualizations"
+Plugins[] = "Morpheus"
+Plugins[] = "Contents"
+
+[PluginsInstalled]
+PluginsInstalled[] = "Login"
+PluginsInstalled[] = "CoreAdminHome"
+PluginsInstalled[] = "UsersManager"
+PluginsInstalled[] = "SitesManager"
+PluginsInstalled[] = "Installation"
+PluginsInstalled[] = "CorePluginsAdmin"
+PluginsInstalled[] = "CoreHome"
+PluginsInstalled[] = "Proxy"
+PluginsInstalled[] = "API"
+PluginsInstalled[] = "Widgetize"
+PluginsInstalled[] = "LanguagesManager"
+PluginsInstalled[] = "Actions"
+PluginsInstalled[] = "Dashboard"
+PluginsInstalled[] = "MultiSites"
+PluginsInstalled[] = "UserSettings"
+PluginsInstalled[] = "Goals"
+PluginsInstalled[] = "SEO"
+PluginsInstalled[] = "UserCountry"
+PluginsInstalled[] = "VisitsSummary"
+PluginsInstalled[] = "VisitFrequency"
+PluginsInstalled[] = "VisitTime"
+PluginsInstalled[] = "VisitorInterest"
+PluginsInstalled[] = "ExampleAPI"
+PluginsInstalled[] = "ExamplePlugin"
+PluginsInstalled[] = "ExampleRssWidget"
+PluginsInstalled[] = "ExampleFeedburner"
+PluginsInstalled[] = "Provider"
+PluginsInstalled[] = "Feedback"
+PluginsInstalled[] = "CoreUpdater"
+PluginsInstalled[] = "UserCountryMap"
+PluginsInstalled[] = "Live"
+PluginsInstalled[] = "CustomVariables"
+PluginsInstalled[] = "PrivacyManager"
+PluginsInstalled[] = "GeoIP"
+PluginsInstalled[] = "ImageGraph"
+PluginsInstalled[] = "DoNotTrack"
+PluginsInstalled[] = "DevicesDetection"
+PluginsInstalled[] = "CoreConsole"
+PluginsInstalled[] = "CoreVisualizations"
+PluginsInstalled[] = "Referrers"
+PluginsInstalled[] = "Morpheus"
+PluginsInstalled[] = "Contents"
+
+[Plugins_Tracker]
+Plugins_Tracker[] = "Provider"
+Plugins_Tracker[] = "Goals"
+Plugins_Tracker[] = "DoNotTrack"
+Plugins_Tracker[] = "UserCountry"
+Plugins_Tracker[] = "DevicesDetection"
+Plugins_Tracker[] = "UsersManager"
+Plugins_Tracker[] = "SitesManager"
+Plugins_Tracker[] = "PrivacyManager"
+