]> git.openstreetmap.org Git - chef.git/blob - cookbooks/ntp/recipes/default.rb
Remove unused role
[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 #     https://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 link "/etc/localtime" do
36   to "/usr/share/zoneinfo/#{node[:tz]}"
37   owner "root"
38   group "root"
39   notifies :run, "execute[dpkg-reconfigure-tzdata]", :immediately
40 end
41
42 service "ntp" do
43   action [:enable, :start]
44   supports :status => true, :restart => true
45 end
46
47 template "/etc/ntp.conf" do
48   source "ntp.conf.erb"
49   owner "root"
50   group "root"
51   mode 0o644
52   notifies :restart, "service[ntp]"
53 end
54
55 munin_plugins = %w[ntp_kernel_err ntp_kernel_pll_freq ntp_kernel_pll_off ntp_offset]
56
57 munin_plugin "ntp_kernel_err"
58 munin_plugin "ntp_kernel_pll_freq"
59 munin_plugin "ntp_kernel_pll_off"
60 munin_plugin "ntp_offset"
61
62 if File.directory?("/etc/munin/plugins")
63   Dir.new("/etc/munin/plugins").each do |plugin|
64     next unless plugin.match(/^ntp_/) && !munin_plugins.include?(plugin)
65
66     munin_plugin plugin do
67       action :delete
68     end
69   end
70 end