]> git.openstreetmap.org Git - chef.git/commitdiff
Use MaxMind PPA for geoipupdate and configure account credentials
authorTom Hughes <tom@compton.nu>
Wed, 1 Jan 2020 16:13:34 +0000 (16:13 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 1 Jan 2020 16:34:54 +0000 (16:34 +0000)
.rubocop.yml
cookbooks/apt/recipes/default.rb
cookbooks/geodns/metadata.rb
cookbooks/geodns/recipes/default.rb
cookbooks/geoipupdate/README.md [new file with mode: 0644]
cookbooks/geoipupdate/attributes/default.rb [new file with mode: 0644]
cookbooks/geoipupdate/metadata.rb [new file with mode: 0644]
cookbooks/geoipupdate/recipes/default.rb [new file with mode: 0644]
cookbooks/geoipupdate/templates/default/GeoIP.conf.erb [new file with mode: 0644]
cookbooks/piwik/metadata.rb
cookbooks/piwik/recipes/default.rb

index 5db1a31045524667dabbea1a6aaf55863ffa3ed4..12d060a1b67140fe609ff94b8a4f77826916ad78 100644 (file)
@@ -3,6 +3,9 @@ inherit_from: .rubocop_todo.yml
 AllCops:
   TargetRubyVersion: 2.3
 
+ChefModernize/IncludingAptDefaultRecipe:
+  Enabled: false
+
 Layout/ExtraSpacing:
   AllowForAlignment: true
 
index 9aa2f7a827760dc54dc5d70c5275c9d42479b496..99558f9dd4324e7c0a257ab2d01396827a8f3859 100644 (file)
@@ -73,6 +73,11 @@ apt_repository "ubuntugis-unstable" do
   uri "ppa:ubuntugis/ubuntugis-unstable"
 end
 
+apt_repository "maxmind" do
+  action repository_actions["maxmind"]
+  uri "ppa:maxmind/ppa"
+end
+
 apt_repository "openstreetmap" do
   action repository_actions["openstreetmap"]
   uri "ppa:osmadmins/ppa"
index 4ce6925bb6c38453b91a7f646262dbdee0d7b178..4782ac0353498ca4999bc18ef3c00ed696830c73 100644 (file)
@@ -6,4 +6,5 @@ description       "Installs and configures a geographic DNS server"
 
 version           "1.0.0"
 supports          "ubuntu"
+depends           "geoipupdate"
 depends           "systemd"
index f24f1b8deecaadc03ec803e555e530d1a3a31b9f..813ac250cfed8404c00584543ea2d3eb48df1a52 100644 (file)
 # limitations under the License.
 #
 
+include_recipe "geoipupdate"
+
 package %w[
-  geoipupdate
   gdnsd
 ]
 
-execute "geoipdate" do
-  command "geoipupdate"
-  user "root"
-  group "root"
-  not_if { ::File.exist?("/var/lib/GeoIP/GeoLite2-Country.mmdb") }
-end
-
 directory "/etc/gdnsd/config.d" do
   owner "nobody"
   group "nogroup"
diff --git a/cookbooks/geoipupdate/README.md b/cookbooks/geoipupdate/README.md
new file mode 100644 (file)
index 0000000..5eb9966
--- /dev/null
@@ -0,0 +1,4 @@
+# geoipupdate Cookbook
+
+This cookbook installs and configures geoipupdate, a tool to keep MaxMind
+GeoIP databases up to date.
diff --git a/cookbooks/geoipupdate/attributes/default.rb b/cookbooks/geoipupdate/attributes/default.rb
new file mode 100644 (file)
index 0000000..3165aa1
--- /dev/null
@@ -0,0 +1,4 @@
+default[:geoipupdate][:account] = "149244"
+default[:geoipupdate][:editions] = %w[GeoLite2-ASN GeoLite2-City GeoLite2-Country]
+
+default[:apt][:sources] |= ["maxmind"]
diff --git a/cookbooks/geoipupdate/metadata.rb b/cookbooks/geoipupdate/metadata.rb
new file mode 100644 (file)
index 0000000..78d65c5
--- /dev/null
@@ -0,0 +1,9 @@
+name              "geoipupdate"
+maintainer        "OpenStreetMap Administrators"
+maintainer_email  "admins@openstreetmap.org"
+license           "Apache-2.0"
+description       "Installs and configures geoipupdate"
+
+version           "1.0.0"
+supports          "ubuntu"
+depends           "apt"
diff --git a/cookbooks/geoipupdate/recipes/default.rb b/cookbooks/geoipupdate/recipes/default.rb
new file mode 100644 (file)
index 0000000..0c4a84c
--- /dev/null
@@ -0,0 +1,46 @@
+#
+# Cookbook:: geoipdate
+# Recipe:: default
+#
+# Copyright:: 2020, 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 "apt"
+
+license_keys = data_bag_item("geoipupdate", "license-keys")
+
+package "geoipupdate" do
+  action [:install, :upgrade]
+end
+
+template "/etc/GeoIP.conf" do
+  source "GeoIP.conf.erb"
+  owner "root"
+  group "root"
+  mode 0o644
+  variables :license_keys => license_keys
+end
+
+execute "geoipdate" do
+  command "geoipupdate"
+  user "root"
+  group "root"
+  not_if { node[:geoipupdate][:editions].all? { |edition| ::File.exist?("/usr/share/GeoIP/#{edition}.mmdb") } }
+end
+
+directory "/var/lib/GeoIP" do
+  action :delete
+  recursive true
+end
diff --git a/cookbooks/geoipupdate/templates/default/GeoIP.conf.erb b/cookbooks/geoipupdate/templates/default/GeoIP.conf.erb
new file mode 100644 (file)
index 0000000..9caa330
--- /dev/null
@@ -0,0 +1,5 @@
+# DO NOT EDIT - This file is being maintained by Chef
+
+AccountID <%= node[:geoipupdate][:account] %>
+LicenseKey <%= @license_keys[node[:geoipupdate][:account]] %>
+EditionIDs <%= Array(node[:geoipupdate][:editions]).join(" ") %>
index 1644aa90ac5a2967eb2b58c4cec30232ba9407b0..b0f20ff08a4f4223cb5b232b4561068e8dff07aa 100644 (file)
@@ -7,4 +7,5 @@ description       "Installs and configures Piwik"
 version           "1.0.0"
 supports          "ubuntu"
 depends           "apache"
+depends           "geoipupdate"
 depends           "mysql"
index 2bd0b97a55ceaad9e9956642a5ddc0d0c17a753f..459712a0e492fe9a80af5258233fdac688f1c974 100644 (file)
@@ -18,6 +18,7 @@
 #
 
 include_recipe "apache"
+include_recipe "geoipupdate"
 include_recipe "mysql"
 
 passwords = data_bag_item("piwik", "passwords")
@@ -31,8 +32,6 @@ package "php-gd"
 package "php-xml"
 package "php-apcu"
 
-package "geoipupdate"
-
 apache_module "expires"
 apache_module "php7.2"
 apache_module "rewrite"
@@ -89,15 +88,15 @@ directory "/opt/piwik-#{version}/piwik/tmp" do
 end
 
 link "/opt/piwik-#{version}/piwik/misc/GeoLite2-ASN.mmdb" do
-  to "/var/lib/GeoIP/GeoLite2-ASN.mmdb"
+  to "/usr/share/GeoIP/GeoLite2-ASN.mmdb"
 end
 
 link "/opt/piwik-#{version}/piwik/misc/GeoLite2-City.mmdb" do
-  to "/var/lib/GeoIP/GeoLite2-City.mmdb"
+  to "/usr/share/GeoIP/GeoLite2-City.mmdb"
 end
 
 link "/opt/piwik-#{version}/piwik/misc/GeoLite2-Country.mmdb" do
-  to "/var/lib/GeoIP/GeoLite2-Country.mmdb"
+  to "/usr/share/GeoIP/GeoLite2-Country.mmdb"
 end
 
 link "/srv/piwik.openstreetmap.org" do