Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'orphan' mode flag. #192

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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