From d3b32515f5ec2b30007cad89f6a7424f04daebd3 Mon Sep 17 00:00:00 2001 From: ericpaliotta Date: Wed, 19 Jun 2024 09:09:45 -0400 Subject: [PATCH] [GH-250] Added the ability to modify logconfig with attributes Signed-off-by: ericpaliotta --- attributes/default.rb | 1 + spec/unit/attributes_spec.rb | 4 ++++ templates/ntp.conf.erb | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/attributes/default.rb b/attributes/default.rb index ae670d5..9730742 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -38,6 +38,7 @@ default['ntp']['varlibdir'] = '/var/lib/ntp' default['ntp']['driftfile'] = "#{node['ntp']['varlibdir']}/ntp.drift" default['ntp']['logfile'] = nil +default['ntp']['logconfig'] = 'all' default['ntp']['conffile'] = '/etc/ntp.conf' default['ntp']['statsdir'] = '/var/log/ntpstats/' default['ntp']['conf_owner'] = 'root' diff --git a/spec/unit/attributes_spec.rb b/spec/unit/attributes_spec.rb index 7873f0b..8e72071 100644 --- a/spec/unit/attributes_spec.rb +++ b/spec/unit/attributes_spec.rb @@ -49,6 +49,10 @@ expect(ntp['logfile']).to be nil end + it 'sets the logconfig to all' do + expect(ntp['logconfig']).to eq('all') + end + it 'sets the conf file to /etc/ntp.conf' do expect(ntp['conffile']).to eq('/etc/ntp.conf') end diff --git a/templates/ntp.conf.erb b/templates/ntp.conf.erb index 9c44736..4560566 100644 --- a/templates/ntp.conf.erb +++ b/templates/ntp.conf.erb @@ -43,6 +43,10 @@ interface listen 127.0.0.1 <% end -%> <% end -%> +<% unless node['ntp']['logconfig'].nil? -%> +logconfig =<%= node['ntp']['logconfig'] %> +<% end -%> + <% if node['ntp']['monitor'] -%> enable monitor <% else -%>