# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
<% if @servers.is_a?(Hash) then @servers.keys.sort.each do |server| -%>
server <%= server %> <%= @servers[server].join(' ') %>
<% end else Array(@servers).each do |server| -%>
server <%= server %> iburst
<% end end -%>

<% Array(@peers).each do |peer| -%>
peer <%= peer %>
<% end -%>

# Ignore stratum in source selection.
stratumweight 0

# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift

# Enable kernel RTC synchronization.
rtcsync

# In first <%= @makestep_updates %> updates step the system clock instead of slew
# if the adjustment is larger than <%= @makestep_seconds %> seconds.
makestep <%= @makestep_seconds %> <%= @makestep_updates %>

# Allow client access from local network.
#allow 192.168/16
<% Array(@queryhosts).each do |allowed| -%>
allow <%= allowed %>
<% end -%>

# Listen for commands only on localhost.
bindcmdaddress 127.0.0.1
bindcmdaddress ::1

# http://chrony.tuxfamily.org/manual.html#port-directive
port <%= @port %>

# Serve time even if not synchronized to any NTP server.
local stratum <%= @local_stratum %>

keyfile <%= @config_keys %>

<% if !@clientlog -%>
# Disable logging of client accesses.
noclientlog
<% end -%>

<% if defined?(@clientloglimit) -%>
# The clientlog size is limited to 512KB by default.  If you have many
# clients, especially in many different subnets, you might want to
# increase the limit.
clientloglimit <%= @clientloglimit %>
<% end -%>

# Send a message to syslog if a clock adjustment is larger than 0.5 seconds.
logchange 0.5

<% if defined?(@mailonchange) -%>
# Send mail  if chronyd applied a correction exceeding given threshold.
mailonchange <%= @mailonchange %> <%= @threshold %>
<% end -%>

logdir /var/log/chrony
<%- if defined?(@log_options) -%>
log <%= @log_options %>
<%- end -%>

<%- if defined?(@refclocks) -%>
# Hardware reference clock drivers
<% if @refclocks.is_a?(Hash) then @refclocks.keys.sort.each do |driver| -%>
<%   if @refclocks.is_a?(Hash) then @refclocks.keys.sort.each do |driver| -%>
<%       if @refclocks[driver].is_a(Array) then @refclocks[driver].sort.each do | instance | -%>
refclock <%= driver %> <%= instance %>
<%   end end end -%>
<%   else -%>
refclock <%= driver %> <%= @refclocks[driver] %>
<%   end end -%>
<% else -%>
<%   Array(@refclocks).sort.each do |refclock| -%>
refclock <%= refclock %>
<%   end end -%>
<% end -%>

<% if @lock_all -%>
# Lock chrony to RAM.
lock_all
<% end -%>
