Skip to content

Commit

Permalink
Merge pull request #192 from benjunmun/orphan
Browse files Browse the repository at this point in the history
Add 'orphan' mode flag.
  • Loading branch information
kenyon authored Feb 26, 2024
2 parents ec083a1 + 81adb9c commit 6243260
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
10 changes: 10 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ The following parameters are available in the `chrony` class:
* [`keys`](#-chrony--keys)
* [`driftfile`](#-chrony--driftfile)
* [`local_stratum`](#-chrony--local_stratum)
* [`local_orphan`](#-chrony--local_orphan)
* [`ntpsigndsocket`](#-chrony--ntpsigndsocket)
* [`stratumweight`](#-chrony--stratumweight)
* [`log_options`](#-chrony--log_options)
Expand Down Expand Up @@ -371,6 +372,15 @@ chrony configuration.

Default value: `10`

##### <a name="-chrony--local_orphan"></a>`local_orphan`

Data type: `Boolean`

Put the server in 'orphan' mode when the local reference is active. Does
nothing if local_stratum is not set.

Default value: `false`

##### <a name="-chrony--ntpsigndsocket"></a>`ntpsigndsocket`

Data type: `Optional[Stdlib::Unixpath]`
Expand Down
4 changes: 4 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@
# Override the stratum of the server which will be reported to clients
# when the local reference is active. Use `false` to not set local_stratum in
# chrony configuration.
# @param local_orphan
# Put the server in 'orphan' mode when the local reference is active. Does
# nothing if local_stratum is not set.
# @param ntpsigndsocket
# This sets the location of the Samba ntp_signd socket when it is running as a Domain Controller (DC).
# @param stratumweight
Expand Down Expand Up @@ -268,6 +271,7 @@
Array[String[1]] $keys = [],
Stdlib::Unixpath $driftfile = '/var/lib/chrony/drift',
Variant[Boolean[false],Integer[1,15]] $local_stratum = 10,
Boolean $local_orphan = false,
Float $logchange = 0.5,
Optional[String[1]] $log_options = undef,
Optional[Integer[0]] $logbanner = undef,
Expand Down
21 changes: 21 additions & 0 deletions spec/classes/chrony_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,27 @@
it { is_expected.not_to contain_file(config_file).with_content(%r{^\s*local stratum}) }
end

context 'local orphan default' do
let(:params) do
{
local_stratum: 10
}
end

it { is_expected.to contain_file(config_file).with_content(%r{^\s*local stratum 10$\s*$}) }
end

context 'local orphan enabled' do
let(:params) do
{
local_stratum: 10,
local_orphan: true
}
end

it { is_expected.to contain_file(config_file).with_content(%r{^\s*local stratum 10 orphan$\s*$}) }
end

context 'with sub-millisecond value for logchange' do
let(:params) do
{
Expand Down
2 changes: 1 addition & 1 deletion templates/chrony.conf.epp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ port <%= $chrony::port %>
<% if $chrony::local_stratum { -%>

# Serve time even if not synchronized to any NTP server.
local stratum <%= $chrony::local_stratum %>
local stratum <%= $chrony::local_stratum %><%= if $chrony::local_orphan {' orphan'} else {''} %>
<% } -%>
<% if $chrony::minsamples { -%>

Expand Down

0 comments on commit 6243260

Please sign in to comment.