#
-# Cookbook Name:: ntp
+# Cookbook:: ntp
# Recipe:: default
#
-# Copyright 2010, OpenStreetMap Foundation.
-# Copyright 2009, Opscode, Inc
+# Copyright:: 2010, OpenStreetMap Foundation.
+# Copyright:: 2009, Opscode, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# See the License for the specific language governing permissions and
# limitations under the License.
-service "ntp" do
- action [:stop, :disable]
-end
-
-package "ntp" do
- action :purge
-end
-
-package "ntpdate" do
- action :purge
-end
-
-if File.directory?("/etc/munin/plugins")
- Dir.new("/etc/munin/plugins").each do |plugin|
- next unless plugin.match?(/^ntp_/)
-
- munin_plugin plugin do
- action :delete
- end
- end
-end
+include_recipe "prometheus"
package %w[
chrony
source "chrony.conf.erb"
owner "root"
group "root"
- mode 0o644
+ mode "644"
+ notifies :restart, "service[chrony]"
+end
+
+service "systemd-timesyncd" do
+ action [:stop, :disable]
+end
+
+systemd_service "chrony-restart" do
+ service "chrony"
+ dropin "restart"
+ restart "on-failure"
notifies :restart, "service[chrony]"
end
action [:enable, :start]
end
-munin_plugin "chrony"
+prometheus_exporter "chrony" do
+ port 9123
+end
+
+# chrony occasionally marks all servers offline during a network outage.
+# force online all sources during a chef run
+execute "chronyc-online" do
+ command "/usr/bin/chronyc online"
+ user "root"
+ group "root"
+ ignore_failure true
+end