Skip to content

Commit

Permalink
cmdport (#50)
Browse files Browse the repository at this point in the history
Added cmdport parameter
  • Loading branch information
przemas75 authored and aboe76 committed Oct 12, 2019
1 parent 07d1b32 commit 213bf67
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

[Full Changelog](https://github.com/aboe76/puppet-chrony/blob/master/CHANGELOG.md)

## [v0.3.1](https://forge.puppet.com/v3/files/aboe-chrony-0.3.1.tar.gz) (2019-10-12)

**Merged pull requests:**

- cmdport parameter [\#50|(<https://github.com/aboe76/puppet-chrony/pull/50)> ([stevekay](https://github.com/przemas75))

## [v0.3.0](https://forge.puppet.com/v3/files/aboe-chrony-0.3.0.tar.gz) (2019-08-05)

**Merged pull requests:**
Expand Down
1 change: 1 addition & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# configure chrony
class chrony::config (
$bindcmdaddress = $chrony::bindcmdaddress,
$cmdport = $chrony::cmdport,
$cmdacl = $chrony::cmdacl,
$commandkey = $chrony::commandkey,
$config = $chrony::config,
Expand Down
1 change: 1 addition & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
class chrony (
Array[String] $bindcmdaddress = $chrony::params::bindcmdaddress,
Array[String] $cmdacl = $chrony::params::cmdacl,
$cmdport = $chrony::params::cmdport,
$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 @@ -18,6 +18,7 @@
$threshold = 0.5
$lock_all = false
$clientloglimit = undef
$cmdport = undef

case $::osfamily {
'Archlinux' : {
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aboe-chrony",
"version": "0.3.0",
"version": "0.3.1",
"author": "aboe",
"summary": "Manage chrony daemon on Linux",
"license": "Apache-2.0",
Expand Down
3 changes: 3 additions & 0 deletions spec/classes/chrony_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
{
queryhosts: ['192.168/16'],
port: '123',
cmdport: '257',
config_keys_mode: '0123',
config_keys_owner: 'steve',
config_keys_group: 'mrt',
Expand Down Expand Up @@ -103,6 +104,7 @@
when 'RedHat'
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*cmdport 257$}) }
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.conf').with_content(%r{^\s*cmdallow 1\.2\.3\.4$}) }
Expand All @@ -117,6 +119,7 @@
when 'Debian'
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*cmdport 257$}) }
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.conf').with_content(%r{^\s*cmdallow 1\.2\.3\.4$}) }
Expand Down
29 changes: 23 additions & 6 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,29 @@
options[:port] = node_config.dig('ssh', 'port') unless node_config.dig('ssh', 'port').nil?
options[:keys] = node_config.dig('ssh', 'private-key') unless node_config.dig('ssh', 'private-key').nil?
options[:password] = node_config.dig('ssh', 'password') unless node_config.dig('ssh', 'password').nil?
options[:verify_host_key] = Net::SSH::Verifiers::Null.new unless node_config.dig('ssh', 'host-key-check').nil?
host = if ENV['TARGET_HOST'].include?(':')
ENV['TARGET_HOST'].split(':').first
else
ENV['TARGET_HOST']
end
# Support both net-ssh 4 and 5.
# rubocop:disable Metrics/BlockNesting
options[:verify_host_key] = if node_config.dig('ssh', 'host-key-check').nil?
# Fall back to SSH behavior. This variable will only be set in net-ssh 5.3+.
if @strict_host_key_checking.nil? || @strict_host_key_checking
Net::SSH::Verifiers::Always.new
else
# SSH's behavior with StrictHostKeyChecking=no: adds new keys to known_hosts.
# If known_hosts points to /dev/null, then equivalent to :never where it
# accepts any key beacuse they're all new.
Net::SSH::Verifiers::AcceptNewOrLocalTunnel.new
end
elsif node_config.dig('ssh', 'host-key-check')
if defined?(Net::SSH::Verifiers::Always)
Net::SSH::Verifiers::Always.new
else
Net::SSH::Verifiers::Secure.new
end
elsif defined?(Net::SSH::Verifiers::Never)
Net::SSH::Verifiers::Never.new
else
Net::SSH::Verifiers::Null.new
end
set :host, options[:host_name] || host
set :ssh_options, options
set :request_pty, true
Expand Down
4 changes: 4 additions & 0 deletions templates/chrony.conf.debian.erb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ makestep <%= @makestep_seconds %> <%= @makestep_updates %>
allow <%= allowed %>
<% end -%>

<% if defined?(@cmdport) -%>
cmdport <%= @cmdport %>
<% end -%>

<% @bindcmdaddress.each do |addr| -%>
bindcmdaddress <%= addr %>
<% end -%>
Expand Down
4 changes: 4 additions & 0 deletions templates/chrony.conf.redhat.erb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ makestep <%= @makestep_seconds %> <%= @makestep_updates %>
allow <%= allowed %>
<% end -%>

<% if defined?(@cmdport) -%>
cmdport <%= @cmdport %>
<% end -%>

<% @bindcmdaddress.each do |addr| -%>
bindcmdaddress <%= addr %>
<% end -%>
Expand Down

0 comments on commit 213bf67

Please sign in to comment.