]> git.openstreetmap.org Git - chef.git/blob - cookbooks/geoipupdate/recipes/default.rb
Purge old geoip packages
[chef.git] / cookbooks / geoipupdate / recipes / default.rb
1 #
2 # Cookbook:: geoipdate
3 # Recipe:: default
4 #
5 # Copyright:: 2020, OpenStreetMap Foundation
6 #
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
10 #
11 #     https://www.apache.org/licenses/LICENSE-2.0
12 #
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.
18 #
19
20 include_recipe "apt"
21
22 license_keys = data_bag_item("geoipupdate", "license-keys")
23
24 package "geoip-database" do
25   action :purge
26 end
27
28 package "geoip-database-contrib" do
29   action :purge
30 end
31
32 package "geoipupdate" do
33   action :purge
34   only_if { ::File.exist?("/etc/cron.d/geoipupdate") }
35 end
36
37 package "geoipupdate"
38
39 template "/etc/GeoIP.conf" do
40   source "GeoIP.conf.erb"
41   owner "root"
42   group "root"
43   mode "644"
44   variables :license_keys => license_keys
45 end
46
47 execute "geoipupdate" do
48   command "geoipupdate"
49   user "root"
50   group "root"
51   not_if { ENV.key?("TEST_KITCHEN") || node[:geoipupdate][:editions].all? { |edition| ::File.exist?("/usr/share/GeoIP/#{edition}.mmdb") } }
52 end
53
54 directory "/var/lib/GeoIP" do
55   action :delete
56   recursive true
57 end