Skip to content

Commit

Permalink
Merge pull request #45 from cernops/ai5546_1
Browse files Browse the repository at this point in the history
Allow configuring bindcmdaddress
  • Loading branch information
aboe76 authored Aug 2, 2019
2 parents 3ef4863 + 360df94 commit 52e6564
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 7 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ class { '::chrony':

The following parameters are available in the chrony module

#### `bindcmdaddress`

Array of addresses of interfaces on which chronyd will listen for monitoring
command packets (defaults to localhost).

#### `chrony_password`

This sets the chrony password to be used in the key file.
Expand Down
1 change: 1 addition & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class chrony::config (
$bindcmdaddress = $chrony::bindcmdaddress,
$commandkey = $chrony::commandkey,
$config = $chrony::config,
$config_template = $chrony::config_template,
Expand Down
1 change: 1 addition & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class chrony (
Array[String] $bindcmdaddress = $chrony::params::bindcmdaddress,
$commandkey = $chrony::params::commandkey,
$config = $chrony::params::config,
$config_template = $chrony::params::config_template,
Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,6 @@
$pools = {}
$makestep_seconds = 10
$makestep_updates = 3
$bindcmdaddress = ['127.0.0.1', '::1']

}
9 changes: 8 additions & 1 deletion spec/classes/chrony_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
when 'RedHat'
context 'using defaults' do
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*port 0$}) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*bindcmdaddress ::1$}) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*bindcmdaddress 127\.0\.0\.1$}) }
['0.pool.ntp.org', '1.pool.ntp.org', '2.pool.ntp.org', '3.pool.ntp.org'].each do |s|
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*server #{s} iburst$}) }
end
Expand All @@ -51,6 +53,8 @@
when 'Debian'
context 'using defaults' do
it { is_expected.to contain_file('/etc/chrony/chrony.conf').with_content(%r{^\s*port 0$}) }
it { is_expected.to contain_file('/etc/chrony/chrony.conf').with_content(%r{^\s*bindcmdaddress ::1$}) }
it { is_expected.to contain_file('/etc/chrony/chrony.conf').with_content(%r{^\s*bindcmdaddress 127\.0\.0\.1$}) }
['0.pool.ntp.org', '1.pool.ntp.org', '2.pool.ntp.org', '3.pool.ntp.org'].each do |s|
it { is_expected.to contain_file('/etc/chrony/chrony.conf').with_content(%r{^\s*server #{s} iburst$}) }
end
Expand All @@ -72,7 +76,8 @@
config_keys_owner: 'steve',
config_keys_group: 'mrt',
config_keys_manage: true,
chrony_password: 'sunny'
chrony_password: 'sunny',
bindcmdaddress: ['10.0.0.1']
}
end

Expand All @@ -92,6 +97,7 @@
context 'with some params passed in' do
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*port 123$}) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^s*allow 192\.168\/16$}) }
it { is_expected.to contain_file('/etc/chrony.conf').with_content(%r{^\s*bindcmdaddress 10\.0\.0\.1$}) }
it { is_expected.to contain_file('/etc/chrony.keys').with_mode('0123') }
it { is_expected.to contain_file('/etc/chrony.keys').with_owner('steve') }
it { is_expected.to contain_file('/etc/chrony.keys').with_group('mrt') }
Expand All @@ -102,6 +108,7 @@
context 'with some params passed in' do
it { is_expected.to contain_file('/etc/chrony/chrony.conf').with_content(%r{^\s*port 123$}) }
it { is_expected.to contain_file('/etc/chrony/chrony.conf').with_content(%r{^s*allow 192\.168\/16$}) }
it { is_expected.to contain_file('/etc/chrony/chrony.conf').with_content(%r{^\s*bindcmdaddress 10\.0\.0\.1$}) }
it { is_expected.to contain_file('/etc/chrony/chrony.keys').with_mode('0123') }
it { is_expected.to contain_file('/etc/chrony/chrony.keys').with_owner('steve') }
it { is_expected.to contain_file('/etc/chrony/chrony.keys').with_group('mrt') }
Expand Down
6 changes: 3 additions & 3 deletions templates/chrony.conf.debian.erb
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ makestep <%= @makestep_seconds %> <%= @makestep_updates %>
allow <%= allowed %>
<% end -%>

# Listen for commands only on localhost.
bindcmdaddress 127.0.0.1
bindcmdaddress ::1
<% @bindcmdaddress.each do |addr| -%>
bindcmdaddress <%= addr %>
<% end -%>

# http://chrony.tuxfamily.org/manual.html#port-directive
port <%= @port %>
Expand Down
6 changes: 3 additions & 3 deletions templates/chrony.conf.redhat.erb
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ makestep <%= @makestep_seconds %> <%= @makestep_updates %>
allow <%= allowed %>
<% end -%>

# Listen for commands only on localhost.
bindcmdaddress 127.0.0.1
bindcmdaddress ::1
<% @bindcmdaddress.each do |addr| -%>
bindcmdaddress <%= addr %>
<% end -%>

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

0 comments on commit 52e6564

Please sign in to comment.