diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b255f12..8144fec1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ Standardise files with files in sous-chefs/repo-management Standardise files with files in sous-chefs/repo-management +Added capability to set logconfig using an attribute + ## 5.1.2 - *2024-05-02* ## 5.1.1 - *2024-05-02* diff --git a/attributes/default.rb b/attributes/default.rb index ae670d5f..97307428 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 7873f0b2..8e720711 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 9c44736a..45605667 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 -%>