]> git.openstreetmap.org Git - chef.git/blob - cookbooks/ntp/recipes/default.rb
nominatim: fix rights for restricted IP log
[chef.git] / cookbooks / ntp / recipes / default.rb
1 #
2 # Cookbook Name:: ntp
3 # Recipe:: default
4 #
5 # Copyright 2010, OpenStreetMap Foundation.
6 # Copyright 2009, Opscode, Inc
7 #
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
11 #
12 #     http://www.apache.org/licenses/LICENSE-2.0
13 #
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
19
20 require "socket"
21
22 package %w[
23   ntp
24   ntpdate
25   tzdata
26 ]
27
28 execute "dpkg-reconfigure-tzdata" do
29   action :nothing
30   command "/usr/sbin/dpkg-reconfigure -f noninteractive tzdata"
31   user "root"
32   group "root"
33 end
34
35 file "/etc/timezone" do
36   owner "root"
37   group "root"
38   mode 0o644
39   content "#{node[:tz]}\n"
40   notifies :run, "execute[dpkg-reconfigure-tzdata]", :immediately
41 end
42
43 service "ntp" do
44   action [:enable, :start]
45   supports :status => true, :restart => true
46 end
47
48 template "/etc/ntp.conf" do
49   source "ntp.conf.erb"
50   owner "root"
51   group "root"
52   mode 0o644
53   notifies :restart, "service[ntp]"
54 end
55
56 munin_plugins = %w[ntp_kernel_err ntp_kernel_pll_freq ntp_kernel_pll_off ntp_offset]
57
58 munin_plugin "ntp_kernel_err"
59 munin_plugin "ntp_kernel_pll_freq"
60 munin_plugin "ntp_kernel_pll_off"
61 munin_plugin "ntp_offset"
62
63 if File.directory?("/etc/munin/plugins")
64   Dir.new("/etc/munin/plugins").each do |plugin|
65     next unless plugin.match(/^ntp_/) && !munin_plugins.include?(plugin)
66
67     munin_plugin plugin do
68       action :delete
69     end
70   end
71 end